Merge changes I6b780c1d,I238d963a,I32076c65 into main am: 51f1006440

Original change: https://android-review.googlesource.com/c/platform/external/dtc/+/2784358

Change-Id: I3768082e802dc56c58e59e2a4d8e246b65dd17b3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Pierre-Clément Tosi 2023-10-12 09:46:35 +00:00 committed by Automerger Merge Worker
commit dc59b8c5ce
5 changed files with 48 additions and 43 deletions

View file

@ -62,6 +62,7 @@ cc_defaults {
"-DNO_YAML"
],
generated_headers: ["dtc_version_gen.h"],
shared_libs: ["libfdt"],
stl: "none",
@ -117,3 +118,17 @@ cc_binary_host {
"util.c",
],
}
genrule {
name: "dtc_version_gen.h",
out: ["version_gen.h"],
srcs: ["version_gen.h.in"],
tool_files: [
"METADATA",
"METADATA_version.sed",
],
cmd: "version=$$("
+ "sed -f $(location METADATA_version.sed) -n $(location METADATA)"
+ ")-Android-build;"
+ "sed s/@VCS_TAG@/$${version}/ $(in) > $(out)",
}

View file

@ -18,68 +18,67 @@ cc_library(
)
genrule(
name = "lexer",
srcs = [
"dtc-lexer.l",
":parser",
],
name = "dtc_lexer_srcs",
srcs = ["dtc-lexer.l"],
outs = ["dtc-lexer.lex.c"],
cmd = "lex -o$@ $(location dtc-lexer.l)",
cmd = "lex -o $@ $<",
)
genrule(
name = "parser",
name = "dtc_parser_srcs",
srcs = ["dtc-parser.y"],
outs = [
"dtc-parser.c",
"dtc-parser.h",
],
cmd = """
bison -b dtc-parser -d $(location dtc-parser.y)
cp ./*.c $(location dtc-parser.c)
cp ./*.h $(location dtc-parser.h)
""",
cmd = "bison -d -o $(location dtc-parser.c) $(location dtc-parser.y)",
)
cc_library(
name = "dtc_gen",
UTILS = [
"util.c",
"util.h",
":version_gen_header",
]
genrule(
name = "version_gen_header",
outs = ["version_gen.h"],
srcs = [
":lexer",
":parser",
"METADATA",
"METADATA_version.sed",
"version_gen.h.in",
],
hdrs = glob(["*.h"]),
copts = COPTS,
deps = [":libfdt"],
cmd = """
version="$$(sed -f $(location METADATA_version.sed) -n $(location METADATA))-Android-build"
sed s/@VCS_TAG@/$${version}/ $(location version_gen.h.in) > $@
""",
)
cc_binary(
name = "dtc",
srcs = [
srcs = UTILS + [
":dtc_lexer_srcs",
":dtc_parser_srcs",
"checks.c",
"data.c",
"dtc.c",
"dtc.h",
"flattree.c",
"fstree.c",
"livetree.c",
"srcpos.c",
"srcpos.h",
"treesource.c",
"util.c",
],
copts = COPTS,
defines = ["NO_YAML"],
deps = [
":dtc_gen",
":libfdt",
],
deps = [":libfdt"],
)
cc_binary(
name = "fdtget",
srcs = [
srcs = UTILS + [
"fdtget.c",
"util.c",
"util.h",
"version_non_gen.h",
],
copts = COPTS,
defines = ["NO_YAML"],
@ -88,11 +87,8 @@ cc_binary(
cc_binary(
name = "fdtput",
srcs = [
srcs = UTILS + [
"fdtput.c",
"util.c",
"util.h",
"version_non_gen.h",
],
copts = COPTS,
defines = ["NO_YAML"],
@ -101,11 +97,8 @@ cc_binary(
cc_binary(
name = "fdtdump",
srcs = [
srcs = UTILS + [
"fdtdump.c",
"util.c",
"util.h",
"version_non_gen.h",
],
copts = COPTS,
defines = ["NO_YAML"],
@ -114,11 +107,8 @@ cc_binary(
cc_binary(
name = "fdtoverlay",
srcs = [
srcs = UTILS + [
"fdtoverlay.c",
"util.c",
"util.h",
"version_non_gen.h",
],
copts = COPTS,
defines = ["NO_YAML"],

1
METADATA_version.sed Normal file
View file

@ -0,0 +1 @@
s/^[[:space:]]*version:[[:space:]]*"v\([[:digit:]][[:digit:]]*.[[:digit:]][[:digit:]]*.[[:digit:]][[:digit:]]*\)"[[:space:]]*/\1/p

2
util.c
View file

@ -21,7 +21,7 @@
#include "libfdt.h"
#include "util.h"
#include "version_non_gen.h"
#include "version_gen.h"
char *xstrdup(const char *s)
{

View file

@ -1 +0,0 @@
#define DTC_VERSION "DTC 1.6.0-Android-build"