platform_external_dtc/METADATA_version.sed
Pierre-Clément Tosi 7eeadceb3e ANDROID: Generate version_gen.h in Soong and Bazel
Upstream provides a DTC_VERSION preprocessor macro to its C code by
generating a version_gen.h header from either of its supported build
systems: Make formats the header from its internal variables (VERSION,
PATCHLEVEL, SUBLEVEL, ...) while Meson uses its vcs_tag() function on
a template, version_gen.h.in.

As AOSP doesn't make use of these build systems, aosp/204511 decided to
hardcode a version_non_gen.h file and patch the corresponding #include.
This unsurprisingly ended up bitrotting as the repo was being upgraded.

Instead, replicate the version_gen.h.in patching in our build systems,
extracting the version number from the METADATA file, which
external_updater.sh will keep up-to-date. Note that this introduces a
dependency on sed in the genrule(), the impact of which is minimized by
making METADATA_version.sed POSIX-compliant.

Keep appending the suffix '-Android-build' to the upstream version.

Test: m dtc && ${ANDROID_HOST_OUT}/bin/dtc --version
Test: bazel build //:dtc && bazel-bin/dtc --version
Change-Id: I6b780c1dbe14d415891defeb652f0692988ed0b1
2023-10-11 19:15:08 +01:00

1 line
131 B
Sed

s/^[[:space:]]*version:[[:space:]]*"v\([[:digit:]][[:digit:]]*.[[:digit:]][[:digit:]]*.[[:digit:]][[:digit:]]*\)"[[:space:]]*/\1/p