Index: build/premake/premake5.lua =================================================================== --- build/premake/premake5.lua +++ build/premake/premake5.lua @@ -476,10 +476,8 @@ pchheader(pch_dir.."precompiled.h") filter {} pchsource(pch_dir.."precompiled.cpp") - defines { "CONFIG_ENABLE_PCH=1" } files { pch_dir.."precompiled.h", pch_dir.."precompiled.cpp" } else - defines { "CONFIG_ENABLE_PCH=0" } flags { "NoPCH" } end Index: source/lib/config.h =================================================================== --- source/lib/config.h +++ source/lib/config.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010 Wildfire Games. +/* Copyright (C) 2021 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -36,11 +36,6 @@ // causing a warning if the tested macro is undefined. // - allow override via compiler settings by checking #ifndef. -// precompiled headers -#ifndef CONFIG_ENABLE_PCH -# define CONFIG_ENABLE_PCH 1 // improve build performance -#endif - // frame pointers #ifndef CONFIG_OMIT_FP # ifdef NDEBUG Index: source/lib/pch/pch_stdlib.h =================================================================== --- source/lib/pch/pch_stdlib.h +++ source/lib/pch/pch_stdlib.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2020 Wildfire Games. +/* Copyright (C) 2021 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -23,7 +23,7 @@ #ifndef INCLUDED_PCH_STDLIB #define INCLUDED_PCH_STDLIB -#if !MINIMAL_PCH +#if PCH_LEVEL >= 3 // all new-form C library headers #include #include @@ -43,9 +43,9 @@ #include #include #include -#endif // !MINIMAL_PCH +#endif // !PCH_LEVEL -#if MINIMAL_PCH < 3 +#if PCH_LEVEL >= 1 // common C++98 STL headers #include #include @@ -58,7 +58,7 @@ #include #endif -#if MINIMAL_PCH < 2 +#if PCH_LEVEL >= 2 // all other C++98 STL headers #include #include @@ -67,7 +67,7 @@ #include #endif -#if !MINIMAL_PCH +#if PCH_LEVEL >= 3 // all other C++98 headers #include #include @@ -88,6 +88,6 @@ #include #include #include -#endif // !MINIMAL_PCH +#endif // !PCH_LEVEL #endif // #ifndef INCLUDED_PCH_STDLIB Index: source/lib/precompiled.h =================================================================== --- source/lib/precompiled.h +++ source/lib/precompiled.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2020 Wildfire Games. +/* Copyright (C) 2021 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -25,18 +25,20 @@ * source file (VC++ requirement). */ -// some libraries have only a small number of source files, and the -// overhead of including loads of headers here outweighs the improvements to -// incremental rebuild performance. -// they can set MINIMAL_PCH to 1 so we include far fewer headers (but -// still do the global disabling of warnings and include config headers etc), -// or set it to 2 to remove STL headers too (precompiling STL helps performance -// in most non-tiny cases) -#ifndef MINIMAL_PCH -# define MINIMAL_PCH 0 +/** + * PCH_LEVEL defines how many standard headers to include in the PCH. + * At 0, only the absolutely necessary headers (OS, ...) get included. + * At 1, some the STL headers get included. + * At 2, more headers still are included. + * Some libraries have only a small number of source files, and the + * overhead of including loads of headers here outweighs the improvements to + * incremental rebuild performance. + */ +#ifndef PCH_LEVEL +# define PCH_LEVEL 0 #endif -#include "lib/config.h" // CONFIG_ENABLE_BOOST, CONFIG_ENABLE_PCH +#include "lib/config.h" // CONFIG_ENABLE_BOOST #include "lib/sysdep/compiler.h" // MSC_VERSION // must come before any STL headers are included @@ -91,18 +93,11 @@ // // precompiled headers // - -// if PCHs are supported and enabled, we make an effort to include all -// system headers. otherwise, only a few central headers (e.g. types) -// are pulled in and source files must include all the system headers -// they use. this policy ensures good compile performance whether or not -// PCHs are being used. - -#if CONFIG_ENABLE_PCH - // anything placed here won't need to be compiled in each translation unit, // but will cause a complete rebuild if they change. +#if PCH_LEVEL > 0 + #include "lib/pch/pch_stdlib.h" // These two files are included (directly or indirectly) by about half of the .cpp files. @@ -111,4 +106,4 @@ #include "ps/CLogger.h" #include "ps/Profile.h" -#endif // #if CONFIG_ENABLE_PCH +#endif // PCH_LEVEL > 0 Index: source/main.cpp =================================================================== --- source/main.cpp +++ source/main.cpp @@ -28,7 +28,7 @@ // not for any PCH effort, but instead for the (common) definitions // included there. -#define MINIMAL_PCH 2 +#define PCH_LEVEL 2 #include "lib/precompiled.h" #include "lib/debug.h" Index: source/pch/atlas/precompiled.h =================================================================== --- source/pch/atlas/precompiled.h +++ source/pch/atlas/precompiled.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2019 Wildfire Games. +/* Copyright (C) 2021 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -15,18 +15,14 @@ * along with 0 A.D. If not, see . */ -#define MINIMAL_PCH 2 +#define PCH_LEVEL 2 #include "lib/precompiled.h" // common precompiled header // Atlas-specific PCH: -#if CONFIG_ENABLE_PCH - // These headers are included in over 60% of files. #include "tools/atlas/GameInterface/Messages.h" #include "ps/CStr.h" #include "ps/Game.h" #include - -#endif // CONFIG_ENABLE_PCH Index: source/pch/engine/precompiled.h =================================================================== --- source/pch/engine/precompiled.h +++ source/pch/engine/precompiled.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2020 Wildfire Games. +/* Copyright (C) 2021 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -19,10 +19,8 @@ // "engine"-specific PCH: -#if CONFIG_ENABLE_PCH #include "ps/CStr.h" #include "ps/Errors.h" #include "lib/file/vfs/vfs_path.h" #include "lib/file/vfs/vfs_util.h" #include "scriptinterface/ScriptTypes.h" -#endif // CONFIG_ENABLE_PCH Index: source/pch/gui/precompiled.h =================================================================== --- source/pch/gui/precompiled.h +++ source/pch/gui/precompiled.h @@ -15,16 +15,13 @@ * along with 0 A.D. If not, see . */ -#define MINIMAL_PCH 2 +#define PCH_LEVEL 2 #include "lib/precompiled.h" // common precompiled header #if MSC_VERSION # pragma warning(disable:4250) // "inherits 'IGUITextOwner::IGUITextOwner::UpdateCachedSize' via dominance" #endif -#if CONFIG_ENABLE_PCH #include "gui/CGUI.h" #include "gui/ObjectBases/IGUIObject.h" #include "ps/CStr.h" - -#endif // CONFIG_ENABLE_PCH Index: source/pch/network/precompiled.h =================================================================== --- source/pch/network/precompiled.h +++ source/pch/network/precompiled.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2020 Wildfire Games. +/* Copyright (C) 2021 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -15,14 +15,11 @@ * along with 0 A.D. If not, see . */ -#define MINIMAL_PCH 2 +#define PCH_LEVEL 2 #include "lib/precompiled.h" // common precompiled header -#if CONFIG_ENABLE_PCH - // These headers are included by almost all compilation units. #include "ps/CStr.h" #include "ps/ThreadUtil.h" #include "network/NetMessage.h" #include "scriptinterface/ScriptInterface.h" -#endif // CONFIG_ENABLE_PCH Index: source/pch/scriptinterface/precompiled.h =================================================================== --- source/pch/scriptinterface/precompiled.h +++ source/pch/scriptinterface/precompiled.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2009 Wildfire Games. +/* Copyright (C) 2021 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -15,5 +15,5 @@ * along with 0 A.D. If not, see . */ -#define MINIMAL_PCH 2 +#define PCH_LEVEL 2 #include "lib/precompiled.h" // common precompiled header Index: source/pch/simulation2/precompiled.h =================================================================== --- source/pch/simulation2/precompiled.h +++ source/pch/simulation2/precompiled.h @@ -15,16 +15,12 @@ * along with 0 A.D. If not, see . */ -#define MINIMAL_PCH 2 +#define PCH_LEVEL 2 #include "lib/precompiled.h" // common precompiled header -#if CONFIG_ENABLE_PCH - // The simulation has many header files (component interfaces) which are quick to compile on their own // but bring in a lot of headers indirectly. Adding these to the precompiled header // cuts down compilation time by about half. #include "simulation2/system/Interface.h" #include "maths/FixedVector2D.h" #include "maths/FixedVector3D.h" - -#endif // CONFIG_ENABLE_PCH Index: source/pch/test/precompiled.h =================================================================== --- source/pch/test/precompiled.h +++ source/pch/test/precompiled.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2019 Wildfire Games. +/* Copyright (C) 2021 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -17,13 +17,9 @@ #include "lib/precompiled.h" // common precompiled header -#if CONFIG_ENABLE_PCH - #include "simulation2/system/ComponentTest.h" #include "lib/self_test.h" #include #include #include #include - -#endif // CONFIG_ENABLE_PCH