Skip to content

Commit 4e1faf2

Browse files
[gn] introduce build_root variable (#4352)
* [gn] introduce build_root variable * [nrfconnect] build from CHIP root directory * [pigweed] bump version * [nrfconnect] ensure the minimum gn version is installed * Restyled by gn Co-authored-by: Restyled.io <commits@restyled.io>
1 parent 8c93ec6 commit 4e1faf2

File tree

126 files changed

+416
-214
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+416
-214
lines changed

.gn

+4-3
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import("//build_overrides/build.gni")
16+
import("//build_overrides/pigweed.gni")
17+
1518
# The location of the build configuration file.
16-
buildconfig = "//build/config/BUILDCONFIG.gn"
19+
buildconfig = "${build_root}/config/BUILDCONFIG.gn"
1720

1821
# CHIP uses angle bracket includes.
1922
check_system_includes = true
2023

21-
import("//build_overrides/pigweed.gni")
22-
2324
script_executable = "python3"
2425

2526
default_args = {

BUILD.gn

+11-9
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,22 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import("//build_overrides/build.gni")
1516
import("//build_overrides/chip.gni")
1617
import("//build_overrides/mbedtls.gni")
1718
import("//build_overrides/nlassert.gni")
1819
import("//build_overrides/nlio.gni")
1920
import("//build_overrides/nlunit_test.gni")
2021
import("//build_overrides/pigweed.gni")
22+
2123
import("//src/platform/device.gni")
2224
import("$dir_pw_build/python.gni")
2325

2426
# This build file should not be used in superproject builds.
2527
assert(chip_root == "//")
2628

27-
import("${chip_root}/build/chip/tests.gni")
28-
import("${chip_root}/build/chip/tools.gni")
29+
import("${build_root}/chip/tests.gni")
30+
import("${build_root}/chip/tools.gni")
2931

3032
if (current_toolchain != "${dir_pw_toolchain}/dummy:dummy") {
3133
declare_args() {
@@ -115,7 +117,7 @@ if (current_toolchain != "${dir_pw_toolchain}/dummy:dummy") {
115117
}
116118
} else {
117119
# This is the unified build. Configure various real toolchains.
118-
import("${chip_root}/build/chip/chip_build.gni")
120+
import("${build_root}/chip/chip_build.gni")
119121
declare_args() {
120122
# Set this to false to disable all builds by default.
121123
enable_default_builds = true
@@ -179,13 +181,13 @@ if (current_toolchain != "${dir_pw_toolchain}/dummy:dummy") {
179181

180182
if (enable_host_clang_build) {
181183
chip_build("host_clang") {
182-
toolchain = "//build/toolchain/host:${host_os}_${host_cpu}_clang"
184+
toolchain = "${build_root}/toolchain/host:${host_os}_${host_cpu}_clang"
183185
}
184186
}
185187

186188
if (enable_host_gcc_build) {
187189
chip_build("host_gcc") {
188-
toolchain = "//build/toolchain/host:${host_os}_${host_cpu}_gcc"
190+
toolchain = "${build_root}/toolchain/host:${host_os}_${host_cpu}_gcc"
189191
}
190192
}
191193

@@ -197,19 +199,19 @@ if (current_toolchain != "${dir_pw_toolchain}/dummy:dummy") {
197199

198200
if (enable_android_builds) {
199201
chip_build("android_arm") {
200-
toolchain = "//build/toolchain/android:android_arm"
202+
toolchain = "${build_root}/toolchain/android:android_arm"
201203
}
202204

203205
chip_build("android_arm64") {
204-
toolchain = "//build/toolchain/android:android_arm64"
206+
toolchain = "${build_root}/toolchain/android:android_arm64"
205207
}
206208

207209
chip_build("android_x64") {
208-
toolchain = "//build/toolchain/android:android_x64"
210+
toolchain = "${build_root}/toolchain/android:android_x64"
209211
}
210212

211213
chip_build("android_x86") {
212-
toolchain = "//build/toolchain/android:android_x86"
214+
toolchain = "${build_root}/toolchain/android:android_x86"
213215
}
214216
}
215217

build/chip/buildconfig_header.gni

+2-1
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,15 @@
101101
# ]
102102
# }
103103

104+
import("//build_overrides/build.gni")
104105
import("//build_overrides/chip.gni")
105106

106107
template("buildconfig_header") {
107108
source_set_name = target_name
108109
gen_target_name = "gen_${target_name}"
109110

110111
action(gen_target_name) {
111-
script = "${chip_root}/build/chip/write_buildconfig_header.py"
112+
script = "${build_root}/chip/write_buildconfig_header.py"
112113

113114
if (defined(invoker.header_dir)) {
114115
header_file = "${invoker.header_dir}/${invoker.header}"

build/chip/chip_build.gni

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import("//build_overrides/chip.gni")
15+
import("//build_overrides/build.gni")
1616

17-
import("${chip_root}/build/chip/tests.gni")
17+
import("${build_root}/chip/tests.gni")
1818

1919
template("chip_build") {
2020
_build_name = target_name

build/chip/chip_test.gni

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import("//build_overrides/build.gni")
1516
import("//build_overrides/chip.gni")
1617
import("//build_overrides/pigweed.gni")
18+
1719
import("$dir_pw_build/python_action.gni")
1820

19-
import("${chip_root}/build/chip/tests.gni")
21+
import("${build_root}/chip/tests.gni")
2022
import("${chip_root}/src/platform/device.gni")
2123
import("${dir_pw_unit_test}/test.gni")
2224

build/chip/chip_test_group.gni

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import("//build_overrides/chip.gni")
15+
import("//build_overrides/build.gni")
1616

17-
import("${chip_root}/build/chip/tests.gni")
17+
import("${build_root}/chip/tests.gni")
1818

1919
assert(chip_build_tests)
2020

build/chip/chip_test_suite.gni

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import("//build_overrides/build.gni")
1516
import("//build_overrides/chip.gni")
1617

17-
import("${chip_root}/build/chip/chip_test.gni")
18-
import("${chip_root}/build/chip/tests.gni")
18+
import("${build_root}/chip/chip_test.gni")
19+
import("${build_root}/chip/tests.gni")
1920
import("${dir_pw_unit_test}/test.gni")
2021

2122
assert(chip_build_tests)

build/chip/happy_test.gni

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import("//build_overrides/build.gni")
1516
import("//build_overrides/chip.gni")
1617

17-
import("${chip_root}/build/chip/tests.gni")
18+
import("${build_root}/chip/tests.gni")
1819

1920
assert(chip_build_tests)
2021
assert(chip_enable_happy_tests)

build/chip/java/BUILD.gn

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import("//build_overrides/chip.gni")
15+
import("//build_overrides/build.gni")
1616

17-
import("//build/config/android/config.gni")
18-
import("//build/config/android_abi.gni")
17+
import("${build_root}/config/android/config.gni")
18+
import("${build_root}/config/android_abi.gni")
1919

2020
# Place a copy of the shared c++ support library in the jni output directory
2121
# See:

build/chip/java/rules.gni

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import("//build_overrides/chip.gni")
15+
import("//build_overrides/build.gni")
1616

17-
import("//build/config/android/config.gni")
17+
import("${build_root}/config/android/config.gni")
1818

19-
javac_runner = "${chip_root}/build/chip/java/javac_runner.py"
20-
jar_runner = "${chip_root}/build/chip/java/jar_runner.py"
19+
javac_runner = "${build_root}/chip/java/javac_runner.py"
20+
jar_runner = "${build_root}/chip/java/jar_runner.py"
2121

2222
assert(android_sdk_root != "", "android_sdk_root must be specified")
2323

build/chip/linux/BUILD.gn

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import("//build/config/linux/pkg_config.gni")
15+
import("//build_overrides/build.gni")
16+
17+
import("${build_root}/config/linux/pkg_config.gni")
1618

1719
pkg_config("glib") {
1820
packages = [

build/config/BUILDCONFIG.gn

+16-11
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,16 @@ if (current_os == "") {
3232
current_os = target_os
3333
}
3434

35-
_chip_overrides = {
36-
import("//build_overrides/chip.gni")
35+
_build_overrides = {
36+
import("//build_overrides/build.gni")
3737
}
3838

3939
_pigweed_overrides = {
4040
import("//build_overrides/pigweed.gni")
4141
}
4242

4343
_chip_defaults = {
44-
import("//build/config/defaults.gni")
44+
import("${_build_overrides.build_root}/config/defaults.gni")
4545
}
4646

4747
declare_args() {
@@ -51,9 +51,9 @@ declare_args() {
5151

5252
if (host_toolchain == "") {
5353
if (_chip_defaults.is_clang) {
54-
host_toolchain = "//build/toolchain/host:${host_os}_${host_cpu}_clang"
54+
host_toolchain = "${_build_overrides.build_root}/toolchain/host:${host_os}_${host_cpu}_clang"
5555
} else {
56-
host_toolchain = "//build/toolchain/host:${host_os}_${host_cpu}_gcc"
56+
host_toolchain = "${_build_overrides.build_root}/toolchain/host:${host_os}_${host_cpu}_gcc"
5757
}
5858
}
5959

@@ -65,24 +65,29 @@ if (_chip_defaults.custom_toolchain != "") {
6565
_default_toolchain = "${_pigweed_overrides.dir_pw_toolchain}/dummy"
6666
} else if (target_os == "freertos") {
6767
if (target_cpu == "arm") {
68-
_default_toolchain = "//build/toolchain/arm_gcc"
68+
_default_toolchain = "${_build_overrides.build_root}/toolchain/arm_gcc"
6969
} else {
7070
assert(false, "Unsupported target_cpu: ${target_cpu}")
7171
}
7272
} else if (target_os == "android") {
7373
if (current_cpu == "arm") {
74-
_default_toolchain = "//build/toolchain/android:android_arm"
74+
_default_toolchain =
75+
"${_build_overrides.build_root}/toolchain/android:android_arm"
7576
} else if (current_cpu == "arm64") {
76-
_default_toolchain = "//build/toolchain/android:android_arm64"
77+
_default_toolchain =
78+
"${_build_overrides.build_root}/toolchain/android:android_arm64"
7779
} else if (current_cpu == "x64") {
78-
_default_toolchain = "//build/toolchain/android:android_x64"
80+
_default_toolchain =
81+
"${_build_overrides.build_root}/toolchain/android:android_x64"
7982
} else if (current_cpu == "x86") {
80-
_default_toolchain = "//build/toolchain/android:android_x86"
83+
_default_toolchain =
84+
"${_build_overrides.build_root}/toolchain/android:android_x86"
8185
} else {
8286
assert(false, "Unsupported target_cpu: ${current_cpu}")
8387
}
8488
} else if (target_os == "ios") {
85-
_default_toolchain = "//build/toolchain/ios:ios_${target_cpu}"
89+
_default_toolchain =
90+
"${_build_overrides.build_root}/toolchain/ios:ios_${target_cpu}"
8691
} else {
8792
assert(false, "No toolchain specified, please specify custom_toolchain")
8893
}

build/config/arm.gni

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import("//build_overrides/build.gni")
16+
1517
if (current_cpu == "arm" || current_cpu == "arm64") {
1618
declare_args() {
1719
# Build file to import for ARM defaults.
@@ -20,7 +22,7 @@ if (current_cpu == "arm" || current_cpu == "arm64") {
2022

2123
if (arm_platform_config == "") {
2224
if (current_os == "android") {
23-
arm_platform_config = "//build/toolchain/android/android_arm.gni"
25+
arm_platform_config = "${build_root}/toolchain/android/android_arm.gni"
2426
}
2527
}
2628

build/config/compiler/BUILD.gn

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import("//build_overrides/chip.gni")
15+
import("//build_overrides/build.gni")
1616
import("//build_overrides/pigweed.gni")
1717

18-
import("//build/config/compiler/compiler.gni")
19-
import("//build/config/target.gni")
18+
import("${build_root}/config/compiler/compiler.gni")
19+
import("${build_root}/config/target.gni")
2020

2121
declare_args() {
2222
# Enable -Werror. This can be disabled if using a different compiler
@@ -28,9 +28,9 @@ _is_embedded_arm = current_os != "ios" && current_os != "mac_os" &&
2828
(current_cpu == "arm" || current_cpu == "arm64")
2929

3030
if (_is_embedded_arm) {
31-
import("//build/config/arm.gni")
31+
import("${build_root}/config/arm.gni")
3232
} else if (current_cpu == "x86" || current_cpu == "x86_64") {
33-
import("//build/config/x86.gni")
33+
import("${build_root}/config/x86.gni")
3434
}
3535

3636
config("release") {

0 commit comments

Comments
 (0)