Merge branch 'master' into bugfix/598

This commit is contained in:
Samuel Surtees 2016-11-04 03:17:04 +10:00 committed by GitHub
commit 1b9af9aa6c
11 changed files with 140 additions and 43 deletions

View File

@ -845,6 +845,7 @@
kind = "list:string", kind = "list:string",
tokens = true, tokens = true,
pathVars = true, pathVars = true,
allowDuplicates = true,
} }
api.register { api.register {
@ -861,6 +862,7 @@
kind = "list:string", kind = "list:string",
tokens = true, tokens = true,
pathVars = true, pathVars = true,
allowDuplicates = true,
} }
api.register { api.register {

View File

@ -410,7 +410,7 @@
function make.forceInclude(cfg, toolset) function make.forceInclude(cfg, toolset)
local includes = toolset.getforceincludes(cfg) local includes = toolset.getforceincludes(cfg)
if not cfg.flags.NoPCH and cfg.pchheader then if not cfg.flags.NoPCH and cfg.pchheader then
table.insert(includes, "-include $(OBJDIR)/$(notdir $(PCH))") table.insert(includes, 1, "-include $(OBJDIR)/$(notdir $(PCH))")
end end
_x(' FORCE_INCLUDE +=%s', make.list(includes)) _x(' FORCE_INCLUDE +=%s', make.list(includes))
end end
@ -445,7 +445,7 @@
if cfg.architecture == premake.UNIVERSAL then if cfg.architecture == premake.UNIVERSAL then
_p(' LINKCMD = libtool -o "$@" $(OBJECTS)') _p(' LINKCMD = libtool -o "$@" $(OBJECTS)')
else else
_p(' LINKCMD = $(AR) -rcs "$@" $(OBJECTS)') _p(' LINKCMD = $(AR) ' .. (toolset.arargs or '-rcs') ..' "$@" $(OBJECTS)')
end end
elseif cfg.kind == premake.UTILITY then elseif cfg.kind == premake.UTILITY then
-- Empty LINKCMD for Utility (only custom build rules) -- Empty LINKCMD for Utility (only custom build rules)

View File

@ -237,6 +237,8 @@
m.nmakeCommandLine(cfg, cfg.buildcommands, "Build") m.nmakeCommandLine(cfg, cfg.buildcommands, "Build")
m.nmakeCommandLine(cfg, cfg.rebuildcommands, "ReBuild") m.nmakeCommandLine(cfg, cfg.rebuildcommands, "ReBuild")
m.nmakeCommandLine(cfg, cfg.cleancommands, "Clean") m.nmakeCommandLine(cfg, cfg.cleancommands, "Clean")
m.nmakePreprocessorDefinitions(cfg, cfg.defines, false, nil)
m.nmakeIncludeDirs(cfg, cfg.includedirs)
p.pop('</PropertyGroup>') p.pop('</PropertyGroup>')
end end
end end
@ -431,6 +433,8 @@
m.elements.lib = function(cfg, explicit) m.elements.lib = function(cfg, explicit)
if cfg.kind == p.STATICLIB then if cfg.kind == p.STATICLIB then
return { return {
m.additionalDependencies,
m.additionalLibraryDirectories,
m.treatLinkerWarningAsErrors, m.treatLinkerWarningAsErrors,
m.targetMachine, m.targetMachine,
m.additionalLinkOptions, m.additionalLinkOptions,
@ -1669,7 +1673,25 @@
m.element("NMakeOutput", nil, "$(OutDir)%s", cfg.buildtarget.name) m.element("NMakeOutput", nil, "$(OutDir)%s", cfg.buildtarget.name)
end end
function m.nmakePreprocessorDefinitions(cfg, defines, escapeQuotes, condition)
if #defines > 0 then
defines = table.concat(defines, ";")
if escapeQuotes then
defines = defines:gsub('"', '\\"')
end
defines = p.esc(defines) .. ";$(NMakePreprocessorDefinitions)"
m.element('NMakePreprocessorDefinitions', condition, defines)
end
end
function m.nmakeIncludeDirs(cfg, includedirs)
if #includedirs > 0 then
local dirs = vstudio.path(cfg, includedirs)
if #dirs > 0 then
m.element("NMakeIncludeSearchPath", nil, "%s", table.concat(dirs, ";"))
end
end
end
function m.objectFileName(fcfg) function m.objectFileName(fcfg)
if fcfg.objname ~= fcfg.basename then if fcfg.objname ~= fcfg.basename then

View File

@ -903,8 +903,8 @@
-- contain any other kind of data. -- contain any other kind of data.
--- ---
local function storeListItem(current, item) local function storeListItem(current, item, allowDuplicates)
if current[item] then if not allowDuplicates and current[item] then
table.remove(current, table.indexof(current, item)) table.remove(current, table.indexof(current, item))
end end
table.insert(current, item) table.insert(current, item)
@ -937,13 +937,13 @@
if type(value) == "table" then if type(value) == "table" then
if #value > 0 then if #value > 0 then
for i = 1, #value do for i = 1, #value do
storeListItem(current, value[i]) storeListItem(current, value[i], field.allowDuplicates)
end end
elseif not table.isempty(value) then elseif not table.isempty(value) then
storeListItem(current, value) storeListItem(current, value, field.allowDuplicates)
end end
elseif value then elseif value then
storeListItem(current, value) storeListItem(current, value, field.allowDuplicates)
end end
return current return current
@ -953,7 +953,7 @@
local function mergeList(field, current, value, processor) local function mergeList(field, current, value, processor)
value = value or {} value = value or {}
for i = 1, #value do for i = 1, #value do
storeListItem(current, value[i]) storeListItem(current, value[i], field.allowDuplicates)
end end
return current return current
end end

View File

@ -26,7 +26,7 @@ int do_isabsolute(const char* path)
return 1; return 1;
if (isalpha(path[0]) && path[1] == ':') if (isalpha(path[0]) && path[1] == ':')
return 1; return 1;
if (path[0] == '"') if (path[0] == '"' || path[0] == '!')
return do_isabsolute(path + 1); return do_isabsolute(path + 1);
// $(foo) and %(foo) // $(foo) and %(foo)

View File

@ -85,6 +85,17 @@
end end
--
-- Multiple of the same command should be emit.
--
function suite.onCommandTwice()
postbuildcommands { "command", "command" }
prepare()
test.capture ("<PostBuildEvent>\n\t<Command>command\r\ncommand</Command>\n</PostBuildEvent>\n")
end
-- --
-- Quotes should not be escaped, other special characters should. -- Quotes should not be escaped, other special characters should.

View File

@ -155,6 +155,20 @@
]] ]]
end end
function suite.additionalDependencies_onSystemLinksStatic()
kind "StaticLib"
links { "lua", "zlib" }
prepare()
test.capture [[
<Link>
<SubSystem>Windows</SubSystem>
</Link>
<Lib>
<AdditionalDependencies>lua.lib;zlib.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Lib>
]]
end
-- --
-- Any system libraries specified in links() with valid extensions should -- Any system libraries specified in links() with valid extensions should
@ -171,6 +185,20 @@
]] ]]
end end
function suite.additionalDependencies_onSystemLinksExtensionsStatic()
kind "StaticLib"
links { "lua.obj", "zlib.lib" }
prepare()
test.capture [[
<Link>
<SubSystem>Windows</SubSystem>
</Link>
<Lib>
<AdditionalDependencies>lua.obj;zlib.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Lib>
]]
end
-- --
-- Any system libraries specified in links() with multiple dots should -- Any system libraries specified in links() with multiple dots should
@ -187,6 +215,20 @@
]] ]]
end end
function suite.additionalDependencies_onSystemLinksExtensionsMultipleDotsStatic()
kind "StaticLib"
links { "lua.5.3.lib", "lua.5.4" }
prepare()
test.capture [[
<Link>
<SubSystem>Windows</SubSystem>
</Link>
<Lib>
<AdditionalDependencies>lua.5.3.lib;lua.5.4.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Lib>
]]
end
-- --
-- Additional library directories should be specified, relative to the project. -- Additional library directories should be specified, relative to the project.

