Build/Core/Vala/Vala.lua

107 lines
3.2 KiB
Lua
Raw Normal View History

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") .. "\""}
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 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
2022-03-05 19:34:41 +00:00
auAddBuildAction("pre", "lua", path.translate(path.join(Aurora.Settings.sAbsScripts, "Core", "Vala", "valaSym2Def.lua"), path.getDefaultSeparator()), true)
end
end
return addVala