Rename project.getfilename() to premake.filename(); now used by rules too

This commit is contained in:
Jason Perkins 2014-08-11 17:28:51 -04:00
parent 08e1494ff3
commit 9230abc637
8 changed files with 54 additions and 56 deletions

View File

@ -184,7 +184,7 @@
function make.csResponseRules(prj)
local toolset = premake.tools.dotnet
local ext = make.getmakefilename(prj, true)
local makefile = path.getname(premake.project.getfilename(prj, ext))
local makefile = path.getname(premake.filename(prj, ext))
local response = path.translate(make.cs.getresponsefilename(prj))
_p('$(RESPONSE): %s', makefile)

View File

@ -59,7 +59,7 @@
function make.cleanrules(sln)
_p('clean:')
for prj in solution.eachproject(sln) do
local prjpath = project.getfilename(prj, make.getmakefilename(prj, true))
local prjpath = premake.filename(prj, make.getmakefilename(prj, true))
local prjdir = path.getdirectory(path.getrelative(sln.location, prjpath))
local prjname = path.getname(prjpath)
_x(1,'@${MAKE} --no-print-directory -C %s -f %s clean', prjdir, prjname)
@ -122,7 +122,7 @@
_p(1,'@echo "==== Building %s ($(%s_config)) ===="', prj.name, cfgvar)
local prjpath = project.getfilename(prj, make.getmakefilename(prj, true))
local prjpath = premake.filename(prj, make.getmakefilename(prj, true))
local prjdir = path.getdirectory(path.getrelative(sln.location, prjpath))
local prjname = path.getname(prjpath)

View File

@ -386,7 +386,7 @@
extension = iif(_ACTION > "vs2008", ".vcxproj", ".vcproj")
end
return project.getfilename(prj, extension)
return premake.filename(prj, extension)
end

View File

@ -144,7 +144,7 @@
--
function premake.generate(obj, ext, callback)
local fn = premake.project.getfilename(obj, ext)
local fn = premake.filename(obj, ext)
printf("Generating %s...", path.getrelative(os.getcwd(), fn))
local f, err = io.open(fn, "wb")
@ -159,6 +159,34 @@
---
-- Returns the full path a file generated from any of the project
-- objects (project, solution, rule).
--
-- @param obj
-- The project object being generated.
-- @param ext
-- An optional extension for the generated file, with the leading dot.
-- @param callback
-- The function responsible for writing the file; will receive the
-- project object as its only argument.
---
function premake.filename(obj, ext)
local fname = obj.location
if ext and not ext:startswith(".") then
fname = path.join(fname, ext)
else
fname = path.join(fname, obj.filename)
if ext then
fname = fname .. ext
end
end
return fname
end
---
-- Sets the output indentation parameters.
--

View File

@ -210,32 +210,17 @@
--
---
-- Returns the file name for this project. Also works with solutions.
--
-- @param prj
-- The project object to query.
-- @param ext
-- 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.
--
-- Deprecated 11 Aug 2014
---
function project.getfilename(prj, ext)
local fn = prj.location
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
return premake.filename(prj, ext)
end
--
-- Return the first configuration of a project, which is used in some
-- actions to generate project-wide defaults.

View File

@ -157,20 +157,6 @@
end
--
-- Returns the file name for this solution.
--
-- @param sln
-- The solution object to query.
-- @param ext
-- An optional file extension to add, with the leading dot.
-- @return
-- The absolute path to the solution's file.
--
solution.getfilename = project.getfilename
--
-- Retrieve the tree of project groups.

View File

@ -1,13 +1,13 @@
--
-- tests/project/test_filename.lua
-- Verify generation of project (and solution) filenames.
-- Copyright (c) 2008-2012 Jason Perkins and the Premake project
-- tests/base/test_filename.lua
-- Verify generation of project/solution/rule filenames.
-- Copyright (c) 2008-2014 Jason Perkins and the Premake project
--
T.project_filename = {}
local suite = T.project_filename
local suite = test.declare("project_filename")
local p = premake
local project = premake.project
--
@ -17,11 +17,11 @@
local sln
function suite.setup()
sln, prj = test.createsolution()
sln = test.createsolution()
end
local function prepare()
prj = premake.solution.getproject(sln, 1)
prj = test.getproject(sln, 1)
end
@ -31,7 +31,7 @@
function suite.isAbsolutePath()
prepare()
test.isequal(os.getcwd(), path.getdirectory(project.getfilename(prj)))
test.isequal(os.getcwd(), path.getdirectory(p.filename(prj)))
end
@ -41,7 +41,7 @@
function suite.isProjectName_onNoFilename()
prepare()
test.isequal("MyProject", path.getname(project.getfilename(prj)))
test.isequal("MyProject", path.getname(p.filename(prj)))
end
@ -52,7 +52,7 @@
function suite.doesUseFilename()
filename "Howdy"
prepare()
test.isequal("Howdy", path.getname(project.getfilename(prj)))
test.isequal("Howdy", path.getname(p.filename(prj)))
end
@ -62,7 +62,7 @@
function suite.doesUseExtension()
prepare()
test.isequal(".xc", path.getextension(project.getfilename(prj, ".xc")))
test.isequal(".xc", path.getextension(p.filename(prj, ".xc")))
end
@ -72,7 +72,7 @@
function suite.worksWithSolution()
prepare()
test.isequal("MySolution", path.getname(project.getfilename(sln)))
test.isequal("MySolution", path.getname(p.filename(sln)))
end
@ -84,7 +84,7 @@
solution ("MySolution")
filename ("Howdy")
prepare()
test.isequal("MyProject", path.getname(project.getfilename(prj)))
test.isequal("MyProject", path.getname(p.filename(prj)))
end
@ -95,6 +95,5 @@
function suite.canOverrideFilename()
prepare()
test.isequal("Makefile", path.getname(project.getfilename(prj, "Makefile")))
test.isequal("Makefile", path.getname(p.filename(prj, "Makefile")))
end

View File

@ -33,6 +33,7 @@
dofile("base/test_context.lua")
dofile("base/test_criteria.lua")
dofile("base/test_detoken.lua")
dofile("base/test_filename.lua")
dofile("base/test_include.lua")
dofile("base/test_option.lua")
dofile("base/test_os.lua")
@ -51,7 +52,6 @@
-- Project object tests
dofile("project/test_config_maps.lua")
dofile("project/test_eachconfig.lua")
dofile("project/test_filename.lua")
dofile("project/test_getconfig.lua")
dofile("project/test_location.lua")
dofile("project/test_vpaths.lua")