xref: /aosp_15_r20/external/dtc/Android.bp (revision cd60bc56d4bea3af4ec04523e4d71c2b272c8aff)
1// Copyright 2016 The Android Open Source Project
2package {
3    default_applicable_licenses: ["external_dtc_license"],
4}
5
6// Added automatically by a large-scale-change that took the approach of
7// 'apply every license found to every target'. While this makes sure we respect
8// every license restriction, it may not be entirely correct.
9//
10// e.g. GPL in an MIT project might only apply to the contrib/ directory.
11//
12// Please consider splitting the single license below into multiple licenses,
13// taking care not to lose any license_kind information, and overriding the
14// default license using the 'licenses: [...]' property on targets as needed.
15//
16// For unused files, consider creating a 'fileGroup' with "//visibility:private"
17// to attach the license to, and including a comment whether the files may be
18// used in the current project.
19//
20// large-scale-change included anything that looked like it might be a license
21// text as a license_text. e.g. LICENSE, NOTICE, COPYING etc.
22//
23// Please consider removing redundant or irrelevant files from 'license_text:'.
24// See: http://go/android-license-faq
25license {
26    name: "external_dtc_license",
27    visibility: [":__subpackages__"],
28    license_kinds: ["SPDX-license-identifier-GPL-2.0"],
29    license_text: ["GPL"],
30}
31
32license {
33    name: "external_dtc_libfdt_license",
34    visibility: [":__subpackages__"],
35    license_kinds: ["SPDX-license-identifier-BSD-2-Clause"],
36    license_text: ["BSD-2-Clause"],
37}
38
39license {
40    name: "external_dtc_tests_license",
41    visibility: [":__subpackages__"],
42    license_kinds: ["SPDX-license-identifier-LGPL-2.1+"],
43    license_text: ["LGPL"],
44}
45
46cc_defaults {
47    name: "dtc_cflags_defaults",
48    cflags: [
49        "-Wall",
50        "-Werror",
51        "-Wno-macro-redefined",
52        "-Wno-missing-field-initializers",
53        "-Wno-sign-compare",
54        "-Wno-unused-parameter",
55    ],
56}
57
58cc_defaults {
59    name: "dt_defaults",
60    defaults: ["dtc_cflags_defaults"],
61    cflags: [
62        "-DNO_YAML",
63    ],
64
65    generated_headers: ["dtc_version_gen.h"],
66    shared_libs: ["libfdt"],
67
68    stl: "none",
69    target: {
70        host: {
71            dist: {
72                targets: [
73                    "dist_files",
74                ],
75                dir: "dtc",
76            },
77        },
78    },
79}
80
81cc_defaults {
82    name: "dtc_defaults",
83    defaults: ["dt_defaults"],
84    srcs: [
85        "checks.c",
86        "data.c",
87        "dtc.c",
88        "dtc-lexer.l",
89        "dtc-parser.y",
90        "flattree.c",
91        "fstree.c",
92        "livetree.c",
93        "srcpos.c",
94        "treesource.c",
95        "util.c",
96    ],
97}
98
99cc_binary {
100    name: "dtc_static",
101    defaults: ["dtc_defaults"],
102    static_executable: true,
103    // TODO(b/373646042): this is a workaround for failed link
104    sanitize: {
105        hwaddress: false,
106    },
107    installable: false, // test only
108}
109
110cc_binary_host {
111    name: "dtc",
112    defaults: ["dtc_defaults"],
113}
114
115cc_binary_host {
116    name: "fdtget",
117    defaults: ["dt_defaults"],
118    srcs: [
119        "fdtget.c",
120        "util.c",
121    ],
122}
123
124cc_binary_host {
125    name: "fdtoverlay",
126    defaults: ["dt_defaults"],
127    srcs: [
128        "fdtoverlay.c",
129        "util.c",
130    ],
131}
132
133cc_binary_host {
134    name: "fdtdump",
135    defaults: ["dt_defaults"],
136    srcs: [
137        "fdtdump.c",
138        "util.c",
139    ],
140}
141
142sh_binary_host {
143    name: "dtdiff",
144    src: "dtdiff",
145    required: ["dtc"],
146}
147
148genrule {
149    name: "dtc_version_gen.h",
150    out: ["version_gen.h"],
151    srcs: ["version_gen.h.in"],
152    tool_files: [
153        "METADATA",
154        "METADATA_version.sed",
155    ],
156    cmd: "version=$$(" +
157        "sed -f $(location METADATA_version.sed) -n $(location METADATA)" +
158        ")-Android-build;" +
159        "sed s/@VCS_TAG@/$${version}/ $(in) > $(out)",
160}
161
162dirgroup {
163    name: "trusty_dirgroup_external_dtc",
164    dirs: ["."],
165    visibility: ["//trusty/vendor/google/aosp/scripts"],
166}
167