diff --git a/src/_premake_init.lua b/src/_premake_init.lua
index 44df506d..f89e35ef 100644
--- a/src/_premake_init.lua
+++ b/src/_premake_init.lua
@@ -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 {
diff --git a/src/actions/make/make_cpp.lua b/src/actions/make/make_cpp.lua
index b445d328..adb3da0b 100644
--- a/src/actions/make/make_cpp.lua
+++ b/src/actions/make/make_cpp.lua
@@ -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)
diff --git a/src/actions/vstudio/vs2010_vcxproj.lua b/src/actions/vstudio/vs2010_vcxproj.lua
index b9487691..5dc1c839 100644
--- a/src/actions/vstudio/vs2010_vcxproj.lua
+++ b/src/actions/vstudio/vs2010_vcxproj.lua
@@ -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('')
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
diff --git a/src/base/api.lua b/src/base/api.lua
index b07dc2a5..f4f251ce 100755
--- a/src/base/api.lua
+++ b/src/base/api.lua
@@ -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
diff --git a/src/host/path_isabsolute.c b/src/host/path_isabsolute.c
index a324b7f3..6995fbe9 100644
--- a/src/host/path_isabsolute.c
+++ b/src/host/path_isabsolute.c
@@ -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)
diff --git a/tests/actions/vstudio/vc2010/test_build_events.lua b/tests/actions/vstudio/vc2010/test_build_events.lua
index 1efed369..3662ef99 100644
--- a/tests/actions/vstudio/vc2010/test_build_events.lua
+++ b/tests/actions/vstudio/vc2010/test_build_events.lua
@@ -85,6 +85,17 @@
end
+--
+-- Multiple of the same command should be emit.
+--
+
+ function suite.onCommandTwice()
+ postbuildcommands { "command", "command" }
+ prepare()
+ test.capture ("\n\tcommand\r\ncommand\n\n")
+ end
+
+
--
-- Quotes should not be escaped, other special characters should.
diff --git a/tests/actions/vstudio/vc2010/test_link.lua b/tests/actions/vstudio/vc2010/test_link.lua
index 2da8d427..7955f84e 100644
--- a/tests/actions/vstudio/vc2010/test_link.lua
+++ b/tests/actions/vstudio/vc2010/test_link.lua
@@ -155,6 +155,20 @@
]]
end
+ function suite.additionalDependencies_onSystemLinksStatic()
+ kind "StaticLib"
+ links { "lua", "zlib" }
+ prepare()
+ test.capture [[
+
+ Windows
+
+
+ lua.lib;zlib.lib;%(AdditionalDependencies)
+
+ ]]
+ 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 [[
+
+ Windows
+
+
+ lua.obj;zlib.lib;%(AdditionalDependencies)
+
+ ]]
+ 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 [[
+
+ Windows
+
+
+ lua.5.3.lib;lua.5.4.lib;%(AdditionalDependencies)
+
+ ]]
+ end
+
--
-- Additional library directories should be specified, relative to the project.
diff --git a/tests/actions/vstudio/vc2010/test_nmake_props.lua b/tests/actions/vstudio/vc2010/test_nmake_props.lua
index b0b60b81..a88e3d81 100644
--- a/tests/actions/vstudio/vc2010/test_nmake_props.lua
+++ b/tests/actions/vstudio/vc2010/test_nmake_props.lua
@@ -114,3 +114,25 @@ command 2
]]
end
+
+ function suite.onDefines()
+ defines { "DEBUG", "_DEBUG" }
+ prepare()
+ test.capture [[
+
+ $(OutDir)MyProject
+ DEBUG;_DEBUG;$(NMakePreprocessorDefinitions)
+
+ ]]
+ end
+
+ function suite.onIncludeDirs()
+ includedirs { "include/lua", "include/zlib" }
+ prepare()
+ test.capture [[
+
+ $(OutDir)MyProject
+ include\lua;include\zlib
+
+ ]]
+ end
diff --git a/tests/base/.testDotFile b/tests/base/.testDotFile
new file mode 100644
index 00000000..b9928548
--- /dev/null
+++ b/tests/base/.testDotFile
@@ -0,0 +1 @@
+This is a test file for os.matchfiles tests.
diff --git a/tests/base/test_os.lua b/tests/base/test_os.lua
index 50e628f0..7b154746 100644
--- a/tests/base/test_os.lua
+++ b/tests/base/test_os.lua
@@ -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()
diff --git a/tests/oven/test_objdirs.lua b/tests/oven/test_objdirs.lua
index 51e60048..0fad6620 100644
--- a/tests/oven/test_objdirs.lua
+++ b/tests/oven/test_objdirs.lua
@@ -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