From f337abb776b8a29b0c2bea54f6eb63e0a16cafb3 Mon Sep 17 00:00:00 2001 From: aleksijuvani Date: Tue, 22 Nov 2016 13:39:10 +0200 Subject: [PATCH] Add tests for linkbuildoutputs API --- tests/actions/make/cpp/test_objects.lua | 68 +++++++++++++++++++- tests/actions/vstudio/vc2010/test_files.lua | 69 +++++++++++++++++++++ 2 files changed, 136 insertions(+), 1 deletion(-) diff --git a/tests/actions/make/cpp/test_objects.lua b/tests/actions/make/cpp/test_objects.lua index 145a0283..801c61ee 100644 --- a/tests/actions/make/cpp/test_objects.lua +++ b/tests/actions/make/cpp/test_objects.lua @@ -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. -- diff --git a/tests/actions/vstudio/vc2010/test_files.lua b/tests/actions/vstudio/vc2010/test_files.lua index 5e580c56..6775cbf8 100755 --- a/tests/actions/vstudio/vc2010/test_files.lua +++ b/tests/actions/vstudio/vc2010/test_files.lua @@ -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 [[ + + + Document + echo $(InputFile) + $(InputName).obj + echo $(InputFile) + $(InputName).obj + + + ]] + end + + function suite.linkBuildOutputs_onOff() + files { "hello.x" } + filter "files:**.x" + buildcommands { "echo $(InputFile)" } + buildoutputs { "$(InputName).obj" } + linkbuildoutputs "Off" + prepare() + test.capture [[ + + + Document + echo $(InputFile) + $(InputName).obj + false + echo $(InputFile) + $(InputName).obj + false + + + ]] + end + + function suite.linkBuildOutputs_onOn() + files { "hello.x" } + filter "files:**.x" + buildcommands { "echo $(InputFile)" } + buildoutputs { "$(InputName).obj" } + linkbuildoutputs "On" + prepare() + test.capture [[ + + + Document + echo $(InputFile) + $(InputName).obj + true + echo $(InputFile) + $(InputName).obj + true + + + ]] + end + + -- -- If two files at different folder levels have the same name, a different -- object file name should be used for each.