diff options
author | Oliver Schneider <oliver@assarbad.net> | 2017-03-22 01:24:08 +0300 |
---|---|---|
committer | Oliver Schneider <oliver@assarbad.net> | 2017-03-22 01:24:08 +0300 |
commit | 59e79356166589c1f0164afe105507addae67cfb (patch) | |
tree | 9dfbd4feb1915ef8f240f74a52728bfbab4d1ed0 /src/base | |
parent | b8625c05bc96cc03d1d940aa7a7682029473f228 (diff) |
Introducing os.str2uuid() as possibility to convert a string deterministically into a (pseudo-)UUID using SHA-3 (256-bit) aka Keccak
Replaced all leading spaces or mixed spaces/tabs with tabs (by rule 1 tab = 4 spaces)
Prepared premake4.lua for this project to generate XP projects and VS2017 projects
--HG--
branch : WDS-build
Diffstat (limited to 'src/base')
-rw-r--r-- | src/base/api.lua | 80 | ||||
-rw-r--r-- | src/base/bake.lua | 306 | ||||
-rw-r--r-- | src/base/project.lua | 2 |
3 files changed, 194 insertions, 194 deletions
diff --git a/src/base/api.lua b/src/base/api.lua index c11056f..52f5ccf 100644 --- a/src/base/api.lua +++ b/src/base/api.lua @@ -757,46 +757,46 @@ error("no active solution", 2) end - -- if this is a new project, or the project in that slot doesn't have a usage, create it - if((not sln.projects[name]) or - ((not sln.projects[name].usage) and (not sln.projects[name].usageProj))) then - premake.CurrentContainer = createproject(name, sln, true) - else - premake.CurrentContainer = iff(sln.projects[name].usage, - sln.projects[name], sln.projects[name].usageProj) - end - - -- add an empty, global configuration to the project - configuration { } - - return premake.CurrentContainer - end - - function project(name) - if (not name) then - --Only return non-usage projects - if(type(premake.CurrentContainer) ~= "project") then return nil end - if(premake.CurrentContainer.usage) then return nil end - return premake.CurrentContainer - end - - -- identify the parent solution - local sln - if (type(premake.CurrentContainer) == "project") then - sln = premake.CurrentContainer.solution - else - sln = premake.CurrentContainer - end - if (type(sln) ~= "solution") then - error("no active solution", 2) - end - - -- if this is a new project, or the old project is a usage project, create it - if((not sln.projects[name]) or sln.projects[name].usage) then - premake.CurrentContainer = createproject(name, sln) - else - premake.CurrentContainer = sln.projects[name]; - end + -- if this is a new project, or the project in that slot doesn't have a usage, create it + if((not sln.projects[name]) or + ((not sln.projects[name].usage) and (not sln.projects[name].usageProj))) then + premake.CurrentContainer = createproject(name, sln, true) + else + premake.CurrentContainer = iff(sln.projects[name].usage, + sln.projects[name], sln.projects[name].usageProj) + end + + -- add an empty, global configuration to the project + configuration { } + + return premake.CurrentContainer + end + + function project(name) + if (not name) then + --Only return non-usage projects + if(type(premake.CurrentContainer) ~= "project") then return nil end + if(premake.CurrentContainer.usage) then return nil end + return premake.CurrentContainer + end + + -- identify the parent solution + local sln + if (type(premake.CurrentContainer) == "project") then + sln = premake.CurrentContainer.solution + else + sln = premake.CurrentContainer + end + if (type(sln) ~= "solution") then + error("no active solution", 2) + end + + -- if this is a new project, or the old project is a usage project, create it + if((not sln.projects[name]) or sln.projects[name].usage) then + premake.CurrentContainer = createproject(name, sln) + else + premake.CurrentContainer = sln.projects[name]; + end -- add an empty, global configuration to the project configuration { } diff --git a/src/base/bake.lua b/src/base/bake.lua index 20aad72..11b702f 100644 --- a/src/base/bake.lua +++ b/src/base/bake.lua @@ -396,61 +396,61 @@ end end - local function getCfgKind(cfg) - if(cfg.kind) then - return cfg.kind; - end - - if(cfg.project.__configs[""] and cfg.project.__configs[""].kind) then - return cfg.project.__configs[""].kind; - end - - return nil - end - - local function getprojrec(dstArray, foundList, cfg, cfgname, searchField, bLinkage) - if(not cfg) then return end - - local foundUsePrjs = {}; - for _, useName in ipairs(cfg[searchField]) do - local testName = useName:lower(); - if((not foundList[testName])) then - local theProj = nil; - local theUseProj = nil; - for _, prj in ipairs(cfg.project.solution.projects) do - if (prj.name:lower() == testName) then - if(prj.usage) then - theUseProj = prj; - else - theProj = prj; - end - end - end - - --Must connect to a usage project. - if(theUseProj) then - foundList[testName] = true; - local prjEntry = { - name = testName, - proj = theProj, - usageProj = theUseProj, - bLinkageOnly = bLinkage, - }; - dstArray[testName] = prjEntry; - table.insert(foundUsePrjs, theUseProj); - end - end - end - - for _, usePrj in ipairs(foundUsePrjs) do - --Links can only recurse through static libraries. - if((searchField ~= "links") or - (getCfgKind(usePrj.__configs[cfgname]) == "StaticLib")) then - getprojrec(dstArray, foundList, usePrj.__configs[cfgname], - cfgname, searchField, bLinkage); - end - end - end + local function getCfgKind(cfg) + if(cfg.kind) then + return cfg.kind; + end + + if(cfg.project.__configs[""] and cfg.project.__configs[""].kind) then + return cfg.project.__configs[""].kind; + end + + return nil + end + + local function getprojrec(dstArray, foundList, cfg, cfgname, searchField, bLinkage) + if(not cfg) then return end + + local foundUsePrjs = {}; + for _, useName in ipairs(cfg[searchField]) do + local testName = useName:lower(); + if((not foundList[testName])) then + local theProj = nil; + local theUseProj = nil; + for _, prj in ipairs(cfg.project.solution.projects) do + if (prj.name:lower() == testName) then + if(prj.usage) then + theUseProj = prj; + else + theProj = prj; + end + end + end + + --Must connect to a usage project. + if(theUseProj) then + foundList[testName] = true; + local prjEntry = { + name = testName, + proj = theProj, + usageProj = theUseProj, + bLinkageOnly = bLinkage, + }; + dstArray[testName] = prjEntry; + table.insert(foundUsePrjs, theUseProj); + end + end + end + + for _, usePrj in ipairs(foundUsePrjs) do + --Links can only recurse through static libraries. + if((searchField ~= "links") or + (getCfgKind(usePrj.__configs[cfgname]) == "StaticLib")) then + getprojrec(dstArray, foundList, usePrj.__configs[cfgname], + cfgname, searchField, bLinkage); + end + end + end -- -- This function will recursively get all projects that the given configuration has in its "uses" @@ -465,84 +465,84 @@ -- field of usage projects. These will only copy linker information, but they will recurse. -- through other "links" fields. -- - local function getprojectsconnections(cfg, cfgname) - local dstArray = {}; - local foundList = {}; - foundList[cfg.project.name:lower()] = true; - - --First, follow the uses recursively. - getprojrec(dstArray, foundList, cfg, cfgname, "uses", false); - - --Next, go through all of the usage projects and recursively get their links. - --But only if they're not already there. Get the links as linkage-only. - local linkArray = {}; - for prjName, prjEntry in pairs(dstArray) do - getprojrec(linkArray, foundList, prjEntry.usageProj.__configs[cfgname], cfgname, - "links", true); - end + local function getprojectsconnections(cfg, cfgname) + local dstArray = {}; + local foundList = {}; + foundList[cfg.project.name:lower()] = true; + + --First, follow the uses recursively. + getprojrec(dstArray, foundList, cfg, cfgname, "uses", false); + + --Next, go through all of the usage projects and recursively get their links. + --But only if they're not already there. Get the links as linkage-only. + local linkArray = {}; + for prjName, prjEntry in pairs(dstArray) do + getprojrec(linkArray, foundList, prjEntry.usageProj.__configs[cfgname], cfgname, + "links", true); + end - --Copy from linkArray into dstArray. - for prjName, prjEntry in pairs(linkArray) do - dstArray[prjName] = prjEntry; - end + --Copy from linkArray into dstArray. + for prjName, prjEntry in pairs(linkArray) do + dstArray[prjName] = prjEntry; + end - return dstArray; - end + return dstArray; + end - local function isnameofproj(cfg, strName) - local sln = cfg.project.solution; - local strTest = strName:lower(); - for prjIx, prj in ipairs(sln.projects) do - if (prj.name:lower() == strTest) then - return true; - end - end + local function isnameofproj(cfg, strName) + local sln = cfg.project.solution; + local strTest = strName:lower(); + for prjIx, prj in ipairs(sln.projects) do + if (prj.name:lower() == strTest) then + return true; + end + end - return false; - end + return false; + end -- -- Copies the field from dstCfg to srcCfg. -- - local function copydependentfield(srcCfg, dstCfg, strSrcField) - local srcField = premake.fields[strSrcField]; - local strDstField = strSrcField; - - if type(srcCfg[strSrcField]) == "table" then - --handle paths. - if (srcField.kind == "dirlist" or srcField.kind == "filelist") and - (not keeprelative[strSrcField]) then - for i,p in ipairs(srcCfg[strSrcField]) do - table.insert(dstCfg[strDstField], - path.rebase(p, srcCfg.project.location, dstCfg.project.location)) - end - else - if(strSrcField == "links") then - for i,p in ipairs(srcCfg[strSrcField]) do - if(not isnameofproj(dstCfg, p)) then - table.insert(dstCfg[strDstField], p) - else - printf("Failed to copy '%s' from proj '%s'.", - p, srcCfg.project.name); - end - end - else - for i,p in ipairs(srcCfg[strSrcField]) do - table.insert(dstCfg[strDstField], p) - end - end - end - else - if(srcField.kind == "path" and (not keeprelative[strSrcField])) then - dstCfg[strDstField] = path.rebase(srcCfg[strSrcField], - prj.location, dstCfg.project.location); - else - dstCfg[strDstField] = srcCfg[strSrcField]; - end - end - end + local function copydependentfield(srcCfg, dstCfg, strSrcField) + local srcField = premake.fields[strSrcField]; + local strDstField = strSrcField; + + if type(srcCfg[strSrcField]) == "table" then + --handle paths. + if (srcField.kind == "dirlist" or srcField.kind == "filelist") and + (not keeprelative[strSrcField]) then + for i,p in ipairs(srcCfg[strSrcField]) do + table.insert(dstCfg[strDstField], + path.rebase(p, srcCfg.project.location, dstCfg.project.location)) + end + else + if(strSrcField == "links") then + for i,p in ipairs(srcCfg[strSrcField]) do + if(not isnameofproj(dstCfg, p)) then + table.insert(dstCfg[strDstField], p) + else + printf("Failed to copy '%s' from proj '%s'.", + p, srcCfg.project.name); + end + end + else + for i,p in ipairs(srcCfg[strSrcField]) do + table.insert(dstCfg[strDstField], p) + end + end + end + else + if(srcField.kind == "path" and (not keeprelative[strSrcField])) then + dstCfg[strDstField] = path.rebase(srcCfg[strSrcField], + prj.location, dstCfg.project.location); + else + dstCfg[strDstField] = srcCfg[strSrcField]; + end + end + end -- @@ -553,36 +553,36 @@ -- if the project is in this solution; instead it will add that project to the configuration's -- links field, expecting that Premake will handle the rest. -- - local function copyusagedata(cfg, cfgname, linkToProjs) - local myPrj = cfg.project; - local bIsStaticLib = (getCfgKind(cfg) == "StaticLib"); - - for prjName, prjEntry in pairs(linkToProjs) do - local srcPrj = prjEntry.usageProj; - local srcCfg = srcPrj.__configs[cfgname]; - - for name, field in pairs(premake.fields) do - if(srcCfg[name]) then - if(field.usagecopy) then - if(not prjEntry.bLinkageOnly) then - copydependentfield(srcCfg, cfg, name) - end - elseif(field.linkagecopy) then - --Copy the linkage data if we're building a non-static thing - --and this is a pure usage project. If it's not pure-usage, then - --we will simply put the project's name in the links field later. - if((not bIsStaticLib) and (not prjEntry.proj)) then - copydependentfield(srcCfg, cfg, name) - end - end - end - end - - if((not bIsStaticLib) and prjEntry.proj) then - table.insert(cfg.links, prjEntry.proj.name); - end - end - end + local function copyusagedata(cfg, cfgname, linkToProjs) + local myPrj = cfg.project; + local bIsStaticLib = (getCfgKind(cfg) == "StaticLib"); + + for prjName, prjEntry in pairs(linkToProjs) do + local srcPrj = prjEntry.usageProj; + local srcCfg = srcPrj.__configs[cfgname]; + + for name, field in pairs(premake.fields) do + if(srcCfg[name]) then + if(field.usagecopy) then + if(not prjEntry.bLinkageOnly) then + copydependentfield(srcCfg, cfg, name) + end + elseif(field.linkagecopy) then + --Copy the linkage data if we're building a non-static thing + --and this is a pure usage project. If it's not pure-usage, then + --we will simply put the project's name in the links field later. + if((not bIsStaticLib) and (not prjEntry.proj)) then + copydependentfield(srcCfg, cfg, name) + end + end + end + end + + if((not bIsStaticLib) and prjEntry.proj) then + table.insert(cfg.links, prjEntry.proj.name); + end + end + end -- diff --git a/src/base/project.lua b/src/base/project.lua index e9a3c7a..acff735 100644 --- a/src/base/project.lua +++ b/src/base/project.lua @@ -307,7 +307,7 @@ -- object - return the project object of the dependency -- - function premake.getlinks(cfg, kind, part) + function premake.getlinks(cfg, kind, part) -- if I'm building a list of link directories, include libdirs local result = iif (part == "directory" and kind == "all", cfg.libdirs, {}) |