mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-29 03:41:31 +00:00
Merge branch main into feat/printer-agent-infra
This commit is contained in:
@@ -88,40 +88,6 @@ function(orcaslicer_discover_tests TARGET)
|
||||
catch_discover_tests(${TARGET} ADD_TAGS_AS_LABELS)
|
||||
endfunction()
|
||||
|
||||
# Stages a private Python runtime beside TARGET's output and (on macOS) links
|
||||
# in the matching rpath, so an embedded pybind11 interpreter in TARGET can find
|
||||
# libpython/the stdlib at runtime without depending on the build machine's
|
||||
# Python install. Apply this to every test target that embeds an interpreter -
|
||||
# duplicating the WIN32/APPLE blocks by hand lets them drift out of sync.
|
||||
function(orcaslicer_stage_test_python_runtime TARGET)
|
||||
if (WIN32)
|
||||
add_custom_command(TARGET ${TARGET} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory "$<TARGET_FILE_DIR:${TARGET}>/python"
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_PREFIX_PATH}/libpython" "$<TARGET_FILE_DIR:${TARGET}>/python"
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
"${CMAKE_PREFIX_PATH}/libpython/python${_bundled_python_abi}.dll"
|
||||
"${CMAKE_PREFIX_PATH}/libpython/vcruntime140.dll"
|
||||
"${CMAKE_PREFIX_PATH}/libpython/vcruntime140_1.dll"
|
||||
"$<TARGET_FILE_DIR:${TARGET}>"
|
||||
COMMENT "Copying Python runtime for ${TARGET}"
|
||||
VERBATIM
|
||||
)
|
||||
elseif (APPLE)
|
||||
target_link_options(${TARGET} PRIVATE
|
||||
"LINKER:-rpath,@executable_path/python/lib")
|
||||
|
||||
add_custom_command(TARGET ${TARGET} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E rm -rf
|
||||
"$<TARGET_FILE_DIR:${TARGET}>/python"
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
||||
"${CMAKE_PREFIX_PATH}/libpython"
|
||||
"$<TARGET_FILE_DIR:${TARGET}>/python"
|
||||
COMMENT "Copying Python runtime for ${TARGET}"
|
||||
VERBATIM
|
||||
)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
add_subdirectory(libnest2d)
|
||||
add_subdirectory(libslic3r)
|
||||
add_subdirectory(slic3rutils)
|
||||
|
||||
@@ -163,6 +163,50 @@ TEST_CASE("H2C multi-nozzle: filaments get distinct nozzles on the 6-nozzle extr
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Grouping context spans the filament count with mis-sized config arrays", "[ToolOrdering][H2C]")
|
||||
{
|
||||
// FilamentGroup indexes the grouping context's filament_info by filament id, so a short
|
||||
// per-filament array must not shorten it: the reads run off the end.
|
||||
DynamicPrintConfig config = DynamicPrintConfig::full_print_config();
|
||||
// Single 6-nozzle extruder: opens the grouping engine without needing a BBL multi-extruder.
|
||||
config.option<ConfigOptionFloats>("nozzle_diameter", true)->values = {0.4};
|
||||
config.option<ConfigOptionIntsNullable>("extruder_max_nozzle_count", true)->values = {6};
|
||||
config.option<ConfigOptionStrings>("extruder_nozzle_stats", true)->values = {"Standard#6"};
|
||||
|
||||
// Four filaments, with filament_type / filament_is_support left short on purpose.
|
||||
config.option<ConfigOptionStrings>("filament_colour", true)->values = {"#FF0000", "#00FF00", "#0000FF", "#FFFF00"};
|
||||
config.option<ConfigOptionStrings>("filament_type", true)->values = {"PLA"};
|
||||
config.option<ConfigOptionBools>("filament_is_support", true)->values = {0};
|
||||
config.option<ConfigOptionFloats>("filament_diameter", true)->values = {1.75, 1.75, 1.75, 1.75};
|
||||
config.option<ConfigOptionInts>("filament_map", true)->values = {1, 1, 1, 1};
|
||||
config.option<ConfigOptionFloats>("flush_volumes_matrix", true)->values = std::vector<double>(16, 140.);
|
||||
config.option<ConfigOptionFloats>("flush_multiplier", true)->values = {1.};
|
||||
|
||||
Model model;
|
||||
model.add_object("cube", "", make_cube(20, 20, 20))->add_instance();
|
||||
|
||||
Print print;
|
||||
print.apply(model, config);
|
||||
// apply() does not pad the per-filament arrays, so the mis-sizing survives into the engine.
|
||||
REQUIRE(print.config().filament_type.values.size() < print.config().filament_colour.values.size());
|
||||
|
||||
std::vector<std::vector<unsigned int>> layer_filaments = {{0, 1}, {1, 2}, {2, 3}};
|
||||
|
||||
SECTION("short per-filament arrays still yield one entry per filament") {
|
||||
auto result = ToolOrdering::get_recommended_filament_maps(layer_filaments, &print, FilamentMapMode::fmmAutoForFlush, {}, {});
|
||||
REQUIRE(result.get_extruder_map(false).size() == 4);
|
||||
for (int f = 0; f < 4; ++f)
|
||||
REQUIRE(result.get_extruder_id(f) == 0);
|
||||
}
|
||||
|
||||
SECTION("filament_ids longer than the filament count is truncated, not paired past the end") {
|
||||
config.option<ConfigOptionStrings>("filament_ids", true)->values = {"a", "b", "c", "d", "e", "f"};
|
||||
print.apply(model, config);
|
||||
auto result = ToolOrdering::get_recommended_filament_maps(layer_filaments, &print, FilamentMapMode::fmmAutoForFlush, {}, {});
|
||||
REQUIRE(result.get_extruder_map(false).size() == 4);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("H2C dynamic selector: per-layer nozzle ids reach the g-code surface", "[ToolOrdering][H2C][Dynamic]")
|
||||
{
|
||||
// The per-layer regroup engine
|
||||
|
||||
@@ -33,6 +33,43 @@ set_property(TARGET ${_TEST_NAME}_tests PROPERTY FOLDER "tests")
|
||||
|
||||
orcaslicer_copy_test_dlls(${_TEST_NAME}_tests)
|
||||
|
||||
orcaslicer_stage_test_python_runtime(${_TEST_NAME}_tests)
|
||||
if (WIN32)
|
||||
add_custom_command(TARGET ${_TEST_NAME}_tests POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory "$<TARGET_FILE_DIR:${_TEST_NAME}_tests>/python"
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_PREFIX_PATH}/libpython" "$<TARGET_FILE_DIR:${_TEST_NAME}_tests>/python"
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
"${CMAKE_PREFIX_PATH}/libpython/python${_bundled_python_abi}.dll"
|
||||
"${CMAKE_PREFIX_PATH}/libpython/vcruntime140.dll"
|
||||
"${CMAKE_PREFIX_PATH}/libpython/vcruntime140_1.dll"
|
||||
"$<TARGET_FILE_DIR:${_TEST_NAME}_tests>"
|
||||
COMMENT "Copying Python runtime for slic3rutils plugin host API tests"
|
||||
VERBATIM
|
||||
)
|
||||
elseif (APPLE)
|
||||
target_link_options(${_TEST_NAME}_tests PRIVATE
|
||||
"LINKER:-rpath,@executable_path/python/lib")
|
||||
|
||||
add_custom_command(TARGET ${_TEST_NAME}_tests POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E rm -rf
|
||||
"$<TARGET_FILE_DIR:${_TEST_NAME}_tests>/python"
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
||||
"${CMAKE_PREFIX_PATH}/libpython"
|
||||
"$<TARGET_FILE_DIR:${_TEST_NAME}_tests>/python"
|
||||
COMMENT "Copying Python runtime for macOS plugin host API tests"
|
||||
VERBATIM
|
||||
)
|
||||
elseif (FLATPAK)
|
||||
# Same <testdir>/python home as WIN32/APPLE; symlink since /app/libpython
|
||||
# already ships in the flatpak (the test exe links libpython3.12.so from it).
|
||||
add_custom_command(TARGET ${_TEST_NAME}_tests POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E rm -rf
|
||||
"$<TARGET_FILE_DIR:${_TEST_NAME}_tests>/python"
|
||||
COMMAND ${CMAKE_COMMAND} -E create_symlink
|
||||
"${CMAKE_PREFIX_PATH}/libpython"
|
||||
"$<TARGET_FILE_DIR:${_TEST_NAME}_tests>/python"
|
||||
COMMENT "Linking Python runtime for flatpak plugin host API tests"
|
||||
VERBATIM
|
||||
)
|
||||
endif()
|
||||
|
||||
orcaslicer_discover_tests(${_TEST_NAME}_tests)
|
||||
|
||||
Reference in New Issue
Block a user