[+] Resource compiler based vala run script
This commit is contained in:
parent
2b6bb149e8
commit
027f2f9ce5
@ -60,6 +60,8 @@ local addBuildCommand = function(when, scriptType, path, cwdRelToProject, args)
|
||||
sRelCompilerWd = Aurora.Settings.sRelCompilerWd,
|
||||
sRelWin32 = Aurora.Settings.sRelWin32,
|
||||
sRelUnixBins = Aurora.Settings.sRelUnixBins,
|
||||
sAbsValac = Aurora.Settings.sAbsValac,
|
||||
_punchthrough = Aurora.Settings._punchthrough -- for extended user code
|
||||
}
|
||||
command = command .. " --settings=" .. base64.encode(json.encode(settings))
|
||||
|
||||
|
@ -44,6 +44,14 @@ function resourceExit(exitCode)
|
||||
os.exit(exitCode)
|
||||
end
|
||||
|
||||
function resourceRun(cmd)
|
||||
if (os.host() == "windows") then
|
||||
return os.execute("call " .. cmd)
|
||||
else
|
||||
return os.execute(cmd)
|
||||
end
|
||||
end
|
||||
|
||||
function resourceRunAndExit(cmd)
|
||||
if (os.host() == "windows") then
|
||||
resourceExit(os.execute("call " .. cmd))
|
||||
|
@ -1,107 +1,80 @@
|
||||
local function isWin32()
|
||||
return os.is("Windows")
|
||||
end
|
||||
|
||||
local function findVala()
|
||||
if (isWin32()) then
|
||||
local auValac = Aurora.Settings.sAbsValac or path.join(Aurora.Settings.sAbsWin32, "valac.exe")
|
||||
if (os.isfile(auValac)) then return auValac end
|
||||
|
||||
local drive = path.getdrive(auGetRoot())
|
||||
|
||||
local localDriveClang = drive .. ":\\msys64\\clang64\\bin\\valac.exe"
|
||||
if (os.isfile(localDriveClang)) then return localDriveClang end
|
||||
|
||||
local localDriveMingw = drive .. ":\\msys64\\mingw64\\bin\\valac.exe"
|
||||
if (os.isfile(localDriveMingw)) then return localDriveMingw end
|
||||
|
||||
local localCClang = "C:\\msys64\\clang64\\bin\\valac.exe"
|
||||
if (os.isfile(localCClang)) then return localCClang end
|
||||
|
||||
local localCMingw = "C:\\msys64\\mingw64\\bin\\valac.exe"
|
||||
if (os.isfile(localCMingw)) then return localCMingw end
|
||||
end
|
||||
|
||||
return "vallac"
|
||||
end
|
||||
|
||||
local function addVala(extended)
|
||||
local exec = findVala()
|
||||
|
||||
local args = ""
|
||||
|
||||
local function expandPartialRelDir(partial)
|
||||
return os.realpath(partial) --path.translate(path.join(os.getcwd(), partial), path.getDefaultSeparator())
|
||||
end
|
||||
|
||||
local function expandPartialNonExistsFile(partial)
|
||||
return path.translate(path.join(os.getcwd(), partial), path.getDefaultSeparator())
|
||||
end
|
||||
|
||||
local function onGir(partial)
|
||||
args = args .. " --girdir=\"" .. expandPartialRelDir(partial) .. "\""
|
||||
end
|
||||
|
||||
local function onVApi(partial)
|
||||
args = args .. " --vapidir=\"" .. expandPartialRelDir(partial) .. "\""
|
||||
end
|
||||
|
||||
auForEach(extended.gir, onGir)
|
||||
auForEach(extended.vapi, onVApi)
|
||||
|
||||
if (extended.girFile) then
|
||||
args = args .. " --gir=" .. extended.girFile
|
||||
end
|
||||
|
||||
local myBrainHurts = false
|
||||
|
||||
local info = auGetCurrentProjectMeta()
|
||||
if ((info.projectType:lower() == "sharedlib") or (extended.girFile)) then
|
||||
args = args .. " --library=" .. (extended.name or info.name)
|
||||
if (usingClang) then
|
||||
visibility "Default"
|
||||
else
|
||||
args = args .. " --symbols=symbols.CIA"
|
||||
myBrainHurts = true
|
||||
linkoptions {"/def:\"" .. expandPartialNonExistsFile("symbols.def") .. "\""}
|
||||
auFilterForPlatforms(function(platform)
|
||||
local isWin32 = platform == "win32"
|
||||
local args = ""
|
||||
|
||||
local function expandPartialRelDir(partial)
|
||||
return os.realpath(partial) --path.translate(path.join(os.getcwd(), partial), path.getDefaultSeparator())
|
||||
end
|
||||
end
|
||||
|
||||
local function expandPartialNonExistsFile(partial)
|
||||
return path.translate(path.join(os.getcwd(), partial), path.getDefaultSeparator())
|
||||
end
|
||||
|
||||
local function onGir(partial)
|
||||
args = args .. " --girdir=\"" .. expandPartialRelDir(partial) .. "\""
|
||||
end
|
||||
|
||||
local function onVApi(partial)
|
||||
args = args .. " --vapidir=\"" .. expandPartialRelDir(partial) .. "\""
|
||||
end
|
||||
|
||||
auForEach(extended.gir, onGir)
|
||||
auForEach(extended.vapi, onVApi)
|
||||
|
||||
if (extended.girFile) then
|
||||
args = args .. " --gir=" .. extended.girFile
|
||||
end
|
||||
|
||||
local myBrainHurts = false
|
||||
|
||||
local info = auGetCurrentProjectMeta()
|
||||
|
||||
if ((info.projectType:lower() == "sharedlib") or (extended.girFile)) then
|
||||
args = args .. " --library=" .. (extended.name or info.name)
|
||||
if (isWin32) then
|
||||
args = args .. " --symbols=symbols.CIA"
|
||||
myBrainHurts = true
|
||||
linkoptions {"/def:\"" .. expandPartialNonExistsFile("symbols.def") .. "\""}
|
||||
else
|
||||
visibility "Default"
|
||||
end
|
||||
end
|
||||
|
||||
local function onPackage(pkg)
|
||||
args = args .. " --pkg=" .. pkg
|
||||
end
|
||||
|
||||
auForEach(extended.package, onPackage)
|
||||
|
||||
args = args .. " --directory=\"" .. os.getcwd() .. "\""
|
||||
|
||||
args = args .. " --ccode"
|
||||
|
||||
if (extended.header) then
|
||||
args = args .. " --header=\"" .. expandPartialNonExistsFile(extended.header) .. "\""
|
||||
end
|
||||
|
||||
|
||||
local resourceFiles = {}
|
||||
local function onSourceFile(partial)
|
||||
local path = expandPartialNonExistsFile(partial) -- eh? didnt't we just use matchfiles?
|
||||
--args = args .. " \"".. path .. "\""
|
||||
|
||||
local function onPackage(pkg)
|
||||
args = args .. " --pkg=" .. pkg
|
||||
end
|
||||
table.insert(resourceFiles, path)
|
||||
|
||||
auForEach(extended.package, onPackage)
|
||||
|
||||
args = args .. " --directory=\"" .. os.getcwd() .. "\""
|
||||
|
||||
args = args .. " --ccode"
|
||||
|
||||
if (extended.header) then
|
||||
args = args .. " --header=\"" .. expandPartialNonExistsFile(extended.header) .. "\""
|
||||
end
|
||||
|
||||
local function onSourceFile(partial)
|
||||
local path = expandPartialNonExistsFile(partial)
|
||||
args = args .. " \"".. path .. "\""
|
||||
|
||||
local cfile = path:gsub("%.vala", "") .. ".c"
|
||||
files(cfile)
|
||||
files(path)
|
||||
end
|
||||
|
||||
local function onSourcePattern(pattern)
|
||||
auForEach(os.matchfiles(pattern), onSourceFile)
|
||||
end
|
||||
|
||||
auForEach(extended.sources, onSourcePattern)
|
||||
|
||||
--print(exec, args)
|
||||
auAddBuildAction("pre", "bin", exec, true, args)
|
||||
|
||||
if (myBrainHurts) then
|
||||
auAddBuildAction("pre", "lua", path.translate(path.join(Aurora.Settings.sAbsScripts, "Core", "Vala", "valaSym2Def.lua"), path.getDefaultSeparator()), true)
|
||||
end
|
||||
local cfile = path:gsub("%.vala", "") .. ".c"
|
||||
files(cfile)
|
||||
files(path)
|
||||
end
|
||||
|
||||
local function onSourcePattern(pattern)
|
||||
auForEach(os.matchfiles(pattern), onSourceFile)
|
||||
end
|
||||
|
||||
auForEach(extended.sources, onSourcePattern)
|
||||
auAddResource(resourceFiles, {args = args, symHack = myBrainHurts}, path.join(Aurora.Settings.sAbsScripts, "Core", "Vala", "run.lua"))
|
||||
end)
|
||||
end
|
||||
|
||||
return addVala
|
45
Core/Vala/run.lua
Normal file
45
Core/Vala/run.lua
Normal file
@ -0,0 +1,45 @@
|
||||
print("Compiling vala files...")
|
||||
print("Changed: ", json.encode_pretty(auResourceCompiler.changedFiles))
|
||||
print("Unchanged: ", json.encode_pretty(auResourceCompiler.unchangedFiles))
|
||||
|
||||
if (#auResourceCompiler.changedFiles == 0) then return end
|
||||
|
||||
local args = auResourceCompiler.arguments.args
|
||||
|
||||
local function addFile(file)
|
||||
args = args .. " \"" .. file .. "\""
|
||||
end
|
||||
|
||||
auForEach(auResourceCompiler.changedFiles, addFile)
|
||||
auForEach(auResourceCompiler.unchangedFiles, addFile)
|
||||
|
||||
local function findVala()
|
||||
if (os.host() == "windows") then
|
||||
local auValac = Aurora.Settings.sAbsValac or path.join(Aurora.Settings.sAbsWin32, "valac.exe")
|
||||
if (os.isfile(auValac)) then return "\"".. auValac .. "\"" end
|
||||
|
||||
local drive = path.getdrive(auGetRoot())
|
||||
|
||||
local localDriveClang = drive .. ":\\msys64\\clang64\\bin\\valac.exe"
|
||||
if (os.isfile(localDriveClang)) then return localDriveClang end
|
||||
|
||||
local localDriveMingw = drive .. ":\\msys64\\mingw64\\bin\\valac.exe"
|
||||
if (os.isfile(localDriveMingw)) then return localDriveMingw end
|
||||
|
||||
local localCClang = "C:\\msys64\\clang64\\bin\\valac.exe"
|
||||
if (os.isfile(localCClang)) then return localCClang end
|
||||
|
||||
local localCMingw = "C:\\msys64\\mingw64\\bin\\valac.exe"
|
||||
if (os.isfile(localCMingw)) then return localCMingw end
|
||||
end
|
||||
|
||||
return "vallac"
|
||||
end
|
||||
|
||||
local exitCode = resourceRun(findVala() .. " " .. args)
|
||||
|
||||
if (auResourceCompiler.arguments.symHack) then
|
||||
auRequire("Core/Vala/valaSym2Def")
|
||||
end
|
||||
|
||||
resourceExit(exitCode)
|
@ -9,7 +9,7 @@ for s in ciaData:gmatch("[^\r\n]+") do
|
||||
table.insert(exports, s)
|
||||
end
|
||||
|
||||
local dllName = auBuild.projectTargetName .. ".dll"
|
||||
local dllName = auBuild.projectTargetFileName
|
||||
|
||||
local buffer = ""
|
||||
buffer = buffer .. "LIBRARY " .. dllName .. "\r\n"
|
||||
|
Loading…
Reference in New Issue
Block a user