[*] 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

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