View File

@ -114,3 +114,25 @@ command 2</NMakeBuildCommandLine>
</PropertyGroup> </PropertyGroup>
]] ]]
end end
function suite.onDefines()
defines { "DEBUG", "_DEBUG" }
prepare()
test.capture [[
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<NMakeOutput>$(OutDir)MyProject</NMakeOutput>
<NMakePreprocessorDefinitions>DEBUG;_DEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
</PropertyGroup>
]]
end
function suite.onIncludeDirs()
includedirs { "include/lua", "include/zlib" }
prepare()
test.capture [[
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<NMakeOutput>$(OutDir)MyProject</NMakeOutput>
<NMakeIncludeSearchPath>include\lua;include\zlib</NMakeIncludeSearchPath>
</PropertyGroup>
]]
end

1
tests/base/.testDotFile Normal file
View File

@ -0,0 +1 @@
This is a test file for os.matchfiles tests.

View File

@ -105,8 +105,8 @@
end end
function suite.matchfiles_OnDottedFile() function suite.matchfiles_OnDottedFile()
local result = os.matchfiles("../.*") local result = os.matchfiles("base/.*")
test.istrue(table.contains(result, "../.gitignore")) test.istrue(table.contains(result, "base/.testDotFile"))
end end
function suite.matchfiles_onComboSearch() function suite.matchfiles_onComboSearch()

