mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-16 05:13:58 -07:00
Generate sources in workspace
Modify our cxxtest module so that it generates sources in the configured build directory instead of the source tree. This simplifies cleaning build output and .gitignore. Make test_root.cpp a build target so it doesn't have to be generated on each run. This means no more building and linking into test target unless needed either. Unfortunately there is no source for test_root.cpp and an update to cxxtest might require a manual make clean. Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
This commit is contained in:
parent
4e98704b71
commit
8d993b9250
4 changed files with 24 additions and 19 deletions
5
.gitignore
vendored
5
.gitignore
vendored
|
|
@ -57,11 +57,6 @@ __pycache__/
|
|||
*.lo
|
||||
*.la
|
||||
|
||||
# Test .cpp files (generated during the build)
|
||||
test_*.cpp
|
||||
stub_*.cpp
|
||||
!test_setup.cpp
|
||||
|
||||
# Translation files
|
||||
binaries/data/mods/public/gui/credits/texts/translators.json
|
||||
*.po
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
local m = {}
|
||||
m._VERSION = "1.0.1-dev"
|
||||
m._VERSION = "1.1.0-dev"
|
||||
|
||||
m.exepath = nil
|
||||
m.rootfile = nil
|
||||
m.runner = "ErrorPrinter"
|
||||
m.options = ""
|
||||
m.rootoptions = ""
|
||||
|
|
@ -19,9 +18,8 @@ end
|
|||
-- Pass all the necessary options to cxxtest (see http://cxxtest.com/guide.html)
|
||||
-- for a reference of available options, that should eventually be implemented in
|
||||
-- this module.
|
||||
function m.init(source_root, have_std, have_eh, runner, includes, root_includes)
|
||||
function m.init(have_std, have_eh, runner, includes, root_includes)
|
||||
|
||||
m.rootfile = source_root.."test_root.cpp"
|
||||
m.runner = runner
|
||||
|
||||
if have_std then
|
||||
|
|
@ -47,11 +45,17 @@ function m.init(source_root, have_std, have_eh, runner, includes, root_includes)
|
|||
project "cxxtestroot"
|
||||
kind "Makefile"
|
||||
|
||||
targetdir "%{wks.location}/generated"
|
||||
targetname "test_root.cpp"
|
||||
|
||||
-- Note: this command is not silent and clutters the output
|
||||
-- Reported upstream: https://github.com/premake/premake-core/issues/954
|
||||
buildmessage 'Generating test root file'
|
||||
buildcommands { m.exepath.." --root "..m.rootoptions.." --runner="..m.runner.." -o "..path.getabsolute(m.rootfile) }
|
||||
cleancommands { "rm " .. path.getabsolute(m.rootfile) }
|
||||
buildcommands {
|
||||
"{MKDIR} %{wks.location}/generated",
|
||||
m.exepath.." --root "..m.rootoptions.." --runner="..m.runner.." -o %{wks.location}/generated/test_root.cpp"
|
||||
}
|
||||
cleancommands { "{DELETE} %{wks.location}/generated/test_root.cpp" }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -64,7 +68,10 @@ function m.configure_project(hdrfiles)
|
|||
dependson { "cxxtestroot" }
|
||||
else
|
||||
prebuildmessage 'Generating test root file'
|
||||
prebuildcommands { m.exepath.." --root "..m.rootoptions.." --runner="..m.runner.." -o "..path.getabsolute(m.rootfile) }
|
||||
prebuildcommands {
|
||||
"{MKDIR} %{wks.location}/generated",
|
||||
m.exepath.." --root "..m.rootoptions.." --runner="..m.runner.." -o %{wks.location}/generated/test_root.cpp"
|
||||
}
|
||||
end
|
||||
|
||||
-- Add headers
|
||||
|
|
@ -76,15 +83,18 @@ function m.configure_project(hdrfiles)
|
|||
-- This doesn't work with xcode, see https://github.com/premake/premake-core/issues/940
|
||||
filter { "files:**.h", "files:not **precompiled.h" }
|
||||
buildmessage 'Generating %{file.basename}.cpp'
|
||||
buildcommands { m.exepath.." --part "..m.options.." -o %{file.directory}/%{file.basename}.cpp %{file.relpath}" }
|
||||
buildoutputs { "%{file.directory}/%{file.basename}.cpp" }
|
||||
buildcommands {
|
||||
"{MKDIR} %{wks.location}/generated",
|
||||
m.exepath.." --part "..m.options.." -o %{wks.location}/generated/%{file.basename}.cpp %{file.relpath}"
|
||||
}
|
||||
buildoutputs { "%{wks.location}/generated/%{file.basename}.cpp" }
|
||||
filter {}
|
||||
|
||||
-- Add source files
|
||||
files { m.rootfile }
|
||||
files { "%{wks.location}/generated/test_root.cpp" }
|
||||
if not (_ACTION == "gmake2") then
|
||||
for _,hdrfile in ipairs(hdrfiles) do
|
||||
local srcfile = string.sub(hdrfile, 1, -3) .. ".cpp"
|
||||
local srcfile = "%{wks.location}/generated/".. path.getbasename(hdrfile) .. ".cpp"
|
||||
files { srcfile }
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1434,7 +1434,7 @@ function setup_tests()
|
|||
table.insert(test_root_include_files, "lib/external_libraries/libsdl.h")
|
||||
end
|
||||
|
||||
cxxtest.init(source_root, true, true, runner, include_files, test_root_include_files)
|
||||
cxxtest.init(true, true, runner, include_files, test_root_include_files)
|
||||
|
||||
local target_type = get_main_project_target_type()
|
||||
project_create("test", target_type)
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@
|
|||
# This script remains for backwards compatibility, but consists of a single
|
||||
# git command.
|
||||
|
||||
cd "$(dirname "$0")/../../" || exit 1
|
||||
git clean -fx build source
|
||||
cd "$(dirname "$0")" || exit 1
|
||||
git clean -fx .
|
||||
|
||||
echo "WARNING: This script has been split with libraries/clean-source-libs.sh"
|
||||
echo "If you want to fix a problem with bundled libs, it's the other script"
|
||||
|
|
|
|||
Loading…
Reference in a new issue