[*] Typescript: include decls in project source alongside dep link dirs

This commit is contained in:
Reece Wilson 2023-07-21 06:16:17 +01:00
parent ce24026ab0
commit dbaaabeab8

View File

@ -96,17 +96,19 @@ local function processProject(meta, object)
local typeDirs = {} local typeDirs = {}
if (object.depends ) then table.insert(typeDirs, path.normalize(path.join(rootdir, object.base)))
if (object.depends) then
auForEach(object.depends, function(dependency) auForEach(object.depends, function(dependency)
local typeDir = path.normalize(path.join(linkPath2, dependency)) local typeDir = path.normalize(path.join(linkPath2, dependency))
table.insert(typeDirs, typeDir) table.insert(typeDirs, typeDir)
end) end)
end end
if (object.depends2) then if (object.depends2) then
auForEach(object.depends2, function(dependency) auForEach(object.depends2, function(dependency)
local typeDir = path.normalize(path.join(linkPath2, dependency)) local typeDir = path.normalize(path.join(linkPath2, dependency))
table.insert(typeDirs, typeDir) table.insert(typeDirs, typeDir)
end) end)
end end
@ -114,11 +116,16 @@ local function processProject(meta, object)
local ew = "" local ew = ""
local ew2 = {} local ew2 = {}
if (object.depends or object.depends2) then local bSingleShot = false
--if (object.depends or object.depends2) then
args = args .. ' --typeRoots "' args = args .. ' --typeRoots "'
auForEach(typeDirs, function(dependency) auForEach(typeDirs, function(dependency)
args = args .. path.normalize(dependency) .. "\",\"" if (bSingleShot) then
args = args .. path.normalize(dependency) .. "\",\""
else
bSingleShot = true
end
table.insert(ew2, dependency .. "/**/*.d.ts") table.insert(ew2, dependency .. "/**/*.d.ts")
table.insert(ew2, dependency .. "/*.d.ts") table.insert(ew2, dependency .. "/*.d.ts")
@ -131,7 +138,7 @@ local function processProject(meta, object)
args = args .. '"' args = args .. '"'
args = args .. ew args = args .. ew
end --end
args = args:gsub(",\"\"", "") args = args:gsub(",\"\"", "")
@ -154,10 +161,10 @@ local function processProject(meta, object)
if (os.host() == "windows") then if (os.host() == "windows") then
pathSuffix = "*\""; pathSuffix = "*\"";
mkdir = "mkdir "; mkdir = "IF NOT EXIST \"PATH\" mkdir \"PATH\"";
else else
pathSuffix = "\""; pathSuffix = "\"";
mkdir = "mkdir -p "; mkdir = "mkdir -p \"PATH\"";
end end
if (object.bundle) then if (object.bundle) then
@ -165,6 +172,11 @@ local function processProject(meta, object)
else else
auForEach(object.files, function(file) auForEach(object.files, function(file)
local part = path.getrelative(meta.path, file):sub(1, -4) local part = path.getrelative(meta.path, file):sub(1, -4)
local isD = false
if (part:ends(".d")) then
part = part:sub(1, -3)
isD = true
end
local script = part .. ".js" local script = part .. ".js"
local dbg = part .. ".js.map" local dbg = part .. ".js.map"
local link = part .. ".d.ts" local link = part .. ".d.ts"
@ -180,33 +192,40 @@ local function processProject(meta, object)
local link2 = part2 .. ".d.ts" local link2 = part2 .. ".d.ts"
local dbg2p = part .. ".d.ts.map" local dbg2p = part .. ".d.ts.map"
auForEach(meta.out, function(dest) if (not isD) then
if (dest:starts(kPathPrefix)) then auForEach(meta.out, function(dest)
dest = Aurora.Settings.sAbsWd .. dest:sub(#kPathPrefix + 1) if (dest:starts(kPathPrefix)) then
end dest = Aurora.Settings.sAbsWd .. dest:sub(#kPathPrefix + 1)
end
prebuildcommands(mkdir .. path.translate(path.normalize(path.getdirectory(path.join(dest, script2))), path.getDefaultSeparator())) prebuildcommands(mkdir:gsub("PATH", path.translate(path.normalize(path.getdirectory(path.join(dest, script2))), path.getDefaultSeparator())))
prebuildcommands(string.format("{COPY} \"%s\" \"%s%s",
path.translate(path.normalize(path.join(compilerPath, script)), path.getDefaultSeparator()),
path.translate(path.normalize(path.join(dest, script2)), path.getDefaultSeparator()), pathSuffix))
end)
prebuildcommands(mkdir:gsub("PATH", path.translate(path.normalize(path.getdirectory(path.join(symPath, dbg2p))), path.getDefaultSeparator())))
prebuildcommands(mkdir:gsub("PATH", path.translate(path.normalize(path.getdirectory(path.join(linkPath, link2))), path.getDefaultSeparator())))
prebuildcommands(string.format("{COPY} \"%s\" \"%s%s", prebuildcommands(string.format("{COPY} \"%s\" \"%s%s",
path.translate(path.normalize(path.join(compilerPath, script)), path.getDefaultSeparator()), path.translate(path.normalize(path.join(compilerPath, dbg)), path.getDefaultSeparator()),
path.translate(path.normalize(path.join(dest, script2)), path.getDefaultSeparator()), pathSuffix)) path.translate(path.normalize(path.join(symPath, dbgp)), path.getDefaultSeparator()), pathSuffix))
end) prebuildcommands(string.format("{COPY} \"%s\" \"%s%s",
path.translate(path.normalize(path.join(compilerPath, dbg2)), path.getDefaultSeparator()),
path.translate(path.normalize(path.join(symPath, dbg2p)), path.getDefaultSeparator()), pathSuffix))
prebuildcommands(mkdir .. path.translate(path.normalize(path.getdirectory(path.join(symPath, dbg2p))), path.getDefaultSeparator()))
prebuildcommands(mkdir .. path.translate(path.normalize(path.getdirectory(path.join(linkPath, link2))), path.getDefaultSeparator()) )
prebuildcommands(string.format("{COPY} \"%s\" \"%s%s", prebuildcommands(string.format("{COPY} \"%s\" \"%s%s",
path.translate(path.normalize(path.join(compilerPath, dbg)), path.getDefaultSeparator()), path.translate(path.normalize(path.join(compilerPath, link)), path.getDefaultSeparator()),
path.translate(path.normalize(path.join(symPath, dbgp)), path.getDefaultSeparator()), pathSuffix)) path.translate(path.normalize(path.join(linkPath, link2)), path.getDefaultSeparator()), pathSuffix))
else
prebuildcommands(string.format("{COPY} \"%s\" \"%s%s", prebuildcommands(string.format("{COPY} \"%s\" \"%s%s",
path.translate(path.normalize(path.join(compilerPath, dbg2)), path.getDefaultSeparator()), file,
path.translate(path.normalize(path.join(symPath, dbg2p)), path.getDefaultSeparator()), pathSuffix)) path.translate(path.normalize(path.join(linkPath, link2)), path.getDefaultSeparator()), pathSuffix))
end
prebuildcommands(string.format("{COPY} \"%s\" \"%s%s",
path.translate(path.normalize(path.join(compilerPath, link)), path.getDefaultSeparator()),
path.translate(path.normalize(path.join(linkPath, link2)), path.getDefaultSeparator()), pathSuffix))
end) end)
end end