* profiles: enforce globally-unique, per-vendor-namespaced setting_id Many non-Bambu vendors copied Bambu's generic setting_ids (GFSA04 alone appeared in 1557 files), so setting_id was not globally unique. This namespaces every vendor's ids and reserves Bambu/OrcaFilamentLibrary space. - Reserve "G*" (Bambu) and "O*" (OrcaFilamentLibrary) id spaces. - Assign each other vendor a 2-char prefix (first+last letter, collision resolved) and renumber every instantiated preset to <PREFIX><NNNN>. - Strip setting_id from base profiles (instantiation:false) per Bambu's convention; assign one to instantiated presets that lacked it. - Remove the pre-existing misspelled "settings_id" key (91 files). - filament_id is left untouched (it is a per-material id). - Add one-time migration script scripts/assign_vendor_setting_ids.py with a persisted registry resources/profiles/vendor_prefixes.json. Re-runs freeze existing ids; only new vendors/profiles get new ids. - Bump version in each changed vendor index file. - Extend scripts/orca_extra_profile_check.py with a CI guard: global uniqueness, in-namespace, no base setting_id, no gaps, no settings_id typo. 7425 profile files changed across 61 vendors; 0 cross-vendor collisions; validator clean; migration idempotent. BBL and OrcaFilamentLibrary id spaces untouched. * profiles: add setting_id authoring guide for new vendors / profiles * profiles: drop in-repo README; setting_id guide now lives in the wiki * profiles: derive setting_id deterministically from vendor/type/name * bump profile version
42 lines
2.4 KiB
C++
42 lines
2.4 KiB
C++
#include <catch2/catch_all.hpp>
|
|
|
|
#include "libslic3r/Preset.hpp"
|
|
|
|
using namespace Slic3r;
|
|
|
|
// Golden vectors from the Python reference generate_preset_setting_id (defined in
|
|
// scripts/assign_vendor_setting_ids.py). The C++ generate_preset_setting_id() MUST stay
|
|
// byte-identical to it, otherwise app-side on-the-fly ids would diverge from the
|
|
// script-assigned ones in the profiles. Regenerate a vector with:
|
|
// python3 -c "from assign_vendor_setting_ids import generate_preset_setting_id as g; print(g('Afinia','filament','Afinia ABS @Afinia H400'))"
|
|
TEST_CASE("preset setting_id matches the Python reference", "[Preset][setting_id]") {
|
|
struct Vec { const char* vendor; const char* type; const char* name; const char* expected; };
|
|
const Vec vectors[] = {
|
|
{"Afinia", "filament", "Afinia ABS @Afinia H400", "TL34qSVkppBvMvgH"},
|
|
{"Afinia", "process", "0.20mm Standard @Afinia H400", "FzmtNsy7XQvpd7w0"},
|
|
{"Afinia", "machine", "Afinia H400 0.4 nozzle", "r4FZagW0S8uoaJPd"},
|
|
{"Anycubic", "filament", "Generic PLA @Anycubic Kobra 2", "YIWGGLQ8Oepd30Fv"},
|
|
{"Creality", "process", "0.16mm Optimal @Creality Ender-3 V3", "2Nrbq8PxssUPBLza"},
|
|
{"Elegoo", "machine", "Elegoo Neptune 4 0.4 nozzle", "69QdWuRQwAZk9rFu"},
|
|
};
|
|
|
|
for (const auto& v : vectors) {
|
|
const std::string id = generate_preset_setting_id(v.vendor, v.type, v.name);
|
|
INFO(v.vendor << "/" << v.type << "/" << v.name);
|
|
CHECK(id.size() == 16);
|
|
CHECK(id == v.expected);
|
|
}
|
|
}
|
|
|
|
TEST_CASE("preset setting_id is deterministic and identity-sensitive", "[Preset][setting_id]") {
|
|
const std::string a = generate_preset_setting_id("VendorX", "filament", "My PLA");
|
|
CHECK(a == generate_preset_setting_id("VendorX", "filament", "My PLA")); // stable
|
|
CHECK(a != generate_preset_setting_id("VendorY", "filament", "My PLA")); // vendor matters
|
|
CHECK(a != generate_preset_setting_id("VendorX", "process", "My PLA")); // type matters
|
|
CHECK(a != generate_preset_setting_id("VendorX", "filament", "My PETG")); // name matters
|
|
|
|
// Empty identity yields no id (callers must not assign one).
|
|
CHECK(generate_preset_setting_id("", "filament", "My PLA").empty());
|
|
CHECK(generate_preset_setting_id("VendorX", "filament", "").empty());
|
|
}
|