Skip to content

Add OPENCC_DICT_FORMAT CMake option to select dictionary output format - #1396

Merged
frankslin merged 1 commit into
BYVoid:masterfrom
frankslin:cmake-text-dict-output
Jul 4, 2026
Merged

frankslin merged 1 commit into
BYVoid:masterfrom
frankslin:cmake-text-dict-output

Conversation

@frankslin

Copy link
Copy Markdown
Collaborator

Adds an OPENCC_DICT_FORMAT cache variable (ocd2 / text / ocd) so CMake builds can produce compiled .ocd2 dictionaries (default), plain .txt dictionaries, or legacy Darts .ocd dictionaries, with config JSON files rewritten to match the chosen format; mirrors the text-backed resource package already produced by the Bazel opencc_resources_zip target.

Detailed Changes:

  • CMakeLists.txt:
    • Add OPENCC_DICT_FORMAT cache variable accepting ocd2, text, or ocd; selecting ocd without ENABLE_DARTS=ON fails configure with a clear error.
  • data/CMakeLists.txt:
    • text: copies raw .txt dictionaries into the build tree (the four bootstrap dictionaries still compile to .ocd2 on demand for the phrase generator); rewrites and installs config JSON files via the conversion script.
    • ocd: adds a per-dictionary .ocd build loop running opencc_dict --to ocd.
    • Both non-default formats pass the target format to the config-conversion script.
  • data/scripts/convert_config_dict_format.py (new, replaces convert_config_to_text.py):
    • Rewrites type/file dict references in config JSON to the given target format (text or ocd); includes a matching Bazel py_binary target.

Adds an OPENCC_DICT_FORMAT cache variable (ocd2 / text / ocd) so CMake builds can
produce compiled .ocd2 dictionaries (default), plain .txt dictionaries, or legacy
Darts .ocd dictionaries, with config JSON files rewritten to match the chosen format;
mirrors the text-backed resource package already produced by the Bazel
opencc_resources_zip target.

Detailed Changes:
- **CMakeLists.txt**:
  - Add `OPENCC_DICT_FORMAT` cache variable accepting `ocd2`, `text`, or `ocd`;
    selecting `ocd` without `ENABLE_DARTS=ON` fails configure with a clear error.
- **data/CMakeLists.txt**:
  - `text`: copies raw `.txt` dictionaries into the build tree (the four bootstrap
    dictionaries still compile to `.ocd2` on demand for the phrase generator); rewrites
    and installs config JSON files via the conversion script.
  - `ocd`: adds a per-dictionary `.ocd` build loop running `opencc_dict --to ocd`.
  - Both non-default formats pass the target format to the config-conversion script.
- **data/scripts/convert_config_dict_format.py** (new, replaces `convert_config_to_text.py`):
  - Rewrites `type`/`file` dict references in config JSON to the given target format
    (`text` or `ocd`); includes a matching Bazel `py_binary` target.
@frankslin
frankslin merged commit dcd4448 into BYVoid:master Jul 4, 2026
34 checks passed
@frankslin
frankslin deleted the cmake-text-dict-output branch July 4, 2026 01:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant