Skip to content

Commit 31b4a6d

Browse files
committed
Reduce script coupling and prune one-time migration tooling
Follow-up cleanup to the symbol-file dedup pipeline, addressing coupling and script sprawl without changing any generated output. - Unify the snake_case -> UpperCamelCase convention into a single modules_yaml.to_upper_camel(). It was implemented three times (build_configs, generate_tizen, rename_unnamed) with two different algorithms (slice-upper vs str.title()) that silently diverge on name parts containing digits or capitals, so the class name and the anonymous-type prefix could disagree. - Make build_configs' include groups data-driven: any group present in modules.yaml is now emitted, instead of being silently dropped unless its key was hardcoded in the renderer. - generate_bindings.sh wipes build/configs/<version> before rendering, so a removed or renamed module leaves no stale ffigen_*.yaml or .symbols/*.yaml behind. - Remove dead code: the unused to_camel_case(), and the unreachable entrypoint-insertion block in update_modules (an early return made it and its `inserted` bookkeeping unreachable). - Delete migration-only scripts now that all six modules.yaml are committed: import_configs.py (bootstrap done), verify_configs.py (round-trip proof done), scan_rootstrap.py (its rootstrap_manifest.yaml baseline was never committed or used). Verified: Tizen 6.0 regeneration is byte-identical to the pre-refactor output (118 files), dart analyze is clean, and check_consistency passes for all six versions.
1 parent 2cd8daa commit 31b4a6d

10 files changed

Lines changed: 38 additions & 798 deletions

scripts/README.md

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ committed.
4949
python3 scripts/check_consistency.py
5050
```
5151

52-
### Inspecting or verifying the derived configs
52+
### Inspecting the derived configs
5353

5454
To render the derived configs without running the generators:
5555

@@ -58,18 +58,6 @@ python3 scripts/build_configs.py <version> # writes to build/configs/
5858
python3 scripts/build_configs.py <version> --out-dir /tmp/rebuild
5959
```
6060

61-
`verify_configs.py` compares two config directories for semantic YAML equality
62-
(copyright years and comment spacing are normalized). It was used to prove that
63-
`build_configs.py` round-trips the previously committed configs, and remains
64-
useful when refactoring the generator:
65-
66-
```sh
67-
python3 scripts/verify_configs.py <dir_a> <dir_b>
68-
```
69-
70-
`import_configs.py` is the one-time migration helper that bootstrapped
71-
`modules.yaml` from the old hand-written configs.
72-
7361
## Generating documentation
7462

7563
The `generate_doc_script.py` script generates markdown API documentation for all supported Tizen versions. It scans the `configs` directory and creates or overwrites `doc/tizen<version>_api.md` for each version.

scripts/build_configs.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,10 @@
2020

2121
import yaml
2222

23+
from modules_yaml import to_upper_camel as camel
2324

24-
# -- helpers -----------------------------------------------------------------
25-
26-
def camel(name: str) -> str:
27-
return ''.join(p[:1].upper() + p[1:] for p in name.split('_') if p)
2825

26+
# -- helpers -----------------------------------------------------------------
2927

3028
def dashed(name: str) -> str:
3129
return name.replace('_', '-')
@@ -155,11 +153,17 @@ def _compiler_opts(cfg: dict, module: dict) -> list[str]:
155153
# include dirs (grouped with comments)
156154
inc = cfg.get('common_include_dirs') or {}
157155
prefix = cfg['rootstrap_prefix']
158-
groups = [
156+
# Emit known groups in their conventional order, then any other group
157+
# present in modules.yaml (so a new include group is never silently
158+
# dropped just because it isn't listed here).
159+
known = [
159160
('tizen', '# include Tizen API directories'),
160161
('efl', '# include EFL directories'),
161162
('glib', '# include glib directories'),
162163
]
164+
known_keys = {k for k, _ in known}
165+
groups = known + [(k, f'# include {k} directories')
166+
for k in inc if k not in known_keys]
163167
for key, comment in groups:
164168
paths = inc.get(key) or []
165169
if not paths:

scripts/generate_bindings.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ if [ ! -d $ROOT_DIR/rootstraps/$version ]; then
2020
fi
2121

2222
# Render symgen.yaml, entrypoints*.h, and ffigen_*.yaml from modules.yaml.
23+
# Wipe the derived config dir first so a removed/renamed module leaves no stale
24+
# ffigen_*.yaml or .symbols/*.yaml behind (everything here is regenerated).
2325
config_dir="$ROOT_DIR/build/configs/$version"
26+
rm -rf "$config_dir"
2427
python3 "$SCRIPT_DIR/build_configs.py" "$version" --out-dir "$config_dir"
2528

2629
dart run symgen --config "$config_dir/symgen.yaml"

scripts/generate_tizen.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,7 @@
33
import re
44
import argparse
55

6-
def to_camel_case(snake_str):
7-
components = snake_str.split('_')
8-
return components[0] + ''.join(x.title() for x in components[1:])
9-
10-
def to_upper_camel_case(snake_str):
11-
components = snake_str.split('_')
12-
return ''.join(x.title() for x in components)
6+
from modules_yaml import to_upper_camel
137

148
def extract_top_level_names(content):
159
"""Return {name: 'real'|'alias'} for top-level exportable declarations.
@@ -101,7 +95,7 @@ def main():
10195
# Convert to upper camel case to match class name suffix
10296
if '_' in base_name:
10397
# Handle cases like mv_barcode_detector -> MvBarcodeDetector
104-
upper_camel = to_upper_camel_case(base_name)
98+
upper_camel = to_upper_camel(base_name)
10599
else:
106100
# Handle cases like accountsSvc -> AccountsSvc
107101
upper_camel = base_name[0].upper() + base_name[1:]

0 commit comments

Comments
 (0)