Merge changes I8efee39a,I5295898f into main
* changes:
FROMGIT: libfdt: fdt_path_offset_namelen: Reject empty path
ANDROID: Revert "libfdt: fdt_path_offset_namelen: Reject empty paths"
diff --git a/Android.bp b/Android.bp
index cb13748..2d121ec 100644
--- a/Android.bp
+++ b/Android.bp
@@ -44,16 +44,25 @@
}
cc_defaults {
- name: "dt_defaults",
+ name: "dtc_cflags_defaults",
cflags: [
"-Wall",
"-Werror",
- "-Wno-sign-compare",
+ "-Wno-macro-redefined",
"-Wno-missing-field-initializers",
+ "-Wno-sign-compare",
"-Wno-unused-parameter",
+ ],
+}
+
+cc_defaults {
+ name: "dt_defaults",
+ defaults: ["dtc_cflags_defaults"],
+ cflags: [
"-DNO_YAML"
],
+ generated_headers: ["dtc_version_gen.h"],
shared_libs: ["libfdt"],
stl: "none",
@@ -109,3 +118,17 @@
"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)",
+}
diff --git a/BUILD.bazel b/BUILD.bazel
index 439621d..56aeed2 100644
--- a/BUILD.bazel
+++ b/BUILD.bazel
@@ -1,88 +1,84 @@
+COPTS = [
+ "-Wall",
+ "-Werror",
+ "-Wno-macro-redefined",
+ "-Wno-missing-field-initializers",
+ "-Wno-sign-compare",
+ "-Wno-unused-parameter",
+]
+
cc_library(
name = "libfdt",
srcs = glob([
"libfdt/*.h",
"libfdt/*.c",
]),
- copts = [
- "-Werror",
- "-Wno-macro-redefined",
- "-Wno-sign-compare",
- ],
+ copts = COPTS,
includes = ["libfdt"],
)
-COPTS = [
- "-Wall",
- "-Werror",
- "-Wno-sign-compare",
- "-Wno-missing-field-initializers",
- "-Wno-unused-parameter",
-]
-
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"],
@@ -91,11 +87,8 @@
cc_binary(
name = "fdtput",
- srcs = [
+ srcs = UTILS + [
"fdtput.c",
- "util.c",
- "util.h",
- "version_non_gen.h",
],
copts = COPTS,
defines = ["NO_YAML"],
@@ -104,11 +97,8 @@
cc_binary(
name = "fdtdump",
- srcs = [
+ srcs = UTILS + [
"fdtdump.c",
- "util.c",
- "util.h",
- "version_non_gen.h",
],
copts = COPTS,
defines = ["NO_YAML"],
@@ -117,11 +107,8 @@
cc_binary(
name = "fdtoverlay",
- srcs = [
+ srcs = UTILS + [
"fdtoverlay.c",
- "util.c",
- "util.h",
- "version_non_gen.h",
],
copts = COPTS,
defines = ["NO_YAML"],
diff --git a/METADATA_version.sed b/METADATA_version.sed
new file mode 100644
index 0000000..9e7ea54
--- /dev/null
+++ b/METADATA_version.sed
@@ -0,0 +1 @@
+s/^[[:space:]]*version:[[:space:]]*"v\([[:digit:]][[:digit:]]*.[[:digit:]][[:digit:]]*.[[:digit:]][[:digit:]]*\)"[[:space:]]*/\1/p
diff --git a/libfdt/Android.bp b/libfdt/Android.bp
index 8f4bdfd..0bf631a 100644
--- a/libfdt/Android.bp
+++ b/libfdt/Android.bp
@@ -7,12 +7,7 @@
cc_library {
name: "libfdt",
host_supported: true,
-
- cflags: [
- "-Werror",
- "-Wno-macro-redefined",
- "-Wno-sign-compare",
- ],
+ defaults: ["dtc_cflags_defaults"],
srcs: [
"fdt.c",
"fdt_check.c",
diff --git a/util.c b/util.c
index 197fb19..507f012 100644
--- a/util.c
+++ b/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)
{
diff --git a/version_non_gen.h b/version_non_gen.h
deleted file mode 100644
index 3376b35..0000000
--- a/version_non_gen.h
+++ /dev/null
@@ -1 +0,0 @@
-#define DTC_VERSION "DTC 1.6.0-Android-build"