Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

These are ALL our changes to premake-core to get our build up and running. #6

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

local corePath = _SCRIPT_DIR


--
-- Disable deprecation warnings for myself, so that older development
-- versions of Premake can be used to bootstrap new builds.
Expand Down Expand Up @@ -72,7 +71,12 @@
-- TODO: defaultConfiguration "Release"
--

if not _OPTIONS["to"] then
_OPTIONS["to"] = "build"
end

solution "Premake5"
platforms { 'x64' }
configurations { "Release", "Debug" }
location ( _OPTIONS["to"] )

Expand All @@ -81,7 +85,7 @@
language "C"
kind "ConsoleApp"
flags { "No64BitChecks", "ExtraWarnings", "StaticRuntime" }
includedirs { "src/host/lua-5.1.4/src" }
includedirs { "src/host/lua-5.2.3/src" }

files
{
Expand All @@ -92,12 +96,12 @@

excludes
{
"src/host/lua-5.1.4/src/lauxlib.c",
"src/host/lua-5.1.4/src/lua.c",
"src/host/lua-5.1.4/src/luac.c",
"src/host/lua-5.1.4/src/print.c",
"src/host/lua-5.1.4/**.lua",
"src/host/lua-5.1.4/etc/*.c"
"src/host/lua-5.2.3/src/lauxlib.c",
"src/host/lua-5.2.3/src/lua.c",
"src/host/lua-5.2.3/src/luac.c",
"src/host/lua-5.2.3/src/print.c",
"src/host/lua-5.2.3/**.lua",
"src/host/lua-5.2.3/etc/*.c"
}

configuration "Debug"
Expand All @@ -111,13 +115,13 @@
flags { "OptimizeSize" }

configuration "vs*"
defines { "_CRT_SECURE_NO_WARNINGS" }
defines { "_CRT_SECURE_NO_WARNINGS", "_CRT_NONSTDC_NO_WARNINGS" }

configuration "vs2005"
defines {"_CRT_SECURE_NO_DEPRECATE" }
defines {"_CRT_SECURE_NO_DEPRECATE" }

configuration "windows"
links { "ole32" }
links { "ole32" }

configuration "linux or bsd or hurd"
defines { "LUA_USE_POSIX", "LUA_USE_DLOPEN" }
Expand All @@ -129,7 +133,7 @@

configuration "macosx"
defines { "LUA_USE_MACOSX" }
links { "CoreServices.framework" }
links { "CoreServices.framework", "readline" }

configuration { "macosx", "gmake" }
toolset "clang"
Expand Down
9 changes: 9 additions & 0 deletions src/_premake_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@
pathVars = true,
}

api.register {
name = "buildoutputsasinputs",
scope = "config",
kind = "string"
}

