diff --git a/.github/workflows/build_orca.yml b/.github/workflows/build_orca.yml index 457f76f7c8..3f242337b6 100644 --- a/.github/workflows/build_orca.yml +++ b/.github/workflows/build_orca.yml @@ -305,9 +305,10 @@ jobs: if: runner.os == 'Windows' shell: pwsh run: | + $tool = Get-ChildItem -Recurse -Path build -Filter "generate_system_cache.exe" | Select-Object -First 1 $profiles = Get-ChildItem -Recurse -Path build -Directory -Filter profiles | Where-Object { $_.FullName -match 'resources' } | Select-Object -First 1 - .\build\src\Release\generate_system_cache.exe --path $profiles.FullName --log_level 2 + & $tool.FullName --path $profiles.FullName --log_level 2 - name: Create installer Win if: runner.os == 'Windows' && !vars.SELF_HOSTED @@ -421,7 +422,8 @@ jobs: if: runner.os == 'Linux' shell: bash run: | - ./build/src/Release/generate_system_cache --path build/package/resources/profiles --log_level 2 + tool=$(find build -name generate_system_cache -type f | head -1) + "$tool" --path build/package/resources/profiles --log_level 2 # Re-pack the AppImage so the cache is included appimage=$(find build -maxdepth 1 -name "OrcaSlicer_Linux_AppImage*.AppImage" | head -1) chmod +x "$appimage" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1f20834d22..91c95b7c5a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -112,10 +112,7 @@ if(ORCA_TOOLS) target_link_libraries(OrcaSlicer_profile_validator libslic3r boost_headeronly libcurl OpenSSL::SSL OpenSSL::Crypto) target_compile_definitions(OrcaSlicer_profile_validator PRIVATE -DBOOST_ALL_NO_LIB -DBOOST_USE_WINAPI_VERSION=0x602 -DBOOST_SYSTEM_USE_UTF8) - # generate_system_cache: pre-generates resources/profiles/system_presets_cache.cache for CI bundling. - add_executable(generate_system_cache dev-utils/generate_system_cache.cpp) - target_link_libraries(generate_system_cache libslic3r boost_headeronly) - target_compile_definitions(generate_system_cache PRIVATE -DBOOST_ALL_NO_LIB -DBOOST_USE_WINAPI_VERSION=0x602 -DBOOST_SYSTEM_USE_UTF8) + endif() # Create a slic3r executable diff --git a/src/dev-utils/CMakeLists.txt b/src/dev-utils/CMakeLists.txt index e3534a024a..ccaf24a96d 100644 --- a/src/dev-utils/CMakeLists.txt +++ b/src/dev-utils/CMakeLists.txt @@ -20,6 +20,20 @@ if (SLIC3R_ENC_CHECK) ) endif() +if (ORCA_TOOLS) + set(_DEV_DEFS -DBOOST_ALL_NO_LIB -DBOOST_USE_WINAPI_VERSION=0x602 -DBOOST_SYSTEM_USE_UTF8) + + # generate_system_cache: pre-generates resources/profiles/system_presets_cache.cache for CI bundling. + add_executable(generate_system_cache generate_system_cache.cpp) + target_link_libraries(generate_system_cache libslic3r boost_headeronly) + target_compile_definitions(generate_system_cache PRIVATE ${_DEV_DEFS}) + + # inspect_system_cache: dumps contents of a .cache file for debugging. + add_executable(inspect_system_cache inspect_system_cache.cpp) + target_link_libraries(inspect_system_cache libslic3r boost_headeronly) + target_compile_definitions(inspect_system_cache PRIVATE ${_DEV_DEFS}) +endif() + # Function that adds source file encoding check to a target # using the above encoding-check binary diff --git a/src/dev-utils/inspect_system_cache.cpp b/src/dev-utils/inspect_system_cache.cpp new file mode 100644 index 0000000000..d8d548bf50 --- /dev/null +++ b/src/dev-utils/inspect_system_cache.cpp @@ -0,0 +1,126 @@ +#include "libslic3r/PresetBundleCache.hpp" + +#include +#include +#include + +using namespace Slic3r; +namespace po = boost::program_options; + +static void print_bar(char c, int n) { std::cout << std::string(n, c) << "\n"; } + +int main(int argc, char* argv[]) +{ + po::options_description desc("OrcaSlicer Cache Inspector\nUsage"); + desc.add_options() + ("help,h", "Show help") + ("path,p", po::value(), "Path to .cache file (required)") + ("vendors,V", "List all vendor IDs and versions") + ("models,m", "List all printer models per vendor") + ("presets,P", "List all preset names") + ("filaments,f", "List filament presets") + ("printers,r", "List printer presets") + ("process,p2", "List print process presets"); + + po::variables_map vm; + try { + po::store(po::parse_command_line(argc, argv, desc), vm); + if (vm.count("help") || !vm.count("path")) { std::cout << desc << "\n"; return 0; } + po::notify(vm); + } catch (const po::error& e) { + std::cerr << "Error: " << e.what() << "\n" << desc << "\n"; return 1; + } + + const std::string path = vm["path"].as(); + + PresetBundleCache::SystemPresetsCache cache; + if (!cache.load(path)) { + std::cerr << "Failed to load cache: " << path << "\n" + << " (wrong format version, truncated file, or not a .cache file)\n"; + return 1; + } + + // ---- Summary ---- + print_bar('=', 60); + std::cout << "Cache file : " << path << "\n"; + std::cout << "Format ver : " << cache.format_version << "\n"; + std::cout << "Config opts: " << cache.config_options_count << "\n"; + print_bar('-', 60); + std::cout << "Vendors : " << cache.vendor_versions.size() << "\n"; + std::cout << "Models : "; + size_t total_models = 0; + for (const auto& vp : cache.vendor_profiles) total_models += vp.models.size(); + std::cout << total_models << "\n"; + std::cout << "Printers : " << cache.printer_presets.size() << "\n"; + std::cout << "Filaments : " << cache.filament_presets.size() << "\n"; + std::cout << "Print proc : " << cache.print_presets.size() << "\n"; + std::cout << "config_maps: " << cache.config_maps.size() << "\n"; + std::cout << "filament_id_maps: " << cache.filament_id_maps.size() << "\n"; + print_bar('=', 60); + + bool show_all = !vm.count("vendors") && !vm.count("models") && + !vm.count("presets") && !vm.count("filaments") && + !vm.count("printers") && !vm.count("process"); + + // ---- Vendor versions ---- + if (show_all || vm.count("vendors")) { + std::cout << "\nVENDOR VERSIONS (" << cache.vendor_versions.size() << ")\n"; + print_bar('-', 60); + for (const auto& [id, ver] : cache.vendor_versions) + std::cout << " " << std::left << std::setw(30) << id << " " << ver << "\n"; + } + + // ---- Models per vendor ---- + if (show_all || vm.count("models")) { + std::cout << "\nVENDOR PROFILES & MODELS\n"; + print_bar('-', 60); + for (const auto& vp : cache.vendor_profiles) { + std::cout << " [" << vp.id << "] v" << vp.config_version + << " (" << vp.models.size() << " models)\n"; + if (vm.count("models")) { + for (const auto& m : vp.models) { + std::cout << " " << std::left << std::setw(40) << m.name + << " variants:" << m.variants.size() << "\n"; + } + } + } + } + + // ---- Printer presets ---- + if (vm.count("presets") || vm.count("printers")) { + std::cout << "\nPRINTER PRESETS (" << cache.printer_presets.size() << ")\n"; + print_bar('-', 60); + for (const auto& cp : cache.printer_presets) { + const auto* pm = cp.config.option("printer_model"); + const auto* pv = cp.config.option("printer_variant"); + std::cout << " " << std::left << std::setw(50) << cp.name + << " model=" << (pm ? pm->value : "?") + << " nozzle=" << (pv ? pv->value : "?") + << (cp.is_visible ? "" : " [hidden]") << "\n"; + } + } + + // ---- Filament presets ---- + if (vm.count("presets") || vm.count("filaments")) { + std::cout << "\nFILAMENT PRESETS (" << cache.filament_presets.size() << ")\n"; + print_bar('-', 60); + for (const auto& cp : cache.filament_presets) { + const auto* fv = cp.config.option("filament_vendor"); + const auto* ft = cp.config.option("filament_type"); + std::cout << " " << std::left << std::setw(50) << cp.name + << " vendor=" << (fv ? fv->value : "?") + << " type=" << (ft && !ft->values.empty() ? ft->values[0] : "?") + << (cp.is_visible ? "" : " [hidden]") << "\n"; + } + } + + // ---- Print process presets ---- + if (vm.count("presets") || vm.count("process")) { + std::cout << "\nPRINT PROCESS PRESETS (" << cache.print_presets.size() << ")\n"; + print_bar('-', 60); + for (const auto& cp : cache.print_presets) + std::cout << " " << cp.name << (cp.is_visible ? "" : " [hidden]") << "\n"; + } + + return 0; +}