218 lines
5.1 KiB
Lua
218 lines
5.1 KiB
Lua
|
require("Utils.utils")
|
||
|
|
||
|
-------------------------------------------------------
|
||
|
-- globals
|
||
|
-------------------------------------------------------
|
||
|
_G["projectsprocessor"] = {}
|
||
|
_G["projectsblocked"] = {}
|
||
|
_G["projectsemitted"] = {}
|
||
|
_G["namespacesemitted"] = {}
|
||
|
_G["usingClang"] = false
|
||
|
_G["usingMSVC"] = false
|
||
|
|
||
|
-------------------------------------------------------
|
||
|
-- process command line arguments into global space
|
||
|
-------------------------------------------------------
|
||
|
require("Boilerplate.options")
|
||
|
|
||
|
-------------------------------------------------------
|
||
|
-- debug stuff
|
||
|
-------------------------------------------------------
|
||
|
function printHeader(key, val)
|
||
|
print("-------------------------------------------------------")
|
||
|
print(key, val)
|
||
|
print("-------------------------------------------------------")
|
||
|
end
|
||
|
|
||
|
function dbgGroup(name)
|
||
|
printHeader("group", name);
|
||
|
group(name)
|
||
|
end
|
||
|
|
||
|
-------------------------------------------------------
|
||
|
-- API
|
||
|
-------------------------------------------------------
|
||
|
local jsonProcessor = require("Boilerplate.jsonProcessor")
|
||
|
|
||
|
local normalizeSourceRoot = function(path)
|
||
|
local backup = path
|
||
|
path = os.realpath(_G.path.join(os.getcwd(), path));
|
||
|
if (not path) then
|
||
|
print("path error, not found?", backup)
|
||
|
return
|
||
|
end
|
||
|
return path
|
||
|
end
|
||
|
|
||
|
local extendInfo = function(this)
|
||
|
local type = this.projectType:lower()
|
||
|
this.isShared = type == "sharedlib"
|
||
|
this.isStatic = type == "staticlib"
|
||
|
this.isExec = type == "consoleapp" or type == 'windowedapp'
|
||
|
this.isConsole = type == "consoleapp"
|
||
|
this.isWindowed = type == "windowedapp"
|
||
|
end
|
||
|
|
||
|
function addVisit(ina)
|
||
|
local args = {
|
||
|
namespace = ina.namespace,
|
||
|
name = ina.name, -- OPT: recommended
|
||
|
path = ina.path,
|
||
|
type = ina.type,
|
||
|
out = ina.out,
|
||
|
translations = ina.translations -- OPT: dictionary of dependency maps
|
||
|
}
|
||
|
|
||
|
local path = normalizeSourceRoot(args.path)
|
||
|
if (not path) then
|
||
|
return
|
||
|
end
|
||
|
|
||
|
local info = {
|
||
|
namespace = args.namespace,
|
||
|
path = path,
|
||
|
projectType = args.type,
|
||
|
out = args.out,
|
||
|
name = args.name,
|
||
|
translations = args.translations
|
||
|
}
|
||
|
|
||
|
extendInfo(info)
|
||
|
|
||
|
local project = {
|
||
|
info = info,
|
||
|
processor = nil
|
||
|
}
|
||
|
|
||
|
if (os.isfile(path .. "/Aurora.lua")) then
|
||
|
project.processor = require(path .. "/Aurora.lua")(info)
|
||
|
elseif (os.isfile(path .. "/Aurora.json")) then
|
||
|
project.processor = jsonProcessor(info)
|
||
|
else
|
||
|
print("Couldnt find Aurora build script for: ", path)
|
||
|
return
|
||
|
end
|
||
|
|
||
|
projectsprocessor[info.name] = project
|
||
|
end
|
||
|
|
||
|
function addScript(ina)
|
||
|
local args = {
|
||
|
namespace = ina.namespace,
|
||
|
script = ina.script,
|
||
|
path = ina.path,
|
||
|
type = ina.type,
|
||
|
out = ina.out
|
||
|
}
|
||
|
|
||
|
local path = normalizeSourceRoot(args.path)
|
||
|
if (not path) then
|
||
|
return
|
||
|
end
|
||
|
|
||
|
local info = {
|
||
|
namespace = args.namespace,
|
||
|
path = path,
|
||
|
projectType = args.type,
|
||
|
out = args.out
|
||
|
}
|
||
|
|
||
|
extendInfo(info)
|
||
|
|
||
|
local project = {
|
||
|
info = info,
|
||
|
processor = nil
|
||
|
}
|
||
|
|
||
|
local procesor = userRequire(args.script)
|
||
|
if (not procesor) then
|
||
|
print("missing project script:", args.script, path)
|
||
|
return
|
||
|
end
|
||
|
|
||
|
project.processor = procesor(info)
|
||
|
if (not project.processor) then
|
||
|
print("script error")
|
||
|
return
|
||
|
end
|
||
|
|
||
|
projectsprocessor[info.name] = project
|
||
|
end
|
||
|
|
||
|
-- private
|
||
|
local processLocalProject = function(proj)
|
||
|
processSubproject(proj.info.name);
|
||
|
end
|
||
|
|
||
|
function processProject()
|
||
|
forEach(projectsprocessor, processLocalProject)
|
||
|
end
|
||
|
|
||
|
function processSubproject(name)
|
||
|
if (projectsblocked[name]) then
|
||
|
return
|
||
|
end
|
||
|
|
||
|
projectsblocked[name] = name
|
||
|
local a = projectsprocessor[name]
|
||
|
if (not a) then
|
||
|
print("missing project: ", name)
|
||
|
return
|
||
|
end
|
||
|
|
||
|
local ns = a.info.namespace
|
||
|
if (not namespacesemitted[ns]) then
|
||
|
namespacesemitted[ns] = "";
|
||
|
dbgGroup(ns)
|
||
|
end
|
||
|
|
||
|
local s = _G["current_project"]
|
||
|
_G["current_project"] = name
|
||
|
a.processor:process(a.processor)
|
||
|
_G["current_project"] = s
|
||
|
|
||
|
projectsemitted[name] = name
|
||
|
end
|
||
|
|
||
|
function isWeakCircularReference(name)
|
||
|
return projectsblocked[name] and not projectsemitted[name]
|
||
|
end
|
||
|
|
||
|
function isProjectLoaded(name)
|
||
|
return projectsemitted[name] and true
|
||
|
end
|
||
|
|
||
|
function getProjectInfo(name)
|
||
|
if (not name) then
|
||
|
return
|
||
|
end
|
||
|
local scre = projectsprocessor[name]
|
||
|
if (not scre) then
|
||
|
return
|
||
|
end
|
||
|
return scre.info
|
||
|
end
|
||
|
|
||
|
function getCurrentProjectName()
|
||
|
return current_project
|
||
|
end
|
||
|
|
||
|
-- private
|
||
|
local buildAction = require("Actions.buildAction")
|
||
|
-- executes inline under iprocessor::process
|
||
|
function addBuildAction(...)
|
||
|
buildAction(...)
|
||
|
end
|
||
|
|
||
|
-- executes inline under iprocessor::process
|
||
|
function addFeature(feature)
|
||
|
local script = os.getcwd() .. "/Build_Script/Features/" .. feature:lower() .. ".lua"
|
||
|
|
||
|
if (not os.isfile(script)) then
|
||
|
return
|
||
|
end
|
||
|
|
||
|
require(script)()
|
||
|
end
|
||
|
|
||
|
require ("Boilerplate.workspace")
|