diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..675acaa --- /dev/null +++ b/.gitignore @@ -0,0 +1,218 @@ +# Aurora's general purpose JS/TS/C/C++/Go vs/vscode/intellij/codelite gitignore reference +# Almost usable for Java and Qt + +# Aurora build configuration +Build_CompilerWorkingDirectory/* +Build_Developers/* +Build_Ship/* +Build_Internal/* +Build_Develop/* +Build_Stage/* +Build_Ship/* +Build_Workspace/* +Build_Symbols/* +Build_Link/* +Build/Developers/* +Build/Ship/* +Build/Develop/* +Build/Stage/* +Build/Ship/* +Build/Workspace/* +Build/Symbols/* +Build/Link/* + +# License Headers VS extension +*.licenseheader + +# Binaries / object files +*.dll +*.exe +*.obj +*.so +*.so.* +*.la +*.lai +*.pdb +*.idb +*.exe~ +*.obj +*.dynlib +*.dylib +*.lib +*.d +*.o +*.a +*.la +*.slo +*.lo +*.out +# go unit test +*.test + +# Autogenerated project files +compile_flags.txt +*.mk +*.project +*cmake +Makefile +*.vcxproj +*.xcodeproj + +# IDE trash +.vscode +.vs +/*.gcno +.intellij +.clion +*.vcxproj.filters +*.vcxproj.user +*.tlog + +# OSX +.DS_Store +.AppleDouble +.LSOverride +xcuserdata/ + +# Win32 +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db +*.lnk + +# Linux is trash and cant hotswap like NT +.nfs* +.fuse_hidden* + +# Ninja +.ninja_deps +.ninja_log + +# PID locks +*.pid +*.pid.lock + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# JetBrains +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# AWS User-specific +.idea/**/aws.xml + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# CMake +cmake-build-*/ + +# Android Studio +.idea/caches/build_file_checksums.ser + +# why would we ever ship this dir? +.idea/caches/* + +# NodeJS +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* +.pnpm-debug.log* + +# node-waf configuration +.lock-wscript + +# Dependency directories +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) +web_modules/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# yarn v2 +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* + +# VS Code Extensions +.vscode-test + +# Qt unit tests +target_wrapper.* + +# QtCreator +*.autosave + +# QtCreator Qml +*.qmlproject.user +*.qmlproject.user.* + +# QtCreator CMake +CMakeLists.txt.user* + +# QtCreator 4.8< compilation database +compile_commands.json + +# QtCreator local machine specific files for imported projects +*creator.user* + +*_qmlcache.qrc + +# QT cache and user files +/.qmake.cache +/.qmake.stash +*.pro.user +*.pro.user.* +*.qbs.user +*.qbs.user.* +*.moc + +# Java trash +hs_err_pid* +.gradle +gradle-app.setting +!gradle-wrapper.jar +.gradletasknamecache +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +pom.xml.next +release.properties +dependency-reduced-pom.xml +buildNumber.properties +.mvn/timing.properties +.mvn/wrapper/maven-wrapper.jar \ No newline at end of file diff --git a/Actions/buildAction.lua b/Actions/buildAction.lua deleted file mode 100644 index ca50d25..0000000 --- a/Actions/buildAction.lua +++ /dev/null @@ -1,106 +0,0 @@ -local getExeFileExt = function() - if os.host() == "windows" then - return ".exe" - end - return "" -end - -local testPath = function(cwd, exe, ext) - local path = cwd .. "/" .. exe .. ext - if (not os.isfile(path)) then - return nil - end - return os.realpath(path) -end - -local getPremakeExec = function() - local exec = premake_exe; - if (exec) then - return exec - end - - if (_PREMAKE_COMMAND) then - premake_exe = _PREMAKE_COMMAND - return premake_exe - end - - local cwd = os.getcwd() - local ext = getExeFileExt() - - local mods = {"auroramake", "premake5", "premake", "genie"} - for k, v in pairs(mods) do - premake_exe = testPath(cwd, v, ext) - if (premake_exe) then - return premake_exe - end - end - - premake_exe = "premake5" - return premake_exe -end - -local addBuildCommand = function(when, scriptType, path, cwdRelToProject, args) - local scriptPath = path - local cwd = getroot() - - if (os.host() == "linux") then - command = "cd \"" .. cwd .. "\" && " - elseif (os.host() == "windows") then - command = "call " - end - - local cur = getProjectInfo(getCurrentProjectName()) - command = command .. getPremakeExec() - command = command .. " --file=\"" .. os.realpath(cwd .. "/Build_Scripts/Actions/buildActionBootstrap.lua") .. "\"" - --command = command .. " --project_name=\"%{prj.name}\"" - command = command .. " --project_name=\"" .. cur.name .. "\"" - command = command .. " --project_arch=\"%{cfg.architecture}\"" - command = command .. " --project_platform=\"%{cfg.system}\"" - - if (cwdRelToProject) then - command = command .. " --actualcwd=\"" .. cur.path .. "\"" - else - command = command .. " --actualcwd=\"" .. os.realpath(cwd) .. "\"" - end - - if (cur and cur.path) then - command = command .. " --project_root=\"" .. cur.path .. "\"" - end - - command = command .. " --scripts=\"" .. os.realpath(cwd .. "/Build_Scripts") .. "\"" - - if (when == "post") then - - local postBuildSuffix = " --cur_binary=\"%{cfg.buildtarget.abspath}\"" - command = command .. postBuildSuffix - end - - local cliArgs = "" - local argsEscaped = "" - if (args) then - argsEscaped = args:gsub("\"", "\\\"") - cliArgs = " " .. argsEscaped - end - - if (scriptType == "lua") then - if (os.isfile(path) and os.realpath(path) == path) then - command = command .. " --luaabsscript=\"" .. path .. "\"" - else - command = command .. " --luascript=\"" .. path .. "\"" - end - - command = command .. " --additional=\"" .. base64.encode(argsEscaped) .. "\"" - elseif (scriptType == "bin") then - command = command .. " --binscript=\"" .. path .. cliArgs .. "\"" - end - - --command = command:gsub("\\","\\\\") - if (when == "post") then - postbuildcommands(command) - elseif (when == "pre") then - prebuildcommands(command) - end - -end - -return addBuildCommand \ No newline at end of file diff --git a/Actions/buildActionBootstrap.lua b/Actions/buildActionBootstrap.lua deleted file mode 100644 index 4ad00c8..0000000 --- a/Actions/buildActionBootstrap.lua +++ /dev/null @@ -1,99 +0,0 @@ -require("Utils/utils") - -newoption -{ - trigger = "binscript", - description = "" -} - -newoption -{ - trigger = "luascript", - description = "" -} - -newoption -{ - trigger = "cur_binary", - description = "" -} - -newoption -{ - trigger = "actualcwd", - description = "" -} - -newoption -{ - trigger = "project_name", - description = "prj.name" -} - -newoption -{ - trigger = "project_arch", - description = "cfg.architecture" -} - -newoption -{ - trigger = "project_platform", - description = "cfg.platform" -} - -newoption -{ - trigger = "project_root", - description = "" -} - -newoption -{ - trigger = "cwd_project_root", - description = "" -} - -newoption -{ - trigger = "additional", - description = "" -} - -newoption -{ - trigger = "luaabsscript", - description = "" -} - -local cwd =_OPTIONS["actualcwd"] -if (cwd) then - os.chdir(cwd) -end - -local binScript = _OPTIONS["binscript"] -if (binScript) then - os.exit(os.execute(binScript)) -end - -_G["_overloadRoot"] = _OPTIONS["actualcwd"] - -_G["build"] = -{ - platform = _OPTIONS["project_platform"], - architecture = _OPTIONS["project_arch"], - projectName = _OPTIONS["project_name"], - projectRoot = _OPTIONS["project_root"], - args = base64.decode(_OPTIONS["additional"]), - root = _overloadRoot -} - -local luaScript = _OPTIONS["luascript"] -local luaAbsScript = _OPTIONS["luaabsscript"] -if (luaScript) then - requireAbs(os.realpath(build.root .. "/Build_UserScripts/" .. luaScript)) -elseif (luaAbsScript) then - requireAbs(luaAbsScript) -end - -os.exit() \ No newline at end of file diff --git a/Boilerplate/buildPostProcess.lua b/Boilerplate/buildPostProcess.lua deleted file mode 100644 index 3aa633f..0000000 --- a/Boilerplate/buildPostProcess.lua +++ /dev/null @@ -1,59 +0,0 @@ -local commonFmt = function(name, type, dir, ex, iswin, buildcfg, realName) - local stringPrefix = ""; - if iswin then - stringPrefix = "*\""; - else - stringPrefix = "\""; - end - - local targetName = string.format("%s.%s.%%{cfg.system}.%%{cfg.architecture}", realName, buildcfg) - local unixName = string.format("%s.%s.%%{cfg.system}.%%{cfg.architecture}", name, buildcfg) - - -- ok, shut up. this was an after thought - -- modules were dynamically loaded in scriptability - targetname(targetName) - - local outputPath = string.format("%s/%s%s", dir, unixName, ex) - local uglyBuildPath = string.format("%%{cfg.targetdir}/%s%s", unixName, ex) - - -- really dont ask what this was for - _G.hack_outputpath = outputPath; - _G.hack_buildoutpath = uglyBuildPath; - - -- - local fmt = string.format("{COPY} \"%s\" \"%s%s", uglyBuildPath, outputPath, stringPrefix); - return fmt; -end - -local LonixFmt1 = function(name, type, dir, ex) - return string.format("mkdir -p \"%s\"", dir); -end - -local postBuildCmdsCopyWindows = function(name, type, cfgHack, dir) - if (type == "SharedLib") then - postbuildcommands({commonFmt(name, type, dir, ".dll", true, cfgHack:lower(), name)}) - elseif ( - (type == "WindowedApp") or - (type == "ConsoleApp") - ) then - postbuildcommands({commonFmt(name, type, dir, ".exe", true, cfgHack:lower(), name)}) - end -end - -local postBuildCmdsCopyLinux = function(name, type, cfgHack, dir) - if (type == "SharedLib") then - postbuildcommands({LonixFmt1(auLibPrefix .. name, type, dir, "")}) - postbuildcommands({commonFmt(auLibPrefix .. name, type, dir, ".so", false, cfgHack:lower(), name)}) - elseif ( - (type == "WindowedApp") or - (type == "ConsoleApp") - ) then - postbuildcommands({LonixFmt1(auLibPrefix .. name, type, dir, "")}) - postbuildcommands({commonFmt(auLibPrefix .. name, type, dir, "", false, cfgHack:lower(), name)}) - end -end - -local handlers = {}; -handlers["target-win32"] = postBuildCmdsCopyWindows; -handlers["target-linux"] = postBuildCmdsCopyLinux; -return require("Utils/lookupCmdArgs")(handlers); \ No newline at end of file diff --git a/Boilerplate/options.lua b/Boilerplate/options.lua deleted file mode 100644 index e2c2aa0..0000000 --- a/Boilerplate/options.lua +++ /dev/null @@ -1,82 +0,0 @@ -newoption -{ - trigger = "target-win32", - description = "Specifies Win32 as the host and compile machine" -} - -newoption -{ - trigger = "target-linux", - description = "Specifies linux as the host and compile machine" -} - -newoption -{ - trigger = "target-switch", - description = "Specifies NX as the host and build chain" -} - -newoption -{ - trigger = "target-switch-pc", - description = "Specifies NX-win32 as the host and build chain" -} - -newoption -{ - trigger = "target-ps5", - description = "Specifies PS5 as the host and build chain" -} - -newoption -{ - trigger = "target-x86_64", - description = "Use Intel vector optimizations and JIT" -} - -newoption -{ - trigger = "target-arm", - description = "Use ARM JIT" -} - -newoption -{ - trigger = "target-wayland", - description = "Compile time support for wayland" -} - -newoption -{ - trigger = "mm-restricted-platform", - description = "uses vendor supplied libcxx for allocations and assumes no jit unless forced" -} - -local tbl = -{ - "target-win32", - "target-linux", - "target-switch", - "target-ps5", - "target-x86_64", - "target-arm", - "target-wayland" -} - -for i, k in pairs(tbl) do - local key = string.sub(k, 8) - _G[key] = false - if (_OPTIONS[k]) then - _G[key] = true - end -end - - -local userOptions = userRequire("options") -if (not userOptions) then - return -end - -for i, k in pairs(userOptions) do - _G[k] = _OPTIONS[k] -end \ No newline at end of file diff --git a/Boilerplate/platform.lua b/Boilerplate/platform.lua deleted file mode 100644 index ba45057..0000000 --- a/Boilerplate/platform.lua +++ /dev/null @@ -1,6 +0,0 @@ -local archMap = {}; -archMap["target-x86_32"] = "x32" -archMap["target-x86_64"] = "x86_64" -archMap["target-aarch"] = "ARM64" ---archMap["target-arm"] = "ARM" unsupported -return require("Utils/lookupCmdArgs")(archMap, true) \ No newline at end of file diff --git a/Boilerplate/preprocessors.lua b/Boilerplate/preprocessors.lua deleted file mode 100644 index 8a3be06..0000000 --- a/Boilerplate/preprocessors.lua +++ /dev/null @@ -1,20 +0,0 @@ -local triggerPairs = {} -triggerPairs["target-win32"] = "_WIN32_AURORA_PREPROCESSOR" -triggerPairs["target-linux"] = "_LINUX_AURORA_PREPROCESSOR" -triggerPairs["target-switch"] = "_SWITCH_AURORA_PREPROCESSOR" -triggerPairs["target-ps4"] = "_PS4_AURORA_PREPROCESSOR" -triggerPairs["target-ps5"] = "_PS5_AURORA_PREPROCESSOR" -triggerPairs["target-xbox"] = "_XBOX_GENERIC_AURORA_PREPROCESSOR" -triggerPairs["target-mac"] = "_APPLE_AURORA_PREPROCESSOR" -triggerPairs["target-ios"] = "_APPLE_MOBILE_AURORA_PREPROCESSOR" -triggerPairs["target-android"] = "_ANDROID_AURORA_PREPROCESSOR" -triggerPairs["mm-restricted-platform"] = "_AURORA_MEM_STRICT" - -local userPaths = userRequire("preprocessors") -if (userPaths) then - if (userPaths.add) then - userPaths.add(triggerPairs) - end -end - -return require("Utils/lookupCmdArgs")(triggerPairs, true); \ No newline at end of file diff --git a/Boilerplate/project.lua b/Boilerplate/project.lua deleted file mode 100644 index 616a857..0000000 --- a/Boilerplate/project.lua +++ /dev/null @@ -1,207 +0,0 @@ -local defintions = require("preprocessors") -local projectCopyCmds = require("buildPostProcess") - -local kPathPrefix = "[BUILD_PATH]" - -local addDest = function(name, projectType, dest) - if (dest:starts(kPathPrefix)) then - local append = dest:sub(#kPathPrefix + 1) - - filter "configurations:Debug" - projectCopyCmds(name, projectType, "debug", getroot() .. "/Build_Develop/" .. append) - - filter "configurations:Release" - projectCopyCmds(name, projectType, "release", getroot() .. "/Build_Stage/" .. append) - - filter "configurations:Ship" - projectCopyCmds(name, projectType, "ship", getroot() .. "/Build_Ship/" .. append) - - filter {} - else - filter "configurations:Debug" - projectCopyCmds(name, projectType, "debug", dest) - - filter "configurations:Release" - projectCopyCmds(name, projectType, "release", dest) - - filter "configurations:Ship" - projectCopyCmds(name, projectType, "ship", dest) - - filter {} - end -end - -local setBestDebugDir = function(dest) - if (not dest or dest:starts(kPathPrefix)) then - local append = dest and dest:sub(#kPathPrefix + 1) - if (not append) then append = "" end - - filter "configurations:Debug" - debugdir(getroot() .. "/Build_Develop/" .. append) - - filter "configurations:Release" - debugdir(getroot() .. "/Build_Stage/" .. append) - - filter "configurations:Ship" - debugdir(getroot() .. "/Build_Ship/" .. append) - - filter {} - else - local path = getroot() .. dest - - debugdir(path) - end -end - -local boilerplateProject = function(name, projectType, src, inc, dest, root) - print("project", name) - project(name) - - targetname(name) - language("C++") -- C and MASM compiler overloads are still available to files requiring different compilers - cppdialect("C++20") - - if (usingMSVC) then - filter {"files:**.cpp or files:**.cc or files:**.cxx"} - buildoptions {"/experimental:module-", "/Zc:__cplusplus"} - filter {} - end - - if (usingClang or usingGXX) then - -- define "_FILE_OFFSET_BITS=64" - -- define "_LARGEFILE64_SOURCE" - -- -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 - end - - if (usingClang or usingMSVC) then - defines "_AU_HAS_ATOMIC_INTRINS" - end - - kind(projectType) - - defines("_AU_BUILDING_" .. string.upper(projectType)) - - if (usingMSVC) then - buildoptions {"-utf-8"} - end - - targetprefix(auLibPrefix) - - if (not _G.win32) then - if ((projectType == "SharedLib") or - (projectType == "StaticLib")) then - pic "On" - - if (usingGXX) then - -- TODO: we dont actually support gxx - -- We expect clang or msvc - -- msvcs thread local is fine, windows has always had decent thread in/out callbacks - -- clang has a cross platform, per variable solution - -- -> `__thread __attribute__((tls_model("initial-exec")));` - -- initial-exec is recommended when pic is on. does not work for dynamically loaded modules - buildoptions{"-ftls-model=initial-exec"} - end - end - end - - if (_G.win32) then - characterset("MBCS") - staticruntime("Off") - - defines "_CRT_SECURE_NO_WARNINGS" - end - - objdir(getroot() .. "/Build_CompilerWorkingDirectory/" .. name) - - if (root) then - location(root) - else - location(os.getcwd()) - end - - -- V8 takes minutes to start up on an i9-9900k, QST/VM tests result in highs of ~30MB/s from 900MB/s - -- In place of page NX traps and suspending thread contexts like most debug operations, - -- they perform an expensive check in each functions prologue :vomit: - -- MSVCs implementation is not fit for use. - justmycode "Off" - - -- again, ye no, i would actually like usable debug builds - defines - { - "_ITERATOR_DEBUG_LEVEL=0", - } - - -- add defintions - defines(defintions) - - local includeCommonBoilerplate = getroot() .. "/Include"; - if (os.isdir(includeCommonBoilerplate)) then - includedirs(includeCommonBoilerplate) - files(includeCommonBoilerplate .. "/**.h*") - end - - -- add includes, if available - if inc ~= nil then - forEach(inc, function(path) - print("", "include", _G.path.normalize(path)) - includedirs(path) - - files(path .. "/**.h") - files(path .. "/**.hpp") - files(path .. "/**.inl") - end) - end - - -- add sources, if available - if src ~= nil then - - annoyingfirst = false - forEach(src, function(path, root) - print("", "source", _G.path.normalize(path)) - - --if (string.sub(path, -2) == ".*") then - if (string.find(path, "*")) then - files {path} - return - end - - if (os.isfile(path)) then - files {path} - return - end - - annoyingfirst = true - - if ((not root) or (root ~= "MAGIC")) then - includedirs(path) - end - - files - { - path .. "/**.*pp", - path .. "/**.inl", - path .. "/**.c", - path .. "/**.cc", - path .. "/**.cxx", - path .. "/**.h", - path .. "/**.masm" -- explicitly required - } - end, root) - end - - local debugDir = nil - - if (type(dest) == "string") then debugDir = dest end - if (type(dest) == "table") then debugDir = dest[1] end - setBestDebugDir(debugDir) - - if (dest) then - forEach(dest, function(v) - addDest(name, projectType, v) - end) - end - - print() -end - -return boilerplateProject \ No newline at end of file diff --git a/Boilerplate/workspace.lua b/Boilerplate/workspace.lua deleted file mode 100644 index 8cf4e73..0000000 --- a/Boilerplate/workspace.lua +++ /dev/null @@ -1,117 +0,0 @@ -local toolPlatforms = {"win32", "linux"} - -------------------------------------------------------- --- build platform -------------------------------------------------------- -local isWin = _G.win32 -local isToolChain = false - -for k in pairs(toolPlatforms) do - if (_G[toolPlatforms[k]]) then - isToolChain = true - end -end - -printHeader("configuration", "platforms") -print("isWin", isWin) -print("isDevelopmentPlatform", isToolChain) -print() - - -------------------------------------------------------- --- create workspace -------------------------------------------------------- -local target = require("platform") - -function startSolution(name) - - workspace(name) - configurations { "Debug", "Release", "Ship" } - - platforms(target) - architecture(target[1]) - - location(getroot() .. "/Build_CompilerWorkingDirectory/") - - symbols "On" - staticruntime "On" - visibility "Hidden" - editandcontinue "Off" - - flags - { - "NoPCH", - "MultiProcessorCompile" - } - - filter "configurations:Debug" - defines { "DEBUG" } - targetdir(getroot() .. "/Build_CompilerWorkingDirectory/Bin/Debug") - debugdir( getroot() .. "/Build_Develop") - flags "NoIncrementalLink" - - filter "configurations:Release or configurations:Ship" - defines { "NDEBUG" } - optimize "Speed" - - filter "configurations:Release" - defines {"STAGING"} - targetdir(getroot() .. "/Build_CompilerWorkingDirectory/Bin/Release") - debugdir(getroot() .. "/Build_Stage") - flags "NoIncrementalLink" - - filter "configurations:Ship" - defines {"SHIP"} - targetdir(getroot() .. "/Build_CompilerWorkingDirectory/Bin/Ship") - debugdir(getroot() .. "/Build_Ship") - flags "LinkTimeOptimization" - filter {} - - - stringpooling "true" - floatingpoint "strict" - - - if ((not isWin) or (_G.forceClang)) then - usingClang = true - toolset "clang" - - buildoptions {"-fms-extensions"} - - filter {"files:**.cpp or files:**.cc"} - buildoptions {"-stdlib=libc++"} - filter {} - - disablewarnings - { - -- we live life on the edge - "unused-result", - -- warning: unused unused enumeration - "unused-value", - "unknown-warning-option" - } - elseif (isWin) then - usingMSVC = true - - disablewarnings - { - "4996", -- The whiny C99 is no longer supported nag - -- please needlessly use '_s' and '_'d functions __error__ - - - "4251", -- MSVC's hurrdurr abis will break if you dynamically link classes - -- counter: sod off again. we have full control of the build process, and we only link against - -- dynamic c/stl runtimes. which brainlet thought this was a good idea? - -- even microsofts own documentation dont state what is guaranteed to be safe. - -- dont mix optimizations, mitigation flags, and so on. - -- rtti works; the stl doesn't abuse inline/module specific globals; who cares? - - "4244" -- conversion from 'double' to 'float', possible loss of data - -- this warning is extremely important; however, we're developing a game engine and utilities - -- pragma warning push + disable + pop and/or static_casts to hint we expect floating point precision - -- loss is extremely annoying and impractical. further, projects including harfbuzz, freetype, - -- and v8 don't seem to care about this warning either - } - end - -end \ No newline at end of file diff --git a/Core/Actions/Actions.lua b/Core/Actions/Actions.lua new file mode 100644 index 0000000..b0b7a50 --- /dev/null +++ b/Core/Actions/Actions.lua @@ -0,0 +1,177 @@ +local isUnixPremake = os.host() == "linux" or os.host() == "mac" +local isWin32 = os.host() == "windows" +local isCmakeToolChain = false + +local getExeFileExt = function() + if isWin32 then + return ".exe" + end + + return "" +end + +local testPath = function(cwd, exe, ext) + local path = cwd .. "/" .. exe .. ext + if (not os.isfile(path)) then + return nil + end + return os.realpath(path) +end + +local function getAuBinsForPlatform() + local cwd = auGetAuroraRoot() + + if (isUnixPremake) then + cwd = cwd .. auGetSetting("sRelUnixBins") + end + + if (isWin32) then + cwd = cwd .. auGetSetting("sRelWin32") + end + + return cwd +end + +local getPremakeExec = function() + local exec = premake_exe; + if (exec) then + return exec + end + + if (isCmakeToolChain) then + premake_exe = auGetSetting("sDefaultCmakePremakeBin") + return premake_exe + end + + if (isUnixPremake or isWin32) then + local cwd = getAuBinsForPlatform() + local ext = getExeFileExt() + + local mods = {auGetSetting("sDefaultCmakePremakeBin"), "auroramake", "aumake", "premake5", "genie"} + for k, v in pairs(mods) do + local abs = testPath(cwd, v, ext) + + if (abs and isUnixPremake) then + premake_exe = v .. ext + else + premake_exe = abs + end + + if (premake_exe) then + return premake_exe + end + end + end + + if (isWin32) then + if (_PREMAKE_COMMAND) then + premake_exe = _PREMAKE_COMMAND + return premake_exe + end + end + + premake_exe = "premake5" + return premake_exe +end + +local addBuildCommand = function(when, scriptType, path, cwdRelToProject, args) + local scriptPath = path + local cwd = auGetRoot() + + local host = os.host() + local cdAware = isUnixPremake + + local command = "" + + if (isCmakeToolChain) then + command = "" + elseif (cdAware and scriptType == "lua") then + command = "cd \"" .. getAuBinsForPlatform() .. "\" && " + elseif (cdAware) then + command = "cd \"" .. cwd .. "\" && " + elseif (host == "windows") then + command = "call " + end + + local cur = getProjectInfo(getCurrentProjectName()) + command = command .. getPremakeExec() + + local oldBootstrapPrefix = Aurora.Settings.sAbsRepoScripts + local bootstrapPrefix = _G.path.getrelative(Aurora.Settings.sAbsCompilerWd .. "/" .. getCurrentProjectName(), Aurora.Settings.sAbsRepoScripts) + + local bootstrap = bootstrapPrefix .. "/Core/Actions/buildActionBootstrap.lua" + + if (cdAware) then + command = command .. " --file=\"" .. bootstrap .. "\"" + else + command = command .. " --file=\"" .. os.realpath(bootstrap) .. "\"" + end + --command = command .. " --project_name=\"%{prj.name}\"" + command = command .. " --project_name=\"" .. cur.name .. "\"" + command = command .. " --project_type=\"" .. cur.projectType .. "\"" + command = command .. " --project_arch=\"%{cfg.architecture}\"" + command = command .. " --project_platform=\"%{cfg.system}\"" + + -- Aurora.Settings could take up too much of the win32 max command line buffer (8191 characters) + -- This seems like a lot, but it should be well within the 9k limit + -- Abs can be skipped and i really dont believe we need the other settings + local settings = + { + sAbsRoot = Aurora.Settings.sAbsRoot, + sRelAuRoot = Aurora.Settings.sRelAuRoot, + sRelScripts = Aurora.Settings.sRelScripts, + sRelRepoScripts = Aurora.Settings.sRelRepoScripts, + sRelDebug = Aurora.Settings.sRelDebug, + sRelStage = Aurora.Settings.sRelStage, + sRelShip = Aurora.Settings.sRelShip, + sRelWd = Aurora.Settings.sRelWd, + sRelSymbols = Aurora.Settings.sRelSymbols, + sRelLinkLibs = Aurora.Settings.sRelLinkLibs + } + command = command .. " --settings=" .. base64.encode(json.encode(settings)) + + -- the last thing i couldn't port + -- we don't need it + --if (when == "post") then + -- local postBuildSuffix = " --cur_binary=\"%{cfg.buildtarget.abspath}\"" + -- command = command .. postBuildSuffix + --end + + if (cwdRelToProject) then + command = command .. " --cwd" + end + + if (cur and cur.path) then + command = command .. " --project_root=\"" .. _G.path.getrelative(settings.sAbsRoot, cur.path) .. "\"" + end + + local cliArgs = "" + local argsEscaped = "" + if (args) then + argsEscaped = args:gsub("\"", "\\\"") + cliArgs = " " .. argsEscaped + end + + if (scriptType == "lua") then + if (os.isfile(Aurora.Settings.sAbsRepoScripts .. path)) then + command = command .. " --luascript=\"" .. path .. "\"" + else + command = command .. " --luaabsscript=\"" .. _G.path.getrelative(settings.sAbsRoot, path) .. "\"" + end + + if (args) then + command = command .. " --additional=\"" .. base64.encode(args) .. "\"" + end + elseif (scriptType == "bin") then + command = command .. " --binscript=\"" .. _G.path.getrelative(settings.sAbsRoot, path) .. cliArgs .. "\"" + end + + if (when == "post") then + postbuildcommands(command) + elseif (when == "pre") then + prebuildcommands(command) + end + +end + +return addBuildCommand \ No newline at end of file diff --git a/Core/Actions/buildActionBootstrap.lua b/Core/Actions/buildActionBootstrap.lua new file mode 100644 index 0000000..f5d9759 --- /dev/null +++ b/Core/Actions/buildActionBootstrap.lua @@ -0,0 +1,97 @@ +local aurora = {} +_G["Aurora"] = aurora + +function auFetchGlobal(name) + local ret = aurora[name] or {} + aurora[name] = ret + return ret +end + +require("./../../Utilities/Utilities") + +local triggers = +{ + "binscript", + "luascript", + "cwd", + "settings", + "project_name", + "project_arch", + "project_platform", + "project_root", + "additional", + "project_type", + "luaabsscript" +} + +auForEach(triggers, function(trigger) + newoption + { + trigger = trigger, + description = "" + } +end) + +local settings = _OPTIONS["settings"] +if (settings) then + Aurora.Settings = json.decode(base64.decode(settings)) + + require("./../../Public/Paths") +end + +local projRoot = path.join(Aurora.Settings.sAbsRoot, _OPTIONS["project_root"] or "./") + +local cwd =_OPTIONS["cwd"] +if (cwd) then + os.chdir(projRoot) +else + os.chdir(Aurora.Settings.sAbsRoot) +end + +local binScript = _OPTIONS["binscript"] +if (binScript) then + os.exit(os.execute(path.join(Aurora.Settings.sAbsRoot, binScript))) +end + +local args = _OPTIONS["additional"] +if (args) then + args = base64.decode(args) +end + +local projName = _OPTIONS["project_name"] +local projType = _OPTIONS["project_type"] +local projPlatform = _OPTIONS["project_platform"] +local projArch = _OPTIONS["project_arch"] + +local targetName = projName .. "." .. projPlatform .. "." .. projArch +local fileName = targetName + +local platform = Aurora.Platforms[platformName] +if (platform) then + fileName = fileName .. (platform.exts or {})[type] or "" +end + +auBuild = +{ + platform = projPlatform, + architecture = projArch, + projectName = projName, + projectType = projType, + projectRoot = projRoot, + projectTargetName = targetName, + projectTargetFileName = fileName, + args = args, + root = cwd +} + +_G["build"] = auBuild + +local luaScript = _OPTIONS["luascript"] +local luaAbsScript = _OPTIONS["luaabsscript"] +if (luaScript) then + auRequireAbs(os.realpath(build.root .. "/Build_UserScripts/" .. luaScript)) +elseif (luaAbsScript) then + auRequireAbs(path.join(Aurora.Settings.sAbsRoot, luaAbsScript)) +end + +os.exit() \ No newline at end of file diff --git a/Core/BuildHooks/BuildHooks.lua b/Core/BuildHooks/BuildHooks.lua new file mode 100644 index 0000000..e2ebe50 --- /dev/null +++ b/Core/BuildHooks/BuildHooks.lua @@ -0,0 +1,132 @@ +local kPathPrefix = "!" + +local function normalizeCpyPath(absPath) + return "../../" .. path.getrelative(Aurora.Settings.sAbsRoot, absPath) +end + +-- file name, type, directory, extension, is windows, configuration, real name +local function formatCpy(name, type, dir, ex, iswin, config, platformName, arch, realName) + local pathSuffix = ""; + + if (iswin) then + pathSuffix = "*\""; + else + pathSuffix = "\""; + end + + if (Aurora.Settings.bDefinePartialABIInTargetName) then + name = string.format("%s.%s.%s.%s", name, config, platformName:gsub("^%l", string.upper), arch) + end + + local outputPath = string.format("%s/%s%s", dir, name, ex) + local outputTarget = string.format("%s/%s", dir, name) + local uglyBuildPath = string.format("%%{cfg.targetdir}/%s%s", name, ex) + + return string.format("{COPY} \"%s\" \"%s%s", uglyBuildPath, outputPath, pathSuffix), outputPath, uglyBuildPath +end + +local function gnuCoreUtilsMkdirRecursive(dir) + return string.format("mkdir -p \"%s\"", dir); +end + +local function archiveShipPdb(pdbPath) + -- TODO (reece): +end + +local function addUserDestCopy(name, type, config, platformName, arch, dir) + local isWin = platformName == "win32" + local debugSymbolPath = nil + + local platform = Aurora.Platforms[platformName] + if (not platform) then + return + end + + local ext = (platform.exts or {})[type] or "" + + local copy, outputPath, file = formatCpy(Aurora.Settings.sLibPrefix .. name, type, dir, ext, isWin, config, platformName, arch, name) + + if (platformName == "linux" or platformName == "freebsd" or platformName == "mac") then + gnuCoreUtilsMkdirRecursive(dir) + end + + if (platform.requiresElfStrip and platform.supportsElfStrip and config == Aurora.Settings.sNameOfShip) then + local debugSymbolPath = normalizeCpyPath(Aurora.Settings.sAbsSymbols) .. "/" .. name .. ".dwarf" + postbuildcommands("objcopy --strip-debug " .. file .. " " .. outputPath) + if (Aurora.Settings.bUseAuBuildHooks) then + postbuildcommands("objcopy --add-gnu-debuglink=" .. debugSymbolPath .. " " .. outputPath) + end + else + postbuildcommands(copy) + end +end + +local function addDest(name, projectType, dest) + local lookup = {} + local append = "" + + if (dest:starts(kPathPrefix)) then + append = dest:sub(#kPathPrefix + 1) + local fu = auFilterConfig(Aurora.Settings.sNameOfDebug) + + lookup[Aurora.Settings.sNameOfDebug] = normalizeCpyPath(Aurora.Settings.sAbsDebug) + lookup[Aurora.Settings.sNameOfInternal] = normalizeCpyPath(Aurora.Settings.sAbsStage) + lookup[Aurora.Settings.sNameOfShip] = normalizeCpyPath(Aurora.Settings.sAbsShip) + else + lookup[Aurora.Settings.sNameOfDebug] = dest + lookup[Aurora.Settings.sNameOfInternal] = dest + lookup[Aurora.Settings.sNameOfShip] = dest + end + + auFilterForConfigPlatforms(function(config, platform, arch) + addUserDestCopy(name, projectType, config, platform, arch, lookup[config] .. append) + end) +end + +local function postBuildCommands(name, type, config, platformName, arch) + if (isWin) then + postbuildcommands(formatCpy(Aurora.Settings.sLibPrefix .. name, type, normalizeCpyPath(Aurora.Settings.sAbsSymbols), ".pdb", true, config, platformName, arch, name)) + + if (type == "SharedLib" or + type == "StaticLib") then + postbuildcommands(formatCpy(Aurora.Settings.sLibPrefix .. name, type, normalizeCpyPath(Aurora.Settings.sRelLinkLibs), ".lib", true, config, platformName, arch, name)) + end + else + if (type == "SharedLib" or + type == "StaticLib") then + postbuildcommands(formatCpy(Aurora.Settings.sLibPrefix .. name, type, normalizeCpyPath(Aurora.Settings.sRelLinkLibs), ext, true, config, platformName, arch, name)) + end + end + + if (config == Aurora.Settings.sNameOfShip) then + local debugSymbolPath = nil + + if (platform.requiresElfStrip and platform.supportsElfStrip) then + debugSymbolPath = normalizeCpyPath(Aurora.Settings.sAbsSymbols) .. "/" .. name .. ".dwarf" + postbuildcommands("objcopy --only-keep-debug " .. file .. " " .. debugSymbolPath) + elseif (isWin) + debugSymbolPath = normalizeCpyPath(Aurora.Settings.sAbsSymbols) .. "/" .. name .. ".pdb" + end + + if (debugSymbolPath) then + archiveShipPdb(debugSymbolPath) + end + else + postbuildcommands(copy) + end +end + +local function startProject(name, projectType, dest) + if (not Aurora.Settings.bUseAuBuildHooks) then + return + end + + auFilterForConfigPlatforms(function(config, platform, arch) + postBuildCommands(name, projectType, config, platform, arch) + end) +end + +return { + startProject = startProject, + addDest = addDest +} \ No newline at end of file diff --git a/Core/Core.lua b/Core/Core.lua new file mode 100644 index 0000000..d10347c --- /dev/null +++ b/Core/Core.lua @@ -0,0 +1,4 @@ +return { + project = auRequire("Core/project"), + solution = auRequire("Core/solution") +} \ No newline at end of file diff --git a/Core/JSON/JSON.lua b/Core/JSON/JSON.lua new file mode 100644 index 0000000..e69de29 diff --git a/Core/JSON/jsonProject.lua b/Core/JSON/jsonProject.lua new file mode 100644 index 0000000..e69de29 diff --git a/Core/JSON/jsonSolution.lua b/Core/JSON/jsonSolution.lua new file mode 100644 index 0000000..e69de29 diff --git a/Core/M4/M4.lua b/Core/M4/M4.lua new file mode 100644 index 0000000..e69de29 diff --git a/Core/Protobuf/Protobuf.lua b/Core/Protobuf/Protobuf.lua new file mode 100644 index 0000000..e69de29 diff --git a/Core/ResourceCompiler/ResourceCompiler.lua b/Core/ResourceCompiler/ResourceCompiler.lua new file mode 100644 index 0000000..e69de29 diff --git a/Core/Target/Target.lua b/Core/Target/Target.lua new file mode 100644 index 0000000..eaecfbe --- /dev/null +++ b/Core/Target/Target.lua @@ -0,0 +1,169 @@ +_auCurrentPlatforms = {} +_auCurrentArchs = {} +_auCurrentFlags = {} +_auExtendedConfig = false +_auExtendedArch = false + +auRequire("Core/Target/arch") +auRequire("Core/Target/flags") +auRequire("Core/Target/platform") + +local function addTarget(prefix, available, flags) + auForEachKV(available, function(key, value) + local option = prefix .. "-" .. key + newoption + { + trigger = option, + description = "" + } + + if (_OPTIONS[option]) then + table.insert(flags, key) + end + end) +end + +local function start() + addTarget("target", Aurora.Platforms, _auCurrentPlatforms) + addTarget("target", Aurora.Architectures, _auCurrentArchs) + addTarget("flag", Aurora.Flags, _auCurrentFlags) + + _auExtendedConfig = #_auCurrentPlatforms > 1 + _auExtendedArch = #_auCurrentArchs > 1 +end + +local function startProject() + auFilterForConfigPlatforms(function(config, platform, architecture) + _G.architecture(Aurora.Architectures[architecture].architecture) + defines(Aurora.Platforms[platform].defines) + end) +end + +local function startSolution() + local configs = {} + + if (not _auExtendedConfig and not _auExtendedArch) then + auForEach(Aurora.Settings.aNamesOfConfigs, function(config) + table.insert(configs, config) + end) + else + auForEach(_auCurrentPlatforms, function(platform) + auForEach(_auCurrentArchs, function(arch) + auForEach(Aurora.Settings.aNamesOfConfigs, function(config) + table.insert(configs, platform .. arch .. config) + end) + end) + end) + end + + configurations(configs) +end + +local function auFilterForArchs(callback, ...) + auForEach(_auCurrentArchs, function(arch, ...) + filter(auConcatVararg({"architecture:" .. arch}, ...)) + callback(arch) + filter {} + end, ...) +end + +local function auFilterForPlatforms(callback, ...) + auFilterForConfigPlatforms(function(config, platform) + callback(platform) + end, extendedFilter) +end + +local function auFilterForConfigs(callback, ...) + auFilterForConfigPlatforms(function(config, platform) + callback(config) + end, extendedFilter) +end + +local function auFilterForConfigPlatforms(callback, ...) + auForEach(_auCurrentPlatforms, function(platform, ...) + auForEach(_auCurrentArchs, function(arch, ...) + auForEach(Aurora.Settings.aNamesOfConfigs, function(config, ...) + + if (not _auExtendedConfig and not _auExtendedArch) then + filter(auConcatVararg({"configurations:" .. config}, ...)) + else + filter(auConcatVararg({"configurations:" .. platform .. arch .. config}, ...)) + end + + callback(config, platform, arch) + filter {} + end, ...) + end, ...) + end, ...) +end + +local function auFilterOf(configFilter, ...) + local ret = {} + + local test = function(val, orArray, notArray) + if (orArray) then + if (type(orArray) == "string") then + if (orArray ~= val) then + return + end + elseif (#orArray > 0) then + if (not auContains(orArray, val)) then + return + end + end + end + + if (notArray) then + if (type(notArray) == "string") then + if (notArray == val) then + return + end + elseif (#notArray > 0) then + if (auContains(notArray, val)) then + return + end + end + end + + return true + end + + auForEach(_auCurrentPlatforms, function(platform) + auForEach(_auCurrentArchs, function(arch) + auForEach(Aurora.Settings.aNamesOfConfigs, function(config) + + if (not test(config, configFilter.configs, configFilter.notConfigs)) then + return + end + + if (not test(arch, configFilter.archs, configFilter.notArchs)) then + return + end + + if (not test(platform, configFilter.platforms, configFilter.notPlatform)) then + return + end + + if (not _auExtendedConfig and not _auExtendedArch) then + table.insert(ret, "configurations:" .. config) + else + table.insert(ret, "configurations:" .. platform .. arch .. config) + end + + end) + end) + end) + + return auConcatVararg({table.concat(ret, " or ")}, ...) +end + +return { + start = start, + startSolution = startSolution, + startProject = startProject, + auFilterForPlatforms = auFilterForPlatforms, + auFilterForConfigs = auFilterForConfigs, + auFilterForConfigPlatforms = auFilterForConfigPlatforms, + auFilterOf = auFilterOf, + auFilterForArchs = auFilterForArchs +} \ No newline at end of file diff --git a/Core/Target/arch.lua b/Core/Target/arch.lua new file mode 100644 index 0000000..0160280 --- /dev/null +++ b/Core/Target/arch.lua @@ -0,0 +1,14 @@ +local arch = { + arm = { + architecture = "ARM64" + }, + x86_64 = { + architecture = "x86_64" + }, + x86_32 = { + architecture = "x86", + note = "I didn't support 32-bit x86 initially. Support is work in progress" + } +} + +auMergeTable(auFetchGlobal("Architectures"), arch) \ No newline at end of file diff --git a/Core/Target/flags.lua b/Core/Target/flags.lua new file mode 100644 index 0000000..b31d6d9 --- /dev/null +++ b/Core/Target/flags.lua @@ -0,0 +1,7 @@ +local flags = { + restricted_platform = { + defines = "_AURORA_MEM_STRICT" + } +} + +auMergeTable(auFetchGlobal("Flags"), flags) \ No newline at end of file diff --git a/Core/Target/platform.lua b/Core/Target/platform.lua new file mode 100644 index 0000000..12866c6 --- /dev/null +++ b/Core/Target/platform.lua @@ -0,0 +1,49 @@ +local platforms = { + win32 = { + defines = "_WIN32_AURORA_PREPROCESSOR", + targetLocal = true, + exts = { + SharedLib = ".dll", + WindowedApp = ".exe", + ConsoleApp = ".exe" + } + }, + freebsd = { + targetLocal = true, + forceLLVMStl = true, + requiresElfStrip = true, + supportsElfStrip = true, + exts = { + SharedLib = ".so" + } + }, + linux = { + defines = "_LINUX_AURORA_PREPROCESSOR", + forceLLVMStl = true, + targetLocal = true, + requiresElfStrip = true, + supportsElfStrip = true, + exts = { + SharedLib = ".so" + } + }, + mac = { + defines = "_APPLE_AURORA_PREPROCESSOR", + targetLocal = true, + exts = { + SharedLib = ".dynlib" + } + }, + ios = { + defines = "_APPLE_MOBILE_AURORA_PREPROCESSOR" + }, + android = { + defines = "_ANDROID_AURORA_PREPROCESSOR", + requiresElfStrip = true, + exts = { + SharedLib = ".so" + } + } +} + +auMergeTable(auFetchGlobal("Platforms"), platforms) \ No newline at end of file diff --git a/Boilerplate/vala.lua b/Core/Vala/Vala.lua similarity index 81% rename from Boilerplate/vala.lua rename to Core/Vala/Vala.lua index 06b6dd8..c57a6bc 100644 --- a/Boilerplate/vala.lua +++ b/Core/Vala/Vala.lua @@ -4,16 +4,21 @@ end local function findVala() if (isWin32()) then - local drive = path.getdrive(getroot()) - local localDriveClang = drive .. ":\\msys64\\clang64\\bin\\valac.exe" - local localDriveMingw = drive .. ":\\msys64\\mingw64\\bin\\valac.exe" - local localCClang = "C:\\msys64\\clang64\\bin\\valac.exe" - local localCMingw = "C:\\msys64\\mingw64\\bin\\valac.exe" - local auValac = _G["auValac"] or getroot() .. "\\Build_Scripts\\ValaWin32\\valac.exe" + 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 else return "vallac" @@ -41,8 +46,8 @@ local function addVala(extended) args = args .. " --vapidir=\"" .. expandPartialRelDir(partial) .. "\"" end - forEach(extended.gir, onGir) - forEach(extended.vapi, onVApi) + auForEach(extended.gir, onGir) + auForEach(extended.vapi, onVApi) if (extended.girFile) then args = args .. " --gir=" .. extended.girFile @@ -66,7 +71,7 @@ local function addVala(extended) args = args .. " --pkg=" .. pkg end - forEach(extended.package, onPackage) + auForEach(extended.package, onPackage) args = args .. " --directory=\"" .. os.getcwd() .. "\"" @@ -90,16 +95,16 @@ local function addVala(extended) end local function onSourcePattern(pattern) - forEach(os.matchfiles(pattern), onSourceFile) + auForEach(os.matchfiles(pattern), onSourceFile) end - forEach(extended.sources, onSourcePattern) + auForEach(extended.sources, onSourcePattern) --print(exec, args) - addBuildAction("pre", "bin", exec, true, args) + auAddBuildAction("pre", "bin", exec, true, args) if (myBrainHurts) then - addBuildAction("pre", "lua", path.translate(path.join(getroot(), "Build_Scripts", "Boilerplate", "valaSym2Def.lua"), path.getDefaultSeparator()), true) + auAddBuildAction("pre", "lua", path.translate(path.join(Aurora.Settings.sAbsRepoScripts, "Core", "Vala", "valaSym2Def.lua"), path.getDefaultSeparator()), true) end end diff --git a/Boilerplate/valaSym2Def.lua b/Core/Vala/valaSym2Def.lua similarity index 85% rename from Boilerplate/valaSym2Def.lua rename to Core/Vala/valaSym2Def.lua index 0a0870a..7c0f6a8 100644 --- a/Boilerplate/valaSym2Def.lua +++ b/Core/Vala/valaSym2Def.lua @@ -11,7 +11,7 @@ end -- so, we can't pull the target module name until we've actually built the binary -- we'll just have to guess for now -local dllName = build.projectName .. "." .. build.platform .. "." .. build.architecture .. ".dll" +local dllName = build.projectTargetName .. ".dll" local buffer = "" buffer = buffer .. "LIBRARY " .. dllName .. "\r\n" diff --git a/Core/base.lua b/Core/base.lua new file mode 100644 index 0000000..8862d7c --- /dev/null +++ b/Core/base.lua @@ -0,0 +1 @@ +auRequire("Core/Target").start() diff --git a/Core/project.lua b/Core/project.lua new file mode 100644 index 0000000..a9f518d --- /dev/null +++ b/Core/project.lua @@ -0,0 +1,298 @@ +local buildHooks = require("Core/BuildHooks") +local targetingCmake = false +local targetingWindows = os.host() == "windows" +local bugHack = targetingCmake or targetingWindows + +local kPathPrefix = "!" + +local addDest = function(name, projectType, dest) + buildHooks.addDest(name, projectType, dest) +end + +local function configureProjectForSolution(prj) + filter(auFilterConfig(Aurora.Settings.sNameOfDebug)) + defines { "DEBUG" } + targetdir(Aurora.Settings.sAbsCompilerWd .. "/Bin/" .. Aurora.Settings.sNameOfDebug) + debugdir(Aurora.Settings.sAbsDebug) + flags "NoIncrementalLink" + + filter(auFilterConfig({Aurora.Settings.sNameOfInternal, Aurora.Settings.sNameOfShip})) + defines { "NDEBUG" } + optimize "Speed" + + filter(auFilterConfig(Aurora.Settings.sNameOfInternal)) + defines { "STAGING" } + targetdir(Aurora.Settings.sAbsCompilerWd .. "/Bin/" .. Aurora.Settings.sNameOfInternal) + debugdir(Aurora.Settings.sAbsStage) + flags "NoIncrementalLink" + + filter(auFilterConfig(Aurora.Settings.sNameOfShip)) + defines { "SHIP" } + targetdir(Aurora.Settings.sAbsCompilerWd .. "/Bin/" .. Aurora.Settings.sNameOfShip) + debugdir(Aurora.Settings.sAbsShip) + flags "LinkTimeOptimization" + filter {} + + auFilterForConfigPlatforms(function(config, platformName, arch) + if (Aurora.Settings.bDefinePartialABIInTargetName) then + targetname(string.format("%s.%s.%s.%s", prj.name, config, platformName:gsub("^%l", string.upper), arch)) + end + + if (not(config == Aurora.Settings.sNameOfShip)) then return end + local platform = Aurora.Platforms[platformName] + + if (platform.requiresElfStrip and not platform.supportsElfStrip) then + symbols "Off" + end + end) +end + +local function setBestDebugDir(dest) + if (not dest or dest:starts(kPathPrefix)) then + local append = dest and dest:sub(#kPathPrefix + 1) + if (not append) then append = "" end + + filter("configurations:" .. Aurora.Settings.sNameOfDebug) + debugdir(Aurora.Settings.sAbsDebug .. "/" .. append) + + filter("configurations:" .. Aurora.Settings.sNameOfInternal) + debugdir(Aurora.Settings.sAbsStage .. "/" .. append) + + filter("configurations:" .. Aurora.Settings.sNameOfShip) + debugdir(Aurora.Settings.sAbsShip .. "/" .. append) + + filter {} + else + debugdir(auGetRoot() .. dest) + end +end + +local function configureProjectForCompiler() + if (targetingCmake) then + filter {"toolset:msc"} + end + + if (bugHack) then + buildoptions {"-utf-8"} + end + + if (targetingCmake) then + filter {"toolset:msc", "files:**.cpp or files:**.cc or files:**.cxx"} + elseif (bugHack) then + filter {"files:**.cpp or files:**.cc or files:**.cxx"} + end + + if (bugHack) then + buildoptions {"/experimental:module-", "/Zc:__cplusplus"} + end + + filter {} +end + +local function configureProjectForPlatform(platform, projType) + if (platform == "win32") then + + characterset(Aurora.Settings.sMsvcDefCharset) + staticruntime("Off") + + if (Aurora.Settings.bHotswap) then + justmycode("On") + else + justmycode("Off") + end + + defines "_CRT_SECURE_NO_WARNINGS" + else + if ((projectType == "SharedLib") or + (projectType == "StaticLib")) then + pic "On" + end + end +end + +local function configureProjectForPlatforms(projType) + auFilterForPlatforms(function(platformName) + configureProjectForPlatform(platformName, projType) + end) +end + +local function configureProjectErrors() + if (not Aurora.Settings.bDisableWarningsThatAnnoyRec) then + return + end + + filter {"toolset:clang"} + buildoptions {"-fms-extensions"} + + disablewarnings + { + -- we live life on the edge + "unused-result", + + -- warning: unused unused enumeration + "unused-value", + + -- :( + "unknown-warning-option" + } + + filter{} + + if (targetingCmake) then + filter {"toolset:msc"} + end + + if (bugHack) then + disablewarnings + { + "4996", -- The whiny C99 is no longer supported nag + -- please needlessly use '_s' and '_'d functions __error__ + + + "4251", -- MSVC's hurrdurr abis will break if you dynamically link classes + -- counter: sod off again. we have full control of the build process, and we only link against + -- dynamic c/stl runtimes. which brainlet thought this was a good idea? + -- even microsofts own documentation dont state what is guaranteed to be safe. + -- dont mix optimizations, mitigation flags, and so on. + -- rtti works; the stl doesn't abuse inline/module specific globals; who cares? + + "4244" -- conversion from 'double' to 'float', possible loss of data + -- this warning is extremely important; however, we're developing a game engine and utilities + -- pragma warning push + disable + pop and/or static_casts to hint we expect floating point precision + -- loss is extremely annoying and impractical. further, projects including harfbuzz, freetype, + -- and v8 don't seem to care about this warning either + } + end + + filter {} +end + +local function configureProjectForDebug(prj) + local debugDir = nil + + if (type(prj.dest) == "string") then + debugDir = prj.dest + end + + if (type(prj.dest) == "table") then + debugDir = prj.dest[1] + end + + setBestDebugDir(debugDir) +end + +local function configureProjectForTarget() + auRequire("Core/Target").startProject() +end + +local function setupProject(prj) + print("project", prj.name) + + project(prj.name) + language("C++") -- C and MASM drivers are still available to files requiring different compilers + + targetname(prj.name) -- TODO (reece): you know what to do + kind(prj.projectType) + + cppdialect(Aurora.Settings.sCppVersion) + targetprefix(Aurora.Settings.sLibPrefix) + + objdir(Aurora.Settings.sAbsCompilerWd .. "/" .. prj.name) + + configureProjectForSolution(prj) + configureProjectErrors() + configureProjectForCompiler() + configureProjectForPlatforms(prj.projectType) + configureProjectForTarget() + configureProjectForDebug(prj) + + defines "_AU_HAS_ATOMIC_INTRINS" + defines("_AU_BUILDING_" .. string.upper(prj.projectType)) + + if (prj.root) then + location(prj.root) + else + location(os.getcwd()) + end + + defines + { + "_ITERATOR_DEBUG_LEVEL=0", + } + + if (Aurora.Settings.bIncludeAuIncludeIfExists) then + local commonInclude = auGetRoot() .. "/Include" + if (os.isdir(commonInclude)) then + includedirs(commonInclude) + files(commonInclude .. "/**.h*") + end + end + + -- add includes, if available + auForEach(prj.inc, function(path) + print("", "include", _G.path.normalize(path)) + includedirs(path) + + files(path .. "/**.h") + files(path .. "/**.hpp") + files(path .. "/**.inl") + end) + + -- add sources, if available + auForEach(prj.src, function(path, root) + print("", "source", _G.path.normalize(path)) + + --if (string.sub(path, -2) == ".*") then + if (string.find(path, "*")) then + files {path} + return + end + + if (os.isfile(path)) then + files {path} + return + end + + if (not root) then + includedirs(path) + end + + files + { + path .. "/**.*pp", + path .. "/**.inl", + path .. "/**.c", + path .. "/**.cc", + path .. "/**.cxx", + path .. "/**.h", + path .. "/**.masm" -- required explicitly + } + end, root) + + buildHooks.startProject(name, projectType) + auForEach(prj.dest, function(v) + addDest(prj.name, prj.projectType, v) + end) + + print() +end + +local function setupProjectCompat(name, projectType, src, inc, dest, root) + local project = + { + name = name, + projectType = projectType, + src = src, + inc = inc, + dest = dest, + root = root + } + + setupProject(project) +end + +return +{ + setupProjectCompat = setupProjectCompat, + startProject = setupProject +} \ No newline at end of file diff --git a/Core/solution.lua b/Core/solution.lua new file mode 100644 index 0000000..4c8124d --- /dev/null +++ b/Core/solution.lua @@ -0,0 +1,49 @@ +local function auStartSolution(sln) + + workspace(sln.name) + + auRequire("Core/Target").startSolution() + + location(Aurora.Settings.sAbsCompilerWd) + + -- Required for core Aurora assumptions. External build chains may mess with these -- not my problem. + symbols "On" -- even ship binaries are initially built with symbols for unix targets to strip them with objcopy + visibility "Hidden" -- posix devs are stupid. default vis is stupid. we're beyond the 70's C OS aka version 7 UNIX + stringpooling "true" -- i've seen hashmaps explode too many times to care about the few ms this saves + floatingpoint "strict" -- x87 sucks so lets be mean. it's a nice to have when working with js runtimes + justmycode "Off" -- some premake warning bug + + -- TODO (reece): consider breaking these out into settings + staticruntime "On" + editandcontinue "Off" + + flags + { + "NoPCH" + } + + if (Aurora.Settings.bMultithreadBuild) then + flags + { + "MultiProcessorCompile" + } + end + + if (Aurora.Settings.bForceClangWin32) then + auFilterForPlatforms(function(platform) + if (platform == "win32") then + toolset "clang" + end + end) + end + + if (Aurora.Settings.bForceLLVMStl) then + filter {"files:**.cpp or files:**.cc or files:**.cxx", "toolset:clang"} + buildoptions {"-stdlib=libc++"} + filter {} + end +end + +return { + start = auStartSolution +} \ No newline at end of file diff --git a/Legacy/aurora.lua b/Legacy/aurora.lua new file mode 100644 index 0000000..dc3b045 --- /dev/null +++ b/Legacy/aurora.lua @@ -0,0 +1,456 @@ +------------------------------------------------------- +-- options.lua +------------------------------------------------------- +local tbl = +{ + "target-win32", + "target-linux", + "target-switch", + "target-ps5", + "target-x86_64", + "target-arm", + "target-wayland" +} + +for i, k in pairs(tbl) do + local key = string.sub(k, 8) + _G[key] = false + if (_OPTIONS[k]) then + _G[key] = true + end +end + +------------------------------------------------------- +-- globals +------------------------------------------------------- +_G["projectsprocessor"] = {} +_G["projectsblocked"] = {} +_G["projectsemitted"] = {} +_G["namespacesemitted"] = {} +_G["usingClang"] = false +_G["usingMSVC"] = false + +------------------------------------------------------- +-- process command line arguments into global space +------------------------------------------------------- + +------------------------------------------------------- +-- API +------------------------------------------------------- +local jsonProcessor = require("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, + deps = {} + } + + local cwd = auGetRoot() + + local remoteLua = path .. "/Aurora.lua" + local remoteJson = path .. "/Aurora.json" + local localJson = cwd .. "/Build_UserScripts/" .. args.name .. ".aurora.json" + local localLua = cwd .. "/Build_UserScripts/" .. args.name .. ".aurora.lua" + + if (os.isfile(localLua)) then + project.processor = auRequireAbs(localLua)(info) + elseif (os.isfile(localJson)) then + info.jpath = localJson + project.processor = jsonProcessor(info) + elseif (os.isfile(remoteLua)) then + project.processor = auRequireAbs(remoteLua)(info) + elseif (os.isfile(remoteJson)) then + info.jpath = remoteJson + 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, + deps = {} + } + + local procesor = userRequire(args.script) + if (not procesor) then + processor = auRequireAbs(args.script) + if (not procesor) then + print("missing project script:", args.script, path) + return + end + 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) + processProject(proj.info.name) +end + +-- private +local processInit = function(project) + if (not project.isInitialized) then + if (project.processor.init) then + project.processor:init() + end + project.isInitialized = true + end +end + +-- private +_G["_resolved_dep_res"] = {} +_G["_resolved_dep"] = {} +function processDepSearch(proj, resolveProject) + local name = proj.info.name + + + _G["_resolved_dep"][name] = name + + if (not proj.resolvedDeps) then + if (proj.processor.resolveDependencies) then + proj.processor:resolveDependencies(function(name, soft) + + table.insert(proj.deps, name) + + if (_G["_resolved_dep"][name]) then + return + end + + local depProj = projectsprocessor[name] + if (not depProj) then + if (not soft) then + auFatal("missing dependency: ", name) + else + return false + end + end + + processDepSearch(depProj, true) + end) + end + proj.resolvedDeps = true + end + + processInit(proj) +end + +-- private +local processNS = function(namespace) + local projs = {} + local projsIdxs = {} + + auForEach(projectsprocessor, function(proj) + if (proj.info.namespace ~= namespace) then + return + end + + local name = proj.info.name + projs[name] = proj + + table.insert(projsIdxs, name) + end) + + table.sort(projsIdxs, function(a, b) + return a:upper() < b:upper() + end) + + auForEach(projsIdxs, function(idx) + processDepSearch(projs[idx], true) + end) + + auForEach(projsIdxs, function(idx) + processLocalProject(projs[idx]) + end) +end + +function processSolution() + local hack = {} + + local hackIdx = {} + auForEach(projectsprocessor, function(proj) + table.insert(hackIdx, proj.info.namespace) + end) + + table.sort(hackIdx, function(a, b) + return a:upper() < b:upper() + end) + + auForEach(hackIdx, processNS) +end + +function attemptNS(ns) + local attemptLoad = false + if (not namespacesemitted[ns]) then + auStartGroup(ns) -- only print the group once + + attemptLoad = true + end + + group(ns) + return attemptLoad +end + +resolved = {} + +function processProject(name, required, noNs) + local a = projectsprocessor[name] + if (not a) then + if (required) then + auFatal("missing project: ", name) + else + return false + end + end + + -- ensure the project is initializd + processInit(a) + + -- legacy recursion + if (projectsblocked[name]) then + return true + end + + projectsblocked[name] = name + + -- process all within the namespace before processing the actual project + local ns = a.info.namespace + local loadOthers = attemptNS(ns) + + -- { + local cwd = os.getcwd() + local old = _G["current_project"] + + _G["current_project"] = name + os.chdir(a.info.path) + + a.processor:process() + + os.chdir(cwd) + _G["current_project"] = old + -- } + + projectsemitted[name] = name + + -- cont + if (loadOthers) then + namespacesemitted[ns] = ""; + processNS(ns) + end + + return true +end + +function isWeakCircularReference(depName) + local curName = getCurrentProjectName() + + local cur = projectsprocessor[curName] + if (not cur) then + return + end + + local dep = projectsprocessor[depName] + if (not dep) then + return + end + + -- TODO: recursion + for index, value in ipairs(dep.deps) do + if value == curName then + return true + end + end + + return false +end + +function isProjectLoaded(name) + local a = projectsprocessor[name] + if (not a) then + return false + end + + return a.isInitialized +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 getProjectProcessor(name) + if (not name) then + return + end + local scre = projectsprocessor[name] + if (not scre) then + return + end + return scre.processor +end + +function getCurrentProjectName() + return current_project +end + +function importAndLinkProject(dep, soft) + local proj = _G["projectsprocessor"][dep] + if (not proj) then + if (soft) then + return false + end + auFatal("Missing project", dep) + end + + local iface = proj.processor + if (not isProjectLoaded(dep)) then + if (soft) then + return false + end + auFatal("missing project: ", dep) + end + + iface:handleReference() + iface:handleLink() + return true +end + +function includeAuProject(dep, soft) + local proj = _G["projectsprocessor"][dep] + if (not proj) then + if (soft) then + return false + end + auFatal("Missing project", dep) + end + + local iface = proj.processor + if (not isProjectLoaded(dep)) then + if (soft) then + return false + end + auFatal("missing project: ", dep) + end + + iface:handleReference() + return true +end + +function linkAuProject(dep, soft) + local proj = _G["projectsprocessor"][dep] + if (not proj) then + if (soft) then + return false + end + auFatal("Missing project", dep) + end + + local iface = proj.processor + if (not isProjectLoaded(dep)) then + if (soft) then + return false + end + auFatal("missing project: ", dep) + end + + iface:handleLink() + return true +end + + +-- executes inline under iprocessor::process +function addFeature(feature) + local script = auGetRoot() .. "/Build_Scripts/Features/" .. feature:lower() .. ".lua" + + if (not os.isfile(script)) then + auFatal("missing feature", feature, script) + return + end + + auRequireAbs(script)() +end \ No newline at end of file diff --git a/Boilerplate/jsonProcessor.lua b/Legacy/jsonProcessor.lua similarity index 81% rename from Boilerplate/jsonProcessor.lua rename to Legacy/jsonProcessor.lua index 5c70527..db44dc8 100644 --- a/Boilerplate/jsonProcessor.lua +++ b/Legacy/jsonProcessor.lua @@ -1,5 +1,5 @@ -local auProject = require("project") -local valaGo = require("vala") +local auProject = auRequire("Core/project").setupProjectCompat +local valaGo = auRequire("Core/Vala") function JsonProcessor(info) local result, err = json.decode(io.readfile(info.jpath)) @@ -50,14 +50,14 @@ function JsonProcessor(info) return end - forEach(result.include, handleUserJsonInclude, info.path, incFiles) + auForEach(result.include, handleUserJsonInclude, info.path, incFiles) end local handleInclude = function(this, incFiles) local otherREsult = info local result = this.result - forEach(result.defines, defines) + auForEach(result.defines, defines) if (result.type:lower() == "aurora") then includeDirEx(info.path .. "/Include") @@ -84,18 +84,18 @@ function JsonProcessor(info) return end - addBuildAction(obj.when, type, obj[type], obj.isCwdProjRoot) + auAddBuildAction(obj.when, type, obj[type], obj.isCwdProjRoot) end local handleDllImportMaybe = function(this) if (this.info.isShared) then - forEach(this.result.dllimport, defines) + auForEach(this.result.dllimport, defines) end end local handleDllExportMaybe = function(this) if (this.info.isShared) then - forEach(this.result.dllexport, defines) + auForEach(this.result.dllexport, defines) end end @@ -118,14 +118,14 @@ function JsonProcessor(info) end local processJsonBlockForLinks = function(object, this) - forEach(object.links, links) - forEach(object.depends, handleDependsShort, this, false) - forEach(object["soft-depends"], handleDependsShort, this, true) + auForEach(object.links, links) + auForEach(object.depends, handleDependsShort, this, false) + auForEach(object["soft-depends"], handleDependsShort, this, true) end function handleEvalForLinks(object, this) - if (isArray(object)) then - forEach(object, handleEvalForLinks, this) + if (auIsArray(object)) then + auForEach(object, handleEvalForLinks, this) return end @@ -143,7 +143,7 @@ function JsonProcessor(info) _G["info"] = info if (_if) then - local val = eval("return " .. _if) + local val = auEval("return " .. _if) if (not val) then return end @@ -166,7 +166,7 @@ function JsonProcessor(info) local processSubLinks = function(this) processJsonBlockForLinks(result, this) - forEach(result.actions, handleActionsForLinks, this) + auForEach(result.actions, handleActionsForLinks, this) end local handleSourcesRel = function(source, path) @@ -176,7 +176,7 @@ function JsonProcessor(info) local handleLink = function(this) dependson (this.info.name) - forEach(result.linkSources, handleSourcesRel, info.path) + auForEach(result.linkSources, handleSourcesRel, info.path) local erase = false; if (not _G["_linkingcur"]) then @@ -232,15 +232,15 @@ function JsonProcessor(info) -- static libs are allowed to reference dllexports in translation units of the parent shared module handleDllExportMaybe(this) - forEach(result.staticImport, defines) + auForEach(result.staticImport, defines) end if (this.info.isStatic) then - forEach(result.staticImpDefines, defines) + auForEach(result.staticImpDefines, defines) end - forEach(result["include-depends"], publicDepends, this, false) - forEach(result["include-soft-depends"], publicDepends, this, true) + auForEach(result["include-depends"], publicDepends, this, false) + auForEach(result["include-soft-depends"], publicDepends, this, true) handleInclude(this, false) @@ -257,8 +257,8 @@ function JsonProcessor(info) local pokeDeps = function(this, resolve) local result = this.result - forEach(result.depends, handleDependsPreemptive, this, false, resolve) - forEach(result["soft-depends"], handleDependsPreemptive, this, true, resolve) + auForEach(result.depends, handleDependsPreemptive, this, false, resolve) + auForEach(result["soft-depends"], handleDependsPreemptive, this, true, resolve) end local handleParse = function(this) @@ -276,7 +276,7 @@ function JsonProcessor(info) info.copy_build_files = {} local function runCopies(prefix, rootPath, name) - local referenceRoot = getroot() .. "/Build_UserScripts/" .. name .. "/" + local referenceRoot = auGetRoot() .. "/Build_UserScripts/" .. name .. "/" local referencePath = referenceRoot .. prefix local copyRoot = rootPath .. "/" .. prefix @@ -287,7 +287,7 @@ function JsonProcessor(info) end end - forEach(result.unpack, runCopies, info.path, info.name) + auForEach(result.unpack, runCopies, info.path, info.name) if (result.type:lower() == "aurora") then @@ -324,7 +324,7 @@ function JsonProcessor(info) handleInclude(a, true) - --forEach(result.defines, defines) + --auForEach(result.defines, defines) --handleJSONInclude(result) -- include auProject public headers, do not use handleInclude, that could reinclude a header included in `project` -- that could potentially fuck with #include_next @@ -406,34 +406,34 @@ function JsonProcessor(info) end local processJsonBlock = function(object) - forEach(object.features, handleFeature, info.path) - forEach(object.sourcePaths, handleSourcePaths, info.path) - forEach(object.excludes, handleExcludes, info.path) - forEach(object.sources, handleSources, info.path) - forEach(object.depends, handleDepends, a, false) - forEach(object["soft-depends"], handleDepends, a, true) - forEach(object.impDefines, defines) - forEach(object.links, links) + auForEach(object.features, handleFeature, info.path) + auForEach(object.sourcePaths, handleSourcePaths, info.path) + auForEach(object.excludes, handleExcludes, info.path) + auForEach(object.sources, handleSources, info.path) + auForEach(object.depends, handleDepends, a, false) + auForEach(object["soft-depends"], handleDepends, a, true) + auForEach(object.impDefines, defines) + auForEach(object.links, links) if (usingMSVC) then - forEach(object.msvcIgnore, disablewarnings) + auForEach(object.msvcIgnore, disablewarnings) end if (usingClang) then - forEach(object.clangIgnore, disablewarnings) + auForEach(object.clangIgnore, disablewarnings) end - forEach(object.impInclude, handleUserJsonInclude, info.path, true) + auForEach(object.impInclude, handleUserJsonInclude, info.path, true) -- this is ran twice. i dont care - forEach(object.unpack, runCopies, info.path, info.name) + auForEach(object.unpack, runCopies, info.path, info.name) addM4Defines(object.m4Defines) end function handleEval(object) - if (isArray(object)) then - forEach(object, handleEval) + if (auIsArray(object)) then + auForEach(object, handleEval) return end if (type(object) == "string") then - eval(object) + auEval(object) return end @@ -444,21 +444,21 @@ function JsonProcessor(info) handleActionCommon(action, handleEval) end - forEach(result.require, handleRequire) + auForEach(result.require, handleRequire) if (not isUtility) then processJsonBlock(result) if (a.info.projectType:lower() == "sharedlib") then - forEach(result.dllexport, defines) + auForEach(result.dllexport, defines) end end - forEach(result.actions, handleAction, info.path) - forEach(result.events, handleBuildEvent, info.path) + auForEach(result.actions, handleAction, info.path) + auForEach(result.events, handleBuildEvent, info.path) if (info.isStatic) then - forEach(result.staticImpDefines, defines) + auForEach(result.staticImpDefines, defines) end if (result.valaSrc) then @@ -483,13 +483,13 @@ function JsonProcessor(info) valaGo(extended) end - forEach(result.events, handleBuildEvent, info.path) + auForEach(result.events, handleBuildEvent, info.path) _G["_linkingcur"] = nil end - forEach(result.subprojs, function(subproj) + auForEach(result.subprojs, function(subproj) local subinfo = { namespace = info.namespace, diff --git a/Public/api.lua b/Public/api.lua new file mode 100644 index 0000000..568c7bf --- /dev/null +++ b/Public/api.lua @@ -0,0 +1,68 @@ +-- private +local buildAction = auRequire("Core/Actions") +local target = auRequire("Core/Target") + +-- executes inline under iprocessor::process +function auAddBuildAction(...) + buildAction(...) +end + +function auStart() + if (_auStart) then return end + _auStart = true + auRequire("Core/base") +end + +function auStartSolution(sln) + auStart() + auRequire("Core").solution.start(sln) +end + +function auStartProject(project) + auRequire("Core").project.start(project) +end + +function auStartProject(project) + auRequire("Core").project.start(project) +end + +function auFilterForPlatforms(callback, ...) + target.auFilterForPlatforms(callback, ...) +end + +function auFilterForConfigs(callback, ...) + target.auFilterForConfigs(callback, ...) +end + +function auFilterForConfigPlatforms(callback, ...) + target.auFilterForConfigPlatforms(callback, ...) +end + +-- Returns an array of filter tables where each optional table is checked against the current combination of config/platform/arch +-- Varargs are logical anded with the final filter table +-- in object -> defer to objects.lua +function auFilterOf(obj, ...) + return target.auFilterOf(obj, ...) +end + +function auFilterConfig(configs) + return auFilterOf({ + configs = configs + }) +end + +function auFilterArch(arch) + return auFilterOf({ + archs = arch + }) +end + +function auFilterPlatform(platform) + return auFilterOf({ + platforms = platform + }) +end + +function auSetupCoreProject(prj) + require("Core/project").startProject(prj) +end \ No newline at end of file diff --git a/Public/base.lua b/Public/base.lua new file mode 100644 index 0000000..4f4db5b --- /dev/null +++ b/Public/base.lua @@ -0,0 +1,38 @@ +local aurora = _G["Aurora"] or {} +_G["Aurora"] = aurora + +function auFetchGlobal(name) + local ret = aurora[name] or {} + aurora[name] = ret + return ret +end + +function auSetDefault(table, key, default) + if (not table[key]) then + table[key] = default + end +end + +if (auFetchGlobal("Configured") == "true") then + return +end + +aurora.Configured = "true" + +-- add configuration +require("settings") + +-- add utilities +require("./../Utilities") + +--- update paths +require("paths") + +-- add internal api +require("groups") + +-- add api objects +require("objects") + +-- add public api +require("api") \ No newline at end of file diff --git a/Public/groups.lua b/Public/groups.lua new file mode 100644 index 0000000..cb1aad9 --- /dev/null +++ b/Public/groups.lua @@ -0,0 +1,10 @@ +function auPrintHeader(key, val) + print("-------------------------------------------------------") + print(key, val) + print("-------------------------------------------------------") +end + +function auStartGroup(name) + auPrintHeader("group", name); + group(name) +end \ No newline at end of file diff --git a/Public/objects.lua b/Public/objects.lua new file mode 100644 index 0000000..fc0c51d --- /dev/null +++ b/Public/objects.lua @@ -0,0 +1,45 @@ +function auEnum(...) + return nil +end + +function auProjectO() + +end + +function auSolutionO() + +end + +function auVisitO() + +end + +function auFilterInO() + -- When passed to filter, the following applys: + -- in configs (^if not opt), and in platforms (^if not opt), and in archs (^if not opt); and + -- notConfigs (^if not opt) does not contain config, and [...] + -- + -- All fields must be string, tables/arrays, or nil + + return + { + configs = nil, + platforms = nil, + archs = nil, + notConfigs = nil, + notPlatforms = nil, + notArchs = nil + } +end + +function auSetupCoreProjectO() + return + { + name = "Unnamed", + projectType = "SharedLibrary", + src = nil, + inc = nil, + dest = "!", -- "!" means default binary export path + root = nil + } +end \ No newline at end of file diff --git a/Public/paths.lua b/Public/paths.lua new file mode 100644 index 0000000..2f1e2ad --- /dev/null +++ b/Public/paths.lua @@ -0,0 +1,44 @@ + +if (not Aurora.Settings.sAbsRoot) then + Aurora.Settings.sAbsRoot = os.realpath(os.getcwd() .. "/../..") .. "/" +end + +if (Aurora.Settings.sRelRoot) then + Aurora.Settings.sAbsRoot = Aurora.Settings.sAbsRoot .. Aurora.Settings.sRelRoot .. "/" +end + +if (Aurora.Settings.sRelAuRoot) then + Aurora.Settings.sAbsAuRoot = Aurora.Settings.sAbsRoot .. Aurora.Settings.sRelAuRoot .. "/" +end + +local function resolvePathAbs2(key, rootKey) + local val = auGetSetting(key) + if (not val) then return end + local path = auGetSetting(rootKey) .. val + Aurora.Settings["sAbs" .. key:sub(5)] = path + return path +end + +local function resolvePathAbs(key) + local path = resolvePathAbs2(key, "sAbsRoot") + if (not os.isdir(path)) then + os.mkdir(path) + end +end + +resolvePathAbs("sRelDebug") +resolvePathAbs("sRelStage") +resolvePathAbs("sRelShip") +resolvePathAbs("sRelWd") +resolvePathAbs("sRelSymbols") +resolvePathAbs("sRelLinkLibs") +resolvePathAbs("sRelCompilerWd") + +local function resolveAuPathAbs(key) + return resolvePathAbs2(key, "sAbsAuRoot") +end + +resolveAuPathAbs("sRelRepoScripts") +resolveAuPathAbs("sRelUnixBins") +resolveAuPathAbs("sRelWin32") +resolveAuPathAbs("sRelScripts") \ No newline at end of file diff --git a/Public/premake5.lua b/Public/premake5.lua new file mode 100644 index 0000000..2dfbaed --- /dev/null +++ b/Public/premake5.lua @@ -0,0 +1,58 @@ +premake.path = premake.path .. ";" .. os.realpath("..\\") + +require("base") + +------------------------------------------------------- +-- run a user script that should be able to directly access +-- the global aurora variable with the util apis available +------------------------------------------------------- +if (os.isfile("../../preconfig.lua")) then + require("../../preconfig") +end + +------------------------------------------------------- +-- print build platform +------------------------------------------------------- +local isWin = os.host() == "windows" +local isToolChain = false +local isUnix = false +local toolPlatforms = {"win32", "linux", "mac"} +local unixPlatforms = {"linux", "mac"} + +for k in pairs(toolPlatforms) do + if (os.host() == k) then + isToolChain = true + end +end + +for k in pairs(unixPlatforms) do + if (os.host() == k) then + isUnix = true + end +end + +auPrintHeader("configuration", "platforms") +print("isWin", isWin) +print("isUnix", isUnix) +print("isDevelopmentPlatform", isToolChain) +print() + + +------------------------------------------------------- +-- start +------------------------------------------------------- +local function start() + auStart() + + if (os.isfile("../../premake5.lua")) then + require("../../premake5") + elseif (os.isfile("../../AuroraSolution.lua")) then + require("../../AuroraSolution") + elseif (os.isfile("../../AuroraSolution.json")) then + -- TODO: ... + else + auFatal("No solution file found in the root") + end +end + +xpcall(start, auFatal) \ No newline at end of file diff --git a/Public/settings.lua b/Public/settings.lua new file mode 100644 index 0000000..8bcecdb --- /dev/null +++ b/Public/settings.lua @@ -0,0 +1,112 @@ +local settings = auFetchGlobal("Settings") + +-- General settings you can probably ignore +auSetDefault(settings, "bPremakeOverload" , nil) +auSetDefault(settings, "sPremakeOverload" , nil) +auSetDefault(settings, "sAbsValac" , nil) + +auSetDefault(settings, "sAbsRoot" , nil) + +-- Root offset from `../../` +-- Embedders should define 'sAbsAuRoot' from their premake scripts +-- Users may change this to account for nested monorepos +auSetDefault(settings, "sRelRoot" , "./") +-- +auSetDefault(settings, "sRelAuRoot" , "./") + +-- The following settings define constants relating to the aurora build scripts + + -- You should probably ignore me + auSetDefault(settings, "sRelScripts" , "./Build_Scripts") + + -- You should probably ignore me + auSetDefault(settings, "sRelWin32" , "./Build_Scripts/Win32") + + -- You should probably ignore me + auSetDefault(settings, "sRelUnixBins" , "./Build_Scripts/bin") + + -- You should probably ignore me + auSetDefault(settings, "sRelRepoScripts" , "./Build_UserScripts") + +-- The following settings are relative to the projects sAbsRoot/sRelRoot + + -- Exported debug binaries + -- Debug binaries, debug stl, debug everything. These binaries suck and you probably shouldn't use them. + auSetDefault(settings, "sRelDebug" , "./Build/Develop") + -- Exported staging binaries. + -- These binaries should be used by teams internally and for qa. + -- They contain most high level debug assertions, leaving the lower level debug assertions disabled for performance reasons + -- Path strings and other debug information should not be shipped in real time or performance critical applications + -- For those use cses, defer to the shippable binaries + auSetDefault(settings, "sRelStage" , "./Build/Stage") + -- Exported ship binaires + -- + -- Ship binaries contain no debug assertions or debug-level push system errors + -- Debug information is still exported for these, albeit stripped from ELF + auSetDefault(settings, "sRelShip" , "./Build/Ship") + -- Working directory for debug run targets should 'bIsBuildDirWd' be set to false + auSetDefault(settings, "sRelWd" , "./Build/CWD") + -- ELF stripped or PDB archieve directory + auSetDefault(settings, "sRelSymbols" , "./Build/Symbols") -- exported private symbols + auSetDefault(settings, "sRelLinkLibs" , "./Build/Link") -- public link files + auSetDefault(settings, "sRelCompilerWd" , "./Build/Workspace") + +-- When enabled, debug run targets shall run under the modules path instead of sRelWd +auSetDefault(settings, "bIsBuildDirWd" , false) + +-- Archives the debug symbols of sRelShip binaries +auSetDefault(settings, "bArchiveShipSyms" , false) + +-- C++ language version. C++14/17/20 +auSetDefault(settings, "sCppVersion", "C++20") + +-- Enables standard aurora post build steps including copy of binaries and stripping of symbols +auSetDefault(settings, "bUseAuBuildHooks", true) + +-- Aurora automatically searches for ./include in the root of your solution for solution wide headers +-- 'bIncludeAuIncludeIfExists' enables this behaviour +auSetDefault(settings, "bIncludeAuIncludeIfExists", true) + +--Enables multithreaded compilation across toolchains that support it +auSetDefault(settings, "bMultithreadBuild", true) + + +auSetDefault(settings, "bUseUnixStdPrefix", false) -- should include the standard unix lib prefix +auSetDefault(settings, "sLibPrefix" , "") -- if false, use this + + +auSetDefault(settings, "sMsvcDefCharset", "MBCS") + +-- +auSetDefault(settings, "sNameOfDebug", "Debug") + +-- +auSetDefault(settings, "sNameOfInternal", "Stage") + +-- +auSetDefault(settings, "sNameOfShip", "Ship") + +-- +auSetDefault(settings, "aNamesOfConfigs", {"Debug", "Stage", "Ship"}) + +-- +auSetDefault(settings, "bDefinePartialABIInTargetName", true) + +-- Disable common warnings. +-- Rationalized as other big projects tend to disable them, builds on linuxs were ugly, and clang and msvc would seethe at different things, and I don't care. +-- You should probably turn this off once in a while to check for hidden issues +auSetDefault(settings, "bDisableWarningsThatAnnoyRec", true) +auSetDefault(settings, "bForceClangWin32", false) + +-- Forces libc++ stl on Linux, where such is not currently recommended by the vendor, but it's worth forcing modern tech +-- G++ is a mess whose future I don't care for. Not that libc++ doesn't do stupid thing on Linux, but au runtime takes care of a lot of things, so idc. +auSetDefault(settings, "bForceLLVMStl", true) + +-- Premake5 binary name to look for when when tied into cmake. Used by build actions and other lua scripted features +auSetDefault(settings, "sDefaultCmakePremakeBin", "premake5") + +-- In place of page NX traps and suspending thread contexts like most debug operations in visual studio, +-- they perform an expensive check in each functions prologue :vomit: +-- V8 took minutes to start up on an i9-9900k, QST/VM tests result in highs of ~30MB/s down from 900MB/s +-- MSVCs justmycode implementation is not fit for use. +auSetDefault(settings, "bHotswap", false) diff --git a/README.md b/README.md index b774149..d0c6fb8 100644 --- a/README.md +++ b/README.md @@ -1,2 +1 @@ -# Build - +Defer to README_Users.txt \ No newline at end of file diff --git a/README_CMake.txt b/README_CMake.txt new file mode 100644 index 0000000..e69de29 diff --git a/README_Developers.txt b/README_Developers.txt new file mode 100644 index 0000000..6d89dcb --- /dev/null +++ b/README_Developers.txt @@ -0,0 +1,60 @@ +# Main + +The Aurora Ecosystem incorporates this repository as an inheritable starting point for building native applications. +Extending and retargeting existing robost meta-pipeline software can be a pain, but with premakes relatively simple +architecture and lua scripts anyone can hack into, software integration pipelines with specific requirements can be +quickly prototyped with little effort. These scripts are intented to be tweaked for specific use cases, and as such, +you may decide to fork them and host them alongside your ./Build_UserScripts away from upstream. + + +# API + +Defer to the code under Public for information on how to integrate these Aurora scripts into your premake pipeline. +API -> ./Global/api.lua +Settings -> ./Public/settings.lua +Entry -> ./Public/base.lua + + +# User Scripts + +We decided that, instead of gluing together old nasty pipelines, we would write simple JSON files to quickly add +and configure a C++ project for the minimum desired outcome. We started writing JSON files around specific project +requirements. Overtime, we wish to unify everything, and extend these scripts to testing and deployment. For now, +they serve as a simple way to describe a C/C++'s project structure. Advanced users can write user scripts in native +lua, using an untouched premake api; however, our experimental clang driver will be limited in its support for your +customers. + + +# Linux requirements + +* LLVM STL / libc++stl +* clang +* coreutils +* objcopy +* premake5 (unix global) + + +# Windows requirements + +None + + +# Project Files + +TODO (reece): + + +# Package Manager + +WIP https://git.reece.sx/AuroraPipeline/Scripts + + +# Existing Pipeline Integration + +Defer to README_Premake.txt / README_CMake.txt + + +# Location + +These build scripts are provided such that you may elect to use a git-submodule pointing to a public git server. + diff --git a/README_Premake.txt b/README_Premake.txt new file mode 100644 index 0000000..2f3417b --- /dev/null +++ b/README_Premake.txt @@ -0,0 +1,22 @@ +# Example + +Including Aurora in your existing pipeline + +```lua +Aurora = { + Settings = { + [TODO:] = ..., + [TODO:] = ..., + [TODO:] = ... + } +} + +require([./] "path/to/aurora" [.lua]) +``` + + +Using Aurora in the official premake example: +``` + + +``` \ No newline at end of file diff --git a/README_Users.txt b/README_Users.txt new file mode 100644 index 0000000..d57950f --- /dev/null +++ b/README_Users.txt @@ -0,0 +1,8 @@ +Run the _. script to generate project files optimized for your platform. +You can find the workspace generated by premake under the default path of ../Build_Workspace + +For ease of installment, some platforms provide [_build/_deploy]_. scripts. +_build -> Compiles Aurora ship binaries to ../Build_Stage +_deploy -> Builds and runs the deploy tasks to push ../Build_Ship to [fill in the blank] + +[!!!] CMAKE IS NOT READY [!!!] \ No newline at end of file diff --git a/Utils/utils.lua b/Utilities/Utilities.lua similarity index 71% rename from Utils/utils.lua rename to Utilities/Utilities.lua index 1edf366..e9cb5c1 100644 --- a/Utils/utils.lua +++ b/Utilities/Utilities.lua @@ -8,4 +8,7 @@ require("eval") require("isArray") require("concatArrays") require("base64") -require("requireAbs") \ No newline at end of file +require("requireAbs") +require("merge") +require("settings") +require("contains") \ No newline at end of file diff --git a/Utils/base64.lua b/Utilities/base64.lua similarity index 96% rename from Utils/base64.lua rename to Utilities/base64.lua index d465a4a..ae67c98 100644 --- a/Utils/base64.lua +++ b/Utilities/base64.lua @@ -29,8 +29,10 @@ local function dec(data) end)) end -_G["base64"] = +auBase64 = { encode = enc, decode = dec } + +_G["base64"] = auBase64 \ No newline at end of file diff --git a/Utilities/concatArrays.lua b/Utilities/concatArrays.lua new file mode 100644 index 0000000..211da3d --- /dev/null +++ b/Utilities/concatArrays.lua @@ -0,0 +1,19 @@ +function auConcatVararg(array, ...) + local ret = {} + local args = table.pack(...) + auForEach(array, function(element) table.insert(ret, element) end) + for i=1, args.n do + table.insert(ret, args[i]) + end + return ret +end + +function auConcatArrays(...) + local ret = {} + local args = table.pack(...) + for i=1, args.n do + local tbl = args[i] + auForEach(tbl, function(re) table.insert(ret, re) end) + end + return ret +end \ No newline at end of file diff --git a/Utilities/contains.lua b/Utilities/contains.lua new file mode 100644 index 0000000..27f7e83 --- /dev/null +++ b/Utilities/contains.lua @@ -0,0 +1,8 @@ +function auContains(array, value) + for i=1, #array do + if array[i] == value then + return true + end + end + return false + end \ No newline at end of file diff --git a/Utils/eval.lua b/Utilities/eval.lua similarity index 60% rename from Utils/eval.lua rename to Utilities/eval.lua index 249eecd..2af3dc3 100644 --- a/Utils/eval.lua +++ b/Utilities/eval.lua @@ -1,3 +1,3 @@ -function eval(src) +function auEval(src) return (loadstring or load)(src)() end \ No newline at end of file diff --git a/Utilities/fatal.lua b/Utilities/fatal.lua new file mode 100644 index 0000000..92039e8 --- /dev/null +++ b/Utilities/fatal.lua @@ -0,0 +1,8 @@ +function auFatal(...) + print("[!!!] Fatal Crash") + print("Error Message:") + print(...) + print("Origin:") + print(debug.traceback()) + os.exit(1) +end \ No newline at end of file diff --git a/Utilities/forEach.lua b/Utilities/forEach.lua new file mode 100644 index 0000000..9926077 --- /dev/null +++ b/Utilities/forEach.lua @@ -0,0 +1,25 @@ +function auForEach(table, cb, ...) + if (not table) then + return + end + + if type(table) == "table" then + for k, v in pairs(table) do + cb(v, ...) + end + else + cb(table, ...) + end +end + +function auForEachKV(table, cb, ...) + if (not table) then + return + end + + if type(table) == "table" then + for k, v in pairs(table) do + cb(k, v, ...) + end + end +end \ No newline at end of file diff --git a/Utilities/getRoot.lua b/Utilities/getRoot.lua new file mode 100644 index 0000000..cbbfb4c --- /dev/null +++ b/Utilities/getRoot.lua @@ -0,0 +1,11 @@ +function auGetRoot() + return auGetProjectRoot() +end + +function auGetProjectRoot() + return Aurora.Settings.sAbsRoot +end + +function auGetAuroraRoot() + return Aurora.Settings.sAbsAuRoot +end \ No newline at end of file diff --git a/Utils/isArray.lua b/Utilities/isArray.lua similarity index 93% rename from Utils/isArray.lua rename to Utilities/isArray.lua index 9d2d5df..0c3c1ff 100644 --- a/Utils/isArray.lua +++ b/Utilities/isArray.lua @@ -1,5 +1,5 @@ -- lua-cjson's is_array by Mark Pulford -function isArray(table) +function auIsArray(table) local max = 0 local count = 0 @@ -20,4 +20,4 @@ function isArray(table) end return max > 0 -end \ No newline at end of file +end \ No newline at end of file diff --git a/Utils/lookupCmdArgs.lua b/Utilities/lookupCmdArgs.lua similarity index 66% rename from Utils/lookupCmdArgs.lua rename to Utilities/lookupCmdArgs.lua index 77ab10a..78ac77a 100644 --- a/Utils/lookupCmdArgs.lua +++ b/Utilities/lookupCmdArgs.lua @@ -1,13 +1,13 @@ -function lookupArgPair(map, array) +function auMapCli(map, allowMultiple) local ret = true - if (array) then + if (allowMultiple) then ret = {} end for k, v in pairs(map) do if (_OPTIONS[k] ~= nil) then - if (not array) then + if (not allowMultiple) then return v end @@ -18,4 +18,4 @@ function lookupArgPair(map, array) return ret end -return lookupArgPair \ No newline at end of file +return auMapCli \ No newline at end of file diff --git a/Utilities/merge.lua b/Utilities/merge.lua new file mode 100644 index 0000000..289b89c --- /dev/null +++ b/Utilities/merge.lua @@ -0,0 +1,15 @@ +-- Copies [key, values] from src into dest, if they do not exist +function auMergeTable(dest, src) + auForEachKV(src, function(key, value) + if (dest[key]) then return end + dest[key] = value + end) +end + +-- Alternative to auConcatArrays +-- Copies src into dest +function auMergeArray(dest, src) + auForEach(src, function(value) + table.insert(dest, value) + end) +end \ No newline at end of file diff --git a/Utilities/requireAbs.lua b/Utilities/requireAbs.lua new file mode 100644 index 0000000..4dc3f4d --- /dev/null +++ b/Utilities/requireAbs.lua @@ -0,0 +1,49 @@ +_auRequireTable = {} + +function auRequireAbs(path, invalidate) + -- this is stupid + + return auRequire(_G.path.getrelative(Aurora.Settings.sAbsScripts, path), nil, invalidate) +end + +function auRequire(relPath, subdir, invalidate) + -- this is stupid + + local buildScripts = auGetAuroraRoot() + local premakeRequireRootCWD = Aurora.Settings.sAbsScripts + + if (not subdir) then + buildScripts = premakeRequireRootCWD + else + buildScripts = buildScripts .. subdir + end + + buildScripts = os.realpath(buildScripts) .. "/" + + if (os.isdir(buildScripts .. relPath)) then + relPath = relPath .. (relPath:match("/[^/]*$") or ("/".. relPath)) .. ".lua" + end + + if (not relPath:ends(".lua")) then + relPath = "/" .. relPath .. ".lua" + end + + if (not os.isfile(buildScripts .. relPath)) then + auFatal("Script not found: ", relPath) + end + + local realPath = os.realpath(buildScripts .. relPath) + + -- premake should support modules.loaded[modname] (iirc), but either way, i'm being extra safe + -- we once used rel paths with require so this was required + -- invalidation requests don't seem to make much sense, but they can stay in a hint + -- wont remove this for.now + local cache = _auRequireTable[realPath] + if (cache and not invalidate) then + return cache + end + + local result = require(realPath:sub(1, #realPath - 4)) + _auRequireTable[realPath] = result + return result +end \ No newline at end of file diff --git a/Utilities/settings.lua b/Utilities/settings.lua new file mode 100644 index 0000000..034c866 --- /dev/null +++ b/Utilities/settings.lua @@ -0,0 +1,3 @@ +function auGetSetting(name) + return Aurora.Settings[name] +end \ No newline at end of file diff --git a/Utils/strings.lua b/Utilities/strings.lua similarity index 98% rename from Utils/strings.lua rename to Utilities/strings.lua index 0ffc23f..e2548c5 100644 --- a/Utils/strings.lua +++ b/Utilities/strings.lua @@ -4,4 +4,4 @@ end function string.ends(input, ending) return ending == "" or input:sub(-#ending) == ending -end +end \ No newline at end of file diff --git a/Utilities/userRequire.lua b/Utilities/userRequire.lua new file mode 100644 index 0000000..ae502c3 --- /dev/null +++ b/Utilities/userRequire.lua @@ -0,0 +1,9 @@ +function auUserRequire(path) + local script = auGetSetting("sAbsRepoScripts") + + if (not os.isfile(script)) then + return + end + + return auRequireAbs(script) +end \ No newline at end of file diff --git a/Utils/concatArrays.lua b/Utils/concatArrays.lua deleted file mode 100644 index d3d7bcf..0000000 --- a/Utils/concatArrays.lua +++ /dev/null @@ -1,10 +0,0 @@ - function concatArrays(...) - local ret = {} - - local args = table.pack(...) - for i=1,args.n do - local tbl = args[i] - forEach(tbl, function(re) table.insert(ret, re) end) - end - return ret -end \ No newline at end of file diff --git a/Utils/fatal.lua b/Utils/fatal.lua deleted file mode 100644 index ddb7e3d..0000000 --- a/Utils/fatal.lua +++ /dev/null @@ -1,5 +0,0 @@ -function fatal(...) - print(...) - print(debug.traceback()) - os.exit(1) -end \ No newline at end of file diff --git a/Utils/forEach.lua b/Utils/forEach.lua deleted file mode 100644 index ce7645a..0000000 --- a/Utils/forEach.lua +++ /dev/null @@ -1,12 +0,0 @@ -function forEach(xd, cb, ...) - if (not xd) then - return - end - if type(xd) == "table" then - for k, v in pairs(xd) do - cb(v, ...) - end - else - cb(xd, ...) - end -end \ No newline at end of file diff --git a/Utils/getRoot.lua b/Utils/getRoot.lua deleted file mode 100644 index 5a95c80..0000000 --- a/Utils/getRoot.lua +++ /dev/null @@ -1,8 +0,0 @@ -local root = os.realpath(os.getcwd() .. "/../..") - -function getroot() - if (_overloadRoot) then - return _overloadRoot - end - return root -end \ No newline at end of file diff --git a/Utils/requireAbs.lua b/Utils/requireAbs.lua deleted file mode 100644 index 7818aa2..0000000 --- a/Utils/requireAbs.lua +++ /dev/null @@ -1,8 +0,0 @@ -function requireAbs(path) - local absRefPath = os.realpath(getroot() .. "/Build_Scripts/") - local relPath = _G.path.getrelative(absRefPath, path) - if (os.isfile(relPath)) then - fatal("Script not found: ", relPath) - end - return require(relPath:sub(1, #relPath - 4)) -end \ No newline at end of file diff --git a/Utils/userRequire.lua b/Utils/userRequire.lua deleted file mode 100644 index f969928..0000000 --- a/Utils/userRequire.lua +++ /dev/null @@ -1,9 +0,0 @@ -function userRequire(path) - local script = getroot() .. "/Build_UserScripts/" .. path - - if (not os.isfile(script)) then - return - end - - return require(script) -end \ No newline at end of file diff --git a/aurora.lua b/aurora.lua index 4ff46d8..8988871 100644 --- a/aurora.lua +++ b/aurora.lua @@ -1,9 +1,67 @@ -require("Utils.utils") +-- +-- If this is your entrypoint, you should consider starting premake from the global directory +-- -if (not auLibPrefix) then - auLibPrefix = "" + +-- Developers should look to the global directory for the user facing API +require("Public.base") + +function startSolution(name) + auStartSolution + { + name = name + } end + +require("Legacy.aurora") + + + + + + + + + + + + + + + +local tbl = +{ + "target-win32", + "target-linux", + "target-switch", + "target-ps5", + "target-x86_64", + "target-arm", + "target-wayland" +} + +for i, k in pairs(tbl) do + local key = string.sub(k, 8) + _G[key] = false + if (_OPTIONS[k]) then + _G[key] = true + end +end + + + + + + + + + + + + + + ------------------------------------------------------- -- globals ------------------------------------------------------- @@ -17,26 +75,11 @@ _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 jsonProcessor = require("jsonProcessor") local normalizeSourceRoot = function(path) local backup = path @@ -89,7 +132,7 @@ function addVisit(ina) deps = {} } - local cwd = getroot() + local cwd = auGetRoot() local remoteLua = path .. "/Aurora.lua" local remoteJson = path .. "/Aurora.json" @@ -97,12 +140,12 @@ function addVisit(ina) local localLua = cwd .. "/Build_UserScripts/" .. args.name .. ".aurora.lua" if (os.isfile(localLua)) then - project.processor = requireAbs(localLua)(info) + project.processor = auRequireAbs(localLua)(info) elseif (os.isfile(localJson)) then info.jpath = localJson project.processor = jsonProcessor(info) elseif (os.isfile(remoteLua)) then - project.processor = requireAbs(remoteLua)(info) + project.processor = auRequireAbs(remoteLua)(info) elseif (os.isfile(remoteJson)) then info.jpath = remoteJson project.processor = jsonProcessor(info) @@ -145,7 +188,7 @@ function addScript(ina) local procesor = userRequire(args.script) if (not procesor) then - processor = requireAbs(args.script) + processor = auRequireAbs(args.script) if (not procesor) then print("missing project script:", args.script, path) return @@ -198,7 +241,7 @@ function processDepSearch(proj, resolveProject) local depProj = projectsprocessor[name] if (not depProj) then if (not soft) then - fatal("missing dependency: ", name) + auFatal("missing dependency: ", name) else return false end @@ -218,7 +261,7 @@ local processNS = function(namespace) local projs = {} local projsIdxs = {} - forEach(projectsprocessor, function(proj) + auForEach(projectsprocessor, function(proj) if (proj.info.namespace ~= namespace) then return end @@ -233,11 +276,11 @@ local processNS = function(namespace) return a:upper() < b:upper() end) - forEach(projsIdxs, function(idx) + auForEach(projsIdxs, function(idx) processDepSearch(projs[idx], true) end) - forEach(projsIdxs, function(idx) + auForEach(projsIdxs, function(idx) processLocalProject(projs[idx]) end) end @@ -246,7 +289,7 @@ function processSolution() local hack = {} local hackIdx = {} - forEach(projectsprocessor, function(proj) + auForEach(projectsprocessor, function(proj) table.insert(hackIdx, proj.info.namespace) end) @@ -254,13 +297,13 @@ function processSolution() return a:upper() < b:upper() end) - forEach(hackIdx, processNS) + auForEach(hackIdx, processNS) end function attemptNS(ns) local attemptLoad = false if (not namespacesemitted[ns]) then - dbgGroup(ns) -- only print the group once + auStartGroup(ns) -- only print the group once attemptLoad = true end @@ -275,7 +318,7 @@ function processProject(name, required, noNs) local a = projectsprocessor[name] if (not a) then if (required) then - fatal("missing project: ", name) + auFatal("missing project: ", name) else return false end @@ -383,7 +426,7 @@ function importAndLinkProject(dep, soft) if (soft) then return false end - fatal("Missing project", dep) + auFatal("Missing project", dep) end local iface = proj.processor @@ -391,7 +434,7 @@ function importAndLinkProject(dep, soft) if (soft) then return false end - fatal("missing project: ", dep) + auFatal("missing project: ", dep) end iface:handleReference() @@ -405,7 +448,7 @@ function includeAuProject(dep, soft) if (soft) then return false end - fatal("Missing project", dep) + auFatal("Missing project", dep) end local iface = proj.processor @@ -413,7 +456,7 @@ function includeAuProject(dep, soft) if (soft) then return false end - fatal("missing project: ", dep) + auFatal("missing project: ", dep) end iface:handleReference() @@ -426,7 +469,7 @@ function linkAuProject(dep, soft) if (soft) then return false end - fatal("Missing project", dep) + auFatal("Missing project", dep) end local iface = proj.processor @@ -434,31 +477,22 @@ function linkAuProject(dep, soft) if (soft) then return false end - fatal("missing project: ", dep) + auFatal("missing project: ", dep) end iface:handleLink() return true -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 = getroot() .. "/Build_Scripts/Features/" .. feature:lower() .. ".lua" + local script = auGetRoot() .. "/Build_Scripts/Features/" .. feature:lower() .. ".lua" if (not os.isfile(script)) then - fatal("missing feature", feature, script) + auFatal("missing feature", feature, script) return end - requireAbs(script)() -end - -require ("Boilerplate.workspace") \ No newline at end of file + auRequireAbs(script)() +end \ No newline at end of file diff --git a/linux_build_x64 b/linux_build_x64 new file mode 100644 index 0000000..eda39f2 --- /dev/null +++ b/linux_build_x64 @@ -0,0 +1,4 @@ +#!/bin/bash + +cd Public +premake5 gmake2 --target-linux --target-x86_64 \ No newline at end of file diff --git a/linux_cmake_publish b/linux_cmake_publish new file mode 100644 index 0000000..815785a --- /dev/null +++ b/linux_cmake_publish @@ -0,0 +1,4 @@ +#!/bin/bash + +cd Public +premake5 cmakeau --target-linux --target-x86_64 --target-x86_32 --target-win32 \ No newline at end of file diff --git a/linux_cmake_x64 b/linux_cmake_x64 new file mode 100644 index 0000000..b00a672 --- /dev/null +++ b/linux_cmake_x64 @@ -0,0 +1,4 @@ +#!/bin/bash + +cd Public +premake5 cmakeau --target-linux --target-x86_64 \ No newline at end of file diff --git a/linux_x64 b/linux_x64 new file mode 100644 index 0000000..ebf836f --- /dev/null +++ b/linux_x64 @@ -0,0 +1,4 @@ +#!/bin/bash + +cd Global +premake5 gmake2 --target-linux --target-x86_64 \ No newline at end of file diff --git a/win_cmake_local.bat b/win_cmake_local.bat new file mode 100644 index 0000000..e69de29 diff --git a/win_cmake_publish.bat b/win_cmake_publish.bat new file mode 100644 index 0000000..a25fa3f --- /dev/null +++ b/win_cmake_publish.bat @@ -0,0 +1,4 @@ +@echo off + +cd Public +premake5 cmakeau --target-linux --target-x86_64 --target-x86_32 --target-win32 \ No newline at end of file diff --git a/win_x64.bat b/win_x64.bat new file mode 100644 index 0000000..2530d88 --- /dev/null +++ b/win_x64.bat @@ -0,0 +1,4 @@ +@echo off + +cd Public +premake5 vs2019 --target-win32 --target-x86_64 \ No newline at end of file diff --git a/win_x86.bat b/win_x86.bat new file mode 100644 index 0000000..62bdc25 --- /dev/null +++ b/win_x86.bat @@ -0,0 +1,4 @@ +@echo off + +cd Public +premake5 vs2019 --target-win32 --target-x86_32 \ No newline at end of file