View File

@ -14,73 +14,70 @@
local wks, prj local wks, prj
function suite.setup() function suite.setup()
end
local function result(buildcfg, platform)
local cfg = test.getconfig(prj, buildcfg, platform)
return path.getrelative(os.getcwd(), cfg.objdir)
end
function suite.singleProject_noPlatforms()
wks = workspace("MyWorkspace") wks = workspace("MyWorkspace")
configurations { "Debug", "Release" } configurations { "Debug", "Release" }
prj = project "MyProject" prj = project "MyProject"
end
test.isequal("obj/Debug", result("Debug")) local function prepare(buildcfg, platform)
test.isequal("obj/Release", result("Release")) cfg = test.getconfig(prj, buildcfg, platform)
end
function suite.singleProject_noPlatforms()
prepare("Debug")
test.isequal(path.getabsolute("obj/Debug"), cfg.objdir)
prepare("Release")
test.isequal(path.getabsolute("obj/Release"), cfg.objdir)
end end
function suite.multipleProjects_noPlatforms() function suite.multipleProjects_noPlatforms()
wks = workspace("MyWorkspace")
configurations { "Debug", "Release" }
prj = project "MyProject"
project "MyProject2" project "MyProject2"
prepare("Debug")
test.createproject(wks) test.createproject(wks)
test.isequal("obj/Debug/MyProject", result("Debug")) test.isequal(path.getabsolute("obj/Debug/MyProject"), cfg.objdir)
end end
function suite.singleProject_withPlatforms() function suite.singleProject_withPlatforms()
wks = workspace("MyWorkspace")
configurations { "Debug", "Release" }
platforms { "x86", "x86_64" } platforms { "x86", "x86_64" }
prj = project "MyProject" prepare("Debug", "x86")
test.isequal("obj/x86/Debug", result("Debug", "x86")) test.isequal(path.getabsolute("obj/x86/Debug"), cfg.objdir)
end end
function suite.singleProject_uniqueByTokens_noPlatforms() function suite.singleProject_uniqueByTokens_noPlatforms()
wks = workspace("MyWorkspace")
configurations { "Debug", "Release" }
prj = project "MyProject"
objdir "obj/%{cfg.buildcfg}" objdir "obj/%{cfg.buildcfg}"
prepare("Debug")
test.isequal("obj/Debug", result("Debug")) test.isequal(path.getabsolute("obj/Debug"), cfg.objdir)
end end
function suite.singleProject_uniqueByTokens_withPlatforms() function suite.singleProject_uniqueByTokens_withPlatforms()
wks = workspace("MyWorkspace")
configurations { "Debug", "Release" }
platforms { "x86", "x86_64" } platforms { "x86", "x86_64" }
prj = project "MyProject"
objdir "obj/%{cfg.buildcfg}_%{cfg.platform}" objdir "obj/%{cfg.buildcfg}_%{cfg.platform}"
prepare("Debug", "x86")
test.isequal("obj/Debug_x86", result("Debug", "x86")) test.isequal(path.getabsolute("obj/Debug_x86"), cfg.objdir)
end end
function suite.allowOverlap_onPrefixCode() function suite.allowOverlap_onPrefixCode()
wks = workspace("MyWorkspace")
configurations { "Debug", "Release" }
platforms { "x86", "x86_64" } platforms { "x86", "x86_64" }
prj = project "MyProject"
objdir "!obj/%{cfg.buildcfg}" objdir "!obj/%{cfg.buildcfg}"
prepare("Debug", "x86")
test.isequal("obj/Debug", result("Debug", "x86")) test.isequal(path.getabsolute("obj/Debug"), cfg.objdir)
end
function suite.allowOverlap_onPrefixCode_withEnvironmentVariable()
platforms { "x86", "x86_64" }
objdir "!$(SolutionDir)/%{cfg.buildcfg}"
prepare("Debug", "x86")
test.isequal("$(SolutionDir)/Debug", cfg.objdir)
end end