Skip to content

Commit

Permalink
[gn] introduce build_root variable (project-chip#4352)
Browse files Browse the repository at this point in the history
* [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>
  • Loading branch information
LuDuda and restyled-commits authored Jan 27, 2021
1 parent 8c93ec6 commit 4e1faf2
Show file tree
Hide file tree
Showing 126 changed files with 416 additions and 214 deletions.
7 changes: 4 additions & 3 deletions .gn
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import("//build_overrides/build.gni")
import("//build_overrides/pigweed.gni")

# The location of the build configuration file.
buildconfig = "//build/config/BUILDCONFIG.gn"
buildconfig = "${build_root}/config/BUILDCONFIG.gn"

# CHIP uses angle bracket includes.
check_system_includes = true

import("//build_overrides/pigweed.gni")

script_executable = "python3"

default_args = {
Expand Down
20 changes: 11 additions & 9 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,22 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import("//build_overrides/build.gni")
import("//build_overrides/chip.gni")
import("//build_overrides/mbedtls.gni")
import("//build_overrides/nlassert.gni")
import("//build_overrides/nlio.gni")
import("//build_overrides/nlunit_test.gni")
import("//build_overrides/pigweed.gni")

import("//src/platform/device.gni")
import("$dir_pw_build/python.gni")

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

import("${chip_root}/build/chip/tests.gni")
import("${chip_root}/build/chip/tools.gni")
import("${build_root}/chip/tests.gni")
import("${build_root}/chip/tools.gni")

if (current_toolchain != "${dir_pw_toolchain}/dummy:dummy") {
declare_args() {
Expand Down Expand Up @@ -115,7 +117,7 @@ if (current_toolchain != "${dir_pw_toolchain}/dummy:dummy") {
}
} else {
# This is the unified build. Configure various real toolchains.
import("${chip_root}/build/chip/chip_build.gni")
import("${build_root}/chip/chip_build.gni")
declare_args() {
# Set this to false to disable all builds by default.
enable_default_builds = true
Expand Down Expand Up @@ -179,13 +181,13 @@ if (current_toolchain != "${dir_pw_toolchain}/dummy:dummy") {

if (enable_host_clang_build) {
chip_build("host_clang") {
toolchain = "//build/toolchain/host:${host_os}_${host_cpu}_clang"
toolchain = "${build_root}/toolchain/host:${host_os}_${host_cpu}_clang"
}
}

if (enable_host_gcc_build) {
chip_build("host_gcc") {
toolchain = "//build/toolchain/host:${host_os}_${host_cpu}_gcc"
toolchain = "${build_root}/toolchain/host:${host_os}_${host_cpu}_gcc"
}
}

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

if (enable_android_builds) {
chip_build("android_arm") {
toolchain = "//build/toolchain/android:android_arm"
toolchain = "${build_root}/toolchain/android:android_arm"
}

chip_build("android_arm64") {
toolchain = "//build/toolchain/android:android_arm64"
toolchain = "${build_root}/toolchain/android:android_arm64"
}

chip_build("android_x64") {
toolchain = "//build/toolchain/android:android_x64"
toolchain = "${build_root}/toolchain/android:android_x64"
}

chip_build("android_x86") {
toolchain = "//build/toolchain/android:android_x86"
toolchain = "${build_root}/toolchain/android:android_x86"
}
}

Expand Down
3 changes: 2 additions & 1 deletion build/chip/buildconfig_header.gni
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,15 @@
# ]
# }

import("//build_overrides/build.gni")
import("//build_overrides/chip.gni")

template("buildconfig_header") {
source_set_name = target_name
gen_target_name = "gen_${target_name}"

action(gen_target_name) {
script = "${chip_root}/build/chip/write_buildconfig_header.py"
script = "${build_root}/chip/write_buildconfig_header.py"

if (defined(invoker.header_dir)) {
header_file = "${invoker.header_dir}/${invoker.header}"
Expand Down
4 changes: 2 additions & 2 deletions build/chip/chip_build.gni
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import("//build_overrides/chip.gni")
import("//build_overrides/build.gni")

import("${chip_root}/build/chip/tests.gni")
import("${build_root}/chip/tests.gni")

template("chip_build") {
_build_name = target_name
Expand Down
4 changes: 3 additions & 1 deletion build/chip/chip_test.gni
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import("//build_overrides/build.gni")
import("//build_overrides/chip.gni")
import("//build_overrides/pigweed.gni")

import("$dir_pw_build/python_action.gni")

import("${chip_root}/build/chip/tests.gni")
import("${build_root}/chip/tests.gni")
import("${chip_root}/src/platform/device.gni")
import("${dir_pw_unit_test}/test.gni")

Expand Down
4 changes: 2 additions & 2 deletions build/chip/chip_test_group.gni
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import("//build_overrides/chip.gni")
import("//build_overrides/build.gni")

import("${chip_root}/build/chip/tests.gni")
import("${build_root}/chip/tests.gni")

assert(chip_build_tests)

Expand Down
5 changes: 3 additions & 2 deletions build/chip/chip_test_suite.gni
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import("//build_overrides/build.gni")
import("//build_overrides/chip.gni")

import("${chip_root}/build/chip/chip_test.gni")
import("${chip_root}/build/chip/tests.gni")
import("${build_root}/chip/chip_test.gni")
import("${build_root}/chip/tests.gni")
import("${dir_pw_unit_test}/test.gni")

assert(chip_build_tests)
Expand Down
3 changes: 2 additions & 1 deletion build/chip/happy_test.gni
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import("//build_overrides/build.gni")
import("//build_overrides/chip.gni")

import("${chip_root}/build/chip/tests.gni")
import("${build_root}/chip/tests.gni")

assert(chip_build_tests)
assert(chip_enable_happy_tests)
Expand Down
6 changes: 3 additions & 3 deletions build/chip/java/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import("//build_overrides/chip.gni")
import("//build_overrides/build.gni")

import("//build/config/android/config.gni")
import("//build/config/android_abi.gni")
import("${build_root}/config/android/config.gni")
import("${build_root}/config/android_abi.gni")

# Place a copy of the shared c++ support library in the jni output directory
# See:
Expand Down
8 changes: 4 additions & 4 deletions build/chip/java/rules.gni
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import("//build_overrides/chip.gni")
import("//build_overrides/build.gni")

import("//build/config/android/config.gni")
import("${build_root}/config/android/config.gni")

javac_runner = "${chip_root}/build/chip/java/javac_runner.py"
jar_runner = "${chip_root}/build/chip/java/jar_runner.py"
javac_runner = "${build_root}/chip/java/javac_runner.py"
jar_runner = "${build_root}/chip/java/jar_runner.py"

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

Expand Down
4 changes: 3 additions & 1 deletion build/chip/linux/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import("//build/config/linux/pkg_config.gni")
import("//build_overrides/build.gni")

import("${build_root}/config/linux/pkg_config.gni")

pkg_config("glib") {
packages = [
Expand Down
27 changes: 16 additions & 11 deletions build/config/BUILDCONFIG.gn
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ if (current_os == "") {
current_os = target_os
}

_chip_overrides = {
import("//build_overrides/chip.gni")
_build_overrides = {
import("//build_overrides/build.gni")
}

_pigweed_overrides = {
import("//build_overrides/pigweed.gni")
}

_chip_defaults = {
import("//build/config/defaults.gni")
import("${_build_overrides.build_root}/config/defaults.gni")
}

declare_args() {
Expand All @@ -51,9 +51,9 @@ declare_args() {

if (host_toolchain == "") {
if (_chip_defaults.is_clang) {
host_toolchain = "//build/toolchain/host:${host_os}_${host_cpu}_clang"
host_toolchain = "${_build_overrides.build_root}/toolchain/host:${host_os}_${host_cpu}_clang"
} else {
host_toolchain = "//build/toolchain/host:${host_os}_${host_cpu}_gcc"
host_toolchain = "${_build_overrides.build_root}/toolchain/host:${host_os}_${host_cpu}_gcc"
}
}

Expand All @@ -65,24 +65,29 @@ if (_chip_defaults.custom_toolchain != "") {
_default_toolchain = "${_pigweed_overrides.dir_pw_toolchain}/dummy"
} else if (target_os == "freertos") {
if (target_cpu == "arm") {
_default_toolchain = "//build/toolchain/arm_gcc"
_default_toolchain = "${_build_overrides.build_root}/toolchain/arm_gcc"
} else {
assert(false, "Unsupported target_cpu: ${target_cpu}")
}
} else if (target_os == "android") {
if (current_cpu == "arm") {
_default_toolchain = "//build/toolchain/android:android_arm"
_default_toolchain =
"${_build_overrides.build_root}/toolchain/android:android_arm"
} else if (current_cpu == "arm64") {
_default_toolchain = "//build/toolchain/android:android_arm64"
_default_toolchain =
"${_build_overrides.build_root}/toolchain/android:android_arm64"
} else if (current_cpu == "x64") {
_default_toolchain = "//build/toolchain/android:android_x64"
_default_toolchain =
"${_build_overrides.build_root}/toolchain/android:android_x64"
} else if (current_cpu == "x86") {
_default_toolchain = "//build/toolchain/android:android_x86"
_default_toolchain =
"${_build_overrides.build_root}/toolchain/android:android_x86"
} else {
assert(false, "Unsupported target_cpu: ${current_cpu}")
}
} else if (target_os == "ios") {
_default_toolchain = "//build/toolchain/ios:ios_${target_cpu}"
_default_toolchain =
"${_build_overrides.build_root}/toolchain/ios:ios_${target_cpu}"
} else {
assert(false, "No toolchain specified, please specify custom_toolchain")
}
Expand Down
4 changes: 3 additions & 1 deletion build/config/arm.gni
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import("//build_overrides/build.gni")

if (current_cpu == "arm" || current_cpu == "arm64") {
declare_args() {
# Build file to import for ARM defaults.
Expand All @@ -20,7 +22,7 @@ if (current_cpu == "arm" || current_cpu == "arm64") {

if (arm_platform_config == "") {
if (current_os == "android") {
arm_platform_config = "//build/toolchain/android/android_arm.gni"
arm_platform_config = "${build_root}/toolchain/android/android_arm.gni"
}
}

Expand Down
10 changes: 5 additions & 5 deletions build/config/compiler/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import("//build_overrides/chip.gni")
import("//build_overrides/build.gni")
import("//build_overrides/pigweed.gni")

import("//build/config/compiler/compiler.gni")
import("//build/config/target.gni")
import("${build_root}/config/compiler/compiler.gni")
import("${build_root}/config/target.gni")

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

if (_is_embedded_arm) {
import("//build/config/arm.gni")
import("${build_root}/config/arm.gni")
} else if (current_cpu == "x86" || current_cpu == "x86_64") {
import("//build/config/x86.gni")
import("${build_root}/config/x86.gni")
}

config("release") {
Expand Down
Loading

0 comments on commit 4e1faf2

Please sign in to comment.