set the platform in vs10 static libs

This commit is contained in:
Unknown 2011-05-01 01:04:27 +01:00
parent 33eff629c4
commit 5ec9f16415
2 changed files with 45 additions and 11 deletions

View File

@ -435,24 +435,25 @@
table.concat(premake.esc(cfg.linkoptions), " ")) table.concat(premake.esc(cfg.linkoptions), " "))
end end
end end
local function link_target_machine(index,cfg)
local platforms = {x32 = 'MachineX86',Native = 'MachineX86', x64 = 'MachineX64'}
if platforms[cfg.platform] then
_p(index,'<TargetMachine>%s</TargetMachine>', platforms[cfg.platform])
end
end
local function item_def_lib(cfg) local function item_def_lib(cfg)
if cfg.kind == 'StaticLib' then if cfg.kind == 'StaticLib' then
_p(1,'<Lib>') _p(1,'<Lib>')
_p(2,'<OutputFile>$(OutDir)%s</OutputFile>',cfg.buildtarget.name) _p(2,'<OutputFile>$(OutDir)%s</OutputFile>',cfg.buildtarget.name)
additional_options(2,cfg) additional_options(2,cfg)
link_target_machine(2,cfg)
_p(1,'</Lib>') _p(1,'</Lib>')
end end
end end
local function link_target_machine(cfg)
local target
if cfg.platform == nil or cfg.platform == "x32" then target ="MachineX86"
elseif cfg.platform == "x64" then target ="MachineX64"
end
_p(3,'<TargetMachine>%s</TargetMachine>', target)
end
local function import_lib(cfg) local function import_lib(cfg)
--Prevent the generation of an import library for a Windows DLL. --Prevent the generation of an import library for a Windows DLL.
@ -499,9 +500,7 @@
end end
import_lib(cfg) import_lib(cfg)
link_target_machine(3,cfg)
_p(3,'<TargetMachine>%s</TargetMachine>', iif(cfg.platform == "x64", "MachineX64", "MachineX86"))
additional_options(3,cfg) additional_options(3,cfg)
else else
common_link_section(cfg) common_link_section(cfg)

View File

@ -180,4 +180,39 @@
test.string_contains(get_buffer(), test.string_contains(get_buffer(),
'<AdditionalOptions>.* %%%(AdditionalOptions%)</AdditionalOptions>.*</Link>') '<AdditionalOptions>.* %%%(AdditionalOptions%)</AdditionalOptions>.*</Link>')
end end
function vs10_project_kinds.staticLibX64_TargetMachineSetInLib()
kind "StaticLib"
platforms{'x64'}
local buffer = get_buffer()
test.string_contains(buffer,'<Lib>.*<TargetMachine>.*</TargetMachine>.*</Lib>')
end
function vs10_project_kinds.staticLibX64_TargetMachineInLibSetToMachineX64()
kind "StaticLib"
platforms{'x64'}
local buffer = get_buffer()
test.string_contains(buffer,'<Lib>.*<TargetMachine>MachineX64</TargetMachine>.*</Lib>')
end
function vs10_project_kinds.staticLibX32_TargetMachineSetInLib()
kind "StaticLib"
platforms{'x32'}
local buffer = get_buffer()
test.string_contains(buffer,'<Lib>.*<TargetMachine>.*</TargetMachine>.*</Lib>')
end
function vs10_project_kinds.staticLibX32_TargetMachineInLibSetToMachineX86()
kind "StaticLib"
platforms{'x32'}
local buffer = get_buffer()
test.string_contains(buffer,'<Lib>.*<TargetMachine>MachineX86</TargetMachine>.*</Lib>')
end
function vs10_project_kinds.staticLibNative_TargetMachineInLibSetToMachineX86()
kind "StaticLib"
platforms{'Native'}
local buffer = get_buffer()
test.string_contains(buffer,'<Lib>.*<TargetMachine>MachineX86</TargetMachine>.*</Lib>')
end