diff --git a/.github/workflows/linux-build.yml b/.github/workflows/linux-build.yml index 2b06f9201..29268941d 100644 --- a/.github/workflows/linux-build.yml +++ b/.github/workflows/linux-build.yml @@ -63,7 +63,7 @@ jobs: # Setup compilation mode and install project 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 - name: Build Nazara diff --git a/.github/workflows/msys2-build.yml b/.github/workflows/msys2-build.yml index b736a2f79..e5d44aac8 100644 --- a/.github/workflows/msys2-build.yml +++ b/.github/workflows/msys2-build.yml @@ -72,7 +72,7 @@ jobs: # Setup compilation mode and install project 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 - name: Build Nazara diff --git a/.github/workflows/windows-build.yml b/.github/workflows/windows-build.yml index 6e51fbf01..bb0051c4d 100644 --- a/.github/workflows/windows-build.yml +++ b/.github/workflows/windows-build.yml @@ -55,7 +55,7 @@ jobs: # Setup compilation mode and install project 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 - name: Build Nazara diff --git a/plugins/Assimp/xmake.lua b/plugins/Assimp/xmake.lua index c2a7cc1b6..08e1e7a7f 100644 --- a/plugins/Assimp/xmake.lua +++ b/plugins/Assimp/xmake.lua @@ -1,13 +1,22 @@ -add_requires("assimp") +option("assimp") + set_default(true) + set_showmenu(true) + set_description("Build Assimp plugin") -target("PluginAssimp") - set_kind("shared") - set_group("Plugins") +option_end() - add_deps("NazaraUtility") - add_packages("assimp") +if has_config("assimp") then + add_requires("assimp") - add_headerfiles("**.hpp") - add_headerfiles("**.inl") - add_includedirs(".") - add_files("**.cpp") + target("PluginAssimp") + set_kind("shared") + set_group("Plugins") + + add_deps("NazaraUtility") + add_packages("assimp") + + add_headerfiles("**.hpp") + add_headerfiles("**.inl") + add_includedirs(".") + add_files("**.cpp") +end diff --git a/tests/xmake.lua b/tests/xmake.lua index 79614f4c4..01c31da6c 100644 --- a/tests/xmake.lua +++ b/tests/xmake.lua @@ -1,30 +1,39 @@ -if is_mode("asan") then - add_defines("CATCH_CONFIG_NO_WINDOWS_SEH") - add_defines("CATCH_CONFIG_NO_POSIX_SIGNALS") +option("tests") + set_default(true) + 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 - -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/**") diff --git a/tools/xmake.lua b/tools/xmake.lua index bf6058822..6a0acd13b 100644 --- a/tools/xmake.lua +++ b/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") - after_load(function (target) - -- retrieve qtbase - local qtdir +if has_config("shadernodes") then + add_requires("nodeeditor", "qt5core", "qt5gui", "qt5widgets", {debug = is_mode("debug")}) - local qtbase = target:pkg("qt5base") - if qtbase then - qtdir = assert(qtbase:get("qtdir")) - else - 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 + rule("qt5.env") + after_load(function (target) + -- retrieve qtbase + local qtdir - target:data_set("qt", qtdir) - 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 + local qtbase = target:pkg("qt5base") + if qtbase then + qtdir = assert(qtbase:get("qtdir")) + else + 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 - else - -- compile c++ source file for moc - batchcmds:compile(sourcefile_moc, objectfile) + + target:data_set("qt", qtdir) + 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 - -- add deps - batchcmds:add_depfiles(sourcefile) - batchcmds:set_depmtime(os.mtime(objectfile)) - batchcmds:set_depcache(target:dependfile(objectfile)) - end) + add_includedirs("../src") + add_headerfiles("../src/ShaderNode/**.hpp", "../src/ShaderNode/**.inl") + add_files("../src/ShaderNode/**.cpp") -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 - - add_includedirs("../src") - add_headerfiles("../src/ShaderNode/**.hpp", "../src/ShaderNode/**.inl") - add_files("../src/ShaderNode/**.cpp") +end