Fixed issues with Makefile naming; removed more deprecated Gmake action code
This commit is contained in:
parent
82633e66ce
commit
30daa20f39
@ -28,6 +28,7 @@
|
||||
* Added NoRuntimeChecks flag to disable Visual Studio default checks
|
||||
* Generated Visual Studio GUIDs are now deterministic
|
||||
* Added support for Visual Studio solution groups
|
||||
* Added dependson() to specify non-linking dependencies (Alexey Orlov)
|
||||
|
||||
|
||||
-------
|
||||
|
@ -142,7 +142,7 @@
|
||||
if count == 1 then
|
||||
return "Makefile"
|
||||
else
|
||||
return this.name .. ".make"
|
||||
return ".make"
|
||||
end
|
||||
end
|
||||
|
||||
@ -238,138 +238,3 @@
|
||||
value = value:gsub("[()]", "")
|
||||
return value
|
||||
end
|
||||
|
||||
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Everything below this point is a candidate for deprecation
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
_MAKE = { }
|
||||
|
||||
|
||||
--
|
||||
-- Escape a string so it can be written to a makefile.
|
||||
--
|
||||
|
||||
function _MAKE.esc(value)
|
||||
local result
|
||||
if (type(value) == "table") then
|
||||
result = { }
|
||||
for _,v in ipairs(value) do
|
||||
table.insert(result, _MAKE.esc(v))
|
||||
end
|
||||
return result
|
||||
else
|
||||
-- handle simple replacements
|
||||
result = value:gsub("\\", "\\\\")
|
||||
result = result:gsub(" ", "\\ ")
|
||||
result = result:gsub("%(", "\\%(")
|
||||
result = result:gsub("%)", "\\%)")
|
||||
|
||||
-- leave $(...) shell replacement sequences alone
|
||||
result = result:gsub("$\\%((.-)\\%)", "$%(%1%)")
|
||||
return result
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Rules for file ops based on the shell type. Can't use defines and $@ because
|
||||
-- it screws up the escaping of spaces and parethesis (anyone know a solution?)
|
||||
--
|
||||
|
||||
function premake.make_copyrule(source, target)
|
||||
_p('%s: %s', target, source)
|
||||
_p('\t@echo Copying $(notdir %s)', target)
|
||||
_p('ifeq (posix,$(SHELLTYPE))')
|
||||
_p('\t$(SILENT) cp -fR %s %s', source, target)
|
||||
_p('else')
|
||||
_p('\t$(SILENT) copy /Y $(subst /,\\\\,%s) $(subst /,\\\\,%s)', source, target)
|
||||
_p('endif')
|
||||
end
|
||||
|
||||
function premake.make_mkdirrule(var)
|
||||
_p('\t@echo Creating %s', var)
|
||||
_p('ifeq (posix,$(SHELLTYPE))')
|
||||
_p('\t$(SILENT) mkdir -p %s', var)
|
||||
_p('else')
|
||||
_p('\t$(SILENT) mkdir $(subst /,\\\\,%s)', var)
|
||||
_p('endif')
|
||||
_p('')
|
||||
end
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Returns a list of object names, properly escaped to be included in the makefile.
|
||||
--
|
||||
|
||||
function _MAKE.getnames(tbl)
|
||||
local result = table.extract(tbl, "name")
|
||||
for k,v in pairs(result) do
|
||||
result[k] = _MAKE.esc(v)
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Write out the raw settings blocks.
|
||||
--
|
||||
|
||||
function make.settings_old(cfg, cc)
|
||||
if #cfg.makesettings > 0 then
|
||||
for _, value in ipairs(cfg.makesettings) do
|
||||
_p(value)
|
||||
end
|
||||
end
|
||||
|
||||
local toolsettings = cc.platforms[cfg.platform].cfgsettings
|
||||
if toolsettings then
|
||||
_p(toolsettings)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Register the "gmake" action
|
||||
--
|
||||
|
||||
newaction {
|
||||
trigger = "gmake",
|
||||
shortname = "GNU Make",
|
||||
description = "Generate GNU makefiles for POSIX, MinGW, and Cygwin",
|
||||
|
||||
valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib" },
|
||||
|
||||
valid_languages = { "C", "C++", "C#" },
|
||||
|
||||
valid_tools = {
|
||||
cc = { "gcc" },
|
||||
dotnet = { "mono", "msnet", "pnet" },
|
||||
},
|
||||
|
||||
onsolution = function(sln)
|
||||
premake.generate(sln, make.getmakefilename(sln, false), premake.make_solution)
|
||||
end,
|
||||
|
||||
onproject = function(prj)
|
||||
local makefile = make.getmakefilename(prj, true)
|
||||
if premake.isdotnetproject(prj) then
|
||||
premake.generate(prj, makefile, premake.make_csharp)
|
||||
else
|
||||
premake.generate(prj, makefile, premake.make_cpp)
|
||||
end
|
||||
end,
|
||||
|
||||
oncleansolution = function(sln)
|
||||
premake.clean.file(sln, make.getmakefilename(sln, false))
|
||||
end,
|
||||
|
||||
oncleanproject = function(prj)
|
||||
premake.clean.file(prj, make.getmakefilename(prj, true))
|
||||
end
|
||||
}
|
||||
|
@ -58,8 +58,10 @@
|
||||
_p('clean:')
|
||||
for prj in solution.eachproject_ng(sln) do
|
||||
local slnpath = solution.getlocation(sln)
|
||||
local prjpath = path.getrelative(slnpath, project.getlocation(prj))
|
||||
_p(1,'@${MAKE} --no-print-directory -C %s -f %s clean', make.esc(prjpath), make.esc(make.getmakefilename(prj, true)))
|
||||
local prjpath = project.getfilename(prj, make.getmakefilename(prj, true))
|
||||
local prjdir = path.getdirectory(path.getrelative(slnpath, prjpath))
|
||||
local prjname = path.getname(prjpath)
|
||||
_p(1,'@${MAKE} --no-print-directory -C %s -f %s clean', make.esc(prjdir), make.esc(prjname))
|
||||
end
|
||||
_p('')
|
||||
end
|
||||
@ -120,9 +122,11 @@
|
||||
_p(1,'@echo "==== Building %s ($(%s_config)) ===="', prj.name, cfgvar)
|
||||
|
||||
local slnpath = solution.getlocation(sln)
|
||||
local prjpath = path.getrelative(slnpath, project.getlocation(prj))
|
||||
local filename = make.getmakefilename(prj, true)
|
||||
_p(1,'@${MAKE} --no-print-directory -C %s -f %s config=$(%s_config)', make.esc(prjpath), make.esc(filename), cfgvar)
|
||||
local prjpath = project.getfilename(prj, make.getmakefilename(prj, true))
|
||||
local prjdir = path.getdirectory(path.getrelative(slnpath, prjpath))
|
||||
local prjname = path.getname(prjpath)
|
||||
|
||||
_p(1,'@${MAKE} --no-print-directory -C %s -f %s config=$(%s_config)', make.esc(prjdir), make.esc(prjname), cfgvar)
|
||||
|
||||
_p('endif')
|
||||
_p('')
|
||||
|
@ -488,14 +488,22 @@
|
||||
-- @param prj
|
||||
-- The project object to query.
|
||||
-- @param ext
|
||||
-- An optional file extension to add, with the leading dot.
|
||||
-- An optional file extension to add, with the leading dot. If provided
|
||||
-- without a leading dot, it will treated as a file name.
|
||||
-- @return
|
||||
-- The absolute path to the project's file.
|
||||
--
|
||||
|
||||
function project.getfilename(prj, ext)
|
||||
local fn = path.join(project.getlocation(prj), prj.filename)
|
||||
if ext then fn = fn .. ext end
|
||||
local fn = project.getlocation(prj)
|
||||
if ext and not ext:startswith(".") then
|
||||
fn = path.join(fn, ext)
|
||||
else
|
||||
fn = path.join(fn, prj.filename)
|
||||
if ext then
|
||||
fn = fn .. ext
|
||||
end
|
||||
end
|
||||
return fn
|
||||
end
|
||||
|
||||
|
@ -87,3 +87,14 @@
|
||||
test.isequal("MyProject", path.getname(project.getfilename(prj)))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- If extension is provided without a leading dot, it should override any
|
||||
-- project filename.
|
||||
--
|
||||
|
||||
function suite.canOverrideFilename()
|
||||
prepare()
|
||||
test.isequal("Makefile", path.getname(project.getfilename(prj, "Makefile")))
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user