Merge pull request #365 from starkos/vs-target-machine-take-2

LGTM
This commit is contained in:
Tom van Dijck 2015-12-16 13:58:54 -08:00
commit d056c744a7
3 changed files with 106 additions and 0 deletions

View File

@ -406,6 +406,7 @@
m.treatLinkerWarningAsErrors,
m.ignoreDefaultLibraries,
m.largeAddressAware,
m.targetMachine,
m.additionalLinkOptions,
}
end
@ -430,6 +431,7 @@
if cfg.kind == p.STATICLIB then
return {
m.treatLinkerWarningAsErrors,
m.targetMachine,
m.additionalLinkOptions,
}
else
@ -1765,6 +1767,22 @@
end
function m.targetMachine(cfg)
-- If a static library project contains a resource file, VS will choke with
-- "LINK : warning LNK4068: /MACHINE not specified; defaulting to X86"
local targetmachine = {
x86 = "MachineX86",
x86_64 = "MachineX64",
}
if cfg.kind == p.STATICLIB then
local value = targetmachine[cfg.architecture]
if value ~= nil then
m.element("TargetMachine", nil, '%s', value)
end
end
end
function m.targetName(cfg)
m.element("TargetName", nil, "%s%s", cfg.buildtarget.prefix, cfg.buildtarget.basename)
end

View File

@ -129,6 +129,7 @@ return {
"actions/vstudio/vc2010/test_prop_sheet.lua",
"actions/vstudio/vc2010/test_resource_compile.lua",
"actions/vstudio/vc2010/test_rule_vars.lua",
"actions/vstudio/vc2010/test_target_machine.lua",
"actions/vstudio/vc2010/test_user_file.lua",
"actions/vstudio/vc2010/test_vectorextensions.lua",

View File

@ -0,0 +1,87 @@
---
-- tests/actions/vstudio/vc2010/test_target_machine.lua
-- Validate generation of the <TargetMachine> element
-- Copyright (c) 2015 Jason Perkins and the Premake project
---
local suite = test.declare("vstudio_vs2010_target_machine")
local vc2010 = premake.vstudio.vc2010
--
-- Setup
--
local wks, prj
function suite.setup()
wks, prj = test.createWorkspace()
end
local function prepare(platform)
local cfg = test.getconfig(prj, "Debug", platform)
vc2010.targetMachine(cfg)
end
--
-- Emit if a static lib project contains a resource file and an
-- architecture is specified.
--
function suite.emitsOnStaticLibWithX86()
kind "StaticLib"
architecture "x86"
prepare()
test.capture [[
<TargetMachine>MachineX86</TargetMachine>
]]
end
function suite.emitsOnStaticLibWithX86_64()
kind "StaticLib"
architecture "x86_64"
prepare()
test.capture [[
<TargetMachine>MachineX64</TargetMachine>
]]
end
--
-- Other combinations should NOT emit anything
--
function suite.isIgnoredOnConsoleAppNoArch()
kind "ConsoleApp"
prepare()
test.isemptycapture()
end
function suite.isIgnoredOnConsoleAppWithX86()
kind "ConsoleApp"
architecture "x86"
prepare()
test.isemptycapture()
end
function suite.isIgnoredOnStaticLibNoArch()
kind "StaticLib"
prepare()
test.isemptycapture()
end
function suite.isIgnoredOnSharedLibNoArch()
kind "SharedLib"
prepare()
test.isemptycapture()
end
function suite.isIgnoredOnSharedLibWithX86()
kind "SharedLib"
architecture "x86"
prepare()
test.isemptycapture()
end