From 3e556a72b608b042061e07f3fcb8491b81f21b42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Wed, 9 Mar 2022 20:06:38 +0100 Subject: [PATCH] Build: Add usepch option to use precompiled headers --- .github/workflows/coverage.yml | 2 +- .github/workflows/linux-build-sanitizer.yml | 4 ++-- .github/workflows/linux-build.yml | 2 +- .github/workflows/msys2-build.yml | 2 +- .github/workflows/windows-build.yml | 2 +- tests/Engine/ClientModules.hpp | 8 ++++++++ tests/Engine/Modules.hpp | 8 ++++++++ tests/xmake.lua | 12 ++++++++---- xmake.lua | 10 ++++++++++ 9 files changed, 40 insertions(+), 10 deletions(-) create mode 100644 tests/Engine/ClientModules.hpp create mode 100644 tests/Engine/Modules.hpp diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 6ff96aadd..7b3cbd5c2 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -66,7 +66,7 @@ jobs: # Setup compilation mode and install project dependencies - name: Configure xmake and install dependencies - run: xmake config --shadernodes=y --tests=y --arch=${{ matrix.arch }} --mode=${{ matrix.mode }} --verbose --yes + run: xmake config --shadernodes=y --tests=y --usepch=y --arch=${{ matrix.arch }} --mode=${{ matrix.mode }} --verbose --yes # Build the engine - name: Build Nazara diff --git a/.github/workflows/linux-build-sanitizer.yml b/.github/workflows/linux-build-sanitizer.yml index 529d9c7da..f32dc9266 100644 --- a/.github/workflows/linux-build-sanitizer.yml +++ b/.github/workflows/linux-build-sanitizer.yml @@ -75,11 +75,11 @@ jobs: # Setup compilation mode and install project dependencies - name: Configure xmake and install dependencies - run: xmake config --shadernodes=y --tests=y --arch=${{ matrix.arch }} --mode=fuzz --verbose --yes + run: xmake config --shadernodes=y --tests=y --usepch=y --arch=${{ matrix.arch }} --mode=fuzz --verbose --yes # Configure xmake with honggfuzz to build the engine - name: Configure xmake with honggfuzz - run: xmake config --shadernodes=y --tests=y --arch=${{ matrix.arch }} --mode=fuzz --verbose --toolchain=hfuzz-clang + run: xmake config --shadernodes=y --tests=y --usepch=y --arch=${{ matrix.arch }} --mode=fuzz --verbose --toolchain=hfuzz-clang # Build the engine - name: Build Nazara diff --git a/.github/workflows/linux-build.yml b/.github/workflows/linux-build.yml index b108228b6..be9abaefb 100644 --- a/.github/workflows/linux-build.yml +++ b/.github/workflows/linux-build.yml @@ -65,7 +65,7 @@ jobs: # Setup compilation mode and install project dependencies - name: Configure xmake and install dependencies - run: xmake config --shadernodes=y --tests=y --arch=${{ matrix.arch }} --mode=${{ matrix.mode }} --verbose --yes + run: xmake config --shadernodes=y --tests=y --usepch=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 64b2a0f78..9543a19e3 100644 --- a/.github/workflows/msys2-build.yml +++ b/.github/workflows/msys2-build.yml @@ -74,7 +74,7 @@ jobs: # Setup compilation mode and install project dependencies - name: Configure xmake and install dependencies - run: xmake config --shadernodes=y --tests=y --arch=${{ matrix.arch }} --mode=${{ matrix.mode }} --verbose --yes + run: xmake config --shadernodes=y --tests=y --usepch=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 95c3bb813..8949fc64a 100644 --- a/.github/workflows/windows-build.yml +++ b/.github/workflows/windows-build.yml @@ -57,7 +57,7 @@ jobs: # Setup compilation mode and install project dependencies - name: Configure xmake and install dependencies - run: xmake.exe config --shadernodes=y --tests=y --arch=${{ matrix.arch }} --mode=${{ matrix.mode }} --verbose --yes + run: xmake.exe config --shadernodes=y --tests=y --usepch=y --arch=${{ matrix.arch }} --mode=${{ matrix.mode }} --verbose --yes # Build the engine - name: Build Nazara diff --git a/tests/Engine/ClientModules.hpp b/tests/Engine/ClientModules.hpp new file mode 100644 index 000000000..a191e4fe1 --- /dev/null +++ b/tests/Engine/ClientModules.hpp @@ -0,0 +1,8 @@ +// used for precompiled headers generation +#include +#include +#include +#include +#include +#include +#include diff --git a/tests/Engine/Modules.hpp b/tests/Engine/Modules.hpp new file mode 100644 index 000000000..956adacba --- /dev/null +++ b/tests/Engine/Modules.hpp @@ -0,0 +1,8 @@ +// used for precompiled headers generation +#include +#include +#include +#include +#include +#include +#include diff --git a/tests/xmake.lua b/tests/xmake.lua index 1daab3e2d..99be3e96f 100644 --- a/tests/xmake.lua +++ b/tests/xmake.lua @@ -24,16 +24,20 @@ if has_config("tests") then 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") + if has_config("usepch") then + set_pcxxheader("Engine/ClientModules.hpp") + end + target("NazaraUnitTests") add_files("main.cpp") remove_headerfiles("Engine/Audio/**") remove_files("Engine/Audio/**") + + if has_config("usepch") then + set_pcxxheader("Engine/Modules.hpp") + end end diff --git a/xmake.lua b/xmake.lua index 9cc3fdd78..a0b1797b7 100644 --- a/xmake.lua +++ b/xmake.lua @@ -109,6 +109,12 @@ NazaraModules = modules includes("xmake/**.lua") +option("usepch") + set_default(false) + set_showmenu(true) + set_description("Use precompiled headers to speedup compilation") +option_end() + set_project("NazaraEngine") set_xmakever("2.6.3") @@ -185,6 +191,10 @@ for name, module in pairs(modules) do add_rules("embed_resources") add_rpathdirs("$ORIGIN") + if has_config("usepch") then + set_pcxxheader("include/Nazara/" .. name .. ".hpp") + end + if module.Deps then add_deps(table.unpack(module.Deps)) end