Skip to content

List every DM_* environment switch the code reads, with its meaning - #318

Closed
v0lumehi wants to merge 1 commit into
seedds:mainfrom
v0lumehi:env-switches
Closed

v0lumehi wants to merge 1 commit into
seedds:mainfrom
v0lumehi:env-switches

Conversation

@v0lumehi

Copy link
Copy Markdown
Contributor

Every DM_* environment switch the code reads, in one table with its meaning

The host, the apps and the tools read their switches from the environment through getenv("DM_...") and os.environ, but nothing listed them. Of the 257 switches the code reads today, 70 were mentioned in no doc at all. The rest were spread over the game notes, the references, the agents' guides and code comments. And a removed one could linger in the docs (#312).

This adds docs/env_switches.tsv, one row per switch:

column from
name the sources
class: player (15), path (40), switch (78), diagnostic (122), test (2) kept by hand
meaning: one line, e.g. `=<MB>` logs every 30 s how much of each window of that size in the alias region is mapped kept by hand
since: the commit that introduced the switch, so a reviewer can check the meaning against it kept by hand
read in, documented in the sources

The 257 are 255 read by the host, the apps and the tools, and 2 read only by tests.

  • dm/tools/env_switches.py writes the table. It takes the generated columns from the sources and carries the hand-kept ones over.

  • dm/tools/tests/test_env_switches.py runs env_switches.py --check in CI's tool tests. It works as a ratchet: today's 257 are the baseline. It fails when:

    • a new getenv("DM_...") has no row and meaning;
    • a row names a switch nothing reads any more;
    • a row has no meaning.

    I checked that adding an unlisted getenv("DM_FAKE_NEW") fails it.

  • dm/tools/env_switch_draft.py <name> gathers what is known about a switch, for whoever writes or reviews a row:

    • the line that reads it and the code comments that name it;
    • the commit that introduced it, and for a removed switch the commit that removed it, each with the paragraph of its message that names it;
    • the doc lines that mention it.

    The history comes from one git log -p pass, plus git log -S for names only shell scripts read. It is cached in .git.

  • docs/development.md. Its tool table links the table.

The meanings were drafted from that material and checked against the code. None had to be left as "unclear".

One finding: DM_MOVIE is read into g_flag.movie, and nothing reads that flag, so it has no effect; its row says so. I left the code alone: this PR changes no getenv and no runtime behaviour.

Checked

  • test_env_switches passes, and fails with an unlisted switch added.
  • test_docs passes.
  • ci.sh (host tests, CPU gfx tests, every gfx test built, dmhost for three profiles, the iOS compile check, all tool tests): no failures.

docs/env_switches.tsv has one row per switch: 257 in all, 255 read by the host, the apps and the tools, and 2 read only by tests. Each row gives:
- the name;
- the class: 15 player, 40 path, 78 switch, 122 diagnostic, 2 test;
- a one-line meaning;
- since: the commit that introduced the switch, so a reviewer can check the meaning against it;
- the files that read it and the docs that mention it.
Before this, 70 of the 257 were mentioned in no doc.

dm/tools/env_switches.py writes the table. "read in" and "documented in" come from the sources; class, meaning and since are kept by hand and carried over. test_env_switches.py runs `env_switches.py --check`, which fails on:
- a switch read but not listed, so a new getenv("DM_...") needs its row and meaning;
- a row for a switch nothing reads any more;
- a row without a meaning.

dm/tools/env_switch_draft.py gathers the material for a meaning:
- the reading line and the code comments that name the switch;
- the commit that introduced it, and for a removed one the commit that removed it, each with the paragraph of its message that names it;
- the doc lines that mention it.
The commits come from one pass over the history (git log -p, with git log -S for names only shell scripts read), cached in .git per revision.

The meanings were drafted from that material and reviewed against the code; none is marked "unclear". One finding: DM_MOVIE is read into g_flag.movie, and nothing reads that flag.

