diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index 65da8ca9..ff206842 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -38,7 +38,7 @@ jobs: cxx_flags: "-stdlib=libstdc++" - version: 19 compiler: clang - install: wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && sudo ./llvm.sh 19 + install: wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && sudo ./llvm.sh 19 all toolchain_root: "/usr/lib/llvm-19" - version: 19 compiler: clang @@ -110,6 +110,13 @@ jobs: ${{ matrix.install }} sudo apt install -y ninja-build + - name: Install libclang for string catalog + run: | + python3 -m venv ${{github.workspace}}/test_venv + source ${{github.workspace}}/test_venv/bin/activate + pip install libclang + echo "${{github.workspace}}/test_venv/bin" >> $GITHUB_PATH + - name: Restore CPM cache env: cache-name: cpm-cache-0 diff --git a/test/log/catalog_extra.json b/test/log/catalog_extra.json index 770af1f6..983e80a5 100644 --- a/test/log/catalog_extra.json +++ b/test/log/catalog_extra.json @@ -1,3 +1,11 @@ { - "extra_key": "extra_value" + "extra_key": "extra_value", + "enums": { + "ns::E": { + "17": "extra_value" + }, + "extra_enum": { + "1": "value" + } + } } diff --git a/tools/gen_str_catalog.py b/tools/gen_str_catalog.py index 9fd9bb27..485e667c 100755 --- a/tools/gen_str_catalog.py +++ b/tools/gen_str_catalog.py @@ -124,7 +124,7 @@ def get_id(stable_ids, key_fn, gen, obj): unique_strings = {i[0][0]: i for i in strings}.values() return ( - {m: {"string": module_string(m), "id": get_module_id(m)} for m in set(modules)}, + {m: {"string": module_string(m), "id": get_module_id(m)} for m in sorted(set(modules))}, {item[0]: {**item[1], "id": get_msg_id(item[1])} for item in unique_strings}, ) @@ -204,15 +204,20 @@ def write_json(messages, modules, enums, extra_inputs: list[str], filename: str, if not mod in d["modules"]: d["modules"].append(mod) - es = dict() - for (k, (_, v)) in enums.items(): - es.update({k: {value: name for (name, value) in v.items()}}) - - str_catalog = dict(**d, enums=es) + str_catalog = dict(**d, enums=dict()) for extra in extra_inputs: with open(extra, "r") as f: str_catalog.update(json.load(f)) + es = dict() + for (k, (_, v)) in enums.items(): + es.update({k: {value: name for (name, value) in v.items()}}) + for (k, v) in es.items(): + if k in str_catalog["enums"]: + str_catalog["enums"][k].update(v) # type: ignore + else: + str_catalog["enums"].update({k: v}) # type: ignore + with open(filename, "w") as f: json.dump(str_catalog, f, indent=4)