Add tests for linkbuildoutputs API
This commit is contained in:
parent
b1825c9ccd
commit
f337abb776
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user