docs/development.md's tool table links the table. No getenv changes.
seedds added a commit that referenced this pull request Oct 26, 2026
…318)

Add docs/env_switches.tsv, one row per switch with its class (player, path,
switch, diagnostic, test) and a one-line meaning: 257 switches, 70 of which
no doc mentioned before. dm/tools/env_switches.py writes it from the sources
and keeps the hand-written class and meaning; test_env_switches.py fails when
the code reads a switch the table does not list, when a row names a switch
nothing reads any more, or when a row has no meaning. It also prints the
names the docs quote that nothing reads.

The check compares only the set of names, so mentioning a switch in a doc,
moving a file or reading a switch in a second place does not fail it. A
macro name stays listed when the code also reads it from the environment
(DM_GAME_ENV overrides the profile's macro of that name).

Remove DM_MOVIE: it set g_flag.movie, which nothing read.

Validation: test_env_switches and test_docs pass; a doc mention of an
undocumented switch passes the check and an unlisted getenv fails it; the
Mac host builds for Mario's profile.

Co-authored-by: v0lumehi <34629096+v0lumehi@users.noreply.github.com>
@seedds

seedds commented Oct 26, 2026

Copy link
Copy Markdown
Owner

Thanks. This landed on main as cc626e7, squashed with some changes and with you as co-author:

  • DM_GAME_ENV was missing. The macro filter dropped it because the generated profile header also defines it as a macro, though hle_os.c reads it with getenv. A macro name now stays in the table when the code also reads it from the environment, and it has a row.
  • The check compares only the set of names, class and meaning. With the generated "read in" / "documented in" columns, mentioning an undocumented switch in any doc, moving a file, or reading a switch in a second place failed CI until the table was written again. The table now has three columns: name, class and meaning. The class definitions are in the tool's row in docs/development.md, and the file has a single header row so GitHub renders it as a table.
  • "since" was dropped. A new row can't name the commit that adds it before that commit exists, and the history search finds it anyway.
  • env_switch_draft.py was dropped. It defaulted to upstream/main, which this repository doesn't have, and the meanings are written now.
  • DM_MOVIE was removed with g_flag.movie, since nothing read it.

Your meanings went in unchanged. The tool still prints the names the docs quote that nothing reads, which is what #312 covers.

@seedds seedds closed this Oct 26, 2026
@v0lumehi
v0lumehi deleted the env-switches branch October 26, 2026 19:41
Know-It-All-Brother pushed a commit to Know-It-All-Brother/nxnative that referenced this pull request Nov 9, 2026
…eedds#318)

Add docs/env_switches.tsv, one row per switch with its class (player, path,
switch, diagnostic, test) and a one-line meaning: 257 switches, 70 of which
no doc mentioned before. dm/tools/env_switches.py writes it from the sources
and keeps the hand-written class and meaning; test_env_switches.py fails when
the code reads a switch the table does not list, when a row names a switch
nothing reads any more, or when a row has no meaning. It also prints the
names the docs quote that nothing reads.

The check compares only the set of names, so mentioning a switch in a doc,
moving a file or reading a switch in a second place does not fail it. A
macro name stays listed when the code also reads it from the environment
(DM_GAME_ENV overrides the profile's macro of that name).

Remove DM_MOVIE: it set g_flag.movie, which nothing read.

Validation: test_env_switches and test_docs pass; a doc mention of an
undocumented switch passes the check and an unlisted getenv fails it; the
Mac host builds for Mario's profile.

Co-authored-by: v0lumehi <34629096+v0lumehi@users.noreply.github.com>
ltrdpper pushed a commit to ltrdpper/BananaNative that referenced this pull request Nov 16, 2026
…ines; large files are read one at a time' (seedds#318) from Wick3dPhant0m/BananaNative:split-large-files into android

Reviewed-on: https://git.eden-emu.dev/moceure/BananaNative/pulls/318
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.

2 participants