Added filename(); set solution or project file name independently of the solution or project name
This commit is contained in:
parent
8a6bb2c837
commit
1747035050
@ -20,11 +20,11 @@
|
||||
},
|
||||
|
||||
onsolution = function(sln)
|
||||
premake.generate(sln, "%%.workspace", premake.codeblocks.workspace)
|
||||
premake.generate(sln, ".workspace", premake.codeblocks.workspace)
|
||||
end,
|
||||
|
||||
onproject = function(prj)
|
||||
premake.generate(prj, "%%.cbp", premake.codeblocks.cbp)
|
||||
premake.generate(prj, ".cbp", premake.codeblocks.cbp)
|
||||
end,
|
||||
|
||||
oncleansolution = function(sln)
|
||||
|
@ -20,11 +20,11 @@
|
||||
},
|
||||
|
||||
onsolution = function(sln)
|
||||
premake.generate(sln, "%%.workspace", premake.codelite.workspace)
|
||||
premake.generate(sln, ".workspace", premake.codelite.workspace)
|
||||
end,
|
||||
|
||||
onproject = function(prj)
|
||||
premake.generate(prj, "%%.project", premake.codelite.project)
|
||||
premake.generate(prj, ".project", premake.codelite.project)
|
||||
end,
|
||||
|
||||
oncleansolution = function(sln)
|
||||
|
@ -61,14 +61,14 @@
|
||||
-- function that will actually do the work of generating the file contents.
|
||||
|
||||
onsolution = function(sln)
|
||||
premake.generate(sln, "%%.sln.txt", premake.example.solution)
|
||||
premake.generate(sln, ".sln.txt", premake.example.solution)
|
||||
end,
|
||||
|
||||
onproject = function(prj)
|
||||
if premake.isdotnetproject(prj) then
|
||||
premake.generate(prj, "%%.csprj.txt", premake.example.project)
|
||||
premake.generate(prj, ".csprj.txt", premake.example.project)
|
||||
else
|
||||
premake.generate(prj, "%%.cprj.txt", premake.example.project)
|
||||
premake.generate(prj, ".cprj.txt", premake.example.project)
|
||||
end
|
||||
end,
|
||||
|
||||
|
@ -33,16 +33,16 @@
|
||||
},
|
||||
|
||||
onsolution = function(sln)
|
||||
premake.generate(sln, "%%.sln", vstudio.sln2005.generate_ng)
|
||||
premake.generate(sln, ".sln", vstudio.sln2005.generate_ng)
|
||||
end,
|
||||
|
||||
onproject = function(prj)
|
||||
if premake.isdotnetproject(prj) then
|
||||
premake.generate(prj, "%%.csproj", vstudio.cs2005.generate_ng)
|
||||
premake.generate(prj, "%%.csproj.user", vstudio.cs2005.generate_user_ng)
|
||||
premake.generate(prj, ".csproj", vstudio.cs2005.generate_ng)
|
||||
premake.generate(prj, ".csproj.user", vstudio.cs2005.generate_user_ng)
|
||||
else
|
||||
premake.generate(prj, "%%.vcproj", vstudio.vc200x.generate_ng)
|
||||
premake.generate(prj, "%%.vcproj.user", vstudio.vc200x.generate_user_ng)
|
||||
premake.generate(prj, ".vcproj", vstudio.vc200x.generate_ng)
|
||||
premake.generate(prj, ".vcproj.user", vstudio.vc200x.generate_user_ng)
|
||||
end
|
||||
end,
|
||||
|
||||
@ -74,16 +74,16 @@
|
||||
},
|
||||
|
||||
onsolution = function(sln)
|
||||
premake.generate(sln, "%%.sln", vstudio.sln2005.generate_ng)
|
||||
premake.generate(sln, ".sln", vstudio.sln2005.generate_ng)
|
||||
end,
|
||||
|
||||
onproject = function(prj)
|
||||
if premake.isdotnetproject(prj) then
|
||||
premake.generate(prj, "%%.csproj", vstudio.cs2005.generate_ng)
|
||||
premake.generate(prj, "%%.csproj.user", vstudio.cs2005.generate_user_ng)
|
||||
premake.generate(prj, ".csproj", vstudio.cs2005.generate_ng)
|
||||
premake.generate(prj, ".csproj.user", vstudio.cs2005.generate_user_ng)
|
||||
else
|
||||
premake.generate(prj, "%%.vcproj", vstudio.vc200x.generate_ng)
|
||||
premake.generate(prj, "%%.vcproj.user", vstudio.vc200x.generate_user_ng)
|
||||
premake.generate(prj, ".vcproj", vstudio.vc200x.generate_ng)
|
||||
premake.generate(prj, ".vcproj.user", vstudio.vc200x.generate_user_ng)
|
||||
end
|
||||
end,
|
||||
|
||||
@ -115,17 +115,17 @@
|
||||
},
|
||||
|
||||
onsolution = function(sln)
|
||||
premake.generate(sln, "%%.sln", vstudio.sln2005.generate_ng)
|
||||
premake.generate(sln, ".sln", vstudio.sln2005.generate_ng)
|
||||
end,
|
||||
|
||||
onproject = function(prj)
|
||||
if premake.isdotnetproject(prj) then
|
||||
premake.generate(prj, "%%.csproj", vstudio.cs2005.generate_ng)
|
||||
premake.generate(prj, "%%.csproj.user", vstudio.cs2005.generate_user_ng)
|
||||
premake.generate(prj, ".csproj", vstudio.cs2005.generate_ng)
|
||||
premake.generate(prj, ".csproj.user", vstudio.cs2005.generate_user_ng)
|
||||
else
|
||||
premake.generate(prj, "%%.vcxproj", vstudio.vc2010.generate_ng)
|
||||
premake.generate(prj, "%%.vcxproj.user", vstudio.vc2010.generate_user_ng)
|
||||
premake.generate(prj, "%%.vcxproj.filters", vstudio.vc2010.generate_filters_ng)
|
||||
premake.generate(prj, ".vcxproj", vstudio.vc2010.generate_ng)
|
||||
premake.generate(prj, ".vcxproj.user", vstudio.vc2010.generate_user_ng)
|
||||
premake.generate(prj, ".vcxproj.filters", vstudio.vc2010.generate_filters_ng)
|
||||
end
|
||||
end,
|
||||
|
||||
@ -158,17 +158,17 @@
|
||||
},
|
||||
|
||||
onsolution = function(sln)
|
||||
premake.generate(sln, "%%.sln", vstudio.sln2005.generate_ng)
|
||||
premake.generate(sln, ".sln", vstudio.sln2005.generate_ng)
|
||||
end,
|
||||
|
||||
onproject = function(prj)
|
||||
if premake.isdotnetproject(prj) then
|
||||
premake.generate(prj, "%%.csproj", vstudio.cs2005.generate_ng)
|
||||
premake.generate(prj, "%%.csproj.user", vstudio.cs2005.generate_user_ng)
|
||||
premake.generate(prj, ".csproj", vstudio.cs2005.generate_ng)
|
||||
premake.generate(prj, ".csproj.user", vstudio.cs2005.generate_user_ng)
|
||||
else
|
||||
premake.generate(prj, "%%.vcxproj", vstudio.vc2010.generate_ng)
|
||||
premake.generate(prj, "%%.vcxproj.user", vstudio.vc2010.generate_user_ng)
|
||||
premake.generate(prj, "%%.vcxproj.filters", vstudio.vc2010.generate_filters_ng)
|
||||
premake.generate(prj, ".vcxproj", vstudio.vc2010.generate_ng)
|
||||
premake.generate(prj, ".vcxproj.user", vstudio.vc2010.generate_user_ng)
|
||||
premake.generate(prj, ".vcxproj.filters", vstudio.vc2010.generate_filters_ng)
|
||||
end
|
||||
end,
|
||||
|
||||
@ -246,7 +246,7 @@
|
||||
extension = iif(_ACTION > "vs2008", ".vcxproj", ".vcproj")
|
||||
end
|
||||
|
||||
return premake.project.getfilename(prj, "%%" .. extension)
|
||||
return project.getfilename(prj, extension)
|
||||
end
|
||||
|
||||
|
||||
@ -448,7 +448,7 @@
|
||||
end
|
||||
|
||||
function vstudio.cleanproject(prj)
|
||||
local fname = premake.project.getfilename(prj, "%%")
|
||||
local fname = project.getfilename(prj)
|
||||
|
||||
os.remove(fname .. ".vcproj")
|
||||
os.remove(fname .. ".vcproj.user")
|
||||
@ -524,16 +524,16 @@
|
||||
},
|
||||
|
||||
onsolution = function(sln)
|
||||
premake.generate(sln, "%%.sln", vstudio.sln2002.generate)
|
||||
premake.generate(sln, ".sln", vstudio.sln2002.generate)
|
||||
end,
|
||||
|
||||
onproject = function(prj)
|
||||
if premake.isdotnetproject(prj) then
|
||||
premake.generate(prj, "%%.csproj", vstudio.cs2002.generate)
|
||||
premake.generate(prj, "%%.csproj.user", vstudio.cs2002.generate_user)
|
||||
premake.generate(prj, ".csproj", vstudio.cs2002.generate)
|
||||
premake.generate(prj, ".csproj.user", vstudio.cs2002.generate_user)
|
||||
else
|
||||
premake.generate(prj, "%%.vcproj", vstudio.vc200x.generate)
|
||||
premake.generate(prj, "%%.vcproj.user", vstudio.vc200x.generate_user)
|
||||
premake.generate(prj, ".vcproj", vstudio.vc200x.generate)
|
||||
premake.generate(prj, ".vcproj.user", vstudio.vc200x.generate_user)
|
||||
end
|
||||
end,
|
||||
|
||||
@ -563,16 +563,16 @@
|
||||
},
|
||||
|
||||
onsolution = function(sln)
|
||||
premake.generate(sln, "%%.sln", vstudio.sln2003.generate)
|
||||
premake.generate(sln, ".sln", vstudio.sln2003.generate)
|
||||
end,
|
||||
|
||||
onproject = function(prj)
|
||||
if premake.isdotnetproject(prj) then
|
||||
premake.generate(prj, "%%.csproj", vstudio.cs2002.generate)
|
||||
premake.generate(prj, "%%.csproj.user", vstudio.cs2002.generate_user)
|
||||
premake.generate(prj, ".csproj", vstudio.cs2002.generate)
|
||||
premake.generate(prj, ".csproj.user", vstudio.cs2002.generate_user)
|
||||
else
|
||||
premake.generate(prj, "%%.vcproj", vstudio.vc200x.generate)
|
||||
premake.generate(prj, "%%.vcproj.user", vstudio.vc200x.generate_user)
|
||||
premake.generate(prj, ".vcproj", vstudio.vc200x.generate)
|
||||
premake.generate(prj, ".vcproj.user", vstudio.vc200x.generate_user)
|
||||
end
|
||||
end,
|
||||
|
||||
@ -602,16 +602,16 @@
|
||||
},
|
||||
|
||||
onsolution = function(sln)
|
||||
premake.generate(sln, "%%.sln", vstudio.sln2005.generate)
|
||||
premake.generate(sln, ".sln", vstudio.sln2005.generate)
|
||||
end,
|
||||
|
||||
onproject = function(prj)
|
||||
if premake.isdotnetproject(prj) then
|
||||
premake.generate(prj, "%%.csproj", vstudio.cs2005.generate)
|
||||
premake.generate(prj, "%%.csproj.user", vstudio.cs2005.generate_user)
|
||||
premake.generate(prj, ".csproj", vstudio.cs2005.generate)
|
||||
premake.generate(prj, ".csproj.user", vstudio.cs2005.generate_user)
|
||||
else
|
||||
premake.generate(prj, "%%.vcproj", vstudio.vc200x.generate)
|
||||
premake.generate(prj, "%%.vcproj.user", vstudio.vc200x.generate_user)
|
||||
premake.generate(prj, ".vcproj", vstudio.vc200x.generate)
|
||||
premake.generate(prj, ".vcproj.user", vstudio.vc200x.generate_user)
|
||||
end
|
||||
end,
|
||||
|
||||
@ -641,16 +641,16 @@
|
||||
},
|
||||
|
||||
onsolution = function(sln)
|
||||
premake.generate(sln, "%%.sln", vstudio.sln2005.generate)
|
||||
premake.generate(sln, ".sln", vstudio.sln2005.generate)
|
||||
end,
|
||||
|
||||
onproject = function(prj)
|
||||
if premake.isdotnetproject(prj) then
|
||||
premake.generate(prj, "%%.csproj", vstudio.cs2005.generate)
|
||||
premake.generate(prj, "%%.csproj.user", vstudio.cs2005.generate_user)
|
||||
premake.generate(prj, ".csproj", vstudio.cs2005.generate)
|
||||
premake.generate(prj, ".csproj.user", vstudio.cs2005.generate_user)
|
||||
else
|
||||
premake.generate(prj, "%%.vcproj", vstudio.vc200x.generate)
|
||||
premake.generate(prj, "%%.vcproj.user", vstudio.vc200x.generate_user)
|
||||
premake.generate(prj, ".vcproj", vstudio.vc200x.generate)
|
||||
premake.generate(prj, ".vcproj.user", vstudio.vc200x.generate_user)
|
||||
end
|
||||
end,
|
||||
|
||||
@ -681,17 +681,17 @@
|
||||
},
|
||||
|
||||
onsolution = function(sln)
|
||||
premake.generate(sln, "%%.sln", vstudio.sln2005.generate)
|
||||
premake.generate(sln, ".sln", vstudio.sln2005.generate)
|
||||
end,
|
||||
|
||||
onproject = function(prj)
|
||||
if premake.isdotnetproject(prj) then
|
||||
premake.generate(prj, "%%.csproj", vstudio.cs2005.generate)
|
||||
premake.generate(prj, "%%.csproj.user", vstudio.cs2005.generate_user)
|
||||
premake.generate(prj, ".csproj", vstudio.cs2005.generate)
|
||||
premake.generate(prj, ".csproj.user", vstudio.cs2005.generate_user)
|
||||
else
|
||||
premake.generate(prj, "%%.vcxproj", premake.vs2010_vcxproj)
|
||||
premake.generate(prj, "%%.vcxproj.user", premake.vs2010_vcxproj_user)
|
||||
premake.generate(prj, "%%.vcxproj.filters", vstudio.vc2010.generate_filters)
|
||||
premake.generate(prj, ".vcxproj", premake.vs2010_vcxproj)
|
||||
premake.generate(prj, ".vcxproj.user", premake.vs2010_vcxproj_user)
|
||||
premake.generate(prj, ".vcxproj.filters", vstudio.vc2010.generate_filters)
|
||||
end
|
||||
end,
|
||||
|
||||
|
@ -38,7 +38,7 @@
|
||||
end,
|
||||
|
||||
onproject = function(prj)
|
||||
premake.generate(prj, "%%.xcodeproj/project.pbxproj", premake.xcode.project)
|
||||
premake.generate(prj, ".xcodeproj/project.pbxproj", premake.xcode.project)
|
||||
end,
|
||||
|
||||
oncleanproject = function(prj)
|
||||
@ -84,11 +84,11 @@
|
||||
default_platform = "Universal",
|
||||
|
||||
onsolution = function(sln)
|
||||
premake.generate(sln, "%%.xcworkspace/contents.xcworkspacedata", premake.xcode4.workspace_generate)
|
||||
premake.generate(sln, ".xcworkspace/contents.xcworkspacedata", premake.xcode4.workspace_generate)
|
||||
end,
|
||||
|
||||
onproject = function(prj)
|
||||
premake.generate(prj, "%%.xcodeproj/project.pbxproj", premake.xcode.project)
|
||||
premake.generate(prj, ".xcodeproj/project.pbxproj", premake.xcode.project)
|
||||
end,
|
||||
|
||||
oncleanproject = function(prj)
|
||||
|
@ -503,6 +503,13 @@
|
||||
tokens = true,
|
||||
}
|
||||
|
||||
api.register {
|
||||
name = "filename",
|
||||
scope = "project",
|
||||
kind = "string",
|
||||
tokens = true,
|
||||
}
|
||||
|
||||
api.register {
|
||||
name = "files",
|
||||
scope = "config",
|
||||
@ -1210,7 +1217,7 @@
|
||||
|
||||
local function createproject(name, sln, isUsage)
|
||||
local prj = {}
|
||||
|
||||
|
||||
-- attach a type
|
||||
setmetatable(prj, {
|
||||
__type = "project",
|
||||
@ -1240,6 +1247,7 @@
|
||||
|
||||
prj.solution = sln
|
||||
prj.name = name
|
||||
prj.filename = name
|
||||
prj.basedir = os.getcwd()
|
||||
prj.script = _SCRIPT
|
||||
prj.uuid = os.uuid()
|
||||
@ -1330,7 +1338,9 @@
|
||||
|
||||
premake.CurrentContainer = premake.solution.get(name)
|
||||
if (not premake.CurrentContainer) then
|
||||
premake.CurrentContainer = premake.solution.new(name)
|
||||
local sln = premake.solution.new(name)
|
||||
sln.filename = name
|
||||
premake.CurrentContainer = sln
|
||||
end
|
||||
|
||||
-- add an empty, global configuration
|
||||
@ -1349,13 +1359,8 @@
|
||||
--
|
||||
|
||||
function external(name)
|
||||
-- define it like a regular project
|
||||
local prj = project(name)
|
||||
|
||||
-- then mark it as external
|
||||
prj.external = true;
|
||||
prj.externalname = prj.name
|
||||
|
||||
return prj
|
||||
end
|
||||
|
||||
|
@ -34,19 +34,18 @@
|
||||
--
|
||||
-- @param obj
|
||||
-- A solution or project object; will be based to the callback function.
|
||||
-- @param filename
|
||||
-- The output filename; see the docs for premake.project.getfilename()
|
||||
-- for the expected format.
|
||||
-- @param ext
|
||||
-- An optional extension for the generated file, with the leading dot.
|
||||
-- @param callback
|
||||
-- The function responsible for writing the file, should take a solution
|
||||
-- or project as a parameters.
|
||||
--
|
||||
|
||||
function premake.generate(obj, filename, callback)
|
||||
filename = premake.project.getfilename(obj, filename)
|
||||
printf("Generating %s...", filename)
|
||||
function premake.generate(obj, ext, callback)
|
||||
local fn = premake5.project.getfilename(obj, ext)
|
||||
printf("Generating %s...", path.getrelative(os.getcwd(), fn))
|
||||
|
||||
local f, err = io.open(filename, "wb")
|
||||
local f, err = io.open(fn, "wb")
|
||||
if (not f) then
|
||||
error(err, 0)
|
||||
end
|
||||
|
@ -267,7 +267,7 @@
|
||||
--
|
||||
|
||||
function premake.project.getfilename(prj, pattern)
|
||||
local fname = pattern:gsub("%%%%", prj.externalname or prj.name)
|
||||
local fname = pattern:gsub("%%%%", prj.filename or prj.name)
|
||||
fname = path.join(premake5.project.getlocation(prj), fname)
|
||||
return path.getrelative(os.getcwd(), fname)
|
||||
end
|
||||
|
@ -319,18 +319,34 @@
|
||||
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 solution's file system location.
|
||||
--
|
||||
-- @param sln
|
||||
-- The solution object to query.
|
||||
-- @param relativeto
|
||||
-- Optional; if supplied, the location will be made relative
|
||||
-- to this path.
|
||||
-- @return
|
||||
-- The path to the solutions's file system location.
|
||||
-- The path to the solution's file system location.
|
||||
--
|
||||
|
||||
function solution.getlocation(sln)
|
||||
return sln.location or sln.basedir
|
||||
end
|
||||
solution.getlocation = project.getlocation
|
||||
|
||||
|
||||
--
|
||||
|
@ -254,7 +254,7 @@
|
||||
|
||||
-- if this is an external project reference, I can't return
|
||||
-- any kind of path info, because I don't know the target name
|
||||
elseif not prj.externalname then
|
||||
elseif not prj.external then
|
||||
if part == "basename" then
|
||||
item = prjcfg.linktarget.basename
|
||||
else
|
||||
|
@ -300,6 +300,24 @@
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- 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.
|
||||
-- @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
|
||||
return fn
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Returns a unique object file name for a project source code file.
|
||||
--
|
||||
@ -357,7 +375,7 @@
|
||||
|
||||
|
||||
--
|
||||
-- Retrieve the project's file system location.
|
||||
-- Retrieve the project's file system location. Also works with solutions.
|
||||
--
|
||||
-- @param prj
|
||||
-- The project object to query.
|
||||
@ -369,7 +387,13 @@
|
||||
--
|
||||
|
||||
function project.getlocation(prj, relativeto)
|
||||
local location = prj.location or prj.solution.location or prj.basedir
|
||||
local location = prj.location
|
||||
if not location and prj.solution then
|
||||
location = prj.solution.location
|
||||
end
|
||||
if not location then
|
||||
location = prj.basedir
|
||||
end
|
||||
if relativeto then
|
||||
location = path.getrelative(relativeto, location)
|
||||
end
|
||||
|
@ -217,7 +217,7 @@
|
||||
for _, link in ipairs(links) do
|
||||
-- skip external project references, since I have no way
|
||||
-- to know the actual output target path
|
||||
if not link.project.externalname then
|
||||
if not link.project.external then
|
||||
if link.kind == premake.STATICLIB then
|
||||
-- Don't use "-l" flag when linking static libraries; instead use
|
||||
-- path/libname.a to avoid linking a shared library of the same
|
||||
|
@ -58,7 +58,8 @@ EndProject
|
||||
--
|
||||
|
||||
function suite.projectNamesAreEscaped()
|
||||
prj.name = 'My "x64" Project';
|
||||
prj.name = 'My "x64" Project'
|
||||
filename ('My "x64" Project')
|
||||
prepare()
|
||||
test.capture [[
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "My "x64" Project", "My "x64" Project.vcproj", "{AE61726D-187C-E440-BD07-2556188A6565}"
|
||||
|
@ -67,6 +67,7 @@
|
||||
dofile("test_project.lua")
|
||||
dofile("project/test_eachconfig.lua")
|
||||
dofile("project/test_filtering.lua")
|
||||
dofile("project/test_filename.lua")
|
||||
dofile("project/test_getconfig.lua")
|
||||
dofile("project/test_hasconfig.lua")
|
||||
dofile("project/test_vpaths.lua")
|
||||
|
89
tests/project/test_filename.lua
Normal file
89
tests/project/test_filename.lua
Normal file
@ -0,0 +1,89 @@
|
||||
--
|
||||
-- tests/project/test_filename.lua
|
||||
-- Verify generation of project (and solution) filenames.
|
||||
-- Copyright (c) 2008-2012 Jason Perkins and the Premake project
|
||||
--
|
||||
|
||||
T.project_filename = {}
|
||||
local suite = T.project_filename
|
||||
|
||||
local project = premake5.project
|
||||
|
||||
|
||||
--
|
||||
-- Setup
|
||||
--
|
||||
|
||||
local sln
|
||||
|
||||
function suite.setup()
|
||||
sln, prj = test.createsolution()
|
||||
end
|
||||
|
||||
local function prepare()
|
||||
prj = premake.solution.getproject_ng(sln, 1)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Should return name as an absolute path.
|
||||
--
|
||||
|
||||
function suite.isAbsolutePath()
|
||||
prepare()
|
||||
test.isequal(os.getcwd(), path.getdirectory(project.getfilename(prj)))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Should use the project name, if no filename was specified.
|
||||
--
|
||||
|
||||
function suite.isProjectName_onNoFilename()
|
||||
prepare()
|
||||
test.isequal("MyProject", path.getname(project.getfilename(prj)))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Should use filename, if set via API.
|
||||
--
|
||||
|
||||
function suite.doesUseFilename()
|
||||
filename "Howdy"
|
||||
prepare()
|
||||
test.isequal("Howdy", path.getname(project.getfilename(prj)))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Appends file extension, if supplied.
|
||||
--
|
||||
|
||||
function suite.doesUseExtension()
|
||||
prepare()
|
||||
test.isequal(".xc", path.getextension(project.getfilename(prj, ".xc")))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Should also work with solutions.
|
||||
--
|
||||
|
||||
function suite.worksWithSolution()
|
||||
prepare()
|
||||
test.isequal("MySolution", path.getname(project.getfilename(sln)))
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Value should not propagate down to projects.
|
||||
--
|
||||
|
||||
function suite.doesNotPropagate()
|
||||
solution ("MySolution")
|
||||
filename ("Howdy")
|
||||
prepare()
|
||||
test.isequal("MyProject", path.getname(project.getfilename(prj)))
|
||||
end
|
||||
|
@ -5,43 +5,32 @@
|
||||
--
|
||||
|
||||
|
||||
T.premake = { }
|
||||
T.premake = {}
|
||||
local suite = T.premake
|
||||
|
||||
|
||||
--
|
||||
-- premake.checktools() tests
|
||||
-- Setup
|
||||
--
|
||||
|
||||
function T.premake.checktools_SetsDefaultTools()
|
||||
_ACTION = "gmake"
|
||||
premake.checktools()
|
||||
test.isequal("gcc", _OPTIONS.cc)
|
||||
test.isequal("mono", _OPTIONS.dotnet)
|
||||
end
|
||||
|
||||
|
||||
function T.premake.checktools_Fails_OnToolMismatch()
|
||||
_ACTION = "gmake"
|
||||
_OPTIONS["cc"] = "xyz"
|
||||
ok, err = premake.checktools()
|
||||
test.isfalse( ok )
|
||||
test.isequal("the GNU Make action does not support /cc=xyz (yet)", err)
|
||||
local sln, prj
|
||||
function suite.setup()
|
||||
sln = test.createsolution()
|
||||
location "MyLocation"
|
||||
prj = premake.solution.getproject_ng(sln, 1)
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- generate() tests
|
||||
--
|
||||
|
||||
function T.premake.generate_OpensCorrectFile()
|
||||
prj = { name = "MyProject", location = "MyLocation" }
|
||||
premake.generate(prj, "%%.prj", function () end)
|
||||
test.openedfile("MyLocation/MyProject.prj")
|
||||
function suite.generate_OpensCorrectFile()
|
||||
premake.generate(prj, ".prj", function () end)
|
||||
test.openedfile(path.join(os.getcwd(), "MyLocation/MyProject.prj"))
|
||||
end
|
||||
|
||||
function T.premake.generate_ClosesFile()
|
||||
prj = { name = "MyProject", location = "MyLocation" }
|
||||
premake.generate(prj, "%%.prj", function () end)
|
||||
premake.generate(prj, ".prj", function () end)
|
||||
test.closedfile(true)
|
||||
end
|
||||
|
@ -34,24 +34,6 @@
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- getfilename() tests
|
||||
--
|
||||
|
||||
function T.project.getfilename_ReturnsRelativePath()
|
||||
local prj = { name = "project", location = "location" }
|
||||
local r = _project.getfilename(prj, path.join(os.getcwd(), "../filename"))
|
||||
test.isequal("../filename", r)
|
||||
end
|
||||
|
||||
function T.project.getfilename_PerformsSubstitutions()
|
||||
local prj = { name = "project", location = "location" }
|
||||
local r = _project.getfilename(prj, "%%.prj")
|
||||
test.isequal("location/project.prj", r)
|
||||
end
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- premake.getlinks() tests
|
||||
--
|
||||
|
Loading…
Reference in New Issue
Block a user