Skip to content

Commit 2699fef

Browse files
committed
feat(build, ci): enable unity builds
1 parent ceeabde commit 2699fef

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

.github/workflows/setup-compilers/action.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ runs:
102102
-DARK_COVERAGE=${{ inputs.coverage }} \
103103
-DARK_BUILD_EXE=On \
104104
-DARK_BUILD_MODULES=$ToggleModules -DARK_MOD_ALL=$ToggleModules -DARK_MOD_DRAFT=$ToggleModules \
105-
-DARK_TESTS=On
105+
-DARK_TESTS=On \
106+
-DARK_UNITY_BUILD=On
106107
cmake --build build --config $BUILD_TYPE -j $(nproc)
107108
108109
- name: Configure CMake Ark

CMakeLists.txt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.12)
1+
cmake_minimum_required(VERSION 3.16)
22

33
project(ark CXX)
44

@@ -22,6 +22,7 @@ option(ARK_SANITIZERS "Enable ASAN and UBSAN" Off)
2222
option(ARK_TESTS "Build ArkScript unit tests" Off)
2323
option(ARK_BENCHMARKS "Build ArkScript benchmarks" Off)
2424
option(ARK_COVERAGE "Enable coverage while building (clang, gcc) (requires ARK_TESTS to be On)" Off)
25+
option(ARK_UNITY_BUILD "Enable unity build" Off)
2526

2627
include(cmake/link_time_optimization.cmake)
2728
include(cmake/sanitizers.cmake)
@@ -53,6 +54,11 @@ target_include_directories(ArkReactor
5354
${ark_SOURCE_DIR}/include)
5455
target_compile_features(ArkReactor PRIVATE cxx_std_20)
5556

57+
if (ARK_UNITY_BUILD)
58+
set_target_properties(ArkReactor PROPERTIES UNITY_BUILD ON UNITY_BUILD_MODE BATCH UNITY_BUILD_BATCH_SIZE 16)
59+
set_source_files_properties(src/arkreactor/VM/VM.cpp PROPERTIES SKIP_UNITY_BUILD_INCLUSION true)
60+
endif ()
61+
5662
if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANG OR APPLE)
5763
message(STATUS "Enabling computed gotos")
5864
target_compile_definitions(ArkReactor PRIVATE ARK_USE_COMPUTED_GOTOS=1)
@@ -194,6 +200,10 @@ if (ARK_TESTS)
194200
target_compile_features(unittests PRIVATE cxx_std_20)
195201
target_compile_definitions(unittests PRIVATE ARK_TESTS_ROOT="${CMAKE_CURRENT_SOURCE_DIR}/")
196202

203+
if (ARK_UNITY_BUILD)
204+
set_target_properties(unittests PROPERTIES UNITY_BUILD ON UNITY_BUILD_MODE BATCH UNITY_BUILD_BATCH_SIZE 16)
205+
endif ()
206+
197207
if (ARK_COVERAGE AND CMAKE_COMPILER_IS_CLANG)
198208
target_compile_options(unittests PRIVATE -coverage -fcoverage-mapping -fprofile-instr-generate)
199209
target_link_options(unittests PRIVATE -coverage -fcoverage-mapping -fprofile-instr-generate)
@@ -250,6 +260,10 @@ if (ARK_BUILD_EXE)
250260
target_link_libraries(arkscript PUBLIC ArkReactor replxx clipp)
251261
target_compile_features(arkscript PRIVATE cxx_std_20)
252262

263+
if (ARK_UNITY_BUILD)
264+
set_target_properties(arkscript PROPERTIES UNITY_BUILD ON UNITY_BUILD_MODE BATCH UNITY_BUILD_BATCH_SIZE 16)
265+
endif ()
266+
253267
enable_lto(arkscript)
254268

255269
# Installs the arkscript executable.

include/Ark/Compiler/Compiler.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ namespace Ark::internal
8585
std::vector<IR::Block> m_temp_pages; ///< we need temporary code pages for some compilations passes
8686
IR::label_t m_current_label = 0;
8787

88-
unsigned m_debug; ///< the debug level of the compiler
8988
Logger m_logger;
9089

9190
/**

src/arkreactor/Compiler/Compiler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace Ark::internal
1919
using namespace literals;
2020

2121
Compiler::Compiler(const unsigned debug) :
22-
m_debug(debug), m_logger("Compiler", debug)
22+
m_logger("Compiler", debug)
2323
{}
2424

2525
void Compiler::process(const Node& ast)

0 commit comments

Comments
 (0)