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",
tokens = true,
pathVars = true,
allowDuplicates = true,
}
api.register {
@ -861,6 +862,7 @@
kind = "list:string",
tokens = true,
pathVars = true,
allowDuplicates = true,
}
api.register {

View File

@ -410,7 +410,7 @@
function make.forceInclude(cfg, toolset)
local includes = toolset.getforceincludes(cfg)
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
_x(' FORCE_INCLUDE +=%s', make.list(includes))
end
@ -445,7 +445,7 @@
if cfg.architecture == premake.UNIVERSAL then
_p(' LINKCMD = libtool -o "$@" $(OBJECTS)')
else
_p(' LINKCMD = $(AR) -rcs "$@" $(OBJECTS)')
_p(' LINKCMD = $(AR) ' .. (toolset.arargs or '-rcs') ..' "$@" $(OBJECTS)')
end
elseif cfg.kind == premake.UTILITY then
-- Empty LINKCMD for Utility (only custom build rules)

View File

@ -237,6 +237,8 @@
m.nmakeCommandLine(cfg, cfg.buildcommands, "Build")
m.nmakeCommandLine(cfg, cfg.rebuildcommands, "ReBuild")
m.nmakeCommandLine(cfg, cfg.cleancommands, "Clean")
m.nmakePreprocessorDefinitions(cfg, cfg.defines, false, nil)
m.nmakeIncludeDirs(cfg, cfg.includedirs)
p.pop('</PropertyGroup>')
end
end
@ -431,6 +433,8 @@
m.elements.lib = function(cfg, explicit)
if cfg.kind == p.STATICLIB then
return {
m.additionalDependencies,
m.additionalLibraryDirectories,
m.treatLinkerWarningAsErrors,
m.targetMachine,
m.additionalLinkOptions,
@ -1669,7 +1673,25 @@
m.element("NMakeOutput", nil, "$(OutDir)%s", cfg.buildtarget.name)
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)
if fcfg.objname ~= fcfg.basename then

View File

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

View File

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

View File

@ -85,6 +85,17 @@
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.

View File

@ -155,6 +155,20 @@
]]
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
@ -171,6 +185,20 @@
]]
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
@ -187,6 +215,20 @@
]]
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.

View File

@ -114,3 +114,25 @@ command 2</NMakeBuildCommandLine>
</PropertyGroup>
]]
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
function suite.matchfiles_OnDottedFile()
local result = os.matchfiles("../.*")
test.istrue(table.contains(result, "../.gitignore"))
local result = os.matchfiles("base/.*")
test.istrue(table.contains(result, "base/.testDotFile"))
end
function suite.matchfiles_onComboSearch()

View File

@ -14,73 +14,70 @@
local wks, prj
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")
configurations { "Debug", "Release" }
prj = project "MyProject"
end
test.isequal("obj/Debug", result("Debug"))
test.isequal("obj/Release", result("Release"))
local function prepare(buildcfg, platform)
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
function suite.multipleProjects_noPlatforms()
wks = workspace("MyWorkspace")
configurations { "Debug", "Release" }
prj = project "MyProject"
project "MyProject2"
prepare("Debug")
test.createproject(wks)
test.isequal("obj/Debug/MyProject", result("Debug"))
test.isequal(path.getabsolute("obj/Debug/MyProject"), cfg.objdir)
end
function suite.singleProject_withPlatforms()
wks = workspace("MyWorkspace")
configurations { "Debug", "Release" }
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
function suite.singleProject_uniqueByTokens_noPlatforms()
wks = workspace("MyWorkspace")
configurations { "Debug", "Release" }
prj = project "MyProject"
objdir "obj/%{cfg.buildcfg}"
prepare("Debug")
test.isequal("obj/Debug", result("Debug"))
test.isequal(path.getabsolute("obj/Debug"), cfg.objdir)
end
function suite.singleProject_uniqueByTokens_withPlatforms()
wks = workspace("MyWorkspace")
configurations { "Debug", "Release" }
platforms { "x86", "x86_64" }
prj = project "MyProject"
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
function suite.allowOverlap_onPrefixCode()
wks = workspace("MyWorkspace")
configurations { "Debug", "Release" }
platforms { "x86", "x86_64" }
prj = project "MyProject"
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