Build/Core/Vala/Vala.lua

111 lines
3.4 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.sAbsRoot, Aurora.Settings.sRelWin32, "\\Vala\\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)
--print("vala source", path)
args = args .. " \"".. path .. "\""
local cfile = path:gsub("%.vala", "") .. ".c"
--print("vala c", cfile)
files(cfile)
if (usingMSVC) then
files(path)
end
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.sAbsRepoScripts, "Core", "Vala", "valaSym2Def.lua"), path.getDefaultSeparator()), true)
end
end
return addVala