XMake: Add options to disable tools/plugins and unit tests building
This commit is contained in:
parent
025deb9ae1
commit
22c99bfd1d
|
|
@ -63,7 +63,7 @@ jobs:
|
||||||
|
|
||||||
# Setup compilation mode and install project dependencies
|
# Setup compilation mode and install project dependencies
|
||||||
- name: Configure xmake and install dependencies
|
- name: Configure xmake and install dependencies
|
||||||
run: xmake config --arch=${{ matrix.arch }} --mode=${{ matrix.mode }} --verbose --yes
|
run: xmake config --shadernodes=y --arch=${{ matrix.arch }} --mode=${{ matrix.mode }} --verbose --yes
|
||||||
|
|
||||||
# Build the engine
|
# Build the engine
|
||||||
- name: Build Nazara
|
- name: Build Nazara
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ jobs:
|
||||||
|
|
||||||
# Setup compilation mode and install project dependencies
|
# Setup compilation mode and install project dependencies
|
||||||
- name: Configure xmake and install dependencies
|
- name: Configure xmake and install dependencies
|
||||||
run: xmake config --arch=${{ matrix.arch }} --mode=${{ matrix.mode }} --verbose --yes
|
run: xmake config --shadernodes=y --arch=${{ matrix.arch }} --mode=${{ matrix.mode }} --verbose --yes
|
||||||
|
|
||||||
# Build the engine
|
# Build the engine
|
||||||
- name: Build Nazara
|
- name: Build Nazara
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ jobs:
|
||||||
|
|
||||||
# Setup compilation mode and install project dependencies
|
# Setup compilation mode and install project dependencies
|
||||||
- name: Configure xmake and install dependencies
|
- name: Configure xmake and install dependencies
|
||||||
run: xmake.exe config --arch=${{ matrix.arch }} --mode=${{ matrix.mode }} --verbose --yes
|
run: xmake.exe config --shadernodes=y --arch=${{ matrix.arch }} --mode=${{ matrix.mode }} --verbose --yes
|
||||||
|
|
||||||
# Build the engine
|
# Build the engine
|
||||||
- name: Build Nazara
|
- name: Build Nazara
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,22 @@
|
||||||
add_requires("assimp")
|
option("assimp")
|
||||||
|
set_default(true)
|
||||||
|
set_showmenu(true)
|
||||||
|
set_description("Build Assimp plugin")
|
||||||
|
|
||||||
target("PluginAssimp")
|
option_end()
|
||||||
set_kind("shared")
|
|
||||||
set_group("Plugins")
|
|
||||||
|
|
||||||
add_deps("NazaraUtility")
|
if has_config("assimp") then
|
||||||
add_packages("assimp")
|
add_requires("assimp")
|
||||||
|
|
||||||
add_headerfiles("**.hpp")
|
target("PluginAssimp")
|
||||||
add_headerfiles("**.inl")
|
set_kind("shared")
|
||||||
add_includedirs(".")
|
set_group("Plugins")
|
||||||
add_files("**.cpp")
|
|
||||||
|
add_deps("NazaraUtility")
|
||||||
|
add_packages("assimp")
|
||||||
|
|
||||||
|
add_headerfiles("**.hpp")
|
||||||
|
add_headerfiles("**.inl")
|
||||||
|
add_includedirs(".")
|
||||||
|
add_files("**.cpp")
|
||||||
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,30 +1,39 @@
|
||||||
if is_mode("asan") then
|
option("tests")
|
||||||
add_defines("CATCH_CONFIG_NO_WINDOWS_SEH")
|
set_default(true)
|
||||||
add_defines("CATCH_CONFIG_NO_POSIX_SIGNALS")
|
set_showmenu(true)
|
||||||
|
set_description("Build unit tests")
|
||||||
|
|
||||||
|
option_end()
|
||||||
|
|
||||||
|
if has_config("tests") then
|
||||||
|
if is_mode("asan") then
|
||||||
|
add_defines("CATCH_CONFIG_NO_WINDOWS_SEH")
|
||||||
|
add_defines("CATCH_CONFIG_NO_POSIX_SIGNALS")
|
||||||
|
end
|
||||||
|
|
||||||
|
add_requires("catch2", "glslang", "spirv-tools")
|
||||||
|
|
||||||
|
-- Common config
|
||||||
|
set_group("Tests")
|
||||||
|
set_kind("binary")
|
||||||
|
|
||||||
|
add_deps("NazaraCore", "NazaraNetwork", "NazaraPhysics2D", "NazaraShader")
|
||||||
|
add_packages("catch2", "glslang", "spirv-tools")
|
||||||
|
add_headerfiles("Engine/**.hpp")
|
||||||
|
add_files("resources.cpp")
|
||||||
|
add_files("Engine/**.cpp")
|
||||||
|
add_includedirs(".")
|
||||||
|
|
||||||
|
--[[if xmake.version():ge("2.5.9") then
|
||||||
|
add_rules("c++.unity_build")
|
||||||
|
end]]
|
||||||
|
|
||||||
|
target("NazaraClientUnitTests")
|
||||||
|
add_deps("NazaraAudio")
|
||||||
|
add_files("main_client.cpp")
|
||||||
|
|
||||||
|
target("NazaraUnitTests")
|
||||||
|
add_files("main.cpp")
|
||||||
|
remove_headerfiles("Engine/Audio/**")
|
||||||
|
remove_files("Engine/Audio/**")
|
||||||
end
|
end
|
||||||
|
|
||||||
add_requires("catch2", "glslang", "spirv-tools")
|
|
||||||
|
|
||||||
-- Common config
|
|
||||||
set_group("Tests")
|
|
||||||
set_kind("binary")
|
|
||||||
|
|
||||||
add_deps("NazaraCore", "NazaraNetwork", "NazaraPhysics2D", "NazaraShader")
|
|
||||||
add_packages("catch2", "glslang", "spirv-tools")
|
|
||||||
add_headerfiles("Engine/**.hpp")
|
|
||||||
add_files("resources.cpp")
|
|
||||||
add_files("Engine/**.cpp")
|
|
||||||
add_includedirs(".")
|
|
||||||
|
|
||||||
--[[if xmake.version():ge("2.5.9") then
|
|
||||||
add_rules("c++.unity_build")
|
|
||||||
end]]
|
|
||||||
|
|
||||||
target("NazaraClientUnitTests")
|
|
||||||
add_deps("NazaraAudio")
|
|
||||||
add_files("main_client.cpp")
|
|
||||||
|
|
||||||
target("NazaraUnitTests")
|
|
||||||
add_files("main.cpp")
|
|
||||||
remove_headerfiles("Engine/Audio/**")
|
|
||||||
remove_files("Engine/Audio/**")
|
|
||||||
|
|
|
||||||
207
tools/xmake.lua
207
tools/xmake.lua
|
|
@ -1,108 +1,117 @@
|
||||||
|
option("shadernodes")
|
||||||
|
set_default(false)
|
||||||
|
set_showmenu(true)
|
||||||
|
set_description("Build ShaderNodes tool")
|
||||||
|
|
||||||
add_requires("nodeeditor", "qt5core", "qt5gui", "qt5widgets", {debug = is_mode("debug"), optional = true})
|
option_end()
|
||||||
|
|
||||||
rule("qt5.env")
|
if has_config("shadernodes") then
|
||||||
after_load(function (target)
|
add_requires("nodeeditor", "qt5core", "qt5gui", "qt5widgets", {debug = is_mode("debug")})
|
||||||
-- retrieve qtbase
|
|
||||||
local qtdir
|
|
||||||
|
|
||||||
local qtbase = target:pkg("qt5base")
|
rule("qt5.env")
|
||||||
if qtbase then
|
after_load(function (target)
|
||||||
qtdir = assert(qtbase:get("qtdir"))
|
-- retrieve qtbase
|
||||||
else
|
local qtdir
|
||||||
local qtcore = target:pkg("qt5core")
|
|
||||||
if not qtcore then
|
|
||||||
os.raise("target " .. target:name() .. " does not use qt5")
|
|
||||||
end
|
|
||||||
qtdir = assert(qtcore:get("qtdir"))
|
|
||||||
end
|
|
||||||
|
|
||||||
target:data_set("qt", qtdir)
|
local qtbase = target:pkg("qt5base")
|
||||||
end)
|
if qtbase then
|
||||||
|
qtdir = assert(qtbase:get("qtdir"))
|
||||||
|
else
|
||||||
rule("qt5.moc")
|
local qtcore = target:pkg("qt5core")
|
||||||
add_deps("qt5.env")
|
if not qtcore then
|
||||||
set_extensions(".h", ".hpp")
|
os.raise("target " .. target:name() .. " does not use qt5")
|
||||||
before_buildcmd_file(function (target, batchcmds, sourcefile, opt)
|
|
||||||
local qtbase = target:dep("qt5core")
|
|
||||||
local qt = assert(qtbase:fetch().qtbase, "qt not found!")
|
|
||||||
|
|
||||||
-- imports
|
|
||||||
import("core.tool.compiler")
|
|
||||||
|
|
||||||
-- get moc
|
|
||||||
local moc = path.join(qt.bindir, is_host("windows") and "moc.exe" or "moc")
|
|
||||||
if not os.isexec(moc) and qt.libexecdir then
|
|
||||||
moc = path.join(qt.libexecdir, is_host("windows") and "moc.exe" or "moc")
|
|
||||||
end
|
|
||||||
assert(moc and os.isexec(moc), "moc not found!")
|
|
||||||
|
|
||||||
-- get c++ source file for moc
|
|
||||||
--
|
|
||||||
-- add_files("mainwindow.h") -> moc_MainWindow.cpp
|
|
||||||
-- add_files("mainwindow.cpp", {rules = "qt.moc"}) -> mainwindow.moc, @see https://github.com/xmake-io/xmake/issues/750
|
|
||||||
--
|
|
||||||
local basename = path.basename(sourcefile)
|
|
||||||
local filename_moc = "moc_" .. basename .. ".cpp"
|
|
||||||
if sourcefile:endswith(".cpp") then
|
|
||||||
filename_moc = basename .. ".moc"
|
|
||||||
end
|
|
||||||
local sourcefile_moc = path.join(target:autogendir(), "rules", "qt", "moc", filename_moc)
|
|
||||||
|
|
||||||
-- add objectfile
|
|
||||||
local objectfile = target:objectfile(sourcefile_moc)
|
|
||||||
table.insert(target:objectfiles(), objectfile)
|
|
||||||
|
|
||||||
-- add commands
|
|
||||||
batchcmds:show_progress(opt.progress, "${color.build.object}compiling.qt.moc %s", sourcefile)
|
|
||||||
|
|
||||||
-- generate c++ source file for moc
|
|
||||||
local flags = {}
|
|
||||||
table.join2(flags, compiler.map_flags("cxx", "define", target:get("defines")))
|
|
||||||
table.join2(flags, compiler.map_flags("cxx", "includedir", target:get("includedirs")))
|
|
||||||
table.join2(flags, compiler.map_flags("cxx", "includedir", target:get("sysincludedirs"))) -- for now, moc process doesn't support MSVC external includes flags and will fail
|
|
||||||
table.join2(flags, compiler.map_flags("cxx", "frameworkdir", target:get("frameworkdirs")))
|
|
||||||
batchcmds:mkdir(path.directory(sourcefile_moc))
|
|
||||||
batchcmds:vrunv(moc, table.join(flags, sourcefile, "-o", sourcefile_moc))
|
|
||||||
|
|
||||||
-- we need compile this moc_xxx.cpp file if exists Q_PRIVATE_SLOT, @see https://github.com/xmake-io/xmake/issues/750
|
|
||||||
local mocdata = io.readfile(sourcefile)
|
|
||||||
if mocdata and mocdata:find("Q_PRIVATE_SLOT") or sourcefile_moc:endswith(".moc") then
|
|
||||||
-- add includedirs of sourcefile_moc
|
|
||||||
target:add("includedirs", path.directory(sourcefile_moc))
|
|
||||||
|
|
||||||
-- remove the object file of sourcefile_moc
|
|
||||||
local objectfiles = target:objectfiles()
|
|
||||||
for idx, objectfile in ipairs(objectfiles) do
|
|
||||||
if objectfile == target:objectfile(sourcefile_moc) then
|
|
||||||
table.remove(objectfiles, idx)
|
|
||||||
break
|
|
||||||
end
|
end
|
||||||
|
qtdir = assert(qtcore:get("qtdir"))
|
||||||
end
|
end
|
||||||
else
|
|
||||||
-- compile c++ source file for moc
|
target:data_set("qt", qtdir)
|
||||||
batchcmds:compile(sourcefile_moc, objectfile)
|
end)
|
||||||
|
|
||||||
|
|
||||||
|
rule("qt5.moc")
|
||||||
|
add_deps("qt5.env")
|
||||||
|
set_extensions(".h", ".hpp")
|
||||||
|
before_buildcmd_file(function (target, batchcmds, sourcefile, opt)
|
||||||
|
local qtbase = target:dep("qt5core")
|
||||||
|
local qt = assert(qtbase:fetch().qtbase, "qt not found!")
|
||||||
|
|
||||||
|
-- imports
|
||||||
|
import("core.tool.compiler")
|
||||||
|
|
||||||
|
-- get moc
|
||||||
|
local moc = path.join(qt.bindir, is_host("windows") and "moc.exe" or "moc")
|
||||||
|
if not os.isexec(moc) and qt.libexecdir then
|
||||||
|
moc = path.join(qt.libexecdir, is_host("windows") and "moc.exe" or "moc")
|
||||||
|
end
|
||||||
|
assert(moc and os.isexec(moc), "moc not found!")
|
||||||
|
|
||||||
|
-- get c++ source file for moc
|
||||||
|
--
|
||||||
|
-- add_files("mainwindow.h") -> moc_MainWindow.cpp
|
||||||
|
-- add_files("mainwindow.cpp", {rules = "qt.moc"}) -> mainwindow.moc, @see https://github.com/xmake-io/xmake/issues/750
|
||||||
|
--
|
||||||
|
local basename = path.basename(sourcefile)
|
||||||
|
local filename_moc = "moc_" .. basename .. ".cpp"
|
||||||
|
if sourcefile:endswith(".cpp") then
|
||||||
|
filename_moc = basename .. ".moc"
|
||||||
|
end
|
||||||
|
local sourcefile_moc = path.join(target:autogendir(), "rules", "qt", "moc", filename_moc)
|
||||||
|
|
||||||
|
-- add objectfile
|
||||||
|
local objectfile = target:objectfile(sourcefile_moc)
|
||||||
|
table.insert(target:objectfiles(), objectfile)
|
||||||
|
|
||||||
|
-- add commands
|
||||||
|
batchcmds:show_progress(opt.progress, "${color.build.object}compiling.qt.moc %s", sourcefile)
|
||||||
|
|
||||||
|
-- generate c++ source file for moc
|
||||||
|
local flags = {}
|
||||||
|
table.join2(flags, compiler.map_flags("cxx", "define", target:get("defines")))
|
||||||
|
table.join2(flags, compiler.map_flags("cxx", "includedir", target:get("includedirs")))
|
||||||
|
table.join2(flags, compiler.map_flags("cxx", "includedir", target:get("sysincludedirs"))) -- for now, moc process doesn't support MSVC external includes flags and will fail
|
||||||
|
table.join2(flags, compiler.map_flags("cxx", "frameworkdir", target:get("frameworkdirs")))
|
||||||
|
batchcmds:mkdir(path.directory(sourcefile_moc))
|
||||||
|
batchcmds:vrunv(moc, table.join(flags, sourcefile, "-o", sourcefile_moc))
|
||||||
|
|
||||||
|
-- we need compile this moc_xxx.cpp file if exists Q_PRIVATE_SLOT, @see https://github.com/xmake-io/xmake/issues/750
|
||||||
|
local mocdata = io.readfile(sourcefile)
|
||||||
|
if mocdata and mocdata:find("Q_PRIVATE_SLOT") or sourcefile_moc:endswith(".moc") then
|
||||||
|
-- add includedirs of sourcefile_moc
|
||||||
|
target:add("includedirs", path.directory(sourcefile_moc))
|
||||||
|
|
||||||
|
-- remove the object file of sourcefile_moc
|
||||||
|
local objectfiles = target:objectfiles()
|
||||||
|
for idx, objectfile in ipairs(objectfiles) do
|
||||||
|
if objectfile == target:objectfile(sourcefile_moc) then
|
||||||
|
table.remove(objectfiles, idx)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
-- compile c++ source file for moc
|
||||||
|
batchcmds:compile(sourcefile_moc, objectfile)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- add deps
|
||||||
|
batchcmds:add_depfiles(sourcefile)
|
||||||
|
batchcmds:set_depmtime(os.mtime(objectfile))
|
||||||
|
batchcmds:set_depcache(target:dependfile(objectfile))
|
||||||
|
end)
|
||||||
|
|
||||||
|
target("NazaraShaderNodes")
|
||||||
|
set_group("Tools")
|
||||||
|
set_kind("binary")
|
||||||
|
add_rules("qt5.moc")
|
||||||
|
|
||||||
|
add_deps("NazaraShader")
|
||||||
|
add_packages("nodeeditor")
|
||||||
|
add_packages("qt5core", "qt5gui", "qt5widgets")
|
||||||
|
if not is_plat("windows") then
|
||||||
|
add_cxflags("-fPIC")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- add deps
|
add_includedirs("../src")
|
||||||
batchcmds:add_depfiles(sourcefile)
|
add_headerfiles("../src/ShaderNode/**.hpp", "../src/ShaderNode/**.inl")
|
||||||
batchcmds:set_depmtime(os.mtime(objectfile))
|
add_files("../src/ShaderNode/**.cpp")
|
||||||
batchcmds:set_depcache(target:dependfile(objectfile))
|
|
||||||
end)
|
|
||||||
|
|
||||||
target("NazaraShaderNodes")
|
end
|
||||||
set_group("Tools")
|
|
||||||
set_kind("binary")
|
|
||||||
add_rules("qt5.moc")
|
|
||||||
|
|
||||||
add_deps("NazaraShader")
|
|
||||||
add_packages("nodeeditor")
|
|
||||||
add_packages("qt5core", "qt5gui", "qt5widgets")
|
|
||||||
if not is_plat("windows") then
|
|
||||||
add_cxflags("-fPIC")
|
|
||||||
end
|
|
||||||
|
|
||||||
add_includedirs("../src")
|
|
||||||
add_headerfiles("../src/ShaderNode/**.hpp", "../src/ShaderNode/**.inl")
|
|
||||||
add_files("../src/ShaderNode/**.cpp")
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue