tools/make_version.py resolves several of its inputs implicitly:
tools/utils.py:92–93 computes DART_DIR = abspath(__file__ + '/../..') and
VERSION_FILE = os.path.join(DART_DIR, 'tools', 'VERSION').
make_version.py reads runtime/vm/<file> for each entry in
VM_SNAPSHOT_FILES (a hardcoded list in the script) to compute the snapshot
MD5 hash.
- The script shells out to
git from inside DART_DIR for the SDK hash
unless --no-git-hash is passed.
Consequences:
- The script can only run from a checked-out SDK tree at the expected on-disk
layout. Vendored Dart copies, sandboxed CI builds, and any build system that
stages inputs into a different directory all need workarounds.
- The script's input set is not declared anywhere a build system can read.
GN today approximates this by listing the snapshot files manually in
runtime/BUILD.gn:419–435's inputs = [...] block. The two lists (the
Python VM_SNAPSHOT_FILES constant and the GN inputs array) must stay in
sync by convention, with no enforcement. They have drifted before and will
drift again.
- CI builds that want a deterministic version string must work around the
implicit git shell-out (e.g., by clobbering PATH).
Why this is an improvement on its own
- Declarative inputs make incremental rebuilds correct: editing
dart.cc
triggers a version.cc regeneration regardless of build system.
- The script becomes reusable: vendored Dart, custom embedders, code-search
indexers, internal CI pipelines all benefit.
- Removes the implicit two-list drift between
VM_SNAPSHOT_FILES in Python and
inputs = [...] in GN.
- A single source of truth for which files affect snapshot compatibility.
How it makes Bazel (and any other non-GN build) easier
Bazel genrule()s require every input to be declared in srcs so the
sandbox can stage it. Matching the staged file set against the Python
VM_SNAPSHOT_FILES list is fragile — any new entry on either side breaks the
genrule silently or with a confusing error. With explicit CLI flags, the
genrule passes its declared inputs directly.
Proposed change (sketch)
Add CLI flags to make_version.py and utils.py:
--dart-dir <path> — overrides __file__-derived DART_DIR
--version-file <path> — overrides tools/VERSION lookup (already partially
threaded through --version-file; complete the plumbing)
--snapshot-files <list> — explicit set of files to hash for
{{SNAPSHOT_HASH}}, replacing the hardcoded VM_SNAPSHOT_FILES constant
--git-hash <hash-or-empty> — accept the SDK hash explicitly instead of
shelling out to git
Keep current behavior as defaults so existing callers don't break.
Affected code
tools/make_version.py — input resolution, arg parsing, VM_SNAPSHOT_FILES
constant
tools/utils.py:92–93 — DART_DIR, VERSION_FILE resolution
tools/utils.py:362,380,419,439,454,469 — GetVersion, GetChannel,
GetGitRevision, GetShortGitHash, GetGitTimestamp,
GetGitTimestampForDpkg — all anchor on DART_DIR
runtime/BUILD.gn:410–455 — action("generate_version_cc_file"), the
inputs = [...] list that has to be kept in sync with VM_SNAPSHOT_FILES
tools/make_version.pyresolves several of its inputs implicitly:tools/utils.py:92–93computesDART_DIR = abspath(__file__ + '/../..')andVERSION_FILE = os.path.join(DART_DIR, 'tools', 'VERSION').make_version.pyreadsruntime/vm/<file>for each entry inVM_SNAPSHOT_FILES(a hardcoded list in the script) to compute the snapshotMD5 hash.
gitfrom insideDART_DIRfor the SDK hashunless
--no-git-hashis passed.Consequences:
layout. Vendored Dart copies, sandboxed CI builds, and any build system that
stages inputs into a different directory all need workarounds.
GN today approximates this by listing the snapshot files manually in
runtime/BUILD.gn:419–435'sinputs = [...]block. The two lists (thePython
VM_SNAPSHOT_FILESconstant and the GNinputsarray) must stay insync by convention, with no enforcement. They have drifted before and will
drift again.
implicit
gitshell-out (e.g., by clobberingPATH).Why this is an improvement on its own
dart.cctriggers a
version.ccregeneration regardless of build system.indexers, internal CI pipelines all benefit.
VM_SNAPSHOT_FILESin Python andinputs = [...]in GN.How it makes Bazel (and any other non-GN build) easier
Bazel
genrule()s require every input to be declared insrcsso thesandbox can stage it. Matching the staged file set against the Python
VM_SNAPSHOT_FILESlist is fragile — any new entry on either side breaks thegenrule silently or with a confusing error. With explicit CLI flags, the
genrule passes its declared inputs directly.
Proposed change (sketch)
Add CLI flags to
make_version.pyandutils.py:--dart-dir <path>— overrides__file__-derived DART_DIR--version-file <path>— overridestools/VERSIONlookup (already partiallythreaded through
--version-file; complete the plumbing)--snapshot-files <list>— explicit set of files to hash for{{SNAPSHOT_HASH}}, replacing the hardcodedVM_SNAPSHOT_FILESconstant--git-hash <hash-or-empty>— accept the SDK hash explicitly instead ofshelling out to
gitKeep current behavior as defaults so existing callers don't break.
Affected code
tools/make_version.py— input resolution, arg parsing,VM_SNAPSHOT_FILESconstant
tools/utils.py:92–93—DART_DIR,VERSION_FILEresolutiontools/utils.py:362,380,419,439,454,469—GetVersion,GetChannel,GetGitRevision,GetShortGitHash,GetGitTimestamp,GetGitTimestampForDpkg— all anchor onDART_DIRruntime/BUILD.gn:410–455—action("generate_version_cc_file"), theinputs = [...]list that has to be kept in sync withVM_SNAPSHOT_FILES