2021-09-14 13:15:46 +00:00
|
|
|
local function isWin32()
|
|
|
|
return os.is("Windows")
|
|
|
|
end
|
|
|
|
|
|
|
|
local function findVala()
|
|
|
|
if (isWin32()) then
|
2022-03-06 17:28:21 +00:00
|
|
|
local auValac = Aurora.Settings.sAbsValac or path.join(Aurora.Settings.sAbsWin32, "valac.exe")
|
2021-09-14 13:15:46 +00:00
|
|
|
if (os.isfile(auValac)) then return auValac end
|
2021-11-13 08:31:32 +00:00
|
|
|
|
|
|
|
local drive = path.getdrive(auGetRoot())
|
|
|
|
|
|
|
|
local localDriveClang = drive .. ":\\msys64\\clang64\\bin\\valac.exe"
|
2021-09-14 13:15:46 +00:00
|
|
|
if (os.isfile(localDriveClang)) then return localDriveClang end
|
2021-11-13 08:31:32 +00:00
|
|
|
|
|
|
|
local localDriveMingw = drive .. ":\\msys64\\mingw64\\bin\\valac.exe"
|
2021-09-14 13:15:46 +00:00
|
|
|
if (os.isfile(localDriveMingw)) then return localDriveMingw end
|
2021-11-13 08:31:32 +00:00
|
|
|
|
|
|
|
local localCClang = "C:\\msys64\\clang64\\bin\\valac.exe"
|
2021-09-14 13:15:46 +00:00
|
|
|
if (os.isfile(localCClang)) then return localCClang end
|
2021-11-13 08:31:32 +00:00
|
|
|
|
|
|
|
local localCMingw = "C:\\msys64\\mingw64\\bin\\valac.exe"
|
2021-09-14 13:15:46 +00:00
|
|
|
if (os.isfile(localCMingw)) then return localCMingw end
|
|
|
|
end
|
2022-01-17 22:12:51 +00:00
|
|
|
|
|
|
|
return "vallac"
|
2021-09-14 13:15:46 +00:00
|
|
|
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
|
|
|
|
|
2021-11-13 08:31:32 +00:00
|
|
|
auForEach(extended.gir, onGir)
|
|
|
|
auForEach(extended.vapi, onVApi)
|
2021-09-14 13:15:46 +00:00
|
|
|
|
|
|
|
if (extended.girFile) then
|
|
|
|
args = args .. " --gir=" .. extended.girFile
|
|
|
|
end
|
|
|
|
|
|
|
|
local myBrainHurts = false
|
|
|
|
|
2022-01-17 22:12:51 +00:00
|
|
|
local info = auGetCurrentProjectMeta()
|
2021-09-14 13:15:46 +00:00
|
|
|
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
|
|
|
|
|
2021-11-13 08:31:32 +00:00
|
|
|
auForEach(extended.package, onPackage)
|
2021-09-14 13:15:46 +00:00
|
|
|
|
|
|
|
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)
|
2022-03-06 17:28:21 +00:00
|
|
|
files(path)
|
2021-09-14 13:15:46 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
local function onSourcePattern(pattern)
|
2021-11-13 08:31:32 +00:00
|
|
|
auForEach(os.matchfiles(pattern), onSourceFile)
|
2021-09-14 13:15:46 +00:00
|
|
|
end
|
|
|
|
|
2021-11-13 08:31:32 +00:00
|
|
|
auForEach(extended.sources, onSourcePattern)
|
2021-09-14 13:15:46 +00:00
|
|
|
|
|
|
|
--print(exec, args)
|
2021-11-13 08:31:32 +00:00
|
|
|
auAddBuildAction("pre", "bin", exec, true, args)
|
2021-09-14 13:15:46 +00:00
|
|
|
|
|
|
|
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)
|
2021-09-14 13:15:46 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return addVala
|