api.register {
name = "buildrule", -- DEPRECATED
scope = "config",
Expand Down Expand Up @@ -446,6 +452,9 @@
"WPF",
"C++11",
"C++14",

"MacOSXBundle",
"NoLibSysDir" -- disable adding /usr/lib on linux
},
aliases = {
FatalWarnings = { "FatalWarnings", "FatalCompileWarnings", "FatalLinkWarnings" },
Expand Down
2 changes: 1 addition & 1 deletion src/_premake_main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
---

function m.installModuleLoader()
table.insert(package.loaders, 2, m.moduleLoader)
table.insert(package.searchers, 2, m.moduleLoader)
end

function m.moduleLoader(name)
Expand Down
10 changes: 5 additions & 5 deletions src/actions/make/_make.lua
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@
---

function make.esc(value)
result = value:gsub("\\", "\\\\")
result = result:gsub(" ", "\\ ")
result = result:gsub("%(", "\\%(")
result = result:gsub("%)", "\\%)")
result = string.gsub(value, "\\", "\\\\")
result = string.gsub(result, " ", "\\ ")
result = string.gsub(result, "%(", "\\(")
result = string.gsub(result, "%)", "\\)")

-- leave $(...) shell replacement sequences alone
result = result:gsub("$\\%((.-)\\%)", "$%(%1%)")
result = result:gsub("$\\%((.-)\\%)", "$(%1)")
return result
end

Expand Down
72 changes: 69 additions & 3 deletions src/actions/make/make_cpp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"phonyRules",
"cppConfigs",
"cppObjects",
"customBuildDepends",
"shellType",
"cppTargetRules",
"targetDirRules",
Expand Down Expand Up @@ -105,12 +106,72 @@
end


--
-- Output the custom build dependencies.
--

function make.getStandardFiles(prj, cfg)
local res = {}

local tr = project.getsourcetree(prj)
premake.tree.traverse(tr, {
onleaf = function(node, depth)
if string.match(node.relpath, "%.h") then
return
end

local filecfg = fileconfig.getconfig(node, cfg)
if filecfg and not fileconfig.hasCustomBuildRule(filecfg) then
table.insert(res, node.relpath)
end
end
})

return res
end


function make.customBuildDepends(prj)

-- now I can write out the lists, project level first...
function listFiles(var, list)
_p('%s \\', var)
for _, objectname in ipairs(list) do
_x('\t%s \\', objectname)
end
_p('')
end

for cfg in project.eachconfig(prj) do
_x('ifeq ($(config),%s)', cfg.shortname)
listFiles('CUSTOMBUILDOUTPUTS :=', make.getStandardFiles(prj, cfg))
_p('endif')
_p('')
end
end


--
-- Output the list of file building rules.
--

function make.cppFileRules(prj)
local tr = project.getsourcetree(prj)

local dependedOnAllFiles = false
premake.tree.traverse(tr, {
onleaf = function(node, depth)
for cfg in project.eachconfig(prj) do
local filecfg = fileconfig.getconfig(node, cfg)

if filecfg and filecfg.buildoutputsasinputs then
dependedOnAllFiles = true
break
end
end
end
})

premake.tree.traverse(tr, {
onleaf = function(node, depth)
-- check to see if this file has custom rules
Expand All @@ -128,17 +189,21 @@
if rules then
cpp.customFileRules(prj, node)
else
cpp.standardFileRules(prj, node)
cpp.standardFileRules(prj, node, dependedOnAllFiles)
end
end
})
_p('')
end

function cpp.standardFileRules(prj, node)
function cpp.standardFileRules(prj, node, dependedOnAllFiles)
-- C/C++ file
if path.iscppfile(node.abspath) then
_x('$(OBJDIR)/%s.o: %s', node.objname, node.relpath)
if dependedOnAllFiles then
_x('$(OBJDIR)/%s.o: %s $(CUSTOMBUILDOUTPUTS)', node.objname, node.relpath)
else
_x('$(OBJDIR)/%s.o: %s', node.objname, node.relpath)
end
_p('\t@echo $(notdir $<)')
cpp.buildcommand(prj, "o", node)

Expand Down Expand Up @@ -407,6 +472,7 @@

function make.ldFlags(cfg, toolset)
local flags = table.join(toolset.getLibraryDirectories(cfg), toolset.getldflags(cfg), cfg.linkoptions)
table.sort(flags)
_p(' ALL_LDFLAGS += $(LDFLAGS)%s', make.list(flags))
end

Expand Down
2 changes: 2 additions & 0 deletions src/actions/make/make_solution.lua
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,11 @@
end
end
if #groupTargets > 0 then
table.sort(groupTargets)
rule = rule .. " " .. table.concat(groupTargets, " ")
end
if #projectTargets > 0 then
table.sort(projectTargets)
rule = rule .. " " .. table.concat(projectTargets, " ")
end
_p(rule)
Expand Down
2 changes: 1 addition & 1 deletion src/actions/vstudio/_vstudio.lua
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@
if not cfg._needsExplicitLink then
local ex = cfg.flags.NoImplicitLink
if not ex then
local prjdeps = project.getdependencies(cfg.project)
local prjdeps = project.getdependencies(cfg.project, "linkOnly")
local cfgdeps = config.getlinks(cfg, "dependencies", "object")
ex = #prjdeps ~= #cfgdeps
end
Expand Down
4 changes: 2 additions & 2 deletions src/actions/vstudio/vs2005_csproj.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
}

function cs2005.generate(prj)
io.utf8()
p.utf8()

premake.callarray(cs2005, cs2005.elements.project, prj)

Expand Down Expand Up @@ -322,7 +322,7 @@
function cs2005.projectReferences(prj)
_p(1,'<ItemGroup>')

local deps = project.getdependencies(prj, true)
local deps = project.getdependencies(prj, 'linkOnly')
if #deps > 0 then
for _, dep in ipairs(deps) do
local relpath = vstudio.path(prj, vstudio.projectfile(dep))
Expand Down
4 changes: 2 additions & 2 deletions src/actions/vstudio/vs2005_solution.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

function sln2005.generate(sln)
-- Mark the file as Unicode
_p('\239\187\191')
premake.utf8()

sln2005.reorderProjects(sln)

Expand Down Expand Up @@ -126,7 +126,7 @@
--

function sln2005.projectdependencies(prj)
local deps = project.getdependencies(prj)
local deps = project.getdependencies(prj, 'dependOnly')
if #deps > 0 then
_p(1,'ProjectSection(ProjectDependencies) = postProject')
for _, dep in ipairs(deps) do
Expand Down
Loading