Build: Add usepch option to use precompiled headers

This commit is contained in:
Jérôme Leclercq 2022-03-09 20:06:38 +01:00
parent 4a8ebf869b
commit 3e556a72b6
9 changed files with 40 additions and 10 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,8 @@
// used for precompiled headers generation
#include <Engine/Modules.hpp>
#include <Nazara/Audio.hpp>
#include <Nazara/Graphics.hpp>
#include <Nazara/OpenGLRenderer.hpp>
#include <Nazara/Platform.hpp>
#include <Nazara/VulkanRenderer.hpp>
#include <Nazara/Widgets.hpp>

8
tests/Engine/Modules.hpp Normal file
View File

@ -0,0 +1,8 @@
// used for precompiled headers generation
#include <Nazara/Core.hpp>
#include <Nazara/Math.hpp>
#include <Nazara/Network.hpp>
#include <Nazara/Physics2D.hpp>
#include <Nazara/Physics3D.hpp>
#include <Nazara/Shader.hpp>
#include <Nazara/Utility.hpp>

View File

@ -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

View File

@ -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