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
Simplify the build file as
- dtc_gen creates an unnecessarily broad (and confusing) dependency list
by using glob([".h"]) as its header list. Instead, dtc now lists
explicitly the few headers it actually needs;
- generating dtc-lexer.lex.c does not require dtc-parser.{c,h};
- Bison can be told to directly create dtc-parser.{c,h} so no need for
an unnecessarily broad copying of *.[ch] to move some intermediate
results.
As a result, we get two genrule() wrapping the source files respectively
generated through lex and bison, which can be listed as srcs of dtc.
Test: bazel build //:all
Change-Id: I238d963af8a338c46f39c8ba9e4314fe536948cf
As dtc compiles util.c, which includes util.h and version_non_gen.h
(or version_gen.h upstream), the cc_binary should list those
dependencies explicitly so that a change in them triggers a rebuild.
Furthermore, dtc also depends on dtc.h and srcpos.h, which are only
found as dependencies by Bazel through the overkill glob(["*.h"]) header
list of dtc_gen so list them explicitly here so that that cc_library can
be dropped.
Introduce the UTILS list to DRY the build file.
Test: bazel build //:dtc
Change-Id: I32076c65b60820dc91f6dc84c3ee3cad310c1db5
Build libfdt with the same warnings as the DTC tools. This effectively
starts using -Wno-missing-field-initializers, -Wno-unused-parameter, and
-Wall.
Test: m libfdt
Test: bazel build //:libfdt
Change-Id: I5a2ae1ee86b4613d0aa7a0174d235976d7be45cc
As we use the flag when building libfdt, also enable it for the tools.
Test: m dtc fdtget fdtoverlay
Test: bazel build //:all
Change-Id: I3c0775436bb9be1367e1937e99a6e87d1dce664c
Currently, the dtc project builds with Make.
As some consumers of this project use Bazel, and eventually all of
AOSP will need to move to Bazel anyway, add a a Bazel build
definition.
Bug: 251879933
Change-Id: I62ea59ee306eda58b764df2a9e5f2f33778e4b5c
Signed-off-by: John Moon <quic_johmoo@quicinc.com>