diff --git a/.github/workflows/build_orca.yml b/.github/workflows/build_orca.yml index 7ccb52b0e6..22e435327f 100644 --- a/.github/workflows/build_orca.yml +++ b/.github/workflows/build_orca.yml @@ -50,6 +50,20 @@ jobs: useLocalCache: true # <--= Use the local cache (default is 'false'). useCloudCache: true + - name: Install codegen tools and generate config sources + run: | + pip install grpcio-tools + python tools/run_codegen.py + if: runner.os == 'Windows' + shell: pwsh + + - name: Install codegen tools and generate config sources + run: | + pip3 install grpcio-tools + python3 tools/run_codegen.py + if: runner.os != 'Windows' + shell: bash + - name: Get the version and date on Ubuntu and macOS if: runner.os != 'Windows' run: | diff --git a/CMakeLists.txt b/CMakeLists.txt index c7fa3f12cf..b6d17a44fd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -872,6 +872,11 @@ function(orcaslicer_copy_dlls target config postfix output_dlls) endfunction() +# Config codegen — generates src/slic3r/GUI/generated/*.cpp from src/PrintConfigs/*.proto. +# Must run before compiling libslic3r (PrintConfig.cpp #includes the generated files). +# Requires: pip install grpcio-tools OR standalone protoc in PATH. +include(cmake/modules/ConfigCodegen.cmake) + # libslic3r, OrcaSlicer GUI and the OrcaSlicer executable. add_subdirectory(deps_src) add_subdirectory(src) diff --git a/build_linux.sh b/build_linux.sh index 98201958f4..baf87f4ca2 100755 --- a/build_linux.sh +++ b/build_linux.sh @@ -545,6 +545,10 @@ if [[ -n "${BUILD_ORCA}" ]] || [[ -n "${BUILD_TESTS}" ]] ; then BUILD_ARGS+=(-DORCA_UPDATER_SIG_KEY="${ORCA_UPDATER_SIG_KEY}") fi + echo "Generating config sources from proto..." + pip install grpcio-tools -q + python3 tools/run_codegen.py || { echo "ERROR: config codegen failed"; exit 1; } + print_and_run cmake -S . -B $BUILD_DIR "${CMAKE_C_CXX_COMPILER_CLANG[@]}" "${CMAKE_LLD_LINKER_ARGS[@]}" "${CMAKE_CCACHE_ARGS[@]}" -G "Ninja Multi-Config" \ -DSLIC3R_PCH=${SLIC3R_PRECOMPILED_HEADERS} \ -DORCA_TOOLS=ON \ diff --git a/build_release_macos.sh b/build_release_macos.sh index 8d417695ad..a7398820fc 100755 --- a/build_release_macos.sh +++ b/build_release_macos.sh @@ -180,6 +180,10 @@ function pack_deps() { } function build_slicer() { + echo "Generating config sources from proto..." + pip3 install grpcio-tools -q + python3 tools/run_codegen.py || { echo "ERROR: config codegen failed"; exit 1; } + # iterate over two architectures: x86_64 and arm64 for _ARCH in x86_64 arm64; do # if ARCH is universal or equal to _ARCH diff --git a/build_release_vs.bat b/build_release_vs.bat index 3f1a2e0af4..daf7cbee95 100644 --- a/build_release_vs.bat +++ b/build_release_vs.bat @@ -126,6 +126,15 @@ if "%1"=="deps" goto :done :slicer echo "building Orca Slicer..." cd %WP% + +echo "generating config sources from proto..." +pip install grpcio-tools -q +python tools/run_codegen.py +if errorlevel 1 ( + echo "ERROR: config codegen failed" + exit /b 1 +) + mkdir %build_dir% cd %build_dir% diff --git a/build_release_vs2022.bat b/build_release_vs2022.bat index 4a5ae11277..f118b3c121 100644 --- a/build_release_vs2022.bat +++ b/build_release_vs2022.bat @@ -57,6 +57,15 @@ if "%1"=="deps" exit /b 0 :slicer echo "building Orca Slicer..." cd %WP% + +echo "generating config sources from proto..." +pip install grpcio-tools -q +python tools/run_codegen.py +if errorlevel 1 ( + echo "ERROR: config codegen failed" + exit /b 1 +) + mkdir %build_dir% cd %build_dir% diff --git a/src/libslic3r/CMakeLists.txt b/src/libslic3r/CMakeLists.txt index 9b67d7ab50..2aef898101 100644 --- a/src/libslic3r/CMakeLists.txt +++ b/src/libslic3r/CMakeLists.txt @@ -489,6 +489,21 @@ add_library(libslic3r STATIC ${lisbslic3r_sources} ${OpenVDBUtils_SOURCES}) source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${lisbslic3r_sources}) +# Ensure codegen runs before compiling libslic3r (PrintConfig.cpp, Preset.cpp, Print.cpp +# all #include generated files — MSVC tracks the #include deps automatically after first build, +# but this dependency ensures the generated files exist and are up-to-date before compilation). +if(TARGET codegen_config) + add_dependencies(libslic3r codegen_config) + # Tell cmake that the three source files that #include generated code depend on them, + # so an incremental build recompiles them when protos change. + set_source_files_properties( + "${CMAKE_CURRENT_SOURCE_DIR}/PrintConfig.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/Preset.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/Print.cpp" + PROPERTIES OBJECT_DEPENDS "${CONFIG_GENERATED_SOURCES}" + ) +endif() + if (SLIC3R_STATIC) set(CGAL_Boost_USE_STATIC_LIBS ON CACHE BOOL "" FORCE) endif () diff --git a/src/slic3r/CMakeLists.txt b/src/slic3r/CMakeLists.txt index c4d6369b72..13bd15031c 100644 --- a/src/slic3r/CMakeLists.txt +++ b/src/slic3r/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.13) +cmake_minimum_required(VERSION 3.13) project(libslic3r_gui) include(PrecompiledHeader) @@ -460,6 +460,7 @@ set(SLIC3R_GUI_SOURCES GUI/TabButton.hpp GUI/Tab.cpp GUI/Tab.hpp + GUI/TabLayoutExtra.cpp GUI/TaskManager.cpp GUI/TaskManager.hpp GUI/TextLines.cpp