Merge changes I6b780c1d,I238d963a,I32076c65 into main
* changes: ANDROID: Generate version_gen.h in Soong and Bazel ANDROID: bazel: Clean up lexer and parser rules ANDROID: bazel: Fix dtc header dependencies
This commit is contained in:
commit
51f1006440
5 changed files with 48 additions and 43 deletions
15
Android.bp
15
Android.bp
|
@ -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)",
|
||||
}
|
||||
|
|
72
BUILD.bazel
72
BUILD.bazel
|
@ -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
1
METADATA_version.sed
Normal file
|
@ -0,0 +1 @@
|
|||
s/^[[:space:]]*version:[[:space:]]*"v\([[:digit:]][[:digit:]]*.[[:digit:]][[:digit:]]*.[[:digit:]][[:digit:]]*\)"[[:space:]]*/\1/p
|
2
util.c
2
util.c
|
@ -21,7 +21,7 @@
|
|||
|
||||
#include "libfdt.h"
|
||||
#include "util.h"
|
||||
#include "version_non_gen.h"
|
||||
#include "version_gen.h"
|
||||
|
||||
char *xstrdup(const char *s)
|
||||
{
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
#define DTC_VERSION "DTC 1.6.0-Android-build"
|
Loading…
Reference in a new issue