Merge pull request #628 from aleksijuvani/no-link-objects-flag
Add NoLinkObjects flag
This commit is contained in:
commit
5c1d86ab78
@ -701,6 +701,12 @@
|
||||
tokens = true,
|
||||
}
|
||||
|
||||
api.register {
|
||||
name = "linkbuildoutputs",
|
||||
scope = "config",
|
||||
kind = "boolean"
|
||||
}
|
||||
|
||||
api.register {
|
||||
name = "linkoptions",
|
||||
scope = "config",
|
||||
|
@ -257,10 +257,8 @@
|
||||
for cfg in project.eachconfig(prj) do
|
||||
local filecfg = incfg[cfg]
|
||||
if filecfg then
|
||||
-- if the custom build outputs an object file, add it to
|
||||
-- the link step automatically to match Visual Studio
|
||||
local output = project.getrelative(prj, filecfg.buildoutputs[1])
|
||||
if path.isobjectfile(output) then
|
||||
if path.isobjectfile(output) and (filecfg.linkbuildoutputs == true or filecfg.linkbuildoutputs == nil) then
|
||||
table.insert(configs[cfg].objects, output)
|
||||
else
|
||||
table.insert(configs[cfg].customfiles, output)
|
||||
|
@ -719,6 +719,7 @@
|
||||
m.excludedFromBuild,
|
||||
m.buildCommands,
|
||||
m.buildOutputs,
|
||||
m.linkObjects,
|
||||
m.buildMessage,
|
||||
m.buildAdditionalInputs
|
||||
}
|
||||
@ -1104,6 +1105,13 @@
|
||||
end
|
||||
|
||||
|
||||
function m.linkObjects(fcfg, condition)
|
||||
if fcfg.linkbuildoutputs ~= nil then
|
||||
m.element("LinkObjects", condition, tostring(fcfg.linkbuildoutputs))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function m.characterSet(cfg)
|
||||
if not vstudio.isMakefile(cfg) then
|
||||
m.element("CharacterSet", nil, iif(cfg.characterset == p.MBCS, "MultiByte", "Unicode"))
|
||||
|
@ -110,7 +110,7 @@ OBJECTS := \
|
||||
-- link automatically to match the behavior of Visual Studio
|
||||
--
|
||||
|
||||
function suite.customBuildRule()
|
||||
function suite.linkBuildOutputs_onNotSpecified()
|
||||
files { "hello.x" }
|
||||
filter "files:**.x"
|
||||
buildmessage "Compiling %{file.name}"
|
||||
@ -137,6 +137,72 @@ endif
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Also include it in the link step if we explicitly specified so with
|
||||
-- linkbuildoutputs.
|
||||
--
|
||||
|
||||
function suite.linkBuildOutputs_onOn()
|
||||
files { "hello.x" }
|
||||
filter "files:**.x"
|
||||
buildmessage "Compiling %{file.name}"
|
||||
buildcommands {
|
||||
'cxc -c "%{file.path}" -o "%{cfg.objdir}/%{file.basename}.xo"',
|
||||
'c2o -c "%{cfg.objdir}/%{file.basename}.xo" -o "%{cfg.objdir}/%{file.basename}.obj"'
|
||||
}
|
||||
buildoutputs { "%{cfg.objdir}/%{file.basename}.obj" }
|
||||
linkbuildoutputs "On"
|
||||
prepare()
|
||||
test.capture [[
|
||||
OBJECTS := \
|
||||
|
||||
RESOURCES := \
|
||||
|
||||
CUSTOMFILES := \
|
||||
|
||||
ifeq ($(config),debug)
|
||||
OBJECTS += \
|
||||
obj/Debug/hello.obj \
|
||||
|
||||
endif
|
||||
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- If linkbuildoutputs says that we shouldn't include it in the link however,
|
||||
-- don't do it.
|
||||
--
|
||||
|
||||
function suite.linkBuildOutputs_onOff()
|
||||
files { "hello.x" }
|
||||
filter "files:**.x"
|
||||
buildmessage "Compiling %{file.name}"
|
||||
buildcommands {
|
||||
'cxc -c "%{file.path}" -o "%{cfg.objdir}/%{file.basename}.xo"',
|
||||
'c2o -c "%{cfg.objdir}/%{file.basename}.xo" -o "%{cfg.objdir}/%{file.basename}.obj"'
|
||||
}
|
||||
buildoutputs { "%{cfg.objdir}/%{file.basename}.obj" }
|
||||
linkbuildoutputs "Off"
|
||||
prepare()
|
||||
test.capture [[
|
||||
OBJECTS := \
|
||||
|
||||
RESOURCES := \
|
||||
|
||||
CUSTOMFILES := \
|
||||
|
||||
ifeq ($(config),debug)
|
||||
CUSTOMFILES += \
|
||||
obj/Debug/hello.obj \
|
||||
|
||||
endif
|
||||
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- If a file is excluded from a configuration, it should not be listed.
|
||||
--
|
||||
|
@ -333,6 +333,75 @@
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- If a custom rule outputs an object file, it's automatically linked, unless
|
||||
-- we explicitly specify that it isn't with linkbuildoutputs.
|
||||
--
|
||||
|
||||
function suite.linkBuildOutputs_onNotSpecified()
|
||||
files { "hello.x" }
|
||||
filter "files:**.x"
|
||||
buildcommands { "echo $(InputFile)" }
|
||||
buildoutputs { "$(InputName).obj" }
|
||||
prepare()
|
||||
test.capture [[
|
||||
<ItemGroup>
|
||||
<CustomBuild Include="hello.x">
|
||||
<FileType>Document</FileType>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">echo $(InputFile)</Command>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(InputName).obj</Outputs>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">echo $(InputFile)</Command>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(InputName).obj</Outputs>
|
||||
</CustomBuild>
|
||||
</ItemGroup>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.linkBuildOutputs_onOff()
|
||||
files { "hello.x" }
|
||||
filter "files:**.x"
|
||||
buildcommands { "echo $(InputFile)" }
|
||||
buildoutputs { "$(InputName).obj" }
|
||||
linkbuildoutputs "Off"
|
||||
prepare()
|
||||
test.capture [[
|
||||
<ItemGroup>
|
||||
<CustomBuild Include="hello.x">
|
||||
<FileType>Document</FileType>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">echo $(InputFile)</Command>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(InputName).obj</Outputs>
|
||||
<LinkObjects Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkObjects>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">echo $(InputFile)</Command>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(InputName).obj</Outputs>
|
||||
<LinkObjects Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkObjects>
|
||||
</CustomBuild>
|
||||
</ItemGroup>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.linkBuildOutputs_onOn()
|
||||
files { "hello.x" }
|
||||
filter "files:**.x"
|
||||
buildcommands { "echo $(InputFile)" }
|
||||
buildoutputs { "$(InputName).obj" }
|
||||
linkbuildoutputs "On"
|
||||
prepare()
|
||||
test.capture [[
|
||||
<ItemGroup>
|
||||
<CustomBuild Include="hello.x">
|
||||
<FileType>Document</FileType>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">echo $(InputFile)</Command>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(InputName).obj</Outputs>
|
||||
<LinkObjects Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkObjects>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">echo $(InputFile)</Command>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(InputName).obj</Outputs>
|
||||
<LinkObjects Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</LinkObjects>
|
||||
</CustomBuild>
|
||||
</ItemGroup>
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- If two files at different folder levels have the same name, a different
|
||||
-- object file name should be used for each.
|
||||
|
Reference in New Issue
Block a user