[+] Initial hack attempt at TSC integration for mixed v8 projects
This commit is contained in:
parent
f15f6098a6
commit
c67d2728ab
@ -43,7 +43,7 @@ local addBuildCommand = function(when, scriptType, path, cwdRelToProject, args)
|
||||
command = command .. " --project_platform=\"%{cfg.platform}\""
|
||||
|
||||
-- Aurora.Settings could take up too much of the win32 max command line buffer (8191 characters)
|
||||
-- This seems like a lot, but it should be well within the 9k limit
|
||||
-- This seems like a lot, but it should be well within the 8k limit
|
||||
-- Abs can be skipped and i really dont believe we need the other settings
|
||||
local settings =
|
||||
{
|
||||
|
@ -100,12 +100,25 @@ if (binScript) then
|
||||
cmd = "call " .. cmd
|
||||
end
|
||||
|
||||
print("Running binary: ", cmd)
|
||||
os.exit(os.execute(cmd))
|
||||
end
|
||||
|
||||
local cmd = _OPTIONS["cmd"]
|
||||
if (cmd) then
|
||||
os.exit(os.execute(base64.decode(cmd)))
|
||||
|
||||
local cmd = base64.decode(cmd)
|
||||
|
||||
if (args) then
|
||||
cmd = cmd .. " " .. args
|
||||
end
|
||||
|
||||
if (os.host() == "windows") then
|
||||
cmd = "call " .. cmd
|
||||
end
|
||||
|
||||
print("Running command: ", cmd)
|
||||
os.exit(os.execute(cmd))
|
||||
end
|
||||
|
||||
local projName = _OPTIONS["project_name"]
|
||||
@ -170,6 +183,8 @@ if (projectBins) then
|
||||
if (os.host() == "windows") then
|
||||
cmd = "call " .. cmd
|
||||
end
|
||||
|
||||
print("Running project: ", cmd)
|
||||
os.exit(os.execute(cmd))
|
||||
end
|
||||
|
||||
|
@ -39,7 +39,7 @@ local function archiveShipPdb(pdbPath)
|
||||
end
|
||||
|
||||
local function isUtils(projectType)
|
||||
return projectType == "Blank" or projectType == "Utility" or projectType == "None"
|
||||
return projectType:lower() == "blank" or projectType:lower() == "utility" or projectType:lower() == "none"
|
||||
end
|
||||
|
||||
local function isNoLinkType(projectType)
|
||||
|
@ -1,7 +1,9 @@
|
||||
local auProject = auRequire("Core/project").startProject
|
||||
local projectHandlers = auRequire("Core/JSON/jsonProjectHandlers")
|
||||
local otherLangs = auRequire("Core/OtherLang")
|
||||
|
||||
function JsonProcessor(info)
|
||||
local interface = {}
|
||||
local result, err = json.decode(io.readfile(info.jpath))
|
||||
|
||||
if (not result) then
|
||||
@ -12,8 +14,24 @@ function JsonProcessor(info)
|
||||
if (not info.name) then
|
||||
info.name = result.name
|
||||
end
|
||||
|
||||
if (not info.projectType) then
|
||||
info.projectType = result.projectType
|
||||
end
|
||||
|
||||
result.name = info.name
|
||||
|
||||
local otherLang = otherLangs[info.projectType]
|
||||
if (otherLang) then
|
||||
info.projectType = "utility"
|
||||
|
||||
interface.lang = {
|
||||
name = info.projectType
|
||||
}
|
||||
|
||||
otherLang.processJson(info, interface.lang, result)
|
||||
end
|
||||
|
||||
-- ported
|
||||
local includeDirEx = function(path, incFiles)
|
||||
includedirs(path)
|
||||
@ -125,10 +143,8 @@ function JsonProcessor(info)
|
||||
dest = info.out,
|
||||
noLink = result.noLink
|
||||
}
|
||||
|
||||
|
||||
if (result.noLink) then
|
||||
print("noLink is deprecated. Use projectType: none")
|
||||
project.projectType = "none"
|
||||
info.projectType = "none"
|
||||
end
|
||||
@ -138,6 +154,11 @@ function JsonProcessor(info)
|
||||
project.projectType = "utility"
|
||||
end
|
||||
end
|
||||
|
||||
if (interface.lang) then
|
||||
project.projectType = "utility"
|
||||
result.type = "utility"
|
||||
end
|
||||
|
||||
if (result.type:lower() == "aurora") then
|
||||
|
||||
@ -165,7 +186,7 @@ function JsonProcessor(info)
|
||||
auProject(project)
|
||||
|
||||
elseif (result.type:lower() == "utility") then
|
||||
project(name)
|
||||
auProject(project)
|
||||
kind "utility"
|
||||
isUtility = true
|
||||
|
||||
@ -185,6 +206,11 @@ function JsonProcessor(info)
|
||||
auForEach(result.dllexport, defines)
|
||||
end
|
||||
end
|
||||
|
||||
if (interface.lang) then
|
||||
projectHandlers.runOtherLang(this, result)
|
||||
otherLang.processProject(info, interface.lang)
|
||||
end
|
||||
end
|
||||
|
||||
auForEach(result.subprojs, function(subproj)
|
||||
@ -200,7 +226,6 @@ function JsonProcessor(info)
|
||||
auAddVist(subinfo)
|
||||
end)
|
||||
|
||||
local interface = {}
|
||||
interface.result = result
|
||||
interface.info = info
|
||||
interface.resolveDependencies = resolveDependencies
|
||||
|
@ -536,6 +536,18 @@ local function __pRunLinkTasks(processor, object, resolve)
|
||||
resolve)
|
||||
end
|
||||
|
||||
local function __pRunOtherLang(processor, object, resolve)
|
||||
__pRunTasks(processor,
|
||||
object,
|
||||
auProjectRefHandlers,
|
||||
{
|
||||
"depends", "soft-depends", "eval",
|
||||
"actions"
|
||||
},
|
||||
false,
|
||||
resolve)
|
||||
end
|
||||
|
||||
local function __pRunIncludeTasks(processor, object, isIncludeLocalProject)
|
||||
__pRunTasks(processor, object, auProjectBlockHandlers, kReferenceTasks, isIncludeLocalProject)
|
||||
|
||||
@ -577,5 +589,6 @@ return auCopyTables(auProjectHeaderHandlers, auProjectBlockHandlers, {
|
||||
runProjectBlock = __pRunMainTasks,
|
||||
runProjectLink = __pRunLinkTasks,
|
||||
runProjectImport = ___pRunImportTask,
|
||||
runProjectRef = ___pRunIncludeTasks
|
||||
runProjectRef = ___pRunIncludeTasks,
|
||||
runOtherLang = __pRunOtherLang
|
||||
})
|
3
Core/OtherLang/OtherLang.lua
Normal file
3
Core/OtherLang/OtherLang.lua
Normal file
@ -0,0 +1,3 @@
|
||||
return {
|
||||
typescript = auRequire("Core/OtherLang/TS")
|
||||
}
|
166
Core/OtherLang/TS/TS.lua
Normal file
166
Core/OtherLang/TS/TS.lua
Normal file
@ -0,0 +1,166 @@
|
||||
local kPathPrefix = "!"
|
||||
|
||||
local function processJson(meta, object, result)
|
||||
auMergeTable(object,
|
||||
{
|
||||
files = {},
|
||||
targetVersion = nil,
|
||||
module = nil,
|
||||
lib = nil,
|
||||
bundle = false,
|
||||
exportIDE = false,
|
||||
typeDirs = {}
|
||||
})
|
||||
|
||||
object.targetVersion = result.target or "esnext"
|
||||
object.module = result.moduleLoader or "esnext"
|
||||
object.base = result.base or "Source"
|
||||
object.exportIDE = result.exportIDE
|
||||
object.bundle = result.bundle
|
||||
object.typeDirs = result.typeDirs
|
||||
object.sources = result.sources
|
||||
object.depends = result.depends
|
||||
object.removeComments = result.removeComments
|
||||
end
|
||||
|
||||
local function processProject(meta, object)
|
||||
|
||||
object.files = os.matchfiles(object.sources)
|
||||
|
||||
object.files = auMap(object.files, os.realpath)
|
||||
files(object.files)
|
||||
|
||||
local path = _G.path
|
||||
local compilerPath = path.join(Aurora.Settings.sAbsCompilerWd, "Typescript")
|
||||
os.mkdir(compilerPath)
|
||||
compilerPath = path.join(compilerPath, meta.name)
|
||||
os.mkdir(compilerPath)
|
||||
|
||||
local linkPath = Aurora.Settings.sAbsLinkLibs
|
||||
os.mkdir(linkPath)
|
||||
local linkPath2 = linkPath
|
||||
linkPath = path.join(linkPath, meta.name)
|
||||
os.mkdir(linkPath)
|
||||
|
||||
local symPath = Aurora.Settings.sAbsSymbols
|
||||
os.mkdir(symPath)
|
||||
local symPath2 = symPath
|
||||
symPath = path.join(symPath, meta.name)
|
||||
os.mkdir(symPath)
|
||||
|
||||
local rootdir = path.normalize(os.getcwd())
|
||||
|
||||
local args = ""
|
||||
|
||||
auForEach(object.files, function(file)
|
||||
args = args .. ' "' .. file .. '"'
|
||||
end)
|
||||
|
||||
args = args .. ' --sourceMap'
|
||||
args = args .. ' --declarationMap'
|
||||
args = args .. ' --inlineSources'
|
||||
args = args .. ' --sourceRoot \"' .. rootdir .. "\""
|
||||
args = args .. ' --mapRoot \"' .. path.normalize(symPath) .. "\""
|
||||
args = args .. ' --rootDir \"' .. rootdir .. "\""
|
||||
args = args .. ' --outDir \"' .. path.normalize(compilerPath) .. "\""
|
||||
|
||||
if (object.bundle) then
|
||||
args = args .. ' --outFile \"' .. path.normalize(path.join(compilerPath, meta.name)) .. ".js\""
|
||||
end
|
||||
|
||||
args = args .. ' --declaration'
|
||||
args = args .. ' --target ' .. object.targetVersion
|
||||
|
||||
if (object.removeComments) then
|
||||
args = args .. ' --removeComments'
|
||||
end
|
||||
|
||||
local typeDirs = {}
|
||||
if (object.depends) then
|
||||
args = args .. ' --typeRoots "'
|
||||
|
||||
auForEach(object.depends, function(dependency)
|
||||
local typeDir = path.join(linkPath2, dependency)
|
||||
table.insert(typeDirs, typeDir)
|
||||
args = args .. typeDir .. ","
|
||||
end)
|
||||
|
||||
args = args .. '"'
|
||||
end
|
||||
|
||||
auAddBuildAction("pre", "cmd", "tsc", false, args)
|
||||
|
||||
if (object.exportIDE) then
|
||||
|
||||
end
|
||||
|
||||
local requiredDirs = {}
|
||||
local requiredCopies = {}
|
||||
|
||||
local pathSuffix = ""
|
||||
local mkdir = ""
|
||||
|
||||
if (os.host() == "windows") then
|
||||
pathSuffix = "*\"";
|
||||
mkdir = "mkdir ";
|
||||
else
|
||||
pathSuffix = "\"";
|
||||
mkdir = "mkdir -p ";
|
||||
end
|
||||
|
||||
if (object.bundle) then
|
||||
|
||||
else
|
||||
auForEach(object.files, function(file)
|
||||
local part = path.getrelative(meta.path, file):sub(1, -4)
|
||||
local script = part .. ".js"
|
||||
local dbg = part .. ".js.map"
|
||||
local link = part .. ".d.ts"
|
||||
local dbg2 = part .. ".d.ts.map"
|
||||
|
||||
local part2 = part
|
||||
if (part2:starts(object.base)) then
|
||||
part2 = part2:sub(#object.base + 2)
|
||||
end
|
||||
|
||||
local script2 = part2 .. ".js"
|
||||
local dbgp = part .. ".js.map"
|
||||
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
|
||||
|
||||
prebuildcommands(mkdir .. 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 .. path.translate(path.normalize(path.getdirectory(symPath .. "/" .. dbg2p)), path.getDefaultSeparator()))
|
||||
prebuildcommands(mkdir .. path.translate(path.normalize(path.getdirectory(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((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((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(linkPath .. "/" .. link2), path.getDefaultSeparator()), pathSuffix))
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return {
|
||||
processJson = processJson,
|
||||
processProject = processProject
|
||||
}
|
0
Core/OtherLang/TS/run.lua
Normal file
0
Core/OtherLang/TS/run.lua
Normal file
@ -30,6 +30,8 @@ local function resourceCompile(files, additional, script)
|
||||
}
|
||||
|
||||
auAddBuildAction("pre", "lua", path.join(Aurora.Settings.sAbsScripts, "Core", "ResourceCompiler", "run.lua"), true, meta)
|
||||
cleancommands("rm ", path.translate(path.normalize(path.join(Aurora.Settings.sAbsCompilerWd, meta.hash) .. ".rsc"), path.getDefaultSeparator()))
|
||||
|
||||
end
|
||||
|
||||
return resourceCompile
|
Loading…
Reference in New Issue
Block a user