Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion test/log/catalog_extra.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
{
"extra_key": "extra_value"
"extra_key": "extra_value",
"enums": {
"ns::E": {
"17": "extra_value"
},
"extra_enum": {
"1": "value"
}
}
}
17 changes: 11 additions & 6 deletions tools/gen_str_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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},
)

Expand Down Expand Up @@ -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)

Expand Down
Loading