From 8fa26373af76179798410ff0e902bc6ffefeb250 Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Tue, 19 May 2020 01:09:41 -0400 Subject: [PATCH 01/59] Add GN files to gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index ee7662752d2ef9..73d0f2863e686b 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,9 @@ configure src/include/BuildConfig.h.in src/include/BuildConfig.h.in~ +# GN build system +out/ + # Repos stuff .repos-warning-stamp From 232ef3028bafae89bb70a38a6f8d8f9ab413c64e Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Tue, 16 Jun 2020 16:13:13 -0400 Subject: [PATCH 02/59] Add GN build support using pw_toolchain & pw_build This uses build infrastructure from pigweed to enable building CHIP with GN. --- .gn | 19 ++ BUILD.gn | 18 ++ build/config/BUILDCONFIG.gn | 81 +++++++++ build/config/compiler/BUILD.gn | 206 ++++++++++++++++++++++ build/config/compiler/compiler.gni | 27 +++ build/config/custom_toolchain.gni | 20 +++ build/config/defaults.gni | 101 +++++++++++ build/toolchain/host_clang/BUILD.gn | 23 +++ build/toolchain/host_clang/toolchains.gni | 116 ++++++++++++ build/toolchain/host_gcc/BUILD.gn | 23 +++ build/toolchain/host_gcc/toolchains.gni | 86 +++++++++ build_overrides/chip.gni | 17 ++ build_overrides/pigweed.gni | 20 +++ 13 files changed, 757 insertions(+) create mode 100644 .gn create mode 100644 BUILD.gn create mode 100644 build/config/BUILDCONFIG.gn create mode 100644 build/config/compiler/BUILD.gn create mode 100644 build/config/compiler/compiler.gni create mode 100644 build/config/custom_toolchain.gni create mode 100644 build/config/defaults.gni create mode 100644 build/toolchain/host_clang/BUILD.gn create mode 100644 build/toolchain/host_clang/toolchains.gni create mode 100644 build/toolchain/host_gcc/BUILD.gn create mode 100644 build/toolchain/host_gcc/toolchains.gni create mode 100644 build_overrides/chip.gni create mode 100644 build_overrides/pigweed.gni diff --git a/.gn b/.gn new file mode 100644 index 00000000000000..8575ac571bff3e --- /dev/null +++ b/.gn @@ -0,0 +1,19 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# The location of the build configuration file. +buildconfig = "//build/config/BUILDCONFIG.gn" + +# CHIP uses angle bracket includes. +check_system_includes = true diff --git a/BUILD.gn b/BUILD.gn new file mode 100644 index 00000000000000..cd4652ff7b6c00 --- /dev/null +++ b/BUILD.gn @@ -0,0 +1,18 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Currently no targets are ported to GN. +source_set("empty") { + sources = [] +} diff --git a/build/config/BUILDCONFIG.gn b/build/config/BUILDCONFIG.gn new file mode 100644 index 00000000000000..21275345a48363 --- /dev/null +++ b/build/config/BUILDCONFIG.gn @@ -0,0 +1,81 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +declare_args() { + # Debug build. Set this to false to remove development features. + is_debug = true +} + +if (target_os == "") { + target_os = host_os +} + +if (target_cpu == "") { + target_cpu = host_cpu +} + +if (current_cpu == "") { + current_cpu = target_cpu +} +if (current_os == "") { + current_os = target_os +} + +_chip_directory = { + import("//build_overrides/chip.gni") +} + +_chip_defaults = { + import("//build/config/defaults.gni") +} + +declare_args() { + # Toolchain to use for host. This is usually set by default. + host_toolchain = "" +} + +if (host_toolchain == "") { + if (_chip_defaults.is_clang) { + host_toolchain = "${_chip_directory.chip_root}/build/toolchain/host_clang:${host_os}_${host_cpu}_clang" + } else { + host_toolchain = "${_chip_directory.chip_root}/build/toolchain/host_gcc:${host_os}_${host_cpu}_gcc" + } +} + +if (_chip_defaults.custom_toolchain != "") { + _default_toolchain = _chip_defaults.custom_toolchain +} else if (target_os == host_os) { + _default_toolchain = host_toolchain +} else { + assert(false, "No toolchain specified, please specify custom_toolchain") +} + +set_default_toolchain(_default_toolchain) + +set_defaults("static_library") { + configs = _chip_defaults.default_configs +} +set_defaults("source_set") { + configs = _chip_defaults.default_configs +} +set_defaults("executable") { + configs = + _chip_defaults.default_configs + _chip_defaults.executable_default_configs +} +set_defaults("shared_library") { + configs = _chip_defaults.default_configs +} +set_defaults("loadable_module") { + configs = _chip_defaults.default_configs +} diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn new file mode 100644 index 00000000000000..7251d94a040471 --- /dev/null +++ b/build/config/compiler/BUILD.gn @@ -0,0 +1,206 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build_overrides/chip.gni") +import("//build_overrides/pigweed.gni") + +import("//build/config/compiler/compiler.gni") + +config("release") { + defines = [ "NDEBUG" ] +} + +config("debug_default") { + if (!is_debug) { + configs = [ ":release" ] + } +} + +config("optimize_zero") { + cflags = [ "-O0" ] + ldflags = cflags +} + +config("optimize_default") { + if (is_debug) { + if (optimize_debug) { + configs = [ "$dir_pw_build:optimize_debugging" ] + } else { + configs = [ ":optimize_zero" ] + } + } else { + if (optimize_for_size) { + configs = [ "$dir_pw_build:optimize_size" ] + } else { + configs = [ "$dir_pw_build:optimize_speed" ] + } + + if (current_os != "mac") { + ldflags = [ + "-Wl,-O2", + "-Wl,--gc-sections", + ] + } + } +} + +config("disabled_warnings") { + cflags = [ + "-Wno-unused-parameter", + "-Wno-unused-function", + "-Wno-unused-variable", + "-Wno-format", + "-Wno-missing-field-initializers", + "-Wno-expansion-to-defined", + "-Wno-implicit-fallthrough", + "-Wno-deprecated-declarations", + ] + cflags_cc = [ + "-Wno-non-virtual-dtor", + "-Wno-deprecated-copy", + ] + if (!is_clang) { + cflags += [ + "-Wno-cast-function-type", + "-Wno-maybe-uninitialized", + "-Wno-unknown-warning-option", + ] + } +} + +config("strict_warnings") { + cflags = [ + "-Wall", + "-Werror", + ] +} + +config("warnings_default") { + configs = [ + ":strict_warnings", + ":disabled_warnings", + ] + + if (current_os != "mac") { + ldflags = [ "-Wl,--fatal-warnings" ] + } +} + +config("symbols_default") { + cflags = [ "-g${symbol_level}" ] +} + +config("gnu11") { + cflags_c = [ "-std=gnu11" ] + cflags_cc = [ "-std=gnu++11" ] +} + +config("std_default") { + configs = [ ":gnu11" ] +} + +config("cosmetic_default") { + configs = [ "$dir_pw_build:colorize_output" ] +} + +config("runtime_default") { + if (is_clang) { + configs = [ + "$dir_pw_toolchain/host_clang:no_system_libcpp", + "$dir_pw_toolchain/host_clang:xcode_sysroot", + ] + } + if (current_os == "linux") { + libs = [ + "dl", + "pthread", + "rt", + ] + } +} + +config("sanitize_default") { +} + +config("fuzzing_default") { +} + +config("no_rtti") { + cflags_cc = [ "-fno-rtti" ] +} + +config("rtti") { + cflags_cc = [ "-frtti" ] +} + +config("rtti_default") { + configs = [ ":no_rtti" ] +} + +config("no_exceptions") { + cflags = [ "-fno-exceptions" ] +} + +config("exceptions") { + cflags = [ "-fexceptions" ] +} + +config("exceptions_default") { + configs = [ ":no_exceptions" ] +} + +config("unwind_tables_default") { + cflags = [ + "-fno-unwind-tables", + "-fno-asynchronous-unwind-tables", + ] +} + +config("size_default") { + cflags = [ + "-fno-common", + "-ffunction-sections", + "-fdata-sections", + ] +} + +config("stack_protector_default") { + cflags = [ "-fno-stack-protector" ] +} + +config("pic_default") { + cflags = [ "-fPIC" ] + ldflags = cflags +} + +config("pie_default") { + if (current_os == "linux") { + ldflags = [ "-pie" ] + } +} + +config("aliasing_default") { + cflags = [ "-fno-strict-aliasing" ] +} + +config("specs_default") { + if (current_cpu == "arm" && current_os == "freertos") { + cflags = [ + "--specs=nosys.specs", + "--specs=nano.specs", + ] + + ldflags = cflags + } +} diff --git a/build/config/compiler/compiler.gni b/build/config/compiler/compiler.gni new file mode 100644 index 00000000000000..b03ea48a00f3cd --- /dev/null +++ b/build/config/compiler/compiler.gni @@ -0,0 +1,27 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +declare_args() { + # Use clang to build. + is_clang = current_os != "freertos" + + # Optimize for size by default. + optimize_for_size = true + + # Optimize debug builds with -Og. + optimize_debug = current_os == "freertos" + + # Symbol level for debugging. + symbol_level = 2 +} diff --git a/build/config/custom_toolchain.gni b/build/config/custom_toolchain.gni new file mode 100644 index 00000000000000..97412cdf5a9f01 --- /dev/null +++ b/build/config/custom_toolchain.gni @@ -0,0 +1,20 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build_overrides/chip.gni") + +declare_args() { + # Toolchain to use for taget. + custom_toolchain = "" +} diff --git a/build/config/defaults.gni b/build/config/defaults.gni new file mode 100644 index 00000000000000..6c26b968fcc30e --- /dev/null +++ b/build/config/defaults.gni @@ -0,0 +1,101 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build_overrides/chip.gni") + +import("//build/config/compiler/compiler.gni") +import("//build/config/custom_toolchain.gni") + +declare_args() { + # Default configs for debugging. + default_configs_debug = [ "${chip_root}/build/config/compiler:debug_default" ] + + # Default configs for specs. + default_configs_specs = [ "${chip_root}/build/config/compiler:specs_default" ] + + # Default configs for optimization. + default_configs_optimize = + [ "${chip_root}/build/config/compiler:optimize_default" ] + + # Default configs for language. + default_configs_std = [ "${chip_root}/build/config/compiler:std_default" ] + + # Defaults configs for symbols. + default_configs_symbols = + [ "${chip_root}/build/config/compiler:symbols_default" ] + + # Defaults configs for aliasing. + default_configs_aliasing = + [ "${chip_root}/build/config/compiler:aliasing_default" ] + + # Defaults configs for size. + default_configs_size = [ "${chip_root}/build/config/compiler:size_default" ] + + # Defaults configs for exceptions. + default_configs_exceptions = + [ "${chip_root}/build/config/compiler:exceptions_default" ] + + # Defaults configs for rtti. + default_configs_rtti = [ "${chip_root}/build/config/compiler:rtti_default" ] + + # Defaults configs for pic. + default_configs_pic = [ "${chip_root}/build/config/compiler:pic_default" ] + + # Defaults configs for pie. + default_configs_pie = [ "${chip_root}/build/config/compiler:pie_default" ] + + # Defaults configs for warnings. + default_configs_warnings = + [ "${chip_root}/build/config/compiler:warnings_default" ] + + # Defaults cosmetic configs. + default_configs_cosmetic = + [ "${chip_root}/build/config/compiler:cosmetic_default" ] + + # Default configs for runtime library. + default_configs_runtime = + [ "${chip_root}/build/config/compiler:runtime_default" ] + + # Defaults sanitizer configs. + default_configs_sanitize = + [ "${chip_root}/build/config/compiler:sanitize_default" ] + + # Defaults fuzzing configs. + default_configs_fuzzing = + [ "${chip_root}/build/config/compiler:fuzzing_default" ] + + # Extra default configs. + default_configs_extra = [] +} + +default_configs = [] +default_configs += default_configs_debug +default_configs += default_configs_optimize +default_configs += default_configs_std +default_configs += default_configs_symbols +default_configs += default_configs_size +default_configs += default_configs_specs +default_configs += default_configs_exceptions +default_configs += default_configs_pic +default_configs += default_configs_rtti +default_configs += default_configs_warnings +default_configs += default_configs_cosmetic +default_configs += default_configs_runtime +default_configs += default_configs_aliasing +default_configs += default_configs_sanitize +default_configs += default_configs_fuzzing +default_configs += default_configs_extra + +executable_default_configs = [] +executable_default_configs += default_configs_pie diff --git a/build/toolchain/host_clang/BUILD.gn b/build/toolchain/host_clang/BUILD.gn new file mode 100644 index 00000000000000..10912d5b8f7546 --- /dev/null +++ b/build/toolchain/host_clang/BUILD.gn @@ -0,0 +1,23 @@ +# Copyright 2020 The Pigweed Authors +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# gn-format disable +import("//build_overrides/pigweed.gni") + +import("$dir_pw_toolchain/generate_toolchain.gni") +import("toolchains.gni") +generate_toolchains("host_toolchains") { + toolchains = pw_toolchain_host_clang_list +} diff --git a/build/toolchain/host_clang/toolchains.gni b/build/toolchain/host_clang/toolchains.gni new file mode 100644 index 00000000000000..48971f92a9fa7d --- /dev/null +++ b/build/toolchain/host_clang/toolchains.gni @@ -0,0 +1,116 @@ +# Copyright 2020 The Pigweed Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + +# gn-format disable +import("//build_overrides/pigweed.gni") +declare_args() { + # Sets the sanitizer to pass to clang. Valid values are those for "-fsanitize" + # listed in https://clang.llvm.org/docs/UsersManual.html#id9. + pw_toolchain_SANITIZER = "" + + # Indicates if this build is a part of OSS-Fuzz, which needs to be able to + # provide its own compiler and flags. This violates the build hermeticisim and + # should only be used for OSS-Fuzz. + pw_toolchain_OSS_FUZZ_ENABLED = false +} + +# Specifies the tools used by host Clang toolchains. +_host_clang_toolchain = { + # Note: On macOS, there is no "llvm-ar", only "ar", which happens to be LLVM + # ar. This should get updated for linux systems. + ar = "ar" + + if (pw_toolchain_OSS_FUZZ_ENABLED) { + cc = getenv("CC") + cxx = getenv("CXX") + } else { + cc = "clang" + cxx = "clang++" + } + + is_host_toolchain = true + link_group = true +} + +# Common default scope shared by all host Clang toolchains. +_defaults = { + if (pw_toolchain_SANITIZER != "") { + configs += + [ "$dir_pw_toolchain/host_clang:sanitize_$pw_toolchain_SANITIZER" ] + } + if (pw_toolchain_OSS_FUZZ_ENABLED) { + default_configs_fuzzing = oss_fuzz_added_configs + default_configs_fuzzing += [ "$dir_pw_fuzzer:oss_fuzz_extra" ] + + # Add the configs to be removed. They will be de-duplicated, and this + # ensures they are present to be removed. + default_configs += oss_fuzz_removed_configs + remove_configs = oss_fuzz_removed_configs + } +} + +pw_toolchain_host_clang = { + default = { + name = "${host_os}_${host_cpu}_clang" + forward_variables_from(_host_clang_toolchain, "*") + defaults = { + forward_variables_from(_defaults, "*") + current_os = host_os + is_clang = true + } + } + + debug = { + name = "${host_os}_${host_cpu}_clang_debug" + forward_variables_from(_host_clang_toolchain, "*") + defaults = { + forward_variables_from(_defaults, "*") + current_os = host_os + is_clang = true + is_debug = true + } + } + + speed_optimized = { + name = "${host_os}_${host_cpu}_clang_speed_optimized" + forward_variables_from(_host_clang_toolchain, "*") + defaults = { + forward_variables_from(_defaults, "*") + current_os = host_os + is_clang = true + is_debug = false + optimize_for_size = false + } + } + + size_optimized = { + name = "${host_os}_${host_cpu}_clang_size_optimized" + forward_variables_from(_host_clang_toolchain, "*") + defaults = { + forward_variables_from(_defaults, "*") + current_os = host_os + is_clang = true + is_debug = false + optimize_for_size = true + } + } +} + +# Describes host clang toolchains. +pw_toolchain_host_clang_list = [ + pw_toolchain_host_clang.default, + pw_toolchain_host_clang.debug, + pw_toolchain_host_clang.speed_optimized, + pw_toolchain_host_clang.size_optimized, +] diff --git a/build/toolchain/host_gcc/BUILD.gn b/build/toolchain/host_gcc/BUILD.gn new file mode 100644 index 00000000000000..260b08169ac48f --- /dev/null +++ b/build/toolchain/host_gcc/BUILD.gn @@ -0,0 +1,23 @@ +# Copyright 2020 The Pigweed Authors +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# gn-format disable +import("//build_overrides/pigweed.gni") + +import("$dir_pw_toolchain/generate_toolchain.gni") +import("toolchains.gni") +generate_toolchains("host_toolchains") { + toolchains = pw_toolchain_host_gcc_list +} diff --git a/build/toolchain/host_gcc/toolchains.gni b/build/toolchain/host_gcc/toolchains.gni new file mode 100644 index 00000000000000..268d3ff3af1cdf --- /dev/null +++ b/build/toolchain/host_gcc/toolchains.gni @@ -0,0 +1,86 @@ +# Copyright 2020 The Pigweed Authors +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# gn-format disable +import("//build_overrides/chip.gni") +import("//build_overrides/pigweed.gni") +_host_gcc_toolchain = { + ar = "ar" + cc = "gcc" + cxx = "g++" + + is_host_toolchain = true + link_group = true +} + +_configs = [ + "$dir_pw_toolchain/host_gcc:disable_psabi_warning", + "$dir_pw_toolchain/host_gcc:mingw_z_format", +] + +pw_toolchain_host_gcc = { + default = { + name = "${host_os}_${host_cpu}_gcc" + forward_variables_from(_host_gcc_toolchain, "*") + defaults = { + default_configs_extra = _configs + current_os = host_os + is_clang = false + } + } + + debug = { + name = "${host_os}_${host_cpu}_gcc_debug" + forward_variables_from(_host_gcc_toolchain, "*") + defaults = { + default_configs_extra = _configs + current_os = host_os + is_clang = false + is_debug = true + } + } + + speed_optimized = { + name = "${host_os}_${host_cpu}_gcc_speed_optimized" + forward_variables_from(_host_gcc_toolchain, "*") + defaults = { + default_configs_extra = _configs + current_os = host_os + is_clang = false + is_debug = false + optimize_for_size = false + } + } + + size_optimized = { + name = "${host_os}_${host_cpu}_gcc_size_optimized" + forward_variables_from(_host_gcc_toolchain, "*") + defaults = { + default_configs_extra = _configs + current_os = host_os + is_clang = false + is_debug = false + optimize_for_size = true + } + } +} + +# Describes host Linux GCC toolchains. +pw_toolchain_host_gcc_list = [ + pw_toolchain_host_gcc.default, + pw_toolchain_host_gcc.debug, + pw_toolchain_host_gcc.speed_optimized, + pw_toolchain_host_gcc.size_optimized, +] diff --git a/build_overrides/chip.gni b/build_overrides/chip.gni new file mode 100644 index 00000000000000..db0f51b0bc980d --- /dev/null +++ b/build_overrides/chip.gni @@ -0,0 +1,17 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +declare_args() { + chip_root = "//" +} diff --git a/build_overrides/pigweed.gni b/build_overrides/pigweed.gni new file mode 100644 index 00000000000000..2ef577a00aa734 --- /dev/null +++ b/build_overrides/pigweed.gni @@ -0,0 +1,20 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +declare_args() { + # Location of the Pigweed repository. + dir_pigweed = "//third_party/pigweed" +} + +import("$dir_pigweed/modules.gni") From 2ff962d027a0c8db67dbea069e9a7aec78e4bec0 Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Mon, 18 May 2020 10:38:46 -0400 Subject: [PATCH 03/59] Add nlunit-test to GN build --- BUILD.gn | 5 ++--- third_party/nlunit-test/BUILD.gn | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 third_party/nlunit-test/BUILD.gn diff --git a/BUILD.gn b/BUILD.gn index cd4652ff7b6c00..d5446c262085a2 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -12,7 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Currently no targets are ported to GN. -source_set("empty") { - sources = [] +group("all") { + deps = [ "third_party/nlunit-test" ] } diff --git a/third_party/nlunit-test/BUILD.gn b/third_party/nlunit-test/BUILD.gn new file mode 100644 index 00000000000000..9c2cc6edb33896 --- /dev/null +++ b/third_party/nlunit-test/BUILD.gn @@ -0,0 +1,26 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +config("nlunit-test_config") { + include_dirs = [ "repo/src" ] +} + +source_set("nlunit-test") { + sources = [ + "repo/src/nlunit-test.c", + "repo/src/nlunit-test.h", + ] + + public_configs = [ ":nlunit-test_config" ] +} From 57817faef39c4b7ac692da47373b3a4f3ad441e1 Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Mon, 18 May 2020 10:43:47 -0400 Subject: [PATCH 04/59] Add nlassert to GN build --- BUILD.gn | 5 ++++- third_party/nlassert/BUILD.gn | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 third_party/nlassert/BUILD.gn diff --git a/BUILD.gn b/BUILD.gn index d5446c262085a2..4cd024eba7cbd3 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -13,5 +13,8 @@ # limitations under the License. group("all") { - deps = [ "third_party/nlunit-test" ] + deps = [ + "third_party/nlassert", + "third_party/nlunit-test", + ] } diff --git a/third_party/nlassert/BUILD.gn b/third_party/nlassert/BUILD.gn new file mode 100644 index 00000000000000..4e2e795ca90946 --- /dev/null +++ b/third_party/nlassert/BUILD.gn @@ -0,0 +1,23 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +config("nlassert_config") { + include_dirs = [ "repo/include" ] +} + +source_set("nlassert") { + sources = [ "repo/include/nlassert.h" ] + + public_configs = [ ":nlassert_config" ] +} From 8c310f65d113f80c299065c03e8f4fb804dc2b44 Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Mon, 18 May 2020 10:49:56 -0400 Subject: [PATCH 05/59] Add nlfaultinjection to GN build --- BUILD.gn | 1 + third_party/nlfaultinjection/BUILD.gn | 28 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 third_party/nlfaultinjection/BUILD.gn diff --git a/BUILD.gn b/BUILD.gn index 4cd024eba7cbd3..1f721a7776eadc 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -15,6 +15,7 @@ group("all") { deps = [ "third_party/nlassert", + "third_party/nlfaultinjection", "third_party/nlunit-test", ] } diff --git a/third_party/nlfaultinjection/BUILD.gn b/third_party/nlfaultinjection/BUILD.gn new file mode 100644 index 00000000000000..98983a113d7d34 --- /dev/null +++ b/third_party/nlfaultinjection/BUILD.gn @@ -0,0 +1,28 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +config("nlfaultinjection_config") { + include_dirs = [ "repo/include" ] +} + +static_library("nlfaultinjection") { + sources = [ + "repo/include/nlfaultinjection.hpp", + "repo/src/nlfaultinjection.cpp", + ] + + deps = [ "//third_party/nlassert" ] + + public_configs = [ ":nlfaultinjection_config" ] +} From e60b1ae3fc56a3e592ff5dda2d5183e727c74483 Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Mon, 18 May 2020 23:01:23 -0400 Subject: [PATCH 06/59] Add nlio to GN build --- BUILD.gn | 1 + third_party/nlio/BUILD.gn | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 third_party/nlio/BUILD.gn diff --git a/BUILD.gn b/BUILD.gn index 1f721a7776eadc..9945aec1df909d 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -16,6 +16,7 @@ group("all") { deps = [ "third_party/nlassert", "third_party/nlfaultinjection", + "third_party/nlio", "third_party/nlunit-test", ] } diff --git a/third_party/nlio/BUILD.gn b/third_party/nlio/BUILD.gn new file mode 100644 index 00000000000000..167db7db5ac469 --- /dev/null +++ b/third_party/nlio/BUILD.gn @@ -0,0 +1,39 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +config("nlio_config") { + include_dirs = [ "repo/include" ] +} + +source_set("nlio") { + sources = [ + "repo/include/nlbyteorder-big.h", + "repo/include/nlbyteorder-little.h", + "repo/include/nlbyteorder.h", + "repo/include/nlbyteorder.hpp", + "repo/include/nlio-base.h", + "repo/include/nlio-base.hpp", + "repo/include/nlio-byteorder-big.h", + "repo/include/nlio-byteorder-big.hpp", + "repo/include/nlio-byteorder-little.h", + "repo/include/nlio-byteorder-little.hpp", + "repo/include/nlio-byteorder.h", + "repo/include/nlio-byteorder.hpp", + "repo/include/nlio-private.h", + "repo/include/nlio.h", + "repo/include/nlio.hpp", + ] + + public_configs = [ ":nlio_config" ] +} From 50ca2c80c9cac20cbb876dca0cf7563e902a99f8 Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Mon, 18 May 2020 10:55:48 -0400 Subject: [PATCH 07/59] Add lwIP to GN build --- BUILD.gn | 7 + build/tests.gni | 18 ++ src/lwip/BUILD.gn | 78 ++++++++ src/lwip/tests/BUILD.gn | 22 ++ third_party/lwip/lwip.gni | 412 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 537 insertions(+) create mode 100644 build/tests.gni create mode 100644 src/lwip/BUILD.gn create mode 100644 src/lwip/tests/BUILD.gn create mode 100644 third_party/lwip/lwip.gni diff --git a/BUILD.gn b/BUILD.gn index 9945aec1df909d..24dbc03b564cfb 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -12,11 +12,18 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("build/tests.gni") + group("all") { deps = [ + "src/lwip:all", "third_party/nlassert", "third_party/nlfaultinjection", "third_party/nlio", "third_party/nlunit-test", ] + + if (chip_build_tests) { + deps += [ "src/lwip/tests" ] + } } diff --git a/build/tests.gni b/build/tests.gni new file mode 100644 index 00000000000000..b81105dc1d4927 --- /dev/null +++ b/build/tests.gni @@ -0,0 +1,18 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +declare_args() { + # Enable building tests. + chip_build_tests = true +} diff --git a/src/lwip/BUILD.gn b/src/lwip/BUILD.gn new file mode 100644 index 00000000000000..6f3d78c1878afe --- /dev/null +++ b/src/lwip/BUILD.gn @@ -0,0 +1,78 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//third_party/lwip/lwip.gni") + +declare_args() { + # Enable lwIP debugging. + lwip_debug = is_debug + + # lwIP platform: standalone, freertos. + lwip_platform = "" +} + +if (lwip_platform == "") { + if (current_os != "freertos") { + lwip_platform = "standalone" + } +} + +assert(lwip_platform == "standalone" || lwip_platform == "nrf5" || + lwip_platform == "efr32", + "Unsupported lwIP platform: ${lwip_platform}") + +config("lwip_config") { + # Automatically enable LWIP_DEBUG for internal is_debug builds. + if (lwip_debug) { + lwip_debug = 1 + } else { + lwip_debug = 0 + } + defines = [ "LWIP_DEBUG=${lwip_debug}" ] + + include_dirs = [ lwip_platform ] + + if (lwip_platform != "standalone") { + include_dirs += [ "freertos" ] + } +} + +lwip_target("lwip") { + public = [ + "${lwip_platform}/arch/cc.h", + "${lwip_platform}/arch/perf.h", + "${lwip_platform}/lwipopts.h", + ] + + sources = [] + + if (lwip_platform == "standalone") { + public += [ "standalone/arch/sys_arch.h" ] + sources += [ "standalone/sys_arch.c" ] + } else { + public += [ + "${lwip_platform}/lwippools.h", + "freertos/arch/sys_arch.h", + ] + sources += [ "freertos/sys_arch.c" ] + } + + public_deps = [] + + public_configs = [ ":lwip_config" ] +} + +group("all") { + deps = [ ":lwip_all" ] +} diff --git a/src/lwip/tests/BUILD.gn b/src/lwip/tests/BUILD.gn new file mode 100644 index 00000000000000..75abf4d9de5ab4 --- /dev/null +++ b/src/lwip/tests/BUILD.gn @@ -0,0 +1,22 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +executable("TestLwIP") { + sources = [ "tests.c" ] + deps = [ "//src/lwip" ] +} + +group("tests") { + deps = [ ":TestLwIP" ] +} diff --git a/third_party/lwip/lwip.gni b/third_party/lwip/lwip.gni new file mode 100644 index 00000000000000..8162d4d8a3e426 --- /dev/null +++ b/third_party/lwip/lwip.gni @@ -0,0 +1,412 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +declare_args() { + # Default enablement for lwIP library components. + # This has no effect on its own; it only changes between opt-out and opt-in. + lwip_default = current_os != "freertos" + + # Root of the lwIP source tree. + lwip_root = get_path_info("repo/lwip", "abspath") +} + +declare_args() { + # Build IPv4 support in lwIP. + lwip_ipv4 = lwip_default + + # Enable IPv6 support in lwIP. + lwip_ipv6 = lwip_default + + # Enable sequential & socket API support in lwIP. + lwip_api = lwip_default + + # Enable ethernet support in lwIP. + lwip_ethernet = lwip_default + + # Enable SLIP interface support in lwIP. + lwip_slip = lwip_default + + # Enable 6LoWPAN support in lwIP. + lwip_6lowpan = lwip_default + + # Enable PPP support in lwIP. + lwip_ppp = lwip_default + + # Default enablement for lwIP application components. + # This has no effect on its own; it only changes between opt-out and opt-in. + lwip_apps_default = false +} + +declare_args() { + # Enable SNMPv2c agent application. + lwip_snmp = lwip_apps_default + + # Enable HTTP server. + lwip_httpd = lwip_apps_default + + # Enable IPERF server. + lwip_iperf = lwip_apps_default + + # Enable SNTP client. + lwip_sntp = lwip_apps_default + + # Enable MDNS responder. + lwip_mdns = lwip_apps_default + + # Enable NetBIOS name server. + lwip_netbiosns = lwip_apps_default + + # Enable TFTP server. + lwip_tftp = lwip_apps_default + + # Enable MQTT client. + lwip_mqtt = lwip_apps_default +} + +# Defines a lwIP build target. +# +# lwIP depends on external header files to compile. This template defines +# a combined build of the lwIP sources plus target configuration. +template("lwip_target") { + assert(lwip_root != "", "lwip_root must be specified") + + lwip_target_name = target_name + + config("${lwip_target_name}_warnings") { + cflags = [ + "-Wno-address", + "-Wno-type-limits", + ] + } + + config("${lwip_target_name}_base_config") { + include_dirs = [ + "${lwip_root}/src/include", + "include", + ] + + # These options may have overlap with lwipopts.h, however this is harmless + # as long the options are the same and if they are not the same it's a + # compile error. + if (lwip_ipv4) { + enable_ipv4 = 1 + } else { + enable_ipv4 = 0 + } + if (lwip_ipv6) { + enable_ipv6 = 1 + } else { + enable_ipv6 = 0 + } + if (lwip_api) { + enable_api = 1 + } else { + enable_api = 0 + } + if (lwip_ethernet) { + enable_ethernet = 1 + } else { + enable_ethernet = 0 + } + if (lwip_slip) { + enable_slip = 1 + } else { + enable_slip = 0 + } + if (lwip_6lowpan) { + enable_6lowpan = 1 + } else { + enable_6lowpan = 0 + } + if (lwip_ppp) { + enable_ppp = 1 + } else { + enable_ppp = 0 + } + defines = [ + "LWIP_IPV4=${enable_ipv4}", + "LWIP_IPV6=${enable_ipv6}", + "LWIP_API=${enable_api}", + "LWIP_ETHERNET=${enable_ethernet}", + "LWIP_SLIP=${enable_slip}", + "LWIP_6LOWPAN=${enable_6lowpan}", + "LWIP_PPP=${enable_ppp}", + ] + } + + source_set(lwip_target_name) { + forward_variables_from(invoker, + [ + "sources", + "public", + "public_configs", + "public_deps", + ]) + + # lwIP headers become empty if the relevant feature is disabled, so the + # whole interface can be public regardless of build options. + public += [ + "${lwip_root}/src/include/lwip/api.h", + "${lwip_root}/src/include/lwip/autoip.h", + "${lwip_root}/src/include/lwip/debug.h", + "${lwip_root}/src/include/lwip/def.h", + "${lwip_root}/src/include/lwip/dhcp.h", + "${lwip_root}/src/include/lwip/dhcp6.h", + "${lwip_root}/src/include/lwip/dns.h", + "${lwip_root}/src/include/lwip/err.h", + "${lwip_root}/src/include/lwip/etharp.h", + "${lwip_root}/src/include/lwip/ethip6.h", + "${lwip_root}/src/include/lwip/icmp.h", + "${lwip_root}/src/include/lwip/icmp6.h", + "${lwip_root}/src/include/lwip/if.h", + "${lwip_root}/src/include/lwip/igmp.h", + "${lwip_root}/src/include/lwip/inet.h", + "${lwip_root}/src/include/lwip/inet_chksum.h", + "${lwip_root}/src/include/lwip/init.h", + "${lwip_root}/src/include/lwip/ip.h", + "${lwip_root}/src/include/lwip/ip4_frag.h", + "${lwip_root}/src/include/lwip/ip6.h", + "${lwip_root}/src/include/lwip/ip6_addr.h", + "${lwip_root}/src/include/lwip/ip6_frag.h", + "${lwip_root}/src/include/lwip/ip6_route_table.h", + "${lwip_root}/src/include/lwip/ip_addr.h", + "${lwip_root}/src/include/lwip/mem.h", + "${lwip_root}/src/include/lwip/memp.h", + "${lwip_root}/src/include/lwip/mld6.h", + "${lwip_root}/src/include/lwip/nd6.h", + "${lwip_root}/src/include/lwip/netbuf.h", + "${lwip_root}/src/include/lwip/netdb.h", + "${lwip_root}/src/include/lwip/netif.h", + "${lwip_root}/src/include/lwip/netifapi.h", + "${lwip_root}/src/include/lwip/opt.h", + "${lwip_root}/src/include/lwip/pbuf.h", + "${lwip_root}/src/include/lwip/priv/tcp_priv.h", + "${lwip_root}/src/include/lwip/priv/tcpip_priv.h", + "${lwip_root}/src/include/lwip/prot/autoip.h", + "${lwip_root}/src/include/lwip/prot/dhcp.h", + "${lwip_root}/src/include/lwip/prot/dns.h", + "${lwip_root}/src/include/lwip/prot/ethernet.h", + "${lwip_root}/src/include/lwip/prot/icmp6.h", + "${lwip_root}/src/include/lwip/prot/igmp.h", + "${lwip_root}/src/include/lwip/prot/mld6.h", + "${lwip_root}/src/include/lwip/prot/nd6.h", + "${lwip_root}/src/include/lwip/raw.h", + "${lwip_root}/src/include/lwip/snmp.h", + "${lwip_root}/src/include/lwip/sockets.h", + "${lwip_root}/src/include/lwip/stats.h", + "${lwip_root}/src/include/lwip/sys.h", + "${lwip_root}/src/include/lwip/tcp.h", + "${lwip_root}/src/include/lwip/tcpip.h", + "${lwip_root}/src/include/lwip/timeouts.h", + "${lwip_root}/src/include/lwip/udp.h", + ] + + sources += [ + "${lwip_root}/src/core/def.c", + "${lwip_root}/src/core/dns.c", + "${lwip_root}/src/core/inet_chksum.c", + "${lwip_root}/src/core/init.c", + "${lwip_root}/src/core/ip.c", + "${lwip_root}/src/core/mem.c", + "${lwip_root}/src/core/memp.c", + "${lwip_root}/src/core/netif.c", + "${lwip_root}/src/core/pbuf.c", + "${lwip_root}/src/core/raw.c", + "${lwip_root}/src/core/stats.c", + "${lwip_root}/src/core/sys.c", + "${lwip_root}/src/core/tcp.c", + "${lwip_root}/src/core/tcp_in.c", + "${lwip_root}/src/core/tcp_out.c", + "${lwip_root}/src/core/timeouts.c", + "${lwip_root}/src/core/udp.c", + "${lwip_root}/src/include/lwip/priv/api_msg.h", + "${lwip_root}/src/include/lwip/priv/memp_std.h", + "${lwip_root}/src/include/lwip/priv/nd6_priv.h", + ] + + if (lwip_ipv4) { + sources += [ + "${lwip_root}/src/core/ipv4/autoip.c", + "${lwip_root}/src/core/ipv4/dhcp.c", + "${lwip_root}/src/core/ipv4/etharp.c", + "${lwip_root}/src/core/ipv4/icmp.c", + "${lwip_root}/src/core/ipv4/igmp.c", + "${lwip_root}/src/core/ipv4/ip4.c", + "${lwip_root}/src/core/ipv4/ip4_addr.c", + "${lwip_root}/src/core/ipv4/ip4_frag.c", + ] + } + + if (lwip_ipv6) { + sources += [ + "${lwip_root}/src/core/ipv6/dhcp6.c", + "${lwip_root}/src/core/ipv6/ethip6.c", + "${lwip_root}/src/core/ipv6/icmp6.c", + "${lwip_root}/src/core/ipv6/inet6.c", + "${lwip_root}/src/core/ipv6/ip6.c", + "${lwip_root}/src/core/ipv6/ip6_addr.c", + "${lwip_root}/src/core/ipv6/ip6_frag.c", + "${lwip_root}/src/core/ipv6/ip6_route_table.c", + "${lwip_root}/src/core/ipv6/mld6.c", + "${lwip_root}/src/core/ipv6/nd6.c", + ] + } + + if (lwip_api) { + sources += [ + "${lwip_root}/src/api/api_lib.c", + "${lwip_root}/src/api/api_msg.c", + "${lwip_root}/src/api/err.c", + "${lwip_root}/src/api/if.c", + "${lwip_root}/src/api/netbuf.c", + "${lwip_root}/src/api/netdb.c", + "${lwip_root}/src/api/netifapi.c", + "${lwip_root}/src/api/sockets.c", + "${lwip_root}/src/api/tcpip.c", + ] + } + + if (lwip_ethernet) { + sources += [ "${lwip_root}/src/netif/ethernet.c" ] + } + + if (lwip_slip) { + sources += [ "${lwip_root}/src/netif/slipif.c" ] + } + + if (lwip_6lowpan) { + sources += [ "${lwip_root}/src/netif/lowpan6.c" ] + } + + # Relax warnings for third_party code. + configs += [ ":${lwip_target_name}_warnings" ] + + public_configs += [ ":${lwip_target_name}_base_config" ] + } + + lwip_apps = [] + + template("lwip_app") { + app_name = target_name + + static_library("${lwip_target_name}_${app_name}") { + forward_variables_from(invoker, [ "sources" ]) + + deps = [ ":lwip" ] + + # Relax warnings for third_party code. + configs += [ ":${lwip_target_name}_warnings" ] + } + } + + if (lwip_snmp) { + lwip_app("snmp") { + sources = [ + "${lwip_root}/src/apps/snmp/snmp_asn1.c", + "${lwip_root}/src/apps/snmp/snmp_core.c", + "${lwip_root}/src/apps/snmp/snmp_mib2.c", + "${lwip_root}/src/apps/snmp/snmp_mib2_icmp.c", + "${lwip_root}/src/apps/snmp/snmp_mib2_interfaces.c", + "${lwip_root}/src/apps/snmp/snmp_mib2_ip.c", + "${lwip_root}/src/apps/snmp/snmp_mib2_snmp.c", + "${lwip_root}/src/apps/snmp/snmp_mib2_system.c", + "${lwip_root}/src/apps/snmp/snmp_mib2_tcp.c", + "${lwip_root}/src/apps/snmp/snmp_mib2_udp.c", + "${lwip_root}/src/apps/snmp/snmp_msg.c", + "${lwip_root}/src/apps/snmp/snmp_netconn.c", + "${lwip_root}/src/apps/snmp/snmp_pbuf_stream.c", + "${lwip_root}/src/apps/snmp/snmp_raw.c", + "${lwip_root}/src/apps/snmp/snmp_scalar.c", + "${lwip_root}/src/apps/snmp/snmp_table.c", + "${lwip_root}/src/apps/snmp/snmp_threadsync.c", + "${lwip_root}/src/apps/snmp/snmp_traps.c", + "${lwip_root}/src/apps/snmp/snmpv3.c", + "${lwip_root}/src/apps/snmp/snmpv3_dummy.c", + "${lwip_root}/src/apps/snmp/snmpv3_mbedtls.c", + ] + } + + lwip_apps += [ ":${lwip_target_name}_snmp" ] + } + + if (lwip_httpd) { + lwip_app("httpd") { + sources = [ + "${lwip_root}/src/apps/httpd/fs.c", + "${lwip_root}/src/apps/httpd/httpd.c", + ] + } + + lwip_apps += [ ":${lwip_target_name}_httpd" ] + } + + if (lwip_iperf) { + lwip_app("lwiperf") { + sources = [ "${lwip_root}/src/apps/lwiperf/lwiperf.c" ] + } + + lwip_apps += [ ":${lwip_target_name}_lwiperf" ] + } + + if (lwip_sntp) { + lwip_app("sntp") { + sources = [ "${lwip_root}/src/apps/sntp/sntp.c" ] + } + + lwip_apps += [ ":${lwip_target_name}_sntp" ] + } + + if (lwip_mdns) { + lwip_app("mdns") { + sources = [ "${lwip_root}/src/apps/mdns/mdns.c" ] + } + + lwip_apps += [ ":${lwip_target_name}_mdns" ] + } + + if (lwip_netbiosns) { + lwip_app("netbiosns") { + sources = [ "${lwip_root}/src/apps/netbiosns/netbiosns.c" ] + } + + lwip_apps += [ ":${lwip_target_name}_netbiosns" ] + } + + if (lwip_tftp) { + lwip_app("tftp") { + sources = [ "${lwip_root}/src/apps/tftp/tftp_server.c" ] + } + + lwip_apps += [ ":${lwip_target_name}_tftp" ] + } + + if (lwip_mqtt) { + lwip_app("mqtt") { + sources = [ "${lwip_root}/src/apps/mqtt/mqtt.c" ] + } + + lwip_apps += [ ":${lwip_target_name}_mqtt" ] + } + + group("${lwip_target_name}_apps") { + deps = lwip_apps + } + + group("${lwip_target_name}_all") { + deps = [ + ":${lwip_target_name}", + ":${lwip_target_name}_apps", + ] + } +} From 66dd10ff190c602ba42a1d2386210c5970c1c472 Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Tue, 19 May 2020 03:17:40 -0400 Subject: [PATCH 08/59] Add Mbed TLS to GN build --- BUILD.gn | 1 + third_party/mbedtls/BUILD.gn | 102 +++++++++++++++++++++++++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 third_party/mbedtls/BUILD.gn diff --git a/BUILD.gn b/BUILD.gn index 24dbc03b564cfb..69bd3f03baf63e 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -17,6 +17,7 @@ import("build/tests.gni") group("all") { deps = [ "src/lwip:all", + "third_party/mbedtls", "third_party/nlassert", "third_party/nlfaultinjection", "third_party/nlio", diff --git a/third_party/mbedtls/BUILD.gn b/third_party/mbedtls/BUILD.gn new file mode 100644 index 00000000000000..aec535aa4409b9 --- /dev/null +++ b/third_party/mbedtls/BUILD.gn @@ -0,0 +1,102 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +config("mbedtls_config") { + include_dirs = [ "repo/include" ] + + if (current_os == "freertos") { + defines = [ + "MBEDTLS_NO_PLATFORM_ENTROPY", + "MBEDTLS_TEST_NULL_ENTROPY", + "MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES", + ] + cflags = [ "-Wno-cpp" ] + } +} + +static_library("mbedtls") { + sources = [ + "repo/library/aes.c", + "repo/library/aesni.c", + "repo/library/arc4.c", + "repo/library/asn1parse.c", + "repo/library/asn1write.c", + "repo/library/base64.c", + "repo/library/bignum.c", + "repo/library/blowfish.c", + "repo/library/camellia.c", + "repo/library/ccm.c", + "repo/library/certs.c", + "repo/library/chacha20.c", + "repo/library/chachapoly.c", + "repo/library/cipher.c", + "repo/library/cipher_wrap.c", + "repo/library/ctr_drbg.c", + "repo/library/debug.c", + "repo/library/des.c", + "repo/library/dhm.c", + "repo/library/ecdh.c", + "repo/library/ecdsa.c", + "repo/library/ecp.c", + "repo/library/ecp_curves.c", + "repo/library/entropy.c", + "repo/library/entropy_poll.c", + "repo/library/error.c", + "repo/library/gcm.c", + "repo/library/hkdf.c", + "repo/library/hmac_drbg.c", + "repo/library/md.c", + "repo/library/md5.c", + "repo/library/md_wrap.c", + "repo/library/oid.c", + "repo/library/pem.c", + "repo/library/pk.c", + "repo/library/pk_wrap.c", + "repo/library/pkcs12.c", + "repo/library/pkcs5.c", + "repo/library/pkparse.c", + "repo/library/pkwrite.c", + "repo/library/platform.c", + "repo/library/platform_util.c", + "repo/library/poly1305.c", + "repo/library/ripemd160.c", + "repo/library/rsa.c", + "repo/library/rsa_internal.c", + "repo/library/sha1.c", + "repo/library/sha256.c", + "repo/library/sha512.c", + "repo/library/ssl_cache.c", + "repo/library/ssl_ciphersuites.c", + "repo/library/ssl_cli.c", + "repo/library/ssl_cookie.c", + "repo/library/ssl_srv.c", + "repo/library/ssl_ticket.c", + "repo/library/ssl_tls.c", + "repo/library/version.c", + "repo/library/version_features.c", + "repo/library/x509.c", + "repo/library/x509_create.c", + "repo/library/x509_crl.c", + "repo/library/x509_csr.c", + "repo/library/x509write_crt.c", + "repo/library/x509write_csr.c", + "repo/library/xtea.c", + ] + + if (current_os != "freertos") { + sources += [ "repo/library/timing.c" ] + } + + public_configs = [ ":mbedtls_config" ] +} From 6852ab6e80caf957262b0db3256aeb3471f036d3 Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Tue, 19 May 2020 06:10:36 -0400 Subject: [PATCH 09/59] Add SystemConfig to GN build --- BUILD.gn | 1 + build/tests.gni | 3 ++ src/BUILD.gn | 17 +++++++ src/system/BUILD.gn | 111 ++++++++++++++++++++++++++++++++++++++++++ src/system/system.gni | 54 ++++++++++++++++++++ 5 files changed, 186 insertions(+) create mode 100644 src/BUILD.gn create mode 100644 src/system/BUILD.gn create mode 100644 src/system/system.gni diff --git a/BUILD.gn b/BUILD.gn index 69bd3f03baf63e..d182aa5b42d9da 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -17,6 +17,7 @@ import("build/tests.gni") group("all") { deps = [ "src/lwip:all", + "src/system:system_config_header", "third_party/mbedtls", "third_party/nlassert", "third_party/nlfaultinjection", diff --git a/build/tests.gni b/build/tests.gni index b81105dc1d4927..2f3d4ce0f78b22 100644 --- a/build/tests.gni +++ b/build/tests.gni @@ -15,4 +15,7 @@ declare_args() { # Enable building tests. chip_build_tests = true + + # Enable use of nlfaultinjection. + chip_with_nlfaultinjection = true } diff --git a/src/BUILD.gn b/src/BUILD.gn new file mode 100644 index 00000000000000..5f4d446904d611 --- /dev/null +++ b/src/BUILD.gn @@ -0,0 +1,17 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +config("includes") { + include_dirs = [ "." ] +} diff --git a/src/system/BUILD.gn b/src/system/BUILD.gn new file mode 100644 index 00000000000000..32ae2668a9ad26 --- /dev/null +++ b/src/system/BUILD.gn @@ -0,0 +1,111 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/tests.gni") +import("system.gni") + +declare_args() { + # Extra header to include in CHIPConfig.h for project. + # TODO - This should probably be in src/core but src/system also uses it. + chip_project_config_include = "" + + # Extra header to include in CHIPConfig.h for platform. + # TODO - This should probably be in src/core but src/system also uses it. + chip_platform_config_include = "" + + # Extra header to include in SystemConfig.h for project. + system_project_config_include = "" + + # Extra header to include in SystemConfig.h for platform. + system_platform_config_include = "" +} + +config("system_config") { + configs = [ "//src:includes" ] + + defines = [] + if (chip_project_config_include != "") { + defines += [ "CHIP_PROJECT_CONFIG_INCLUDE=${chip_project_config_include}" ] + } + if (chip_platform_config_include != "") { + defines += + [ "CHIP_PLATFORM_CONFIG_INCLUDE=${chip_platform_config_include}" ] + } + if (system_project_config_include != "") { + defines += + [ "SYSTEM_PROJECT_CONFIG_INCLUDE=${system_project_config_include}" ] + } + if (system_platform_config_include != "") { + defines += + [ "SYSTEM_PLATFORM_CONFIG_INCLUDE=${system_platform_config_include}" ] + } + if (chip_build_tests) { + defines += [ "CHIP_SYSTEM_CONFIG_TEST=1" ] + } else { + defines += [ "CHIP_SYSTEM_CONFIG_TEST=0" ] + } + if (chip_with_nlfaultinjection) { + defines += [ "CHIP_WITH_NLFAULTINJECTION=1" ] + } else { + defines += [ "CHIP_WITH_NLFAULTINJECTION=0" ] + } + if (chip_system_config_use_lwip) { + defines += [ "CHIP_SYSTEM_CONFIG_USE_LWIP=1" ] + } else { + defines += [ "CHIP_SYSTEM_CONFIG_USE_LWIP=0" ] + } + if (chip_system_config_use_sockets) { + defines += [ "CHIP_SYSTEM_CONFIG_USE_SOCKETS=1" ] + } else { + defines += [ "CHIP_SYSTEM_CONFIG_USE_SOCKETS=0" ] + } + if (chip_system_config_locking == "posix") { + defines += [ "CHIP_SYSTEM_CONFIG_POSIX_LOCKING=1" ] + } else { + defines += [ "CHIP_SYSTEM_CONFIG_POSIX_LOCKING=0" ] + } + if (chip_system_config_locking == "freertos") { + defines += [ "CHIP_SYSTEM_CONFIG_FREERTOS_LOCKING=1" ] + } else { + defines += [ "CHIP_SYSTEM_CONFIG_FREERTOS_LOCKING=0" ] + } + if (chip_system_config_locking == "none") { + defines += [ "CHIP_SYSTEM_CONFIG_NO_LOCKING=1" ] + } else { + defines += [ "CHIP_SYSTEM_CONFIG_NO_LOCKING=0" ] + } + if (chip_system_config_provide_statistics) { + defines += [ "CHIP_SYSTEM_CONFIG_PROVIDE_STATISTICS=1" ] + } else { + defines += [ "CHIP_SYSTEM_CONFIG_PROVIDE_STATISTICS=0" ] + } + if (chip_system_config_use_malloc) { + defines += [ "CONFIG_HAVE_HEAP=1" ] + defines += [ "HAVE_MALLOC=1" ] + defines += [ "HAVE_FREE=1" ] + } + if (chip_system_config_clock == "clock_gettime") { + defines += [ "HAVE_CLOCK_GETTIME=1" ] + defines += [ "HAVE_CLOCK_SETTIME=1" ] + } + if (chip_system_config_clock == "gettimeofday") { + defines += [ "HAVE_GETTIMEOFDAY=1" ] + } +} + +source_set("system_config_header") { + sources = [ "SystemConfig.h" ] + + public_configs = [ ":system_config" ] +} diff --git a/src/system/system.gni b/src/system/system.gni new file mode 100644 index 00000000000000..532390bd43a6b8 --- /dev/null +++ b/src/system/system.gni @@ -0,0 +1,54 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +declare_args() { + # Build tests. + chip_system_config_test = true + + # Use malloc. + chip_system_config_use_malloc = current_os != "freertos" + + # Use the lwIP library. + chip_system_config_use_lwip = current_os == "freertos" + + # Use BSD/POSIX socket API. + chip_system_config_use_sockets = current_os != "freertos" + + # Mutex implementation: posix, freertos, none. + chip_system_config_locking = "" + + # Clock implementation: clock_gettime, gettimeofday + chip_system_config_clock = "clock_gettime" + + # Enable metrics collection. + chip_system_config_provide_statistics = true +} + +if (chip_system_config_locking == "") { + if (current_os != "freertos") { + chip_system_config_locking = "posix" + } else { + chip_system_config_locking = "none" + } +} + +assert(chip_system_config_locking == "posix" || + chip_system_config_locking == "freertos" || + chip_system_config_locking == "none", + "Please select a valid mutex implementation: posix, freertos, none") + +assert( + chip_system_config_clock == "clock_gettime" || + chip_system_config_clock == "gettimeofday", + "Please select a valid clock implementation: clock_gettime, gettimeofday") From 5e29e725b72546b69139983d8ad09b130a734862 Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Wed, 20 May 2020 08:21:56 -0400 Subject: [PATCH 10/59] Add CHIPConfig to GN build --- BUILD.gn | 1 + src/lib/BUILD.gn | 17 +++++++ src/lib/core/BUILD.gn | 105 ++++++++++++++++++++++++++++++++++++++++++ src/lib/core/core.gni | 65 ++++++++++++++++++++++++++ 4 files changed, 188 insertions(+) create mode 100644 src/lib/BUILD.gn create mode 100644 src/lib/core/BUILD.gn create mode 100644 src/lib/core/core.gni diff --git a/BUILD.gn b/BUILD.gn index d182aa5b42d9da..fa867b66f4b553 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -16,6 +16,7 @@ import("build/tests.gni") group("all") { deps = [ + "src/lib/core:chip_config_header", "src/lwip:all", "src/system:system_config_header", "third_party/mbedtls", diff --git a/src/lib/BUILD.gn b/src/lib/BUILD.gn new file mode 100644 index 00000000000000..5f4d446904d611 --- /dev/null +++ b/src/lib/BUILD.gn @@ -0,0 +1,17 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +config("includes") { + include_dirs = [ "." ] +} diff --git a/src/lib/core/BUILD.gn b/src/lib/core/BUILD.gn new file mode 100644 index 00000000000000..91c7b92afd0797 --- /dev/null +++ b/src/lib/core/BUILD.gn @@ -0,0 +1,105 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/tests.gni") +import("core.gni") + +config("chip_config") { + # TODO - Move CHIP_PROJECT_CONFIG_INCLUDE, CHIP_PLATFORM_CONFIG_INCLUDE here. + # Currently those are also used from src/system. + defines = [] + + if (chip_build_tests) { + defines += [ "CHIP_CONFIG_TEST=1" ] + } else { + defines += [ "CHIP_CONFIG_TEST=0" ] + } + if (chip_error_logging) { + defines += [ "CHIP_ERROR_LOGGING=1" ] + } else { + defines += [ "CHIP_ERROR_LOGGING=0" ] + } + if (chip_progress_logging) { + defines += [ "CHIP_PROGRESS_LOGGING=1" ] + } else { + defines += [ "CHIP_PROGRESS_LOGGING=0" ] + } + if (chip_detail_logging) { + defines += [ "CHIP_DETAIL_LOGGING=1" ] + } else { + defines += [ "CHIP_DETAIL_LOGGING=0" ] + } + + if (chip_config_short_error_str) { + defines += [ "CHIP_CONFIG_SHORT_ERROR_STR=1" ] + } else { + defines += [ "CHIP_CONFIG_SHORT_ERROR_STR=0" ] + } + + if (chip_config_enable_arg_parser) { + defines += [ "CHIP_CONFIG_ENABLE_ARG_PARSER=1" ] + } else { + defines += [ "CHIP_CONFIG_ENABLE_ARG_PARSER=0" ] + } + + if (chip_target_style == "unix") { + defines += [ "CHIP_TARGET_STYLE_UNIX=1" ] + } else { + defines += [ "CHIP_TARGET_STYLE_UNIX=0" ] + } + if (chip_target_style == "embedded") { + defines += [ "CHIP_TARGET_STYLE_EMBEDDED=1" ] + } else { + defines += [ "CHIP_TARGET_STYLE_EMBEDDED=0" ] + } + + if (chip_logging_style == "android") { + defines += [ "CHIP_LOGGING_STYLE_ANDROID=1" ] + } else { + defines += [ "CHIP_LOGGING_STYLE_ANDROID=0" ] + } + if (chip_logging_style == "external") { + defines += [ "CHIP_LOGGING_STYLE_EXTERNAL=1" ] + } else { + defines += [ "CHIP_LOGGING_STYLE_EXTERNAL=0" ] + } + if (chip_logging_style == "stdio") { + defines += [ "CHIP_LOGGING_STYLE_STDIO=1" ] + } else { + defines += [ "CHIP_LOGGING_STYLE_STDIO=0" ] + } + if (chip_logging_style == "stdio_weak") { + defines += [ "CHIP_LOGGING_STYLE_STDIO_WEAK=1" ] + } else { + defines += [ "CHIP_LOGGING_STYLE_STDIO_WEAK=0" ] + } + + configs = [ + "//src:includes", + "//src/lib:includes", + ] +} + +source_set("chip_config_header") { + sources = [ + "CHIPConfig.h", + "CHIPEventLoggingConfig.h", + "CHIPTimeConfig.h", + "CHIPTunnelConfig.h", + ] + + public_configs = [ ":chip_config" ] + + public_deps = [ "//src/system:system_config_header" ] +} diff --git a/src/lib/core/core.gni b/src/lib/core/core.gni new file mode 100644 index 00000000000000..0fa97c99e2e57a --- /dev/null +++ b/src/lib/core/core.gni @@ -0,0 +1,65 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +declare_args() { + # Enable logging. Shorthand for chip_error_logging, etc. + chip_logging = true +} + +declare_args() { + # Configure target tyle: unix, embedded. + chip_target_style = "" + + # Configure logging style: stdio, external. + chip_logging_style = "" + + # Enable error logging. + chip_error_logging = chip_logging + + # Enable progress logging. + chip_progress_logging = chip_logging + + # Enable detail logging. + chip_detail_logging = chip_logging + + # Enable short error strings. + chip_config_short_error_str = false + + # Enable argument parser. + chip_config_enable_arg_parser = true +} + +if (chip_target_style == "") { + if (current_os != "freertos") { + chip_target_style = "unix" + } else { + chip_target_style = "embedded" + } +} + +if (chip_logging_style == "") { + if (current_os != "freertos") { + chip_logging_style = "stdio" + } else { + chip_logging_style = "external" + } +} + +assert(chip_target_style == "unix" || chip_target_style == "embedded", + "Please select a valid target style: unix, embedded") + +assert( + chip_logging_style == "android" || chip_logging_style == "external" || + chip_logging_style == "stdio" || chip_logging_style == "stdio_weak", + "Please select a valid logging style: android, external, stdio, stdio_weak") From 2482c796bce93eab71cfbfd54866494075996a5e Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Wed, 20 May 2020 08:55:49 -0400 Subject: [PATCH 11/59] Add src/lib/support to GN build --- BUILD.gn | 1 + src/BUILD.gn | 6 ++++ src/lib/support/BUILD.gn | 71 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+) create mode 100644 src/lib/support/BUILD.gn diff --git a/BUILD.gn b/BUILD.gn index fa867b66f4b553..9bffcff3a003fa 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -17,6 +17,7 @@ import("build/tests.gni") group("all") { deps = [ "src/lib/core:chip_config_header", + "src/lib/support", "src/lwip:all", "src/system:system_config_header", "third_party/mbedtls", diff --git a/src/BUILD.gn b/src/BUILD.gn index 5f4d446904d611..24c34ce9108087 100644 --- a/src/BUILD.gn +++ b/src/BUILD.gn @@ -12,6 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. +config("public_includes") { + include_dirs = [ "include" ] +} + config("includes") { include_dirs = [ "." ] + + configs = [ ":public_includes" ] } diff --git a/src/lib/support/BUILD.gn b/src/lib/support/BUILD.gn new file mode 100644 index 00000000000000..826bf3d9876d56 --- /dev/null +++ b/src/lib/support/BUILD.gn @@ -0,0 +1,71 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/tests.gni") + +config("support_config") { + configs = [ + "//src:includes", + "//src/lib:includes", + "//src/system:system_config", + ] +} + +static_library("support") { + sources = [ + "Base64.cpp", + "Base64.h", + "CHIPArgParser.cpp", + "CHIPCounter.cpp", + "CHIPCounter.h", + "CodeUtils.h", + "DLLUtil.h", + "ErrorStr.cpp", + "ErrorStr.h", + "FibonacciUtils.cpp", + "FibonacciUtils.h", + "PersistedCounter.cpp", + "PersistedCounter.h", + "RandUtils.cpp", + "RandUtils.h", + "TestUtils.cpp", + "TestUtils.h", + "TimeUtils.cpp", + "TimeUtils.h", + "logging/CHIPLogging.cpp", + "logging/CHIPLogging.h", + "logging/CHIPLoggingLogV.cpp", + "verhoeff/Verhoeff.cpp", + "verhoeff/Verhoeff.h", + "verhoeff/Verhoeff10.cpp", + "verhoeff/Verhoeff16.cpp", + "verhoeff/Verhoeff32.cpp", + "verhoeff/Verhoeff36.cpp", + ] + + public_deps = [ + "//src/lib/core:chip_config_header", + "//third_party/nlassert", + ] + + public_configs = [ ":support_config" ] + + if (chip_with_nlfaultinjection) { + sources += [ + "CHIPFaultInjection.cpp", + "CHIPFaultInjection.h", + ] + public_deps += [ "//third_party/nlfaultinjection" ] + } +} From 39c687181d0aa6f0bf6a046632072aa7fc374350 Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Wed, 20 May 2020 09:04:17 -0400 Subject: [PATCH 12/59] Add src/system to GN build --- BUILD.gn | 2 +- src/system/BUILD.gn | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/BUILD.gn b/BUILD.gn index 9bffcff3a003fa..0e1b3f54c2fe27 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -19,7 +19,7 @@ group("all") { "src/lib/core:chip_config_header", "src/lib/support", "src/lwip:all", - "src/system:system_config_header", + "src/system", "third_party/mbedtls", "third_party/nlassert", "third_party/nlfaultinjection", diff --git a/src/system/BUILD.gn b/src/system/BUILD.gn index 32ae2668a9ad26..dd0a01f4cb66f0 100644 --- a/src/system/BUILD.gn +++ b/src/system/BUILD.gn @@ -109,3 +109,40 @@ source_set("system_config_header") { public_configs = [ ":system_config" ] } + +source_set("system") { + sources = [ + "SystemAlignSize.h", + "SystemClock.cpp", + "SystemClock.h", + "SystemConfig.h", + "SystemError.cpp", + "SystemError.h", + "SystemEvent.h", + "SystemFaultInjection.h", + "SystemLayer.cpp", + "SystemLayer.h", + "SystemLayerPrivate.h", + "SystemMutex.cpp", + "SystemMutex.h", + "SystemObject.cpp", + "SystemObject.h", + "SystemPacketBuffer.cpp", + "SystemPacketBuffer.h", + "SystemStats.cpp", + "SystemStats.h", + "SystemTimer.cpp", + "SystemTimer.h", + "TimeSource.h", + ] + + public_deps = [ + "//src/lib/support", + "//third_party/nlassert", + ] + + if (chip_with_nlfaultinjection) { + sources += [ "SystemFaultInjection.cpp" ] + public_deps += [ "//third_party/nlfaultinjection" ] + } +} From 43d65929c17830f1ffb0ad985c4823eb630a223a Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Wed, 20 May 2020 09:36:03 -0400 Subject: [PATCH 13/59] Add src/inet to GN build --- BUILD.gn | 1 + src/inet/BUILD.gn | 149 ++++++++++++++++++++++++++++++++++++++++++++++ src/inet/inet.gni | 36 +++++++++++ 3 files changed, 186 insertions(+) create mode 100644 src/inet/BUILD.gn create mode 100644 src/inet/inet.gni diff --git a/BUILD.gn b/BUILD.gn index 0e1b3f54c2fe27..0db022481e0c75 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -16,6 +16,7 @@ import("build/tests.gni") group("all") { deps = [ + "src/inet", "src/lib/core:chip_config_header", "src/lib/support", "src/lwip:all", diff --git a/src/inet/BUILD.gn b/src/inet/BUILD.gn new file mode 100644 index 00000000000000..417ff954434886 --- /dev/null +++ b/src/inet/BUILD.gn @@ -0,0 +1,149 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/tests.gni") +import("inet.gni") + +declare_args() { + # Extra header to include in SystemConfig.h for project. + inet_project_config_include = "" + + # Extra header to include in SystemConfig.h for platform. + inet_platform_config_include = "" +} + +config("inet_config") { + configs = [ "//src:includes" ] + + defines = [] + if (inet_project_config_include != "") { + defines += [ "INET_PROJECT_CONFIG_INCLUDE=${inet_project_config_include}" ] + } + if (inet_platform_config_include != "") { + defines += + [ "INET_PLATFORM_CONFIG_INCLUDE=${inet_platform_config_include}" ] + } + if (chip_build_tests) { + defines += [ "INET_CONFIG_TEST=1" ] + } else { + defines += [ "INET_CONFIG_TEST=0" ] + } + if (inet_config_enable_ipv4) { + defines += [ "INET_CONFIG_ENABLE_IPV4=1" ] + } else { + defines += [ "INET_CONFIG_ENABLE_IPV4=0" ] + } + if (inet_config_enable_dns_resolver) { + defines += [ "INET_CONFIG_ENABLE_DNS_RESOLVER=1" ] + } else { + defines += [ "INET_CONFIG_ENABLE_DNS_RESOLVER=0" ] + } + if (inet_config_enable_async_dns_sockets) { + defines += [ "INET_CONFIG_ENABLE_ASYNC_DNS_SOCKETS=1" ] + } else { + defines += [ "INET_CONFIG_ENABLE_ASYNC_DNS_SOCKETS=0" ] + } + if (inet_config_enable_raw_endpoint) { + defines += [ "INET_CONFIG_ENABLE_RAW_ENDPOINT=1" ] + } else { + defines += [ "INET_CONFIG_ENABLE_RAW_ENDPOINT=0" ] + } + if (inet_config_enable_tcp_endpoint) { + defines += [ "INET_CONFIG_ENABLE_TCP_ENDPOINT=1" ] + } else { + defines += [ "INET_CONFIG_ENABLE_TCP_ENDPOINT=0" ] + } + if (inet_config_enable_tun_endpoint) { + defines += [ "INET_CONFIG_ENABLE_TUN_ENDPOINT=1" ] + } else { + defines += [ "INET_CONFIG_ENABLE_TUN_ENDPOINT=0" ] + } + if (inet_config_enable_udp_endpoint) { + defines += [ "INET_CONFIG_ENABLE_UDP_ENDPOINT=1" ] + } else { + assert(false, "CHIP currently request UDP endpoint") + } +} + +source_set("inet_config_header") { + sources = [ "InetConfig.h" ] + + public_configs = [ ":inet_config" ] + + public_deps = [ "//src/system:system_config_header" ] +} + +source_set("inet") { + sources = [ + "AsyncDNSResolverSockets.cpp", + "AsyncDNSResolverSockets.h", + "EndPointBasis.cpp", + "EndPointBasis.h", + "IANAConstants.h", + "IPAddress-StringFuncts.cpp", + "IPAddress.cpp", + "IPAddress.h", + "IPEndPointBasis.cpp", + "IPEndPointBasis.h", + "IPPrefix.cpp", + "IPPrefix.h", + "Inet.h", + "InetArgParser.cpp", + "InetArgParser.h", + "InetError.cpp", + "InetError.h", + "InetFaultInjection.h", + "InetInterface.cpp", + "InetInterface.h", + "InetLayer.cpp", + "InetLayer.h", + "InetLayerBasis.cpp", + "InetLayerBasis.h", + "InetLayerEvents.h", + "InetUtils.cpp", + "RawEndPoint.cpp", + "RawEndPoint.h", + "TCPEndPoint.cpp", + "TCPEndPoint.h", + "UDPEndPoint.cpp", + "UDPEndPoint.h", + "arpa-inet-compatibility.h", + ] + + public_deps = [ + ":inet_config_header", + "//src/lib/support", + "//src/system", + "//third_party/nlio", + ] + + if (inet_config_enable_dns_resolver) { + sources += [ + "DNSResolver.cpp", + "DNSResolver.h", + ] + } + + if (inet_config_enable_tun_endpoint) { + sources += [ + "TunEndPoint.cpp", + "TunEndPoint.h", + ] + } + + if (chip_with_nlfaultinjection) { + sources += [ "InetFaultInjection.cpp" ] + public_deps += [ "//third_party/nlfaultinjection" ] + } +} diff --git a/src/inet/inet.gni b/src/inet/inet.gni new file mode 100644 index 00000000000000..380c0e31e00577 --- /dev/null +++ b/src/inet/inet.gni @@ -0,0 +1,36 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +declare_args() { + # Enable IPv4 support. + inet_config_enable_ipv4 = true + + # Enable DNS resolver. + inet_config_enable_dns_resolver = true + + # Enable async DNS. + inet_config_enable_async_dns_sockets = true + + # Enable raw endpoint. + inet_config_enable_raw_endpoint = true + + # Enable UDP endpoint. + inet_config_enable_udp_endpoint = true + + # Enable TCP endpoint. + inet_config_enable_tcp_endpoint = true + + # Enable TUN endpoint. + inet_config_enable_tun_endpoint = current_os == "linux" +} From d2d6e3a30afd06e68bbf46e41c0bc676cf566d0e Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Wed, 20 May 2020 11:49:02 -0400 Subject: [PATCH 14/59] Add BLE to GN build --- BUILD.gn | 1 + src/ble/BUILD.gn | 75 ++++++++++++++++++++++++++++++++++++++++++++++++ src/ble/ble.gni | 18 ++++++++++++ 3 files changed, 94 insertions(+) create mode 100644 src/ble/BUILD.gn create mode 100644 src/ble/ble.gni diff --git a/BUILD.gn b/BUILD.gn index 0db022481e0c75..68738ae97f2918 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -16,6 +16,7 @@ import("build/tests.gni") group("all") { deps = [ + "src/ble", "src/inet", "src/lib/core:chip_config_header", "src/lib/support", diff --git a/src/ble/BUILD.gn b/src/ble/BUILD.gn new file mode 100644 index 00000000000000..28e7c840bc7fb2 --- /dev/null +++ b/src/ble/BUILD.gn @@ -0,0 +1,75 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("ble.gni") + +declare_args() { + # Extra header to include in BleConfig.h for project. + ble_project_config_include = "" + + # Extra header to include in BleConfig.h for platform. + ble_platform_config_include = "" +} + +config("ble_config") { + configs = [ "//src:includes" ] + + defines = [] + if (ble_project_config_include != "") { + defines += [ "BLE_PROJECT_CONFIG_INCLUDE=${ble_project_config_include}" ] + } + if (ble_platform_config_include != "") { + defines += [ "BLE_PLATFORM_CONFIG_INCLUDE=${ble_platform_config_include}" ] + } + + if (config_network_layer_ble) { + defines += [ "CONFIG_NETWORK_LAYER_BLE=1" ] + } else { + defines += [ "CONFIG_NETWORK_LAYER_BLE=0" ] + } +} + +source_set("ble_config_header") { + sources = [ "BleConfig.h" ] + + public_configs = [ ":ble_config" ] + + public_deps = [ "//src/system:system_config_header" ] +} + +source_set("ble") { + sources = [ + "BLEEndPoint.cpp", + "BLEEndPoint.h", + "Ble.h", + "BleApplicationDelegate.h", + "BleConfig.h", + "BleError.cpp", + "BleError.h", + "BleLayer.cpp", + "BleLayer.h", + "BlePlatformDelegate.h", + "BleUUID.cpp", + "BleUUID.h", + "BtpEngine.cpp", + "BtpEngine.h", + "CHIPBleServiceData.h", + ] + + public_deps = [ + ":ble_config_header", + "//src/inet", + "//src/lib/support", + ] +} diff --git a/src/ble/ble.gni b/src/ble/ble.gni new file mode 100644 index 00000000000000..f532ab579ecda5 --- /dev/null +++ b/src/ble/ble.gni @@ -0,0 +1,18 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +declare_args() { + # Enable BLE support. + config_network_layer_ble = true +} From 3f186fe2c07c0b0de193326b959b1d2055940bcb Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Wed, 20 May 2020 12:04:33 -0400 Subject: [PATCH 15/59] Add src/lib/core to GN build --- BUILD.gn | 2 +- src/lib/core/BUILD.gn | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/BUILD.gn b/BUILD.gn index 68738ae97f2918..f92b93d37c4ca2 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -18,7 +18,7 @@ group("all") { deps = [ "src/ble", "src/inet", - "src/lib/core:chip_config_header", + "src/lib/core", "src/lib/support", "src/lwip:all", "src/system", diff --git a/src/lib/core/BUILD.gn b/src/lib/core/BUILD.gn index 91c7b92afd0797..ca1427544af1b7 100644 --- a/src/lib/core/BUILD.gn +++ b/src/lib/core/BUILD.gn @@ -13,6 +13,7 @@ # limitations under the License. import("//build/tests.gni") +import("//src/inet/inet.gni") import("core.gni") config("chip_config") { @@ -103,3 +104,41 @@ source_set("chip_config_header") { public_deps = [ "//src/system:system_config_header" ] } + +source_set("core") { + sources = [ + "CHIPCallback.h", + "CHIPCircularTLVBuffer.cpp", + "CHIPCircularTLVBuffer.h", + "CHIPCore.h", + "CHIPEncoding.h", + "CHIPError.cpp", + "CHIPError.h", + "CHIPKeyIds.cpp", + "CHIPKeyIds.h", + "CHIPTLV.h", + "CHIPTLVDebug.cpp", + "CHIPTLVReader.cpp", + "CHIPTLVTags.h", + "CHIPTLVTypes.h", + "CHIPTLVUpdater.cpp", + "CHIPTLVUtilities.cpp", + "CHIPTLVWriter.cpp", + ] + + public_deps = [ + ":chip_config_header", + "//src/ble", + "//src/inet", + "//src/lib/support", + "//src/system", + "//third_party/nlio", + ] + + allow_circular_includes_from = [ + "//src/ble", + "//src/lib/support", + "//src/inet", + "//src/system", + ] +} From 1cd9fbcca41ca57c4333230a7438df41d3af244c Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Wed, 20 May 2020 23:02:50 -0400 Subject: [PATCH 16/59] Add src/crypto to GN build --- BUILD.gn | 1 + src/crypto/BUILD.gn | 59 +++++++++++++++++++++++++++++++++++++++++++ src/crypto/crypto.gni | 29 +++++++++++++++++++++ 3 files changed, 89 insertions(+) create mode 100644 src/crypto/BUILD.gn create mode 100644 src/crypto/crypto.gni diff --git a/BUILD.gn b/BUILD.gn index f92b93d37c4ca2..6f60af4dc0799b 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -17,6 +17,7 @@ import("build/tests.gni") group("all") { deps = [ "src/ble", + "src/crypto", "src/inet", "src/lib/core", "src/lib/support", diff --git a/src/crypto/BUILD.gn b/src/crypto/BUILD.gn new file mode 100644 index 00000000000000..19531e114e235c --- /dev/null +++ b/src/crypto/BUILD.gn @@ -0,0 +1,59 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("crypto.gni") + +config("crypto_config") { + defines = [] + if (chip_crypto == "mbedtls") { + defines += [ "CHIP_CRYPTO_MBEDTLS=1" ] + } else { + defines += [ "CHIP_CRYPTO_MBEDTLS=0" ] + } + if (chip_crypto == "openssl") { + defines += [ "CHIP_CRYPTO_OPENSSL=1" ] + } else { + defines += [ "CHIP_CRYPTO_OPENSSL=0" ] + } +} + +if (chip_crypto == "openssl") { + config("openssl_config") { + libs = [ + "ssl", + "crypto", + ] + } +} + +source_set("crypto") { + sources = [ "CHIPCryptoPAL.h" ] + + public_deps = [ + "//src/lib/core", + "//third_party/nlassert", + ] + + public_configs = [ ":crypto_config" ] + + if (chip_crypto == "mbedtls") { + sources += [ "CHIPCryptoPALmbedTLS.cpp" ] + public_deps += [ "//third_party/mbedtls" ] + } else if (chip_crypto == "openssl") { + sources += [ "CHIPCryptoPALOpenSSL.cpp" ] + public_configs += [ ":openssl_config" ] + } else { + assert(false, "Invalid CHIP crypto") + } +} diff --git a/src/crypto/crypto.gni b/src/crypto/crypto.gni new file mode 100644 index 00000000000000..bf37682cffae58 --- /dev/null +++ b/src/crypto/crypto.gni @@ -0,0 +1,29 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +declare_args() { + # Crypto implementation: mbedtls, openssl. + chip_crypto = "" +} + +if (chip_crypto == "") { + if (current_os == "freertos" || current_os == "mac") { + chip_crypto = "mbedtls" + } else { + chip_crypto = "openssl" + } +} + +assert(chip_crypto == "mbedtls" || chip_crypto == "openssl", + "Please select a valid crypto implementation: mbedtls, openssl") From 3a2dc2d4823de847ddd8d649de17246f47c7e90d Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Mon, 15 Jun 2020 17:57:29 -0400 Subject: [PATCH 17/59] Add transport to GN build --- BUILD.gn | 1 + src/transport/BUILD.gn | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 src/transport/BUILD.gn diff --git a/BUILD.gn b/BUILD.gn index 6f60af4dc0799b..7e8f531eb36974 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -23,6 +23,7 @@ group("all") { "src/lib/support", "src/lwip:all", "src/system", + "src/transport", "third_party/mbedtls", "third_party/nlassert", "third_party/nlfaultinjection", diff --git a/src/transport/BUILD.gn b/src/transport/BUILD.gn new file mode 100644 index 00000000000000..177a8cf1a4d97b --- /dev/null +++ b/src/transport/BUILD.gn @@ -0,0 +1,37 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +source_set("transport") { + sources = [ + "Base.h", + "MessageHeader.cpp", + "MessageHeader.h", + "PeerAddress.h", + "PeerConnectionState.h", + "PeerConnections.h", + "SecureSession.cpp", + "SecureSession.h", + "SecureSessionMgr.cpp", + "SecureSessionMgr.h", + "UDP.cpp", + "UDP.h", + ] + + public_deps = [ + "//src/crypto", + "//src/inet", + "//src/lib/core", + "//src/lib/support", + ] +} From 6fb7847859fcce127c8ec0d6280b75b876581f22 Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Wed, 20 May 2020 12:20:51 -0400 Subject: [PATCH 18/59] Add src/controller to GN build --- BUILD.gn | 1 + src/controller/BUILD.gn | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 src/controller/BUILD.gn diff --git a/BUILD.gn b/BUILD.gn index 7e8f531eb36974..b9eb30f14b26a3 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -17,6 +17,7 @@ import("build/tests.gni") group("all") { deps = [ "src/ble", + "src/controller", "src/crypto", "src/inet", "src/lib/core", diff --git a/src/controller/BUILD.gn b/src/controller/BUILD.gn new file mode 100644 index 00000000000000..9603d9c735c441 --- /dev/null +++ b/src/controller/BUILD.gn @@ -0,0 +1,26 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +source_set("controller") { + sources = [ + "CHIPDeviceController.cpp", + "CHIPDeviceController.h", + ] + + public_deps = [ + "//src/lib/core", + "//src/lib/support", + "//src/transport", + ] +} From 300ce26fb64240dbaf85d2228e7fe6e679e9f273 Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Wed, 20 May 2020 12:57:03 -0400 Subject: [PATCH 19/59] Add libCHIP.a to GN build --- BUILD.gn | 1 + src/BUILD.gn | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/BUILD.gn b/BUILD.gn index b9eb30f14b26a3..92ced096a0ad70 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -16,6 +16,7 @@ import("build/tests.gni") group("all") { deps = [ + "src", "src/ble", "src/controller", "src/crypto", diff --git a/src/BUILD.gn b/src/BUILD.gn index 24c34ce9108087..1682ff9e7659d2 100644 --- a/src/BUILD.gn +++ b/src/BUILD.gn @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//build_overrides/chip.gni") + config("public_includes") { include_dirs = [ "include" ] } @@ -21,3 +23,26 @@ config("includes") { configs = [ ":public_includes" ] } + +static_library("chip") { + public_deps = [ + "ble", + "controller", + "crypto", + "inet", + "lib/core", + "lib/support", + "system", + "transport", + ] + + output_name = "libCHIP" + + output_dir = "${root_out_dir}/lib" + + complete_static_lib = true +} + +group("src") { + deps = [ ":chip" ] +} From a9604a85193577e141ea98cc0fbeef95f122634d Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Wed, 20 May 2020 22:06:29 -0400 Subject: [PATCH 20/59] Add CHIPVersion.h generation to GN build --- build/chip_version.gni | 27 +++++ scripts/gen_chip_version.py | 231 ++++++++++++++++++++++++++++++++++++ src/lib/support/BUILD.gn | 24 ++++ 3 files changed, 282 insertions(+) create mode 100644 build/chip_version.gni create mode 100755 scripts/gen_chip_version.py diff --git a/build/chip_version.gni b/build/chip_version.gni new file mode 100644 index 00000000000000..2cbeb38d7ee828 --- /dev/null +++ b/build/chip_version.gni @@ -0,0 +1,27 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +declare_args() { + # CHIP major version number. + chip_version_major = 0 + + # CHIP minor version number. + chip_version_minor = 0 + + # CHIP patch version number. + chip_version_patch = 0 + + # CHIP extra version string. + chip_version_extra = "" +} diff --git a/scripts/gen_chip_version.py b/scripts/gen_chip_version.py new file mode 100755 index 00000000000000..36348f6be4e9f3 --- /dev/null +++ b/scripts/gen_chip_version.py @@ -0,0 +1,231 @@ +#!/usr/bin/env python + +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import optparse +import sys + +TEMPLATE = '''/* + * + * Copyright (c) 2020 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the \"License\"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an \"AS IS\" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * \@file + * This file defines constants and macros for introspecting and + * manipulating CHIP versions. + * + * !!! WARNING !!! WARNING !!! WARNING !!! WARNING !!! + * + * DO NOT EDIT THIS FILE! This file is automatically-generated by + * the '${program}' script. + * + * The constants and macros defined here may be used to, for , + * example, conditionally-compile older, newer, or changed CHIP + * APIs based on the CHIP version. For example: + * + * \@code + * #if CHIP_VERSION_CODE >= CHIP_VERSION_CODE_ENCODE(1, 5, 0) + * ... + * #else + * ... + * #endif + * \@endcode + * + */ + +#ifndef CHIP_VERSION_H_ +#define CHIP_VERSION_H_ + +#define _CHIP_VERSION_CODE_MAJOR_WIDTH 8 +#define _CHIP_VERSION_CODE_MINOR_WIDTH 8 +#define _CHIP_VERSION_CODE_PATCH_WIDTH 8 + +#define _CHIP_VERSION_CODE_MAJOR_MASK ((1 << _CHIP_VERSION_CODE_MAJOR_WIDTH) - 1) +#define _CHIP_VERSION_CODE_MINOR_MASK ((1 << _CHIP_VERSION_CODE_MINOR_WIDTH) - 1) +#define _CHIP_VERSION_CODE_PATCH_MASK ((1 << _CHIP_VERSION_CODE_PATCH_WIDTH) - 1) + +#define _CHIP_VERSION_CODE_MAJOR_SHIFT 24 +#define _CHIP_VERSION_CODE_MINOR_SHIFT 16 +#define _CHIP_VERSION_CODE_PATCH_SHIFT 8 + +/** + * \@def CHIP_VERSION_CODE_ENCODE(major, minor, patch) + * + * \@brief + * Encode a CHIP version code from its constituent \@a major, \@a minor, and \@a patch + * components. + * + * This macro may be used in conjunction with CHIP_VERSION_CODE to, for + * example, conditionally-compile older, newer, or changed CHIP APIs based + * on the CHIP version. For example: + * + * \@code + * #if CHIP_VERSION_CODE >= CHIP_VERSION_CODE_ENCODE(1, 5, 0) + * ... + * #else + * ... + * #endif + * \@endcode + * + */ +#define CHIP_VERSION_CODE_ENCODE(major, minor, patch) \\ + ((((major) & _CHIP_VERSION_CODE_MAJOR_MASK) << _CHIP_VERSION_CODE_MAJOR_SHIFT) | \\ + (((minor) & _CHIP_VERSION_CODE_MINOR_MASK) << _CHIP_VERSION_CODE_MINOR_SHIFT) | \\ + (((patch) & _CHIP_VERSION_CODE_PATCH_MASK) << _CHIP_VERSION_CODE_PATCH_SHIFT)) + +/** + * \@def CHIP_VERSION_CODE_DECODE_MAJOR(code) + * + * \@brief + * Decode a CHIP major version component from a CHIP version \@a code. + * + */ +#define CHIP_VERSION_CODE_DECODE_MAJOR(code) (((code) >> _CHIP_VERSION_CODE_MAJOR_SHIFT) & _CHIP_VERSION_CODE_MAJOR_MASK) + +/** + * \@def CHIP_VERSION_CODE_DECODE_MINOR(code) + * + * \@brief + * Decode a CHIP minor version component from a CHIP version \@a code. + * + */ +#define CHIP_VERSION_CODE_DECODE_MINOR(code) (((code) >> _CHIP_VERSION_CODE_MINOR_SHIFT) & _CHIP_VERSION_CODE_MINOR_MASK) + +/** + * \@def CHIP_VERSION_CODE_DECODE_PATCH(code) + * + * \@brief + * Decode a CHIP patch version component from a CHIP version \@a code. + * + */ +#define CHIP_VERSION_CODE_DECODE_PATCH(code) (((code) >> _CHIP_VERSION_CODE_PATCH_SHIFT) & _CHIP_VERSION_CODE_PATCH_MASK) + +/** + * \@def CHIP_VERSION_MAJOR + * + * \@brief + * The CHIP version major component, as an unsigned integer. + * + */ +#define CHIP_VERSION_MAJOR %(chip_major)d + +/** + * \@def CHIP_VERSION_MINOR + * + * \@brief + * The CHIP version minor component, as an unsigned integer. + * + */ +#define CHIP_VERSION_MINOR %(chip_minor)d + +/** + * \@def CHIP_VERSION_PATCH + * + * \@brief + * The CHIP version patch component, as an unsigned integer. + * + */ +#define CHIP_VERSION_PATCH %(chip_patch)d + +/** + * \@def CHIP_VERSION_EXTRA + * + * \@brief + * The CHIP version extra component, as a quoted C string. + * + */ +#define CHIP_VERSION_EXTRA \"%(chip_extra)s\" + +/** + * \@def CHIP_VERSION_STRING + * + * \@brief + * The CHIP version, as a quoted C string. + * + */ +#define CHIP_VERSION_STRING \"%(chip_version)s\" + +/** + * \@def CHIP_VERSION_CODE + * + * \@brief + * The CHIP version, including the major, minor, and patch components, + * encoded as an unsigned integer. + * + * This macro may be used in conjunction with CHIP_VERSION_CODE_ENCODE + * to, for example, conditionally-compile older, newer, or changed CHIP + * APIs based on the CHIP version. For example: + * + * \@code + * #if CHIP_VERSION_CODE >= CHIP_VERSION_CODE_ENCODE(1, 5, 0) + * ... + * #else + * ... + * #endif + * \@endcode + * + */ +#define CHIP_VERSION_CODE CHIP_VERSION_CODE_ENCODE( \\ + CHIP_VERSION_MAJOR, \\ + CHIP_VERSION_MINOR, \\ + CHIP_VERSION_PATCH \\ + ) + +#endif /* CHIP_VERSION_H_ */ +''' + + +def main(argv): + parser = optparse.OptionParser() + + parser.add_option('--output_file') + parser.add_option('--chip_major', type=int, default=0) + parser.add_option('--chip_minor', type=int, default=0) + parser.add_option('--chip_patch', type=int, default=0) + parser.add_option('--chip_extra', type=str, default='') + + options, _ = parser.parse_args(argv) + + template_args = { + 'chip_major': options.chip_major, + 'chip_minor': options.chip_minor, + 'chip_patch': options.chip_patch, + 'chip_extra': options.chip_extra, + } + + template_args['chip_version'] = '%d.%d.%d%s' % (options.chip_major, options.chip_minor, options.chip_patch, options.chip_extra) + + with open(options.output_file, 'w') as chip_version_file: + chip_version_file.write(TEMPLATE % template_args) + + return 0 + + +if __name__ == '__main__': + sys.exit(main(sys.argv[1:])) diff --git a/src/lib/support/BUILD.gn b/src/lib/support/BUILD.gn index 826bf3d9876d56..c8cdacbb8ea1ce 100644 --- a/src/lib/support/BUILD.gn +++ b/src/lib/support/BUILD.gn @@ -12,14 +12,37 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//build/chip_version.gni") import("//build/tests.gni") +action("gen_chip_version") { + script = "//scripts/gen_chip_version.py" + + version_file = "${target_gen_dir}/CHIPVersion.h" + outputs = [ version_file ] + args = [ + "--output_file=" + rebase_path(version_file, root_build_dir), + "--chip_major=${chip_version_major}", + "--chip_minor=${chip_version_minor}", + "--chip_patch=${chip_version_patch}", + "--chip_extra={chip_version_extra}", + ] +} + +source_set("chip_version_header") { + sources = get_target_outputs(":gen_chip_version") + + deps = [ ":gen_chip_version" ] +} + config("support_config") { configs = [ "//src:includes", "//src/lib:includes", "//src/system:system_config", ] + + include_dirs = [ target_gen_dir ] } static_library("support") { @@ -55,6 +78,7 @@ static_library("support") { ] public_deps = [ + ":chip_version_header", "//src/lib/core:chip_config_header", "//third_party/nlassert", ] From f06d13b606735f1cd929d14d8c1f776319fa5efb Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Wed, 20 May 2020 22:08:23 -0400 Subject: [PATCH 21/59] Add src/lib/support/tests to GN build --- BUILD.gn | 5 +++- build/chip_test_suite.gni | 47 ++++++++++++++++++++++++++++++++++ src/lib/core/BUILD.gn | 2 ++ src/lib/support/tests/BUILD.gn | 39 ++++++++++++++++++++++++++++ 4 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 build/chip_test_suite.gni create mode 100644 src/lib/support/tests/BUILD.gn diff --git a/BUILD.gn b/BUILD.gn index 92ced096a0ad70..2548674e084370 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -34,6 +34,9 @@ group("all") { ] if (chip_build_tests) { - deps += [ "src/lwip/tests" ] + deps += [ + "src/lib/support/tests", + "src/lwip/tests", + ] } } diff --git a/build/chip_test_suite.gni b/build/chip_test_suite.gni new file mode 100644 index 00000000000000..5ce1ffe93791bc --- /dev/null +++ b/build/chip_test_suite.gni @@ -0,0 +1,47 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/tests.gni") + +assert(chip_build_tests) + +template("chip_test_suite") { + suite_name = target_name + + static_library("${suite_name}_common") { + forward_variables_from(invoker, + [ + "deps", + "public_deps", + ]) + if (defined(invoker.common_sources)) { + sources = invoker.common_sources + } + } + + tests = [] + foreach(test, invoker.tests) { + executable(test) { + sources = [ "${test}Driver.cpp" ] + + public_deps = [ ":${suite_name}_common" ] + } + + tests += [ ":${test}" ] + } + + group(suite_name) { + deps = tests + } +} diff --git a/src/lib/core/BUILD.gn b/src/lib/core/BUILD.gn index ca1427544af1b7..b3488bdbdb8202 100644 --- a/src/lib/core/BUILD.gn +++ b/src/lib/core/BUILD.gn @@ -86,6 +86,8 @@ config("chip_config") { defines += [ "CHIP_LOGGING_STYLE_STDIO_WEAK=0" ] } + include_dirs = [ target_gen_dir ] + configs = [ "//src:includes", "//src/lib:includes", diff --git a/src/lib/support/tests/BUILD.gn b/src/lib/support/tests/BUILD.gn new file mode 100644 index 00000000000000..23fb0a87157258 --- /dev/null +++ b/src/lib/support/tests/BUILD.gn @@ -0,0 +1,39 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/chip_test_suite.gni") + +chip_test_suite("tests") { + common_sources = [ + "TestCHIPArgParser.cpp", + "TestCHIPCounter.cpp", + "TestErrorStr.cpp", + "TestPersistedCounter.cpp", + "TestPersistedStorageImplementation.cpp", + "TestPersistedStorageImplementation.h", + "TestSupport.h", + "TestTimeUtils.cpp", + ] + + public_deps = [ + "//src/lib/core", + "//third_party/nlunit-test", + ] + + tests = [ + "TestErrorStr", + "TestCHIPArgParser", + "TestTimeUtils", + ] +} From ef0be27bb1f4754e8516baa9e60d6017dfd97e8e Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Wed, 20 May 2020 20:58:45 -0400 Subject: [PATCH 22/59] Add src/system/tests to GN build --- BUILD.gn | 1 + src/system/tests/BUILD.gn | 40 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 src/system/tests/BUILD.gn diff --git a/BUILD.gn b/BUILD.gn index 2548674e084370..ab4152b30ff969 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -37,6 +37,7 @@ group("all") { deps += [ "src/lib/support/tests", "src/lwip/tests", + "src/system/tests", ] } } diff --git a/src/system/tests/BUILD.gn b/src/system/tests/BUILD.gn new file mode 100644 index 00000000000000..be5bff5de74ad8 --- /dev/null +++ b/src/system/tests/BUILD.gn @@ -0,0 +1,40 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/chip_test_suite.gni") + +chip_test_suite("tests") { + common_sources = [ + "TestSystemErrorStr.cpp", + "TestSystemLayer.h", + "TestSystemObject.cpp", + "TestSystemPacketBuffer.cpp", + "TestSystemTimer.cpp", + "TestTimeSource.cpp", + ] + + public_deps = [ + "//src/inet", + "//src/system", + "//third_party/nlunit-test", + ] + + tests = [ + "TestSystemErrorStr", + "TestSystemObject", + "TestSystemPacketBuffer", + "TestSystemTimer", + "TestTimeSource", + ] +} From 8ac81f13e2d886a026fd512b4db8043053667793 Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Wed, 20 May 2020 22:35:32 -0400 Subject: [PATCH 23/59] Add src/inet/tests to GN build --- BUILD.gn | 1 + src/inet/tests/BUILD.gn | 46 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 src/inet/tests/BUILD.gn diff --git a/BUILD.gn b/BUILD.gn index ab4152b30ff969..f08cf1e5c52699 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -35,6 +35,7 @@ group("all") { if (chip_build_tests) { deps += [ + "src/inet/tests", "src/lib/support/tests", "src/lwip/tests", "src/system/tests", diff --git a/src/inet/tests/BUILD.gn b/src/inet/tests/BUILD.gn new file mode 100644 index 00000000000000..fad33acf99f0e7 --- /dev/null +++ b/src/inet/tests/BUILD.gn @@ -0,0 +1,46 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/chip_test_suite.gni") + +chip_test_suite("tests") { + common_sources = [ + "TapAddrAutoconf.cpp", + "TapAddrAutoconf.h", + "TestInetAddress.cpp", + "TestInetCommon.cpp", + "TestInetCommon.h", + "TestInetCommonOptions.cpp", + "TestInetCommonOptions.h", + "TestInetEndPoint.cpp", + "TestInetErrorStr.cpp", + "TestInetLayer.cpp", + "TestInetLayer.h", + "TestInetLayerCommon.cpp", + "TestInetLayerDNS.cpp", + "TestInetLayerMulticast.cpp", + "TestLwIPDNS.cpp", + ] + + public_deps = [ + "//src/inet", + "//src/lib/core", + "//third_party/nlunit-test", + ] + + tests = [ + "TestInetAddress", + "TestInetErrorStr", + ] +} From 8904fdf2c629af430e9d63736b72f64b9c6e6bfe Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Wed, 20 May 2020 22:51:05 -0400 Subject: [PATCH 24/59] Add src/ble/tests to GN build --- BUILD.gn | 1 + src/ble/tests/BUILD.gn | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 src/ble/tests/BUILD.gn diff --git a/BUILD.gn b/BUILD.gn index f08cf1e5c52699..59538adc891bde 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -35,6 +35,7 @@ group("all") { if (chip_build_tests) { deps += [ + "src/ble/tests", "src/inet/tests", "src/lib/support/tests", "src/lwip/tests", diff --git a/src/ble/tests/BUILD.gn b/src/ble/tests/BUILD.gn new file mode 100644 index 00000000000000..7c5c6715e5d38f --- /dev/null +++ b/src/ble/tests/BUILD.gn @@ -0,0 +1,29 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/chip_test_suite.gni") + +chip_test_suite("tests") { + common_sources = [ + "TestBleErrorStr.cpp", + "TestBleLayer.h", + ] + + public_deps = [ + "//src/ble", + "//third_party/nlunit-test", + ] + + tests = [ "TestBleErrorStr" ] +} From daf4c476c05529536bdd2894db196831f8408d5c Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Wed, 20 May 2020 22:54:01 -0400 Subject: [PATCH 25/59] Add src/lib/core/tests to GN build --- BUILD.gn | 1 + src/lib/core/tests/BUILD.gn | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 src/lib/core/tests/BUILD.gn diff --git a/BUILD.gn b/BUILD.gn index 59538adc891bde..7910cc3038eaef 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -37,6 +37,7 @@ group("all") { deps += [ "src/ble/tests", "src/inet/tests", + "src/lib/core/tests", "src/lib/support/tests", "src/lwip/tests", "src/system/tests", diff --git a/src/lib/core/tests/BUILD.gn b/src/lib/core/tests/BUILD.gn new file mode 100644 index 00000000000000..8a4780a60aa5dc --- /dev/null +++ b/src/lib/core/tests/BUILD.gn @@ -0,0 +1,37 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/chip_test_suite.gni") + +chip_test_suite("tests") { + common_sources = [ + "TestCHIPCallback.cpp", + "TestCHIPErrorStr.cpp", + "TestCHIPTLV.cpp", + "TestCore.h", + "TestReferenceCounted.cpp", + ] + + public_deps = [ + "//src/lib/core", + "//third_party/nlunit-test", + ] + + tests = [ + "TestCHIPErrorStr", + "TestReferenceCounted", + "TestCHIPTLV", + "TestCHIPCallback", + ] +} From 004ce9805c3d277d60ba9d6742b7f215817f77a5 Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Thu, 21 May 2020 00:54:50 -0400 Subject: [PATCH 26/59] Add src/crypto/tests to GN build --- BUILD.gn | 1 + src/crypto/tests/BUILD.gn | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 src/crypto/tests/BUILD.gn diff --git a/BUILD.gn b/BUILD.gn index 7910cc3038eaef..9f30192b28e9f8 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -36,6 +36,7 @@ group("all") { if (chip_build_tests) { deps += [ "src/ble/tests", + "src/crypto/tests", "src/inet/tests", "src/lib/core/tests", "src/lib/support/tests", diff --git a/src/crypto/tests/BUILD.gn b/src/crypto/tests/BUILD.gn new file mode 100644 index 00000000000000..2c55d1c424b2ca --- /dev/null +++ b/src/crypto/tests/BUILD.gn @@ -0,0 +1,34 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/chip_test_suite.gni") + +chip_test_suite("tests") { + common_sources = [ + "AES_CCM_128_test_vectors.h", + "AES_CCM_256_test_vectors.h", + "CHIPCryptoPALTest.cpp", + "ECDH_P256_test_vectors.h", + "HKDF_SHA256_test_vectors.h", + "TestCryptoLayer.h", + ] + + public_deps = [ + "//src/crypto", + "//src/lib/core", + "//third_party/nlunit-test", + ] + + tests = [ "CHIPCryptoPALTest" ] +} From 55bc6236cb2c93a1a2a6a63782d25e5c2a10e1d1 Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Thu, 21 May 2020 00:29:29 -0400 Subject: [PATCH 27/59] Add src/app to GN build --- BUILD.gn | 2 ++ build/chip_test_suite.gni | 24 +++++++++++++---- src/BUILD.gn | 1 + src/app/BUILD.gn | 17 ++++++++++++ src/app/chip-zcl/BUILD.gn | 33 +++++++++++++++++++++++ src/app/gen/BUILD.gn | 42 +++++++++++++++++++++++++++++ src/app/plugin/BUILD.gn | 50 +++++++++++++++++++++++++++++++++++ src/app/plugin/tests/BUILD.gn | 38 ++++++++++++++++++++++++++ 8 files changed, 202 insertions(+), 5 deletions(-) create mode 100644 src/app/BUILD.gn create mode 100644 src/app/chip-zcl/BUILD.gn create mode 100644 src/app/gen/BUILD.gn create mode 100644 src/app/plugin/BUILD.gn create mode 100644 src/app/plugin/tests/BUILD.gn diff --git a/BUILD.gn b/BUILD.gn index 9f30192b28e9f8..eb02e75f1bd055 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -17,6 +17,7 @@ import("build/tests.gni") group("all") { deps = [ "src", + "src/app", "src/ble", "src/controller", "src/crypto", @@ -35,6 +36,7 @@ group("all") { if (chip_build_tests) { deps += [ + "src/app/plugin/tests", "src/ble/tests", "src/crypto/tests", "src/inet/tests", diff --git a/build/chip_test_suite.gni b/build/chip_test_suite.gni index 5ce1ffe93791bc..a22c04a2640232 100644 --- a/build/chip_test_suite.gni +++ b/build/chip_test_suite.gni @@ -31,14 +31,28 @@ template("chip_test_suite") { } tests = [] - foreach(test, invoker.tests) { - executable(test) { - sources = [ "${test}Driver.cpp" ] + if (defined(invoker.tests)) { + foreach(test, invoker.tests) { + executable(test) { + sources = [ "${test}Driver.cpp" ] - public_deps = [ ":${suite_name}_common" ] + public_deps = [ ":${suite_name}_common" ] + } + + tests += [ ":${test}" ] } + } + + if (defined(invoker.c_tests)) { + foreach(test, invoker.c_tests) { + executable(test) { + sources = [ "${test}Driver.c" ] - tests += [ ":${test}" ] + public_deps = [ ":${suite_name}_common" ] + } + + tests += [ ":${test}" ] + } } group(suite_name) { diff --git a/src/BUILD.gn b/src/BUILD.gn index 1682ff9e7659d2..9536501652ae24 100644 --- a/src/BUILD.gn +++ b/src/BUILD.gn @@ -26,6 +26,7 @@ config("includes") { static_library("chip") { public_deps = [ + "app/plugin:chip", "ble", "controller", "crypto", diff --git a/src/app/BUILD.gn b/src/app/BUILD.gn new file mode 100644 index 00000000000000..3dfc7f10eaa306 --- /dev/null +++ b/src/app/BUILD.gn @@ -0,0 +1,17 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +group("app") { + public_deps = [ "plugin:chip" ] +} diff --git a/src/app/chip-zcl/BUILD.gn b/src/app/chip-zcl/BUILD.gn new file mode 100644 index 00000000000000..2f1094466b61e0 --- /dev/null +++ b/src/app/chip-zcl/BUILD.gn @@ -0,0 +1,33 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/tests.gni") + +config("chip-zcl_config") { + include_dirs = [ + ".", + "..", + ] +} + +source_set("chip-zcl") { + sources = [ + "chip-zcl-buffer.h", + "chip-zcl-codec.h", + "chip-zcl-struct.h", + "chip-zcl.h", + ] + + public_configs = [ ":chip-zcl_config" ] +} diff --git a/src/app/gen/BUILD.gn b/src/app/gen/BUILD.gn new file mode 100644 index 00000000000000..d651eb4585a11e --- /dev/null +++ b/src/app/gen/BUILD.gn @@ -0,0 +1,42 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +config("gen_config") { + include_dirs = [ "." ] +} + +static_library("gen") { + sources = [ + "gen-attribute-storage.h", + "gen-attribute-type.h", + "gen-callback-stubs.c", + "gen-callbacks.h", + "gen-cluster-id.h", + "gen-command-handler.c", + "gen-command-handler.h", + "gen-command-id.h", + "gen-endpoint-config.h", + "gen-global-command-handler.c", + "gen-global-command-handler.h", + "gen-specs.c", + "gen-types.h", + "gen.h", + ] + + check_includes = false + + public_configs = [ ":gen_config" ] + + public_deps = [ "//src/app/chip-zcl" ] +} diff --git a/src/app/plugin/BUILD.gn b/src/app/plugin/BUILD.gn new file mode 100644 index 00000000000000..c419f05684311b --- /dev/null +++ b/src/app/plugin/BUILD.gn @@ -0,0 +1,50 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +source_set("common") { + sources = [ + "cluster-server-basic/basic-server.c", + "cluster-server-identify/identify-server.c", + "cluster-server-level-control/level-control-server-tokens.h", + "cluster-server-level-control/level-control-server.c", + "cluster-server-level-control/level-control-server.h", + "cluster-server-on-off/on-off-server-tokens.h", + "cluster-server-on-off/on-off-server.c", + "cluster-server-on-off/on-off-server.h", + "codec-simple/codec-simple.c", + "core-api/core-api.c", + "core-data-model/zcl-data-model.c", + "core-message-dispatch/dispatch.c", + "core-message-dispatch/dispatch.h", + ] + + public_deps = [ + "//src/app/chip-zcl", + "//src/app/gen", + "//src/lib/support", + "//src/system", + ] +} + +source_set("chip") { + sources = [ "binding-chip/chip.cpp" ] + + public_deps = [ ":common" ] +} + +source_set("mock") { + sources = [ "binding-mock/mock.c" ] + + public_deps = [ ":common" ] +} diff --git a/src/app/plugin/tests/BUILD.gn b/src/app/plugin/tests/BUILD.gn new file mode 100644 index 00000000000000..e4d7b56c6e2455 --- /dev/null +++ b/src/app/plugin/tests/BUILD.gn @@ -0,0 +1,38 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/chip_test_suite.gni") + +chip_test_suite("tests") { + common_sources = [ + "ChipZclUnitTests.h", + "cluster-cmd-on-off-test.c", + "cluster-server-basic-test.c", + "cluster-server-identify-test.c", + "cluster-server-level-control-test.c", + "cluster-server-on-off-test.c", + "codec-simple-test.c", + "core-data-model-test.c", + "core-message-dispatch-test.c", + ] + + public_deps = [ + "//src/app/plugin:mock", + "//src/inet", + "//src/system", + "//third_party/nlunit-test", + ] + + c_tests = [ "ChipZclUnitTests" ] +} From a4ccc314318fa3dfbe0c4937c4e0af1d76e431b5 Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Mon, 15 Jun 2020 19:14:58 -0400 Subject: [PATCH 28/59] Add src/setup_payload to GN build --- BUILD.gn | 5 +++++ build/tools.gni | 18 ++++++++++++++++++ src/setup_payload/BUILD.gn | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 build/tools.gni create mode 100644 src/setup_payload/BUILD.gn diff --git a/BUILD.gn b/BUILD.gn index eb02e75f1bd055..2c7eaaf0169752 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -13,6 +13,7 @@ # limitations under the License. import("build/tests.gni") +import("build/tools.gni") group("all") { deps = [ @@ -46,4 +47,8 @@ group("all") { "src/system/tests", ] } + + if (chip_build_tools) { + deps += [ "src/setup_payload" ] + } } diff --git a/build/tools.gni b/build/tools.gni new file mode 100644 index 00000000000000..6c9d4eab7739f4 --- /dev/null +++ b/build/tools.gni @@ -0,0 +1,18 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +declare_args() { + # Build CHIP tools. + chip_build_tools = current_os != "freertos" +} diff --git a/src/setup_payload/BUILD.gn b/src/setup_payload/BUILD.gn new file mode 100644 index 00000000000000..e15e7f7686b4e3 --- /dev/null +++ b/src/setup_payload/BUILD.gn @@ -0,0 +1,37 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +source_set("setup_payload") { + sources = [ + "Base41.cpp", + "Base41.h", + "ManualSetupPayloadGenerator.cpp", + "ManualSetupPayloadGenerator.h", + "ManualSetupPayloadParser.cpp", + "ManualSetupPayloadParser.h", + "QRCodeSetupPayloadGenerator.cpp", + "QRCodeSetupPayloadGenerator.h", + "QRCodeSetupPayloadParser.cpp", + "QRCodeSetupPayloadParser.h", + "SetupPayload.cpp", + "SetupPayload.h", + "SetupPayloadHelper.cpp", + "SetupPayloadHelper.h", + ] + + public_deps = [ + "//src/lib/core", + "//src/lib/support", + ] +} From ec7b598032ea4a5c8ff8da5354e09943b69abe0d Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Mon, 15 Jun 2020 19:13:32 -0400 Subject: [PATCH 29/59] Add src/setup_payout/tests to GN build --- BUILD.gn | 1 + src/setup_payload/BUILD.gn | 8 ++++++- src/setup_payload/tests/BUILD.gn | 37 ++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 src/setup_payload/tests/BUILD.gn diff --git a/BUILD.gn b/BUILD.gn index 2c7eaaf0169752..d3e8d1448cdd7f 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -44,6 +44,7 @@ group("all") { "src/lib/core/tests", "src/lib/support/tests", "src/lwip/tests", + "src/setup_payload/tests", "src/system/tests", ] } diff --git a/src/setup_payload/BUILD.gn b/src/setup_payload/BUILD.gn index e15e7f7686b4e3..5a56f2c6a2e9ff 100644 --- a/src/setup_payload/BUILD.gn +++ b/src/setup_payload/BUILD.gn @@ -12,7 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -source_set("setup_payload") { +config("setup_payload_config") { + include_dirs = [ "." ] +} + +static_library("setup_payload") { sources = [ "Base41.cpp", "Base41.h", @@ -34,4 +38,6 @@ source_set("setup_payload") { "//src/lib/core", "//src/lib/support", ] + + public_configs = [ ":setup_payload_config" ] } diff --git a/src/setup_payload/tests/BUILD.gn b/src/setup_payload/tests/BUILD.gn new file mode 100644 index 00000000000000..a10f3b29aed56f --- /dev/null +++ b/src/setup_payload/tests/BUILD.gn @@ -0,0 +1,37 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/chip_test_suite.gni") + +chip_test_suite("tests") { + common_sources = [ + "TestManualCode.cpp", + "TestManualCode.h", + "TestQRCode.cpp", + "TestQRCode.h", + "TestQRCodeTLV.cpp", + "TestQRCodeTLV.h", + ] + + public_deps = [ + "//src/setup_payload", + "//third_party/nlunit-test", + ] + + tests = [ + "TestQRCodeTLV", + "TestManualCode", + "TestQRCode", + ] +} From 2a20feffad69061fac87d3aa57ff19a90b8add1d Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Mon, 15 Jun 2020 16:57:49 -0400 Subject: [PATCH 30/59] Add qrcodetool to GN build --- BUILD.gn | 5 ++++- src/qrcodetool/BUILD.gn | 31 +++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 src/qrcodetool/BUILD.gn diff --git a/BUILD.gn b/BUILD.gn index d3e8d1448cdd7f..c76fee2a7243bb 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -50,6 +50,9 @@ group("all") { } if (chip_build_tools) { - deps += [ "src/setup_payload" ] + deps += [ + "src/qrcodetool", + "src/setup_payload", + ] } } diff --git a/src/qrcodetool/BUILD.gn b/src/qrcodetool/BUILD.gn new file mode 100644 index 00000000000000..30817e3cfd56e6 --- /dev/null +++ b/src/qrcodetool/BUILD.gn @@ -0,0 +1,31 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/tools.gni") + +assert(chip_build_tools) + +executable("qrcodetool") { + sources = [ + "qrcodetool.cpp", + "qrcodetool_command_manager.h", + "setup_payload_commands.cpp", + "setup_payload_commands.h", + ] + + public_deps = [ + "//src/lib/support", + "//src/setup_payload", + ] +} From 2e3cabc33a1272a0e7bab840a6ad53fb3696715c Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Mon, 15 Jun 2020 22:23:30 -0400 Subject: [PATCH 31/59] Add ARM toolchain support --- build/config/BUILDCONFIG.gn | 6 ++++ build/config/arm.gni | 40 +++++++++++++++++++++ build/config/compiler/BUILD.gn | 34 ++++++++++++++++++ build/config/defaults.gni | 4 +++ build/toolchain/arm_gcc/BUILD.gn | 19 ++++++++++ build/toolchain/arm_gcc/arm_toolchain.gni | 44 +++++++++++++++++++++++ 6 files changed, 147 insertions(+) create mode 100644 build/config/arm.gni create mode 100644 build/toolchain/arm_gcc/BUILD.gn create mode 100644 build/toolchain/arm_gcc/arm_toolchain.gni diff --git a/build/config/BUILDCONFIG.gn b/build/config/BUILDCONFIG.gn index 21275345a48363..72e57f9f11c29c 100644 --- a/build/config/BUILDCONFIG.gn +++ b/build/config/BUILDCONFIG.gn @@ -57,6 +57,12 @@ if (_chip_defaults.custom_toolchain != "") { _default_toolchain = _chip_defaults.custom_toolchain } else if (target_os == host_os) { _default_toolchain = host_toolchain +} else if (target_os == "freertos") { + if (target_cpu == "arm") { + _default_toolchain = "//build/toolchain/arm_gcc" + } else { + assert(false, "Unsupported target_cpu: ${target_cpu}") + } } else { assert(false, "No toolchain specified, please specify custom_toolchain") } diff --git a/build/config/arm.gni b/build/config/arm.gni new file mode 100644 index 00000000000000..7a7b2d3405e913 --- /dev/null +++ b/build/config/arm.gni @@ -0,0 +1,40 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +assert(current_cpu == "arm" || current_cpu == "arm64") + +if (current_cpu == "arm") { + declare_args() { + # ARM architecture (value for -march flag). + arm_arch = "" + + # ARM CPU (value for -mcpu flag). + arm_cpu = "" + + # ARM tuning (value for -mtune flag). + arm_tune = "" + + # ARM FPU (value for -mfpu flag). + arm_fpu = "" + + # ARM float ABI (value for -mfloat-api flag). + arm_float_abi = "" + + # ARM ABI (value for -mapi flag). + arm_abi = "" + + # ARM thumb instruction set (value for -mthumb flag). + arm_use_thumb = true + } +} diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn index 7251d94a040471..88b2144ff78dd3 100644 --- a/build/config/compiler/BUILD.gn +++ b/build/config/compiler/BUILD.gn @@ -17,6 +17,10 @@ import("//build_overrides/pigweed.gni") import("//build/config/compiler/compiler.gni") +if (current_cpu == "arm") { + import("${chip_root}/build/config/arm.gni") +} + config("release") { defines = [ "NDEBUG" ] } @@ -27,6 +31,34 @@ config("debug_default") { } } +config("abi_default") { + cflags = [] + if (current_cpu == "arm") { + if (arm_arch != "") { + cflags += [ "-march=${arm_arch}" ] + } + if (arm_cpu != "") { + cflags += [ "-mcpu=${arm_cpu}" ] + } + if (arm_tune != "") { + cflags += [ "-mtune=${arm_tune}" ] + } + if (arm_abi != "") { + cflags += [ "-mabi=${arm_abi}" ] + } + if (arm_fpu != "") { + cflags += [ "-mfpu=${arm_fpu}" ] + } + if (arm_float_abi != "") { + cflags += [ "-mfloat-abi=${arm_float_abi}" ] + } + if (arm_use_thumb) { + cflags += [ "-mthumb" ] + } + } + ldflags = cflags +} + config("optimize_zero") { cflags = [ "-O0" ] ldflags = cflags @@ -201,6 +233,8 @@ config("specs_default") { "--specs=nano.specs", ] + libs = [ "nosys" ] + ldflags = cflags } } diff --git a/build/config/defaults.gni b/build/config/defaults.gni index 6c26b968fcc30e..4f1dba4bce0470 100644 --- a/build/config/defaults.gni +++ b/build/config/defaults.gni @@ -18,6 +18,9 @@ import("//build/config/compiler/compiler.gni") import("//build/config/custom_toolchain.gni") declare_args() { + # Default configs for abi. + default_configs_abi = [ "${chip_root}/build/config/compiler:abi_default" ] + # Default configs for debugging. default_configs_debug = [ "${chip_root}/build/config/compiler:debug_default" ] @@ -80,6 +83,7 @@ declare_args() { } default_configs = [] +default_configs += default_configs_abi default_configs += default_configs_debug default_configs += default_configs_optimize default_configs += default_configs_std diff --git a/build/toolchain/arm_gcc/BUILD.gn b/build/toolchain/arm_gcc/BUILD.gn new file mode 100644 index 00000000000000..2edca649611cef --- /dev/null +++ b/build/toolchain/arm_gcc/BUILD.gn @@ -0,0 +1,19 @@ +# Copyright 2020 The Pigweed Authors +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("arm_toolchain.gni") + +arm_toolchain("arm_gcc") { +} diff --git a/build/toolchain/arm_gcc/arm_toolchain.gni b/build/toolchain/arm_gcc/arm_toolchain.gni new file mode 100644 index 00000000000000..a28cac6aad8dca --- /dev/null +++ b/build/toolchain/arm_gcc/arm_toolchain.gni @@ -0,0 +1,44 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build_overrides/pigweed.gni") +import("$dir_pw_toolchain/generate_toolchain.gni") + +template("arm_toolchain") { + _arm_gcc_toolchain_tools = { + _tool_name_root = "arm-none-eabi-" + ar = _tool_name_root + "ar" + cc = _tool_name_root + "gcc" + cxx = _tool_name_root + "g++" + } + + _toolchain = { + name = target_name + forward_variables_from(_arm_gcc_toolchain_tools, "*") + defaults = { + current_cpu = "arm" + current_os = "none" + + if (defined(invoker.toolchain_args_file)) { + import(invoker.toolchain_args_file) + } else if (defined(invoker.defaults)) { + forward_variables_from(invoker.defaults, "*") + } + } + } + + generate_toolchains("host_toolchains") { + toolchains = [ _toolchain ] + } +} From 885a7235838b655e93d4f9839670b9c38f0c3e4d Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Thu, 28 May 2020 05:32:11 -0400 Subject: [PATCH 32/59] Add support for building nRF5 lock app --- BUILD.gn | 7 + build/device.gni | 28 ++++ build/examples.gni | 18 +++ build/tests.gni | 2 +- build/toolchain/arm_gcc/arm_toolchain.gni | 2 +- examples/lock-app/nrf5/BUILD.gn | 85 ++++++++++ examples/lock-app/nrf5/args.gni | 23 +++ examples/lock-app/nrf5/common_args.gni | 45 ++++++ examples/lock-app/nrf5/toolchain/BUILD.gn | 20 +++ src/BUILD.gn | 1 + src/lib/core/BUILD.gn | 2 + src/lwip/BUILD.gn | 3 + src/lwip/efr32/lwipopts.h | 5 +- src/lwip/nrf5/lwipopts.h | 3 + src/platform/BUILD.gn | 93 +++++++++++ src/system/BUILD.gn | 6 + third_party/nrf5_sdk/BUILD.gn | 29 ++++ third_party/nrf5_sdk/nrf5_sdk.gni | 181 ++++++++++++++++++++++ 18 files changed, 549 insertions(+), 4 deletions(-) create mode 100644 build/device.gni create mode 100644 build/examples.gni create mode 100644 examples/lock-app/nrf5/BUILD.gn create mode 100644 examples/lock-app/nrf5/args.gni create mode 100644 examples/lock-app/nrf5/common_args.gni create mode 100644 examples/lock-app/nrf5/toolchain/BUILD.gn create mode 100644 src/platform/BUILD.gn create mode 100644 third_party/nrf5_sdk/BUILD.gn create mode 100644 third_party/nrf5_sdk/nrf5_sdk.gni diff --git a/BUILD.gn b/BUILD.gn index c76fee2a7243bb..7206ad2e6f361f 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("build/examples.gni") import("build/tests.gni") import("build/tools.gni") @@ -55,4 +56,10 @@ group("all") { "src/setup_payload", ] } + + if (build_nrf5_lock_app) { + deps += [ + "examples/lock-app/nrf5(examples/lock-app/nrf5/toolchain:nrf5_lock_app)", + ] + } } diff --git a/build/device.gni b/build/device.gni new file mode 100644 index 00000000000000..5bdddee5c68177 --- /dev/null +++ b/build/device.gni @@ -0,0 +1,28 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +declare_args() { + # Device platform layer: freertos, nrf5, none. + device_platform = "" +} + +if (device_platform == "") { + if (current_os != "freertos") { + device_platform = "none" + } +} + +assert((current_os != "freertos" && device_platform == "none") || + device_platform == "nrf5", + "Please select a valid value for device_platform") diff --git a/build/examples.gni b/build/examples.gni new file mode 100644 index 00000000000000..115db6bf82e5a7 --- /dev/null +++ b/build/examples.gni @@ -0,0 +1,18 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +declare_args() { + # Enable nRF5 lock app example. + build_nrf5_lock_app = false +} diff --git a/build/tests.gni b/build/tests.gni index 2f3d4ce0f78b22..4e4e3455b758d0 100644 --- a/build/tests.gni +++ b/build/tests.gni @@ -14,7 +14,7 @@ declare_args() { # Enable building tests. - chip_build_tests = true + chip_build_tests = current_os != "freertos" # Enable use of nlfaultinjection. chip_with_nlfaultinjection = true diff --git a/build/toolchain/arm_gcc/arm_toolchain.gni b/build/toolchain/arm_gcc/arm_toolchain.gni index a28cac6aad8dca..3db265f9e9d6a6 100644 --- a/build/toolchain/arm_gcc/arm_toolchain.gni +++ b/build/toolchain/arm_gcc/arm_toolchain.gni @@ -28,7 +28,7 @@ template("arm_toolchain") { forward_variables_from(_arm_gcc_toolchain_tools, "*") defaults = { current_cpu = "arm" - current_os = "none" + current_os = invoker.current_os if (defined(invoker.toolchain_args_file)) { import(invoker.toolchain_args_file) diff --git a/examples/lock-app/nrf5/BUILD.gn b/examples/lock-app/nrf5/BUILD.gn new file mode 100644 index 00000000000000..43bd7c9323d4de --- /dev/null +++ b/examples/lock-app/nrf5/BUILD.gn @@ -0,0 +1,85 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//third_party/nrf5_sdk/nrf5_sdk.gni") + +assert(current_os == "freertos") + +nrf5_platform_dir = "//examples/platform/nrf528xx" + +nrf5_sdk("sdk") { + include_dirs = [ + "main/include", + "main", + "${nrf5_platform_dir}/app/project_include", + "${nrf5_platform_dir}/util/include", + "${nrf5_platform_dir}/app/include", + ] + + sources = [ + "${nrf5_platform_dir}/app/project_include/CHIPProjectConfig.h", + "${nrf5_platform_dir}/app/project_include/FreeRTOSConfig.h", + "${nrf5_platform_dir}/app/project_include/OpenThreadConfig.h", + "${nrf5_platform_dir}/app/project_include/freertos_tasks_c_additions.h", + "${nrf5_platform_dir}/app/project_include/nrf_log_ctrl_internal.h", + "main/include/app_config.h", + ] + + defines = [] + if (is_debug) { + defines += [ "BUILD_RELEASE=0" ] + } else { + defines += [ "BUILD_RELEASE=1" ] + } + + defines += [ "USE_APP_CONFIG" ] +} + +executable("lock_app") { + public_deps = [ + ":sdk", + "//src:chip", + "//src/platform", + ] + + sources = [ + "${nrf5_platform_dir}/app/Server.cpp", + "${nrf5_platform_dir}/app/chipinit.cpp", + "${nrf5_platform_dir}/app/include/Server.h", + "${nrf5_platform_dir}/app/include/chipinit.h", + "${nrf5_platform_dir}/app/support/CXXExceptionStubs.cpp", + "${nrf5_platform_dir}/app/support/FreeRTOSNewlibLockSupport.c", + "${nrf5_platform_dir}/app/support/nRF5Sbrk.c", + "${nrf5_platform_dir}/util/LEDWidget.cpp", + "${nrf5_platform_dir}/util/include/LEDWidget.h", + "main/AppTask.cpp", + "main/BoltLockManager.cpp", + "main/DataModelHandler.cpp", + "main/include/AppEvent.h", + "main/include/AppTask.h", + "main/include/BoltLockManager.h", + "main/include/DataModelHandler.h", + "main/main.cpp", + ] + + output_dir = root_out_dir + + ldscript = "${nrf5_platform_dir}/app/ldscripts/chip-nrf52840-example.ld" + + ldflags = [ "-T" + rebase_path(ldscript, root_build_dir) ] +} + +group("nrf5") { + deps = [ ":lock_app" ] +} diff --git a/examples/lock-app/nrf5/args.gni b/examples/lock-app/nrf5/args.gni new file mode 100644 index 00000000000000..e48ffabb16780a --- /dev/null +++ b/examples/lock-app/nrf5/args.gni @@ -0,0 +1,23 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("common_args.gni") + +# These values help set up the default toolchain in standalone sample app +# builds. They must be in a separate file to avoid namespace conflicts in +# multi target builds. +custom_toolchain = "//examples/lock-app/nrf5/toolchain:nrf5_lock_app" +target_cpu = "arm" +target_os = "freertos" +# Don't add more args here, add them to common_args.gni. diff --git a/examples/lock-app/nrf5/common_args.gni b/examples/lock-app/nrf5/common_args.gni new file mode 100644 index 00000000000000..62d9e150b4aec3 --- /dev/null +++ b/examples/lock-app/nrf5/common_args.gni @@ -0,0 +1,45 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +build_nrf5_lock_app = true + +device_platform = "nrf5" + +arm_arch = "armv7e-m" +arm_float_abi = "hard" +arm_cpu = "cortex-m4" +arm_fpu = "fpv4-sp-d16" + +lwip_platform = "nrf5" +lwip_ipv6 = true +lwip_ipv4 = false +lwip_api = true + +inet_config_enable_ipv4 = false +inet_config_enable_dns_resolver = false + +chip_build_tests = false +nrf5_sdk_target = "//examples/lock-app/nrf5:sdk" + +ble_platform_config_include = "" +ble_project_config_include = "" +chip_device_platform_config_include = + "" +chip_device_project_config_include = "" +chip_platform_config_include = "" +chip_project_config_include = "" +inet_platform_config_include = "" +inet_project_config_include = "" +system_platform_config_include = "" +system_project_config_include = "" diff --git a/examples/lock-app/nrf5/toolchain/BUILD.gn b/examples/lock-app/nrf5/toolchain/BUILD.gn new file mode 100644 index 00000000000000..5c10a1f123c4ba --- /dev/null +++ b/examples/lock-app/nrf5/toolchain/BUILD.gn @@ -0,0 +1,20 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/toolchain/arm_gcc/arm_toolchain.gni") + +arm_toolchain("nrf5_lock_app") { + toolchain_args_file = "../common_args.gni" + current_os = "freertos" +} diff --git a/src/BUILD.gn b/src/BUILD.gn index 9536501652ae24..643c7111a00344 100644 --- a/src/BUILD.gn +++ b/src/BUILD.gn @@ -33,6 +33,7 @@ static_library("chip") { "inet", "lib/core", "lib/support", + "platform", "system", "transport", ] diff --git a/src/lib/core/BUILD.gn b/src/lib/core/BUILD.gn index b3488bdbdb8202..ac89a8b38cc572 100644 --- a/src/lib/core/BUILD.gn +++ b/src/lib/core/BUILD.gn @@ -133,6 +133,7 @@ source_set("core") { "//src/ble", "//src/inet", "//src/lib/support", + "//src/platform", "//src/system", "//third_party/nlio", ] @@ -142,5 +143,6 @@ source_set("core") { "//src/lib/support", "//src/inet", "//src/system", + "//src/platform", ] } diff --git a/src/lwip/BUILD.gn b/src/lwip/BUILD.gn index 6f3d78c1878afe..f4b28fdfe37012 100644 --- a/src/lwip/BUILD.gn +++ b/src/lwip/BUILD.gn @@ -69,6 +69,9 @@ lwip_target("lwip") { } public_deps = [] + if (lwip_platform == "nrf5") { + public_deps += [ "//third_party/nrf5_sdk" ] + } public_configs = [ ":lwip_config" ] } diff --git a/src/lwip/efr32/lwipopts.h b/src/lwip/efr32/lwipopts.h index 60e3c10c92118b..15e67108a67255 100644 --- a/src/lwip/efr32/lwipopts.h +++ b/src/lwip/efr32/lwipopts.h @@ -142,9 +142,10 @@ #define DEFAULT_UDP_RECVMBOX_SIZE 6 #define DEFAULT_TCP_RECVMBOX_SIZE 6 -// TODO: make LWIP_DEBUG conditional on build type - +#ifndef LWIP_DEBUG #define LWIP_DEBUG 1 +#endif + #define MEMP_OVERFLOW_CHECK (0) #define MEMP_SANITY_CHECK (0) #define MEM_DEBUG (LWIP_DBG_OFF) diff --git a/src/lwip/nrf5/lwipopts.h b/src/lwip/nrf5/lwipopts.h index 2f3f466d6ba5ea..9f719ebec0bb9b 100644 --- a/src/lwip/nrf5/lwipopts.h +++ b/src/lwip/nrf5/lwipopts.h @@ -129,7 +129,10 @@ // TODO: make LWIP_DEBUG conditional on build type +#ifndef LWIP_DEBUG #define LWIP_DEBUG 1 +#endif + #define MEMP_OVERFLOW_CHECK (0) #define MEMP_SANITY_CHECK (0) #define MEM_DEBUG (LWIP_DBG_OFF) diff --git a/src/platform/BUILD.gn b/src/platform/BUILD.gn new file mode 100644 index 00000000000000..865eff2df013c3 --- /dev/null +++ b/src/platform/BUILD.gn @@ -0,0 +1,93 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/device.gni") + +if (device_platform != "none") { + declare_args() { + # Extra header to include in CHIPDeviceConfig.h for project. + chip_device_project_config_include = "" + + # Extra header to include in CHIPDeviceConfig.h for platform. + chip_device_platform_config_include = "" + } + + config("platform_config") { + configs = [ "//src:includes" ] + + defines = [] + if (chip_device_project_config_include != "") { + defines += [ "CHIP_DEVICE_PROJECT_CONFIG_INCLUDE=${chip_device_project_config_include}" ] + } + if (chip_device_platform_config_include != "") { + defines += [ "CHIP_DEVICE_PLATFORM_CONFIG_INCLUDE=${chip_device_platform_config_include}" ] + } + + if (device_platform == "nrf5") { + defines += [ + "CHIP_DEVICE_LAYER_TARGET_NRF5=1", + "CHIP_DEVICE_LAYER_TARGET=nRF5", + ] + } else { + defines += [ "CHIP_DEVICE_LAYER_TARGET_NRF5=0" ] + } + } + + source_set("platform") { + sources = [ + "GeneralUtils.cpp", + "Globals.cpp", + "PersistedStorage.cpp", + "SystemEventSupport.cpp", + "SystemTimerSupport.cpp", + ] + + public_deps = [ + "//src/ble", + "//src/lib/core:chip_config_header", + "//src/lib/support", + "//third_party/nlio", + ] + + public_configs = [ ":platform_config" ] + + if (device_platform == "nrf5") { + sources += [ + "FreeRTOS/SystemTimeSupport.cpp", + "nRF5/BLEManagerImpl.cpp", + "nRF5/BLEManagerImpl.h", + "nRF5/BlePlatformConfig.h", + "nRF5/CHIPDevicePlatformConfig.h", + "nRF5/CHIPDevicePlatformEvent.h", + "nRF5/CHIPPlatformConfig.h", + "nRF5/ConfigurationManagerImpl.cpp", + "nRF5/ConfigurationManagerImpl.h", + "nRF5/ConnectivityManagerImpl.cpp", + "nRF5/ConnectivityManagerImpl.h", + "nRF5/InetPlatformConfig.h", + "nRF5/Logging.cpp", + "nRF5/PlatformManagerImpl.cpp", + "nRF5/PlatformManagerImpl.h", + "nRF5/SystemPlatformConfig.h", + "nRF5/nRF5Config.cpp", + "nRF5/nRF5Config.h", + "nRF5/nRF5Utils.cpp", + "nRF5/nRF5Utils.h", + ] + } + } +} else { + group("platform") { + } +} diff --git a/src/system/BUILD.gn b/src/system/BUILD.gn index dd0a01f4cb66f0..5398bae98d2fbe 100644 --- a/src/system/BUILD.gn +++ b/src/system/BUILD.gn @@ -108,6 +108,12 @@ source_set("system_config_header") { sources = [ "SystemConfig.h" ] public_configs = [ ":system_config" ] + + public_deps = [] + + if (chip_system_config_use_lwip) { + public_deps += [ "//src/lwip" ] + } } source_set("system") { diff --git a/third_party/nrf5_sdk/BUILD.gn b/third_party/nrf5_sdk/BUILD.gn new file mode 100644 index 00000000000000..07aeefba4f1f12 --- /dev/null +++ b/third_party/nrf5_sdk/BUILD.gn @@ -0,0 +1,29 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/device.gni") +import("//third_party/nrf5_sdk/nrf5_sdk.gni") + +assert(device_platform == "nrf5") + +declare_args() { + # Build target to use for nRF5 SDK. Use this to set global SDK defines. + nrf5_sdk_target = "" +} + +assert(nrf5_sdk_target != "", "nrf5_sdk_target must be specified") + +group("nrf5_sdk") { + public_deps = [ nrf5_sdk_target ] +} diff --git a/third_party/nrf5_sdk/nrf5_sdk.gni b/third_party/nrf5_sdk/nrf5_sdk.gni new file mode 100644 index 00000000000000..232881e9d53dab --- /dev/null +++ b/third_party/nrf5_sdk/nrf5_sdk.gni @@ -0,0 +1,181 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +declare_args() { + # Location of the nRF5 SDK. + nrf5_sdk_root = "" +} + +if (nrf5_sdk_root == "") { + nrf5_sdk_root = getenv("NRF5_SDK_ROOT") +} + +assert(nrf5_sdk_root != "", "nrf5_sdk_root must be specified") + +# Defines an nRF SDK build target. +# +# Parameters: +# nrf5_sdk_root - The location of the nRF SDK. +# sources - The sources files to build. +template("nrf5_sdk") { + if (defined(invoker.nrf5_sdk_root)) { + nrf5_sdk_root = invoker.nrf5_sdk_root + } + + assert(nrf5_sdk_root != "", "nrf5_sdk_root must be specified") + + sdk_target_name = target_name + + config("${sdk_target_name}_config") { + include_dirs = [] + if (defined(invoker.include_dirs)) { + include_dirs += invoker.include_dirs + } + include_dirs += [ + "${nrf5_sdk_root}/components", + "${nrf5_sdk_root}/components/boards", + "${nrf5_sdk_root}/components/ble/ble_advertising", + "${nrf5_sdk_root}/components/ble/common", + "${nrf5_sdk_root}/components/ble/nrf_ble_gatt", + "${nrf5_sdk_root}/components/libraries/atomic", + "${nrf5_sdk_root}/components/libraries/atomic_fifo", + "${nrf5_sdk_root}/components/libraries/balloc", + "${nrf5_sdk_root}/components/libraries/bsp", + "${nrf5_sdk_root}/components/libraries/button", + "${nrf5_sdk_root}/components/libraries/crc16", + "${nrf5_sdk_root}/components/libraries/delay", + "${nrf5_sdk_root}/components/libraries/experimental_section_vars", + "${nrf5_sdk_root}/components/libraries/fds", + "${nrf5_sdk_root}/components/libraries/fstorage", + "${nrf5_sdk_root}/components/libraries/log", + "${nrf5_sdk_root}/components/libraries/log/src", + "${nrf5_sdk_root}/components/libraries/memobj", + "${nrf5_sdk_root}/components/libraries/mem_manager", + "${nrf5_sdk_root}/components/libraries/mutex", + "${nrf5_sdk_root}/components/libraries/queue", + "${nrf5_sdk_root}/components/libraries/ringbuf", + "${nrf5_sdk_root}/components/libraries/stack_info", + "${nrf5_sdk_root}/components/libraries/strerror", + "${nrf5_sdk_root}/components/libraries/timer", + "${nrf5_sdk_root}/components/libraries/util", + "${nrf5_sdk_root}/components/softdevice/common", + "${nrf5_sdk_root}/components/softdevice/s140/headers", + "${nrf5_sdk_root}/components/softdevice/s140/headers/nrf52", + "${nrf5_sdk_root}/components/softdevice/mbr/nrf52840/headers", + "${nrf5_sdk_root}/components/thread/freertos_mbedtls_mutex", + "${nrf5_sdk_root}/components/toolchain/cmsis/include", + "${nrf5_sdk_root}/config/nrf52840/config", + "${nrf5_sdk_root}/external/fprintf", + "${nrf5_sdk_root}/external/freertos/config", + "${nrf5_sdk_root}/external/freertos/portable/CMSIS/nrf52", + "${nrf5_sdk_root}/external/freertos/portable/GCC/nrf52", + "${nrf5_sdk_root}/external/freertos/source/include", + "${nrf5_sdk_root}/external/segger_rtt", + "${nrf5_sdk_root}/integration/nrfx", + "${nrf5_sdk_root}/integration/nrfx/legacy", + "${nrf5_sdk_root}/modules/nrfx", + "${nrf5_sdk_root}/modules/nrfx/drivers/include", + "${nrf5_sdk_root}/modules/nrfx/hal", + "${nrf5_sdk_root}/modules/nrfx/mdk", + ] + + lib_dirs = [ "${nrf5_sdk_root}/modules/nrfx/mdk" ] + + defines = [ + "NRF52840_XXAA", + "BOARD_PCA10056", + "BSP_DEFINES_ONLY", + "CONFIG_GPIO_AS_PINRESET", + "FLOAT_ABI_HARD", + "__HEAP_SIZE=40960", + "__STACK_SIZE=8192", + "SOFTDEVICE_PRESENT", + "PRINTF_DISABLE_SUPPORT_EXPONENTIAL", + "S140", + ] + if (defined(invoker.defines)) { + defines += invoker.defines + } + cflags = [ "-Wno-array-bounds" ] + } + + # TODO - Break up this monolith and make it configurable. + source_set(sdk_target_name) { + sources = [ + "${nrf5_sdk_root}/components/ble/common/ble_advdata.c", + "${nrf5_sdk_root}/components/ble/common/ble_srv_common.c", + "${nrf5_sdk_root}/components/ble/nrf_ble_gatt/nrf_ble_gatt.c", + "${nrf5_sdk_root}/components/boards/boards.c", + "${nrf5_sdk_root}/components/libraries/atomic/nrf_atomic.c", + "${nrf5_sdk_root}/components/libraries/atomic_fifo/nrf_atfifo.c", + "${nrf5_sdk_root}/components/libraries/balloc/nrf_balloc.c", + "${nrf5_sdk_root}/components/libraries/button/app_button.c", + "${nrf5_sdk_root}/components/libraries/crc16/crc16.c", + "${nrf5_sdk_root}/components/libraries/experimental_section_vars/nrf_section_iter.c", + "${nrf5_sdk_root}/components/libraries/fds/fds.c", + "${nrf5_sdk_root}/components/libraries/fstorage/nrf_fstorage.c", + "${nrf5_sdk_root}/components/libraries/fstorage/nrf_fstorage_sd.c", + "${nrf5_sdk_root}/components/libraries/log/src/nrf_log_backend_rtt.c", + "${nrf5_sdk_root}/components/libraries/log/src/nrf_log_backend_serial.c", + "${nrf5_sdk_root}/components/libraries/log/src/nrf_log_default_backends.c", + "${nrf5_sdk_root}/components/libraries/log/src/nrf_log_frontend.c", + "${nrf5_sdk_root}/components/libraries/log/src/nrf_log_str_formatter.c", + "${nrf5_sdk_root}/components/libraries/mem_manager/mem_manager.c", + "${nrf5_sdk_root}/components/libraries/memobj/nrf_memobj.c", + "${nrf5_sdk_root}/components/libraries/queue/nrf_queue.c", + "${nrf5_sdk_root}/components/libraries/ringbuf/nrf_ringbuf.c", + "${nrf5_sdk_root}/components/libraries/strerror/nrf_strerror.c", + "${nrf5_sdk_root}/components/libraries/timer/app_timer_freertos.c", + "${nrf5_sdk_root}/components/libraries/uart/retarget.c", + "${nrf5_sdk_root}/components/libraries/util/app_error.c", + "${nrf5_sdk_root}/components/libraries/util/app_error_handler_gcc.c", + "${nrf5_sdk_root}/components/libraries/util/app_error_weak.c", + "${nrf5_sdk_root}/components/libraries/util/app_util_platform.c", + "${nrf5_sdk_root}/components/libraries/util/nrf_assert.c", + "${nrf5_sdk_root}/components/softdevice/common/nrf_sdh.c", + "${nrf5_sdk_root}/components/softdevice/common/nrf_sdh_ble.c", + "${nrf5_sdk_root}/components/softdevice/common/nrf_sdh_soc.c", + "${nrf5_sdk_root}/external/fprintf/nrf_fprintf.c", + "${nrf5_sdk_root}/external/fprintf/nrf_fprintf_format.c", + "${nrf5_sdk_root}/external/freertos/portable/CMSIS/nrf52/port_cmsis.c", + "${nrf5_sdk_root}/external/freertos/portable/CMSIS/nrf52/port_cmsis_systick.c", + "${nrf5_sdk_root}/external/freertos/portable/GCC/nrf52/port.c", + "${nrf5_sdk_root}/external/freertos/source/croutine.c", + "${nrf5_sdk_root}/external/freertos/source/event_groups.c", + "${nrf5_sdk_root}/external/freertos/source/list.c", + "${nrf5_sdk_root}/external/freertos/source/portable/MemMang/heap_3.c", + "${nrf5_sdk_root}/external/freertos/source/queue.c", + "${nrf5_sdk_root}/external/freertos/source/stream_buffer.c", + "${nrf5_sdk_root}/external/freertos/source/tasks.c", + "${nrf5_sdk_root}/external/freertos/source/timers.c", + "${nrf5_sdk_root}/external/segger_rtt/SEGGER_RTT.c", + "${nrf5_sdk_root}/external/segger_rtt/SEGGER_RTT_Syscalls_GCC.c", + "${nrf5_sdk_root}/external/segger_rtt/SEGGER_RTT_printf.c", + "${nrf5_sdk_root}/integration/nrfx/legacy/nrf_drv_clock.c", + "${nrf5_sdk_root}/integration/nrfx/legacy/nrf_drv_rng.c", + "${nrf5_sdk_root}/modules/nrfx/drivers/src/nrfx_clock.c", + "${nrf5_sdk_root}/modules/nrfx/drivers/src/nrfx_gpiote.c", + "${nrf5_sdk_root}/modules/nrfx/drivers/src/nrfx_uart.c", + "${nrf5_sdk_root}/modules/nrfx/drivers/src/nrfx_uarte.c", + "${nrf5_sdk_root}/modules/nrfx/drivers/src/prs/nrfx_prs.c", + "${nrf5_sdk_root}/modules/nrfx/mdk/gcc_startup_nrf52840.S", + "${nrf5_sdk_root}/modules/nrfx/mdk/system_nrf52840.c", + ] + if (defined(invoker.sources)) { + sources += invoker.sources + } + + public_configs = [ ":${sdk_target_name}_config" ] + } +} From 8682167f5455fd36dc13bb133c93659da678e49e Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Thu, 11 Jun 2020 20:47:45 -0400 Subject: [PATCH 33/59] Run unit tests with some help from pigweed This enables running tests during the build. Just run gn gen out/debug ninja -C out/debug check --- .gn | 6 ++++++ BUILD.gn | 36 ++++++++++++++++++++----------- build/args/host.gni | 0 build/chip_test.gni | 45 +++++++++++++++++++++++++++++++++++++++ build/chip_test_group.gni | 32 ++++++++++++++++++++++++++++ build/chip_test_suite.gni | 40 ++++++++++++++++++++++------------ src/lwip/tests/BUILD.gn | 7 ++++-- 7 files changed, 138 insertions(+), 28 deletions(-) create mode 100644 build/args/host.gni create mode 100644 build/chip_test.gni create mode 100644 build/chip_test_group.gni diff --git a/.gn b/.gn index 8575ac571bff3e..a4557d19977246 100644 --- a/.gn +++ b/.gn @@ -17,3 +17,9 @@ buildconfig = "//build/config/BUILDCONFIG.gn" # CHIP uses angle bracket includes. check_system_includes = true + +import("//build_overrides/pigweed.gni") + +default_args = { + pw_unit_test_AUTOMATIC_RUNNER = "$dir_pigweed/targets/host/run_test" +} diff --git a/BUILD.gn b/BUILD.gn index 7206ad2e6f361f..b5f072fc9d75b3 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -16,7 +16,7 @@ import("build/examples.gni") import("build/tests.gni") import("build/tools.gni") -group("all") { +group("default") { deps = [ "src", "src/app", @@ -37,17 +37,7 @@ group("all") { ] if (chip_build_tests) { - deps += [ - "src/app/plugin/tests", - "src/ble/tests", - "src/crypto/tests", - "src/inet/tests", - "src/lib/core/tests", - "src/lib/support/tests", - "src/lwip/tests", - "src/setup_payload/tests", - "src/system/tests", - ] + deps += [ ":tests" ] } if (chip_build_tools) { @@ -63,3 +53,25 @@ group("all") { ] } } + +if (chip_build_tests) { + import("build/chip_test_group.gni") + + chip_test_group("tests") { + deps = [ + "src/app/plugin/tests", + "src/ble/tests", + "src/crypto/tests", + "src/inet/tests", + "src/lib/core/tests", + "src/lib/support/tests", + "src/lwip/tests", + "src/setup_payload/tests", + "src/system/tests", + ] + } + + group("check") { + deps = [ ":tests_run" ] + } +} diff --git a/build/args/host.gni b/build/args/host.gni new file mode 100644 index 00000000000000..e69de29bb2d1d6 diff --git a/build/chip_test.gni b/build/chip_test.gni new file mode 100644 index 00000000000000..8a6bebe5d67186 --- /dev/null +++ b/build/chip_test.gni @@ -0,0 +1,45 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/tests.gni") +import("//third_party/pigweed/pw_unit_test/test.gni") + +assert(chip_build_tests) + +template("chip_test") { + _test_name = target_name + + _test_output_dir = "${root_out_dir}/tests" + if (defined(invoker.output_dir)) { + _test_output_dir = invoker.output_dir + } + + executable(_test_name) { + forward_variables_from(invoker, "*", [ "output_dir" ]) + output_dir = _test_output_dir + } + + pw_python_script(_test_name + "_run") { + deps = [ ":${_test_name}" ] + inputs = [ pw_unit_test_AUTOMATIC_RUNNER ] + script = "$dir_pw_unit_test/py/pw_unit_test/test_runner.py" + args = [ + "--runner", + pw_unit_test_AUTOMATIC_RUNNER, + "--test", + get_path_info("$_test_output_dir:$_test_name", "abspath"), + ] + stamp = true + } +} diff --git a/build/chip_test_group.gni b/build/chip_test_group.gni new file mode 100644 index 00000000000000..94e8e9464c154d --- /dev/null +++ b/build/chip_test_group.gni @@ -0,0 +1,32 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/tests.gni") + +assert(chip_build_tests) + +template("chip_test_group") { + _test_group_name = target_name + + group("${_test_group_name}") { + deps = invoker.deps + } + + group("${_test_group_name}_run") { + deps = [] + foreach(_test, invoker.deps) { + deps += [ get_label_info(_test, "label_no_toolchain") + "_run" ] + } + } +} diff --git a/build/chip_test_suite.gni b/build/chip_test_suite.gni index a22c04a2640232..d8dbf6fbe3aeed 100644 --- a/build/chip_test_suite.gni +++ b/build/chip_test_suite.gni @@ -12,14 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//build/chip_test.gni") import("//build/tests.gni") +import("//third_party/pigweed/pw_unit_test/test.gni") assert(chip_build_tests) template("chip_test_suite") { - suite_name = target_name + _suite_name = target_name - static_library("${suite_name}_common") { + static_library("${_suite_name}_common") { forward_variables_from(invoker, [ "deps", @@ -32,30 +34,40 @@ template("chip_test_suite") { tests = [] if (defined(invoker.tests)) { - foreach(test, invoker.tests) { - executable(test) { - sources = [ "${test}Driver.cpp" ] + foreach(_test, invoker.tests) { + chip_test(_test) { + sources = [ "${_test}Driver.cpp" ] - public_deps = [ ":${suite_name}_common" ] + public_deps = [ ":${_suite_name}_common" ] } - tests += [ ":${test}" ] + tests += [ _test ] } } if (defined(invoker.c_tests)) { - foreach(test, invoker.c_tests) { - executable(test) { - sources = [ "${test}Driver.c" ] + foreach(_test, invoker.c_tests) { + chip_test(_test) { + sources = [ "${_test}Driver.c" ] - public_deps = [ ":${suite_name}_common" ] + public_deps = [ ":${_suite_name}_common" ] } - tests += [ ":${test}" ] + tests += [ _test ] } } - group(suite_name) { - deps = tests + group(_suite_name) { + deps = [] + foreach(_test, tests) { + deps += [ ":${_test}" ] + } + } + + group("${_suite_name}_run") { + deps = [] + foreach(_test, tests) { + deps += [ ":${_test}_run" ] + } } } diff --git a/src/lwip/tests/BUILD.gn b/src/lwip/tests/BUILD.gn index 75abf4d9de5ab4..0e6610bc3a6b5f 100644 --- a/src/lwip/tests/BUILD.gn +++ b/src/lwip/tests/BUILD.gn @@ -12,11 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -executable("TestLwIP") { +import("//build/chip_test.gni") +import("//build/chip_test_group.gni") + +chip_test("TestLwIP") { sources = [ "tests.c" ] deps = [ "//src/lwip" ] } -group("tests") { +chip_test_group("tests") { deps = [ ":TestLwIP" ] } From c381ba06468d8c8d4f56bb81792c717dd0b607e4 Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Tue, 16 Jun 2020 15:01:56 -0400 Subject: [PATCH 34/59] Make the build relocatable --- BUILD.gn | 67 +++--- build/args/host.gni | 0 build/chip_test.gni | 6 +- build/chip_test_group.gni | 4 +- build/chip_test_suite.gni | 8 +- build/chip_version.gni | 2 + build_overrides/chip.gni | 9 + build_overrides/lwip.gni | 17 ++ build_overrides/mbedtls.gni | 17 ++ build_overrides/nlassert.gni | 17 ++ build_overrides/nlfaultinjection.gni | 17 ++ build_overrides/nlio.gni | 17 ++ build_overrides/nlunit_test.gni | 17 ++ build_overrides/nrf5_sdk.gni | 18 ++ examples/lock-app/nrf5/BUILD.gn | 12 +- examples/lock-app/nrf5/args.gni | 5 +- examples/lock-app/nrf5/common_args.gni | 4 +- examples/lock-app/nrf5/toolchain/BUILD.gn | 4 +- src/BUILD.gn | 20 +- src/app/chip-zcl/BUILD.gn | 4 +- src/app/gen/BUILD.gn | 4 +- src/app/plugin/BUILD.gn | 10 +- src/app/plugin/tests/BUILD.gn | 12 +- src/ble/BUILD.gn | 10 +- src/ble/tests/BUILD.gn | 8 +- src/controller/BUILD.gn | 8 +- src/crypto/BUILD.gn | 8 +- src/crypto/tests/BUILD.gn | 10 +- src/inet/BUILD.gn | 16 +- src/inet/inet.gni | 2 + src/inet/tests/BUILD.gn | 10 +- src/lib/BUILD.gn | 2 + src/lib/core/BUILD.gn | 34 +-- src/lib/core/tests/BUILD.gn | 8 +- src/lib/support/BUILD.gn | 20 +- src/lib/support/tests/BUILD.gn | 8 +- src/lwip/BUILD.gn | 7 +- src/lwip/tests/BUILD.gn | 8 +- src/platform/BUILD.gn | 14 +- src/qrcodetool/BUILD.gn | 8 +- src/setup_payload/BUILD.gn | 6 +- src/setup_payload/tests/BUILD.gn | 8 +- src/system/BUILD.gn | 14 +- src/system/tests/BUILD.gn | 10 +- src/transport/BUILD.gn | 10 +- third_party/lwip/lwip.gni | 273 +++++++++++----------- third_party/nlfaultinjection/BUILD.gn | 4 +- third_party/nrf5_sdk/BUILD.gn | 5 +- third_party/nrf5_sdk/nrf5_sdk.gni | 2 + 49 files changed, 502 insertions(+), 302 deletions(-) delete mode 100644 build/args/host.gni create mode 100644 build_overrides/lwip.gni create mode 100644 build_overrides/mbedtls.gni create mode 100644 build_overrides/nlassert.gni create mode 100644 build_overrides/nlfaultinjection.gni create mode 100644 build_overrides/nlio.gni create mode 100644 build_overrides/nlunit_test.gni create mode 100644 build_overrides/nrf5_sdk.gni diff --git a/BUILD.gn b/BUILD.gn index b5f072fc9d75b3..e683f31a72e795 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -12,28 +12,29 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("build/examples.gni") -import("build/tests.gni") -import("build/tools.gni") +import("//build_overrides/chip.gni") + +import("${chip_root}/build/examples.gni") +import("${chip_root}/build/tests.gni") +import("${chip_root}/build/tools.gni") group("default") { deps = [ - "src", - "src/app", - "src/ble", - "src/controller", - "src/crypto", - "src/inet", - "src/lib/core", - "src/lib/support", - "src/lwip:all", - "src/system", - "src/transport", - "third_party/mbedtls", - "third_party/nlassert", - "third_party/nlfaultinjection", - "third_party/nlio", - "third_party/nlunit-test", + "${chip_root}/src", + "${chip_root}/src/app", + "${chip_root}/src/ble", + "${chip_root}/src/controller", + "${chip_root}/src/crypto", + "${chip_root}/src/inet", + "${chip_root}/src/lib/core", + "${chip_root}/src/lib/support", + "${chip_root}/src/lwip:all", + "${chip_root}/src/system", + "${chip_root}/src/transport", + "${mbedtls_root}:mbedtls", + "${nlassert_root}:nlassert", + "${nlio_root}:nlio", + "${nlunit_test_root}:nlunit-test", ] if (chip_build_tests) { @@ -42,32 +43,30 @@ group("default") { if (chip_build_tools) { deps += [ - "src/qrcodetool", - "src/setup_payload", + "${chip_root}/src/qrcodetool", + "${chip_root}/src/setup_payload", ] } if (build_nrf5_lock_app) { - deps += [ - "examples/lock-app/nrf5(examples/lock-app/nrf5/toolchain:nrf5_lock_app)", - ] + deps += [ "${nrf5_lock_app_root}:nrf5(${nrf5_lock_app_root}/toolchain:nrf5_lock_app)" ] } } if (chip_build_tests) { - import("build/chip_test_group.gni") + import("${chip_root}/build/chip_test_group.gni") chip_test_group("tests") { deps = [ - "src/app/plugin/tests", - "src/ble/tests", - "src/crypto/tests", - "src/inet/tests", - "src/lib/core/tests", - "src/lib/support/tests", - "src/lwip/tests", - "src/setup_payload/tests", - "src/system/tests", + "${chip_root}/src/app/plugin/tests", + "${chip_root}/src/ble/tests", + "${chip_root}/src/crypto/tests", + "${chip_root}/src/inet/tests", + "${chip_root}/src/lib/core/tests", + "${chip_root}/src/lib/support/tests", + "${chip_root}/src/lwip/tests", + "${chip_root}/src/setup_payload/tests", + "${chip_root}/src/system/tests", ] } diff --git a/build/args/host.gni b/build/args/host.gni deleted file mode 100644 index e69de29bb2d1d6..00000000000000 diff --git a/build/chip_test.gni b/build/chip_test.gni index 8a6bebe5d67186..2c147df16e89dd 100644 --- a/build/chip_test.gni +++ b/build/chip_test.gni @@ -12,8 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//build/tests.gni") -import("//third_party/pigweed/pw_unit_test/test.gni") +import("//build_overrides/chip.gni") + +import("${chip_root}/build/tests.gni") +import("${dir_pw_unit_test}/test.gni") assert(chip_build_tests) diff --git a/build/chip_test_group.gni b/build/chip_test_group.gni index 94e8e9464c154d..b77ed3feb0464a 100644 --- a/build/chip_test_group.gni +++ b/build/chip_test_group.gni @@ -12,7 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//build/tests.gni") +import("//build_overrides/chip.gni") + +import("${chip_root}/build/tests.gni") assert(chip_build_tests) diff --git a/build/chip_test_suite.gni b/build/chip_test_suite.gni index d8dbf6fbe3aeed..3529416c40930d 100644 --- a/build/chip_test_suite.gni +++ b/build/chip_test_suite.gni @@ -12,9 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//build/chip_test.gni") -import("//build/tests.gni") -import("//third_party/pigweed/pw_unit_test/test.gni") +import("//build_overrides/chip.gni") + +import("${chip_root}/build/chip_test.gni") +import("${chip_root}/build/tests.gni") +import("${dir_pw_unit_test}/test.gni") assert(chip_build_tests) diff --git a/build/chip_version.gni b/build/chip_version.gni index 2cbeb38d7ee828..e461af388a8ed9 100644 --- a/build/chip_version.gni +++ b/build/chip_version.gni @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//build_overrides/chip.gni") + declare_args() { # CHIP major version number. chip_version_major = 0 diff --git a/build_overrides/chip.gni b/build_overrides/chip.gni index db0f51b0bc980d..f00dd7d13d14e4 100644 --- a/build_overrides/chip.gni +++ b/build_overrides/chip.gni @@ -14,4 +14,13 @@ declare_args() { chip_root = "//" + nrf5_lock_app_root = "//examples/lock-app/nrf5" } + +import("lwip.gni") +import("mbedtls.gni") +import("nlassert.gni") +import("nlfaultinjection.gni") +import("nlio.gni") +import("nlunit_test.gni") +import("pigweed.gni") diff --git a/build_overrides/lwip.gni b/build_overrides/lwip.gni new file mode 100644 index 00000000000000..a61e407eb47073 --- /dev/null +++ b/build_overrides/lwip.gni @@ -0,0 +1,17 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +declare_args() { + lwip_root = "//third_party/lwip" +} diff --git a/build_overrides/mbedtls.gni b/build_overrides/mbedtls.gni new file mode 100644 index 00000000000000..4149ec197410a4 --- /dev/null +++ b/build_overrides/mbedtls.gni @@ -0,0 +1,17 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +declare_args() { + mbedtls_root = "//third_party/mbedtls" +} diff --git a/build_overrides/nlassert.gni b/build_overrides/nlassert.gni new file mode 100644 index 00000000000000..edddf80e35658d --- /dev/null +++ b/build_overrides/nlassert.gni @@ -0,0 +1,17 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +declare_args() { + nlassert_root = "//third_party/nlassert" +} diff --git a/build_overrides/nlfaultinjection.gni b/build_overrides/nlfaultinjection.gni new file mode 100644 index 00000000000000..3071268214eaa4 --- /dev/null +++ b/build_overrides/nlfaultinjection.gni @@ -0,0 +1,17 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +declare_args() { + nlfaultinjection_root = "//third_party/nlfaultinjection" +} diff --git a/build_overrides/nlio.gni b/build_overrides/nlio.gni new file mode 100644 index 00000000000000..46d854e7e91fbe --- /dev/null +++ b/build_overrides/nlio.gni @@ -0,0 +1,17 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +declare_args() { + nlio_root = "//third_party/nlio" +} diff --git a/build_overrides/nlunit_test.gni b/build_overrides/nlunit_test.gni new file mode 100644 index 00000000000000..d49ca9e0deea94 --- /dev/null +++ b/build_overrides/nlunit_test.gni @@ -0,0 +1,17 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +declare_args() { + nlunit_test_root = "//third_party/nlunit-test" +} diff --git a/build_overrides/nrf5_sdk.gni b/build_overrides/nrf5_sdk.gni new file mode 100644 index 00000000000000..f9422dc9eb319c --- /dev/null +++ b/build_overrides/nrf5_sdk.gni @@ -0,0 +1,18 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +declare_args() { + # Root directory for nRF5 SDK build files. + nrf5_sdk_build_root = "//third_party/nrf5_sdk" +} diff --git a/examples/lock-app/nrf5/BUILD.gn b/examples/lock-app/nrf5/BUILD.gn index 43bd7c9323d4de..257d1a6d4e3b96 100644 --- a/examples/lock-app/nrf5/BUILD.gn +++ b/examples/lock-app/nrf5/BUILD.gn @@ -12,16 +12,20 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//third_party/nrf5_sdk/nrf5_sdk.gni") +import("//build_overrides/chip.gni") +import("//build_overrides/nrf5_sdk.gni") + +import("${nrf5_sdk_build_root}/nrf5_sdk.gni") assert(current_os == "freertos") -nrf5_platform_dir = "//examples/platform/nrf528xx" +nrf5_platform_dir = "${chip_root}/examples/platform/nrf528xx" nrf5_sdk("sdk") { include_dirs = [ "main/include", "main", + "${chip_root}/src/include", "${nrf5_platform_dir}/app/project_include", "${nrf5_platform_dir}/util/include", "${nrf5_platform_dir}/app/include", @@ -49,8 +53,8 @@ nrf5_sdk("sdk") { executable("lock_app") { public_deps = [ ":sdk", - "//src:chip", - "//src/platform", + "${chip_root}/src:chip", + "${chip_root}/src/platform", ] sources = [ diff --git a/examples/lock-app/nrf5/args.gni b/examples/lock-app/nrf5/args.gni index e48ffabb16780a..82c43f1aa82775 100644 --- a/examples/lock-app/nrf5/args.gni +++ b/examples/lock-app/nrf5/args.gni @@ -12,12 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("common_args.gni") +import("//build_overrides/chip.gni") +import("${nrf5_lock_app_root}/common_args.gni") # These values help set up the default toolchain in standalone sample app # builds. They must be in a separate file to avoid namespace conflicts in # multi target builds. -custom_toolchain = "//examples/lock-app/nrf5/toolchain:nrf5_lock_app" +custom_toolchain = "${nrf5_lock_app_root}/toolchain:nrf5_lock_app" target_cpu = "arm" target_os = "freertos" # Don't add more args here, add them to common_args.gni. diff --git a/examples/lock-app/nrf5/common_args.gni b/examples/lock-app/nrf5/common_args.gni index 62d9e150b4aec3..c90f5c70d7a35b 100644 --- a/examples/lock-app/nrf5/common_args.gni +++ b/examples/lock-app/nrf5/common_args.gni @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//build_overrides/chip.gni") + build_nrf5_lock_app = true device_platform = "nrf5" @@ -30,7 +32,7 @@ inet_config_enable_ipv4 = false inet_config_enable_dns_resolver = false chip_build_tests = false -nrf5_sdk_target = "//examples/lock-app/nrf5:sdk" +nrf5_sdk_target = "${nrf5_lock_app_root}:sdk" ble_platform_config_include = "" ble_project_config_include = "" diff --git a/examples/lock-app/nrf5/toolchain/BUILD.gn b/examples/lock-app/nrf5/toolchain/BUILD.gn index 5c10a1f123c4ba..dceae1f9ff5aca 100644 --- a/examples/lock-app/nrf5/toolchain/BUILD.gn +++ b/examples/lock-app/nrf5/toolchain/BUILD.gn @@ -12,9 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//build_overrides/chip.gni") + import("//build/toolchain/arm_gcc/arm_toolchain.gni") arm_toolchain("nrf5_lock_app") { - toolchain_args_file = "../common_args.gni" + toolchain_args_file = "${nrf5_lock_app_root}/common_args.gni" current_os = "freertos" } diff --git a/src/BUILD.gn b/src/BUILD.gn index 643c7111a00344..9a8ca0d15149cb 100644 --- a/src/BUILD.gn +++ b/src/BUILD.gn @@ -26,16 +26,16 @@ config("includes") { static_library("chip") { public_deps = [ - "app/plugin:chip", - "ble", - "controller", - "crypto", - "inet", - "lib/core", - "lib/support", - "platform", - "system", - "transport", + "${chip_root}/src/app/plugin:chip", + "${chip_root}/src/ble", + "${chip_root}/src/controller", + "${chip_root}/src/crypto", + "${chip_root}/src/inet", + "${chip_root}/src/lib/core", + "${chip_root}/src/lib/support", + "${chip_root}/src/platform", + "${chip_root}/src/system", + "${chip_root}/src/transport", ] output_name = "libCHIP" diff --git a/src/app/chip-zcl/BUILD.gn b/src/app/chip-zcl/BUILD.gn index 2f1094466b61e0..714289e55c14ce 100644 --- a/src/app/chip-zcl/BUILD.gn +++ b/src/app/chip-zcl/BUILD.gn @@ -12,7 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//build/tests.gni") +import("//build_overrides/chip.gni") + +import("${chip_root}/build/tests.gni") config("chip-zcl_config") { include_dirs = [ diff --git a/src/app/gen/BUILD.gn b/src/app/gen/BUILD.gn index d651eb4585a11e..224960c95e5022 100644 --- a/src/app/gen/BUILD.gn +++ b/src/app/gen/BUILD.gn @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//build_overrides/chip.gni") + config("gen_config") { include_dirs = [ "." ] } @@ -38,5 +40,5 @@ static_library("gen") { public_configs = [ ":gen_config" ] - public_deps = [ "//src/app/chip-zcl" ] + public_deps = [ "${chip_root}/src/app/chip-zcl" ] } diff --git a/src/app/plugin/BUILD.gn b/src/app/plugin/BUILD.gn index c419f05684311b..be937adc52a3e5 100644 --- a/src/app/plugin/BUILD.gn +++ b/src/app/plugin/BUILD.gn @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//build_overrides/chip.gni") + source_set("common") { sources = [ "cluster-server-basic/basic-server.c", @@ -30,10 +32,10 @@ source_set("common") { ] public_deps = [ - "//src/app/chip-zcl", - "//src/app/gen", - "//src/lib/support", - "//src/system", + "${chip_root}/src/app/chip-zcl", + "${chip_root}/src/app/gen", + "${chip_root}/src/lib/support", + "${chip_root}/src/system", ] } diff --git a/src/app/plugin/tests/BUILD.gn b/src/app/plugin/tests/BUILD.gn index e4d7b56c6e2455..02a44e7a9aa9fd 100644 --- a/src/app/plugin/tests/BUILD.gn +++ b/src/app/plugin/tests/BUILD.gn @@ -12,7 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//build/chip_test_suite.gni") +import("//build_overrides/chip.gni") + +import("${chip_root}/build/chip_test_suite.gni") chip_test_suite("tests") { common_sources = [ @@ -28,10 +30,10 @@ chip_test_suite("tests") { ] public_deps = [ - "//src/app/plugin:mock", - "//src/inet", - "//src/system", - "//third_party/nlunit-test", + "${chip_root}/src/app/plugin:mock", + "${chip_root}/src/inet", + "${chip_root}/src/system", + "${nlunit_test_root}:nlunit-test", ] c_tests = [ "ChipZclUnitTests" ] diff --git a/src/ble/BUILD.gn b/src/ble/BUILD.gn index 28e7c840bc7fb2..158e716034969a 100644 --- a/src/ble/BUILD.gn +++ b/src/ble/BUILD.gn @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//build_overrides/chip.gni") + import("ble.gni") declare_args() { @@ -23,7 +25,7 @@ declare_args() { } config("ble_config") { - configs = [ "//src:includes" ] + configs = [ "${chip_root}/src:includes" ] defines = [] if (ble_project_config_include != "") { @@ -45,7 +47,7 @@ source_set("ble_config_header") { public_configs = [ ":ble_config" ] - public_deps = [ "//src/system:system_config_header" ] + public_deps = [ "${chip_root}/src/system:system_config_header" ] } source_set("ble") { @@ -69,7 +71,7 @@ source_set("ble") { public_deps = [ ":ble_config_header", - "//src/inet", - "//src/lib/support", + "${chip_root}/src/inet", + "${chip_root}/src/lib/support", ] } diff --git a/src/ble/tests/BUILD.gn b/src/ble/tests/BUILD.gn index 7c5c6715e5d38f..ecf399b4e8b3c8 100644 --- a/src/ble/tests/BUILD.gn +++ b/src/ble/tests/BUILD.gn @@ -12,7 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//build/chip_test_suite.gni") +import("//build_overrides/chip.gni") + +import("${chip_root}/build/chip_test_suite.gni") chip_test_suite("tests") { common_sources = [ @@ -21,8 +23,8 @@ chip_test_suite("tests") { ] public_deps = [ - "//src/ble", - "//third_party/nlunit-test", + "${chip_root}/src/ble", + "${nlunit_test_root}:nlunit-test", ] tests = [ "TestBleErrorStr" ] diff --git a/src/controller/BUILD.gn b/src/controller/BUILD.gn index 9603d9c735c441..ba630d8e383555 100644 --- a/src/controller/BUILD.gn +++ b/src/controller/BUILD.gn @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//build_overrides/chip.gni") + source_set("controller") { sources = [ "CHIPDeviceController.cpp", @@ -19,8 +21,8 @@ source_set("controller") { ] public_deps = [ - "//src/lib/core", - "//src/lib/support", - "//src/transport", + "${chip_root}/src/lib/core", + "${chip_root}/src/lib/support", + "${chip_root}/src/transport", ] } diff --git a/src/crypto/BUILD.gn b/src/crypto/BUILD.gn index 19531e114e235c..feee19b0c7d467 100644 --- a/src/crypto/BUILD.gn +++ b/src/crypto/BUILD.gn @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//build_overrides/chip.gni") + import("crypto.gni") config("crypto_config") { @@ -41,15 +43,15 @@ source_set("crypto") { sources = [ "CHIPCryptoPAL.h" ] public_deps = [ - "//src/lib/core", - "//third_party/nlassert", + "${chip_root}/src/lib/core", + "${nlassert_root}:nlassert", ] public_configs = [ ":crypto_config" ] if (chip_crypto == "mbedtls") { sources += [ "CHIPCryptoPALmbedTLS.cpp" ] - public_deps += [ "//third_party/mbedtls" ] + public_deps += [ "${mbedtls_root}:mbedtls" ] } else if (chip_crypto == "openssl") { sources += [ "CHIPCryptoPALOpenSSL.cpp" ] public_configs += [ ":openssl_config" ] diff --git a/src/crypto/tests/BUILD.gn b/src/crypto/tests/BUILD.gn index 2c55d1c424b2ca..d195709de0a33e 100644 --- a/src/crypto/tests/BUILD.gn +++ b/src/crypto/tests/BUILD.gn @@ -12,7 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//build/chip_test_suite.gni") +import("//build_overrides/chip.gni") + +import("${chip_root}/build/chip_test_suite.gni") chip_test_suite("tests") { common_sources = [ @@ -25,9 +27,9 @@ chip_test_suite("tests") { ] public_deps = [ - "//src/crypto", - "//src/lib/core", - "//third_party/nlunit-test", + "${chip_root}/src/crypto", + "${chip_root}/src/lib/core", + "${nlunit_test_root}:nlunit-test", ] tests = [ "CHIPCryptoPALTest" ] diff --git a/src/inet/BUILD.gn b/src/inet/BUILD.gn index 417ff954434886..dfe29fb99ee922 100644 --- a/src/inet/BUILD.gn +++ b/src/inet/BUILD.gn @@ -12,7 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//build/tests.gni") +import("//build_overrides/chip.gni") + +import("${chip_root}/build/tests.gni") import("inet.gni") declare_args() { @@ -24,7 +26,7 @@ declare_args() { } config("inet_config") { - configs = [ "//src:includes" ] + configs = [ "${chip_root}/src:includes" ] defines = [] if (inet_project_config_include != "") { @@ -81,7 +83,7 @@ source_set("inet_config_header") { public_configs = [ ":inet_config" ] - public_deps = [ "//src/system:system_config_header" ] + public_deps = [ "${chip_root}/src/system:system_config_header" ] } source_set("inet") { @@ -123,9 +125,9 @@ source_set("inet") { public_deps = [ ":inet_config_header", - "//src/lib/support", - "//src/system", - "//third_party/nlio", + "${chip_root}/src/lib/support", + "${chip_root}/src/system", + "${nlio_root}:nlio", ] if (inet_config_enable_dns_resolver) { @@ -144,6 +146,6 @@ source_set("inet") { if (chip_with_nlfaultinjection) { sources += [ "InetFaultInjection.cpp" ] - public_deps += [ "//third_party/nlfaultinjection" ] + public_deps += [ "${nlfaultinjection_root}:nlfaultinjection" ] } } diff --git a/src/inet/inet.gni b/src/inet/inet.gni index 380c0e31e00577..231c388066cd37 100644 --- a/src/inet/inet.gni +++ b/src/inet/inet.gni @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//build_overrides/chip.gni") + declare_args() { # Enable IPv4 support. inet_config_enable_ipv4 = true diff --git a/src/inet/tests/BUILD.gn b/src/inet/tests/BUILD.gn index fad33acf99f0e7..7f9c0922118b1e 100644 --- a/src/inet/tests/BUILD.gn +++ b/src/inet/tests/BUILD.gn @@ -12,7 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//build/chip_test_suite.gni") +import("//build_overrides/chip.gni") + +import("${chip_root}/build/chip_test_suite.gni") chip_test_suite("tests") { common_sources = [ @@ -34,9 +36,9 @@ chip_test_suite("tests") { ] public_deps = [ - "//src/inet", - "//src/lib/core", - "//third_party/nlunit-test", + "${chip_root}/src/inet", + "${chip_root}/src/lib/core", + "${nlunit_test_root}:nlunit-test", ] tests = [ diff --git a/src/lib/BUILD.gn b/src/lib/BUILD.gn index 5f4d446904d611..310ae29efbdcdb 100644 --- a/src/lib/BUILD.gn +++ b/src/lib/BUILD.gn @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//build_overrides/chip.gni") + config("includes") { include_dirs = [ "." ] } diff --git a/src/lib/core/BUILD.gn b/src/lib/core/BUILD.gn index ac89a8b38cc572..e4695d9d404a54 100644 --- a/src/lib/core/BUILD.gn +++ b/src/lib/core/BUILD.gn @@ -12,8 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//build/tests.gni") -import("//src/inet/inet.gni") +import("//build_overrides/chip.gni") + +import("${chip_root}/build/tests.gni") +import("${chip_root}/src/inet/inet.gni") import("core.gni") config("chip_config") { @@ -89,8 +91,8 @@ config("chip_config") { include_dirs = [ target_gen_dir ] configs = [ - "//src:includes", - "//src/lib:includes", + "${chip_root}/src:includes", + "${chip_root}/src/lib:includes", ] } @@ -104,7 +106,7 @@ source_set("chip_config_header") { public_configs = [ ":chip_config" ] - public_deps = [ "//src/system:system_config_header" ] + public_deps = [ "${chip_root}/src/system:system_config_header" ] } source_set("core") { @@ -130,19 +132,19 @@ source_set("core") { public_deps = [ ":chip_config_header", - "//src/ble", - "//src/inet", - "//src/lib/support", - "//src/platform", - "//src/system", - "//third_party/nlio", + "${chip_root}/src/ble", + "${chip_root}/src/inet", + "${chip_root}/src/lib/support", + "${chip_root}/src/platform", + "${chip_root}/src/system", + "${nlio_root}:nlio", ] allow_circular_includes_from = [ - "//src/ble", - "//src/lib/support", - "//src/inet", - "//src/system", - "//src/platform", + "${chip_root}/src/ble", + "${chip_root}/src/lib/support", + "${chip_root}/src/inet", + "${chip_root}/src/platform", + "${chip_root}/src/system", ] } diff --git a/src/lib/core/tests/BUILD.gn b/src/lib/core/tests/BUILD.gn index 8a4780a60aa5dc..09e8ea552e2537 100644 --- a/src/lib/core/tests/BUILD.gn +++ b/src/lib/core/tests/BUILD.gn @@ -12,7 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//build/chip_test_suite.gni") +import("//build_overrides/chip.gni") + +import("${chip_root}/build/chip_test_suite.gni") chip_test_suite("tests") { common_sources = [ @@ -24,8 +26,8 @@ chip_test_suite("tests") { ] public_deps = [ - "//src/lib/core", - "//third_party/nlunit-test", + "${chip_root}/src/lib/core", + "${nlunit_test_root}:nlunit-test", ] tests = [ diff --git a/src/lib/support/BUILD.gn b/src/lib/support/BUILD.gn index c8cdacbb8ea1ce..072aa4f208d249 100644 --- a/src/lib/support/BUILD.gn +++ b/src/lib/support/BUILD.gn @@ -12,11 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//build/chip_version.gni") -import("//build/tests.gni") +import("//build_overrides/chip.gni") + +import("${chip_root}/build/chip_version.gni") +import("${chip_root}/build/tests.gni") action("gen_chip_version") { - script = "//scripts/gen_chip_version.py" + script = "${chip_root}/scripts/gen_chip_version.py" version_file = "${target_gen_dir}/CHIPVersion.h" outputs = [ version_file ] @@ -37,9 +39,9 @@ source_set("chip_version_header") { config("support_config") { configs = [ - "//src:includes", - "//src/lib:includes", - "//src/system:system_config", + "${chip_root}/src:includes", + "${chip_root}/src/lib:includes", + "${chip_root}/src/system:system_config", ] include_dirs = [ target_gen_dir ] @@ -79,8 +81,8 @@ static_library("support") { public_deps = [ ":chip_version_header", - "//src/lib/core:chip_config_header", - "//third_party/nlassert", + "${chip_root}/src/lib/core:chip_config_header", + "${nlassert_root}:nlassert", ] public_configs = [ ":support_config" ] @@ -90,6 +92,6 @@ static_library("support") { "CHIPFaultInjection.cpp", "CHIPFaultInjection.h", ] - public_deps += [ "//third_party/nlfaultinjection" ] + public_deps += [ "${nlfaultinjection_root}:nlfaultinjection" ] } } diff --git a/src/lib/support/tests/BUILD.gn b/src/lib/support/tests/BUILD.gn index 23fb0a87157258..ff8997dc688eb8 100644 --- a/src/lib/support/tests/BUILD.gn +++ b/src/lib/support/tests/BUILD.gn @@ -12,7 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//build/chip_test_suite.gni") +import("//build_overrides/chip.gni") + +import("${chip_root}/build/chip_test_suite.gni") chip_test_suite("tests") { common_sources = [ @@ -27,8 +29,8 @@ chip_test_suite("tests") { ] public_deps = [ - "//src/lib/core", - "//third_party/nlunit-test", + "${chip_root}/src/lib/core", + "${nlunit_test_root}:nlunit-test", ] tests = [ diff --git a/src/lwip/BUILD.gn b/src/lwip/BUILD.gn index f4b28fdfe37012..416094f25252b3 100644 --- a/src/lwip/BUILD.gn +++ b/src/lwip/BUILD.gn @@ -12,7 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//third_party/lwip/lwip.gni") +import("//build_overrides/chip.gni") +import("//build_overrides/nrf5_sdk.gni") + +import("${lwip_root}/lwip.gni") declare_args() { # Enable lwIP debugging. @@ -70,7 +73,7 @@ lwip_target("lwip") { public_deps = [] if (lwip_platform == "nrf5") { - public_deps += [ "//third_party/nrf5_sdk" ] + public_deps += [ "${nrf5_sdk_build_root}:nrf5_sdk" ] } public_configs = [ ":lwip_config" ] diff --git a/src/lwip/tests/BUILD.gn b/src/lwip/tests/BUILD.gn index 0e6610bc3a6b5f..18ddbd07e5ed8b 100644 --- a/src/lwip/tests/BUILD.gn +++ b/src/lwip/tests/BUILD.gn @@ -12,12 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//build/chip_test.gni") -import("//build/chip_test_group.gni") +import("//build_overrides/chip.gni") + +import("${chip_root}/build/chip_test.gni") +import("${chip_root}/build/chip_test_group.gni") chip_test("TestLwIP") { sources = [ "tests.c" ] - deps = [ "//src/lwip" ] + deps = [ "${chip_root}/src/lwip" ] } chip_test_group("tests") { diff --git a/src/platform/BUILD.gn b/src/platform/BUILD.gn index 865eff2df013c3..b91283fa42f277 100644 --- a/src/platform/BUILD.gn +++ b/src/platform/BUILD.gn @@ -12,7 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//build/device.gni") +import("//build_overrides/chip.gni") + +import("${chip_root}/build/device.gni") if (device_platform != "none") { declare_args() { @@ -24,7 +26,7 @@ if (device_platform != "none") { } config("platform_config") { - configs = [ "//src:includes" ] + configs = [ "${chip_root}/src:includes" ] defines = [] if (chip_device_project_config_include != "") { @@ -54,10 +56,10 @@ if (device_platform != "none") { ] public_deps = [ - "//src/ble", - "//src/lib/core:chip_config_header", - "//src/lib/support", - "//third_party/nlio", + "${chip_root}/src/ble", + "${chip_root}/src/lib/core:chip_config_header", + "${chip_root}/src/lib/support", + "${nlio_root}:nlio", ] public_configs = [ ":platform_config" ] diff --git a/src/qrcodetool/BUILD.gn b/src/qrcodetool/BUILD.gn index 30817e3cfd56e6..0b033c86d217fc 100644 --- a/src/qrcodetool/BUILD.gn +++ b/src/qrcodetool/BUILD.gn @@ -12,7 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//build/tools.gni") +import("//build_overrides/chip.gni") + +import("${chip_root}/build/tools.gni") assert(chip_build_tools) @@ -25,7 +27,7 @@ executable("qrcodetool") { ] public_deps = [ - "//src/lib/support", - "//src/setup_payload", + "${chip_root}/src/lib/support", + "${chip_root}/src/setup_payload", ] } diff --git a/src/setup_payload/BUILD.gn b/src/setup_payload/BUILD.gn index 5a56f2c6a2e9ff..afacb16da61cbb 100644 --- a/src/setup_payload/BUILD.gn +++ b/src/setup_payload/BUILD.gn @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//build_overrides/chip.gni") + config("setup_payload_config") { include_dirs = [ "." ] } @@ -35,8 +37,8 @@ static_library("setup_payload") { ] public_deps = [ - "//src/lib/core", - "//src/lib/support", + "${chip_root}/src/lib/core", + "${chip_root}/src/lib/support", ] public_configs = [ ":setup_payload_config" ] diff --git a/src/setup_payload/tests/BUILD.gn b/src/setup_payload/tests/BUILD.gn index a10f3b29aed56f..1ee0de764e6653 100644 --- a/src/setup_payload/tests/BUILD.gn +++ b/src/setup_payload/tests/BUILD.gn @@ -12,7 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//build/chip_test_suite.gni") +import("//build_overrides/chip.gni") + +import("${chip_root}/build/chip_test_suite.gni") chip_test_suite("tests") { common_sources = [ @@ -25,8 +27,8 @@ chip_test_suite("tests") { ] public_deps = [ - "//src/setup_payload", - "//third_party/nlunit-test", + "${chip_root}/src/setup_payload", + "${nlunit_test_root}:nlunit-test", ] tests = [ diff --git a/src/system/BUILD.gn b/src/system/BUILD.gn index 5398bae98d2fbe..35e525ce0f9ffe 100644 --- a/src/system/BUILD.gn +++ b/src/system/BUILD.gn @@ -12,7 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//build/tests.gni") +import("//build_overrides/chip.gni") + +import("${chip_root}/build/tests.gni") import("system.gni") declare_args() { @@ -32,7 +34,7 @@ declare_args() { } config("system_config") { - configs = [ "//src:includes" ] + configs = [ "${chip_root}/src:includes" ] defines = [] if (chip_project_config_include != "") { @@ -112,7 +114,7 @@ source_set("system_config_header") { public_deps = [] if (chip_system_config_use_lwip) { - public_deps += [ "//src/lwip" ] + public_deps += [ "${chip_root}/src/lwip" ] } } @@ -143,12 +145,12 @@ source_set("system") { ] public_deps = [ - "//src/lib/support", - "//third_party/nlassert", + "${chip_root}/src/lib/support", + "${nlassert_root}:nlassert", ] if (chip_with_nlfaultinjection) { sources += [ "SystemFaultInjection.cpp" ] - public_deps += [ "//third_party/nlfaultinjection" ] + public_deps += [ "${nlfaultinjection_root}:nlfaultinjection" ] } } diff --git a/src/system/tests/BUILD.gn b/src/system/tests/BUILD.gn index be5bff5de74ad8..62ba300b9a1cb0 100644 --- a/src/system/tests/BUILD.gn +++ b/src/system/tests/BUILD.gn @@ -12,7 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//build/chip_test_suite.gni") +import("//build_overrides/chip.gni") + +import("${chip_root}/build/chip_test_suite.gni") chip_test_suite("tests") { common_sources = [ @@ -25,9 +27,9 @@ chip_test_suite("tests") { ] public_deps = [ - "//src/inet", - "//src/system", - "//third_party/nlunit-test", + "${chip_root}/src/inet", + "${chip_root}/src/system", + "${nlunit_test_root}:nlunit-test", ] tests = [ diff --git a/src/transport/BUILD.gn b/src/transport/BUILD.gn index 177a8cf1a4d97b..e662531cd439d5 100644 --- a/src/transport/BUILD.gn +++ b/src/transport/BUILD.gn @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//build_overrides/chip.gni") + source_set("transport") { sources = [ "Base.h", @@ -29,9 +31,9 @@ source_set("transport") { ] public_deps = [ - "//src/crypto", - "//src/inet", - "//src/lib/core", - "//src/lib/support", + "${chip_root}/src/crypto", + "${chip_root}/src/inet", + "${chip_root}/src/lib/core", + "${chip_root}/src/lib/support", ] } diff --git a/third_party/lwip/lwip.gni b/third_party/lwip/lwip.gni index 8162d4d8a3e426..e9ffce8084d965 100644 --- a/third_party/lwip/lwip.gni +++ b/third_party/lwip/lwip.gni @@ -12,13 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//build_overrides/lwip.gni") + declare_args() { # Default enablement for lwIP library components. # This has no effect on its own; it only changes between opt-out and opt-in. lwip_default = current_os != "freertos" - - # Root of the lwIP source tree. - lwip_root = get_path_info("repo/lwip", "abspath") } declare_args() { @@ -79,7 +78,7 @@ declare_args() { # lwIP depends on external header files to compile. This template defines # a combined build of the lwIP sources plus target configuration. template("lwip_target") { - assert(lwip_root != "", "lwip_root must be specified") + _lwip_root = "${lwip_root}/repo/lwip" lwip_target_name = target_name @@ -92,7 +91,7 @@ template("lwip_target") { config("${lwip_target_name}_base_config") { include_dirs = [ - "${lwip_root}/src/include", + "${lwip_root}/repo/lwip/src/include", "include", ] @@ -157,136 +156,136 @@ template("lwip_target") { # lwIP headers become empty if the relevant feature is disabled, so the # whole interface can be public regardless of build options. public += [ - "${lwip_root}/src/include/lwip/api.h", - "${lwip_root}/src/include/lwip/autoip.h", - "${lwip_root}/src/include/lwip/debug.h", - "${lwip_root}/src/include/lwip/def.h", - "${lwip_root}/src/include/lwip/dhcp.h", - "${lwip_root}/src/include/lwip/dhcp6.h", - "${lwip_root}/src/include/lwip/dns.h", - "${lwip_root}/src/include/lwip/err.h", - "${lwip_root}/src/include/lwip/etharp.h", - "${lwip_root}/src/include/lwip/ethip6.h", - "${lwip_root}/src/include/lwip/icmp.h", - "${lwip_root}/src/include/lwip/icmp6.h", - "${lwip_root}/src/include/lwip/if.h", - "${lwip_root}/src/include/lwip/igmp.h", - "${lwip_root}/src/include/lwip/inet.h", - "${lwip_root}/src/include/lwip/inet_chksum.h", - "${lwip_root}/src/include/lwip/init.h", - "${lwip_root}/src/include/lwip/ip.h", - "${lwip_root}/src/include/lwip/ip4_frag.h", - "${lwip_root}/src/include/lwip/ip6.h", - "${lwip_root}/src/include/lwip/ip6_addr.h", - "${lwip_root}/src/include/lwip/ip6_frag.h", - "${lwip_root}/src/include/lwip/ip6_route_table.h", - "${lwip_root}/src/include/lwip/ip_addr.h", - "${lwip_root}/src/include/lwip/mem.h", - "${lwip_root}/src/include/lwip/memp.h", - "${lwip_root}/src/include/lwip/mld6.h", - "${lwip_root}/src/include/lwip/nd6.h", - "${lwip_root}/src/include/lwip/netbuf.h", - "${lwip_root}/src/include/lwip/netdb.h", - "${lwip_root}/src/include/lwip/netif.h", - "${lwip_root}/src/include/lwip/netifapi.h", - "${lwip_root}/src/include/lwip/opt.h", - "${lwip_root}/src/include/lwip/pbuf.h", - "${lwip_root}/src/include/lwip/priv/tcp_priv.h", - "${lwip_root}/src/include/lwip/priv/tcpip_priv.h", - "${lwip_root}/src/include/lwip/prot/autoip.h", - "${lwip_root}/src/include/lwip/prot/dhcp.h", - "${lwip_root}/src/include/lwip/prot/dns.h", - "${lwip_root}/src/include/lwip/prot/ethernet.h", - "${lwip_root}/src/include/lwip/prot/icmp6.h", - "${lwip_root}/src/include/lwip/prot/igmp.h", - "${lwip_root}/src/include/lwip/prot/mld6.h", - "${lwip_root}/src/include/lwip/prot/nd6.h", - "${lwip_root}/src/include/lwip/raw.h", - "${lwip_root}/src/include/lwip/snmp.h", - "${lwip_root}/src/include/lwip/sockets.h", - "${lwip_root}/src/include/lwip/stats.h", - "${lwip_root}/src/include/lwip/sys.h", - "${lwip_root}/src/include/lwip/tcp.h", - "${lwip_root}/src/include/lwip/tcpip.h", - "${lwip_root}/src/include/lwip/timeouts.h", - "${lwip_root}/src/include/lwip/udp.h", + "${_lwip_root}/src/include/lwip/api.h", + "${_lwip_root}/src/include/lwip/autoip.h", + "${_lwip_root}/src/include/lwip/debug.h", + "${_lwip_root}/src/include/lwip/def.h", + "${_lwip_root}/src/include/lwip/dhcp.h", + "${_lwip_root}/src/include/lwip/dhcp6.h", + "${_lwip_root}/src/include/lwip/dns.h", + "${_lwip_root}/src/include/lwip/err.h", + "${_lwip_root}/src/include/lwip/etharp.h", + "${_lwip_root}/src/include/lwip/ethip6.h", + "${_lwip_root}/src/include/lwip/icmp.h", + "${_lwip_root}/src/include/lwip/icmp6.h", + "${_lwip_root}/src/include/lwip/if.h", + "${_lwip_root}/src/include/lwip/igmp.h", + "${_lwip_root}/src/include/lwip/inet.h", + "${_lwip_root}/src/include/lwip/inet_chksum.h", + "${_lwip_root}/src/include/lwip/init.h", + "${_lwip_root}/src/include/lwip/ip.h", + "${_lwip_root}/src/include/lwip/ip4_frag.h", + "${_lwip_root}/src/include/lwip/ip6.h", + "${_lwip_root}/src/include/lwip/ip6_addr.h", + "${_lwip_root}/src/include/lwip/ip6_frag.h", + "${_lwip_root}/src/include/lwip/ip6_route_table.h", + "${_lwip_root}/src/include/lwip/ip_addr.h", + "${_lwip_root}/src/include/lwip/mem.h", + "${_lwip_root}/src/include/lwip/memp.h", + "${_lwip_root}/src/include/lwip/mld6.h", + "${_lwip_root}/src/include/lwip/nd6.h", + "${_lwip_root}/src/include/lwip/netbuf.h", + "${_lwip_root}/src/include/lwip/netdb.h", + "${_lwip_root}/src/include/lwip/netif.h", + "${_lwip_root}/src/include/lwip/netifapi.h", + "${_lwip_root}/src/include/lwip/opt.h", + "${_lwip_root}/src/include/lwip/pbuf.h", + "${_lwip_root}/src/include/lwip/priv/tcp_priv.h", + "${_lwip_root}/src/include/lwip/priv/tcpip_priv.h", + "${_lwip_root}/src/include/lwip/prot/autoip.h", + "${_lwip_root}/src/include/lwip/prot/dhcp.h", + "${_lwip_root}/src/include/lwip/prot/dns.h", + "${_lwip_root}/src/include/lwip/prot/ethernet.h", + "${_lwip_root}/src/include/lwip/prot/icmp6.h", + "${_lwip_root}/src/include/lwip/prot/igmp.h", + "${_lwip_root}/src/include/lwip/prot/mld6.h", + "${_lwip_root}/src/include/lwip/prot/nd6.h", + "${_lwip_root}/src/include/lwip/raw.h", + "${_lwip_root}/src/include/lwip/snmp.h", + "${_lwip_root}/src/include/lwip/sockets.h", + "${_lwip_root}/src/include/lwip/stats.h", + "${_lwip_root}/src/include/lwip/sys.h", + "${_lwip_root}/src/include/lwip/tcp.h", + "${_lwip_root}/src/include/lwip/tcpip.h", + "${_lwip_root}/src/include/lwip/timeouts.h", + "${_lwip_root}/src/include/lwip/udp.h", ] sources += [ - "${lwip_root}/src/core/def.c", - "${lwip_root}/src/core/dns.c", - "${lwip_root}/src/core/inet_chksum.c", - "${lwip_root}/src/core/init.c", - "${lwip_root}/src/core/ip.c", - "${lwip_root}/src/core/mem.c", - "${lwip_root}/src/core/memp.c", - "${lwip_root}/src/core/netif.c", - "${lwip_root}/src/core/pbuf.c", - "${lwip_root}/src/core/raw.c", - "${lwip_root}/src/core/stats.c", - "${lwip_root}/src/core/sys.c", - "${lwip_root}/src/core/tcp.c", - "${lwip_root}/src/core/tcp_in.c", - "${lwip_root}/src/core/tcp_out.c", - "${lwip_root}/src/core/timeouts.c", - "${lwip_root}/src/core/udp.c", - "${lwip_root}/src/include/lwip/priv/api_msg.h", - "${lwip_root}/src/include/lwip/priv/memp_std.h", - "${lwip_root}/src/include/lwip/priv/nd6_priv.h", + "${_lwip_root}/src/core/def.c", + "${_lwip_root}/src/core/dns.c", + "${_lwip_root}/src/core/inet_chksum.c", + "${_lwip_root}/src/core/init.c", + "${_lwip_root}/src/core/ip.c", + "${_lwip_root}/src/core/mem.c", + "${_lwip_root}/src/core/memp.c", + "${_lwip_root}/src/core/netif.c", + "${_lwip_root}/src/core/pbuf.c", + "${_lwip_root}/src/core/raw.c", + "${_lwip_root}/src/core/stats.c", + "${_lwip_root}/src/core/sys.c", + "${_lwip_root}/src/core/tcp.c", + "${_lwip_root}/src/core/tcp_in.c", + "${_lwip_root}/src/core/tcp_out.c", + "${_lwip_root}/src/core/timeouts.c", + "${_lwip_root}/src/core/udp.c", + "${_lwip_root}/src/include/lwip/priv/api_msg.h", + "${_lwip_root}/src/include/lwip/priv/memp_std.h", + "${_lwip_root}/src/include/lwip/priv/nd6_priv.h", ] if (lwip_ipv4) { sources += [ - "${lwip_root}/src/core/ipv4/autoip.c", - "${lwip_root}/src/core/ipv4/dhcp.c", - "${lwip_root}/src/core/ipv4/etharp.c", - "${lwip_root}/src/core/ipv4/icmp.c", - "${lwip_root}/src/core/ipv4/igmp.c", - "${lwip_root}/src/core/ipv4/ip4.c", - "${lwip_root}/src/core/ipv4/ip4_addr.c", - "${lwip_root}/src/core/ipv4/ip4_frag.c", + "${_lwip_root}/src/core/ipv4/autoip.c", + "${_lwip_root}/src/core/ipv4/dhcp.c", + "${_lwip_root}/src/core/ipv4/etharp.c", + "${_lwip_root}/src/core/ipv4/icmp.c", + "${_lwip_root}/src/core/ipv4/igmp.c", + "${_lwip_root}/src/core/ipv4/ip4.c", + "${_lwip_root}/src/core/ipv4/ip4_addr.c", + "${_lwip_root}/src/core/ipv4/ip4_frag.c", ] } if (lwip_ipv6) { sources += [ - "${lwip_root}/src/core/ipv6/dhcp6.c", - "${lwip_root}/src/core/ipv6/ethip6.c", - "${lwip_root}/src/core/ipv6/icmp6.c", - "${lwip_root}/src/core/ipv6/inet6.c", - "${lwip_root}/src/core/ipv6/ip6.c", - "${lwip_root}/src/core/ipv6/ip6_addr.c", - "${lwip_root}/src/core/ipv6/ip6_frag.c", - "${lwip_root}/src/core/ipv6/ip6_route_table.c", - "${lwip_root}/src/core/ipv6/mld6.c", - "${lwip_root}/src/core/ipv6/nd6.c", + "${_lwip_root}/src/core/ipv6/dhcp6.c", + "${_lwip_root}/src/core/ipv6/ethip6.c", + "${_lwip_root}/src/core/ipv6/icmp6.c", + "${_lwip_root}/src/core/ipv6/inet6.c", + "${_lwip_root}/src/core/ipv6/ip6.c", + "${_lwip_root}/src/core/ipv6/ip6_addr.c", + "${_lwip_root}/src/core/ipv6/ip6_frag.c", + "${_lwip_root}/src/core/ipv6/ip6_route_table.c", + "${_lwip_root}/src/core/ipv6/mld6.c", + "${_lwip_root}/src/core/ipv6/nd6.c", ] } if (lwip_api) { sources += [ - "${lwip_root}/src/api/api_lib.c", - "${lwip_root}/src/api/api_msg.c", - "${lwip_root}/src/api/err.c", - "${lwip_root}/src/api/if.c", - "${lwip_root}/src/api/netbuf.c", - "${lwip_root}/src/api/netdb.c", - "${lwip_root}/src/api/netifapi.c", - "${lwip_root}/src/api/sockets.c", - "${lwip_root}/src/api/tcpip.c", + "${_lwip_root}/src/api/api_lib.c", + "${_lwip_root}/src/api/api_msg.c", + "${_lwip_root}/src/api/err.c", + "${_lwip_root}/src/api/if.c", + "${_lwip_root}/src/api/netbuf.c", + "${_lwip_root}/src/api/netdb.c", + "${_lwip_root}/src/api/netifapi.c", + "${_lwip_root}/src/api/sockets.c", + "${_lwip_root}/src/api/tcpip.c", ] } if (lwip_ethernet) { - sources += [ "${lwip_root}/src/netif/ethernet.c" ] + sources += [ "${_lwip_root}/src/netif/ethernet.c" ] } if (lwip_slip) { - sources += [ "${lwip_root}/src/netif/slipif.c" ] + sources += [ "${_lwip_root}/src/netif/slipif.c" ] } if (lwip_6lowpan) { - sources += [ "${lwip_root}/src/netif/lowpan6.c" ] + sources += [ "${_lwip_root}/src/netif/lowpan6.c" ] } # Relax warnings for third_party code. @@ -313,27 +312,27 @@ template("lwip_target") { if (lwip_snmp) { lwip_app("snmp") { sources = [ - "${lwip_root}/src/apps/snmp/snmp_asn1.c", - "${lwip_root}/src/apps/snmp/snmp_core.c", - "${lwip_root}/src/apps/snmp/snmp_mib2.c", - "${lwip_root}/src/apps/snmp/snmp_mib2_icmp.c", - "${lwip_root}/src/apps/snmp/snmp_mib2_interfaces.c", - "${lwip_root}/src/apps/snmp/snmp_mib2_ip.c", - "${lwip_root}/src/apps/snmp/snmp_mib2_snmp.c", - "${lwip_root}/src/apps/snmp/snmp_mib2_system.c", - "${lwip_root}/src/apps/snmp/snmp_mib2_tcp.c", - "${lwip_root}/src/apps/snmp/snmp_mib2_udp.c", - "${lwip_root}/src/apps/snmp/snmp_msg.c", - "${lwip_root}/src/apps/snmp/snmp_netconn.c", - "${lwip_root}/src/apps/snmp/snmp_pbuf_stream.c", - "${lwip_root}/src/apps/snmp/snmp_raw.c", - "${lwip_root}/src/apps/snmp/snmp_scalar.c", - "${lwip_root}/src/apps/snmp/snmp_table.c", - "${lwip_root}/src/apps/snmp/snmp_threadsync.c", - "${lwip_root}/src/apps/snmp/snmp_traps.c", - "${lwip_root}/src/apps/snmp/snmpv3.c", - "${lwip_root}/src/apps/snmp/snmpv3_dummy.c", - "${lwip_root}/src/apps/snmp/snmpv3_mbedtls.c", + "${_lwip_root}/src/apps/snmp/snmp_asn1.c", + "${_lwip_root}/src/apps/snmp/snmp_core.c", + "${_lwip_root}/src/apps/snmp/snmp_mib2.c", + "${_lwip_root}/src/apps/snmp/snmp_mib2_icmp.c", + "${_lwip_root}/src/apps/snmp/snmp_mib2_interfaces.c", + "${_lwip_root}/src/apps/snmp/snmp_mib2_ip.c", + "${_lwip_root}/src/apps/snmp/snmp_mib2_snmp.c", + "${_lwip_root}/src/apps/snmp/snmp_mib2_system.c", + "${_lwip_root}/src/apps/snmp/snmp_mib2_tcp.c", + "${_lwip_root}/src/apps/snmp/snmp_mib2_udp.c", + "${_lwip_root}/src/apps/snmp/snmp_msg.c", + "${_lwip_root}/src/apps/snmp/snmp_netconn.c", + "${_lwip_root}/src/apps/snmp/snmp_pbuf_stream.c", + "${_lwip_root}/src/apps/snmp/snmp_raw.c", + "${_lwip_root}/src/apps/snmp/snmp_scalar.c", + "${_lwip_root}/src/apps/snmp/snmp_table.c", + "${_lwip_root}/src/apps/snmp/snmp_threadsync.c", + "${_lwip_root}/src/apps/snmp/snmp_traps.c", + "${_lwip_root}/src/apps/snmp/snmpv3.c", + "${_lwip_root}/src/apps/snmp/snmpv3_dummy.c", + "${_lwip_root}/src/apps/snmp/snmpv3_mbedtls.c", ] } @@ -343,8 +342,8 @@ template("lwip_target") { if (lwip_httpd) { lwip_app("httpd") { sources = [ - "${lwip_root}/src/apps/httpd/fs.c", - "${lwip_root}/src/apps/httpd/httpd.c", + "${_lwip_root}/src/apps/httpd/fs.c", + "${_lwip_root}/src/apps/httpd/httpd.c", ] } @@ -353,7 +352,7 @@ template("lwip_target") { if (lwip_iperf) { lwip_app("lwiperf") { - sources = [ "${lwip_root}/src/apps/lwiperf/lwiperf.c" ] + sources = [ "${_lwip_root}/src/apps/lwiperf/lwiperf.c" ] } lwip_apps += [ ":${lwip_target_name}_lwiperf" ] @@ -361,7 +360,7 @@ template("lwip_target") { if (lwip_sntp) { lwip_app("sntp") { - sources = [ "${lwip_root}/src/apps/sntp/sntp.c" ] + sources = [ "${_lwip_root}/src/apps/sntp/sntp.c" ] } lwip_apps += [ ":${lwip_target_name}_sntp" ] @@ -369,7 +368,7 @@ template("lwip_target") { if (lwip_mdns) { lwip_app("mdns") { - sources = [ "${lwip_root}/src/apps/mdns/mdns.c" ] + sources = [ "${_lwip_root}/src/apps/mdns/mdns.c" ] } lwip_apps += [ ":${lwip_target_name}_mdns" ] @@ -377,7 +376,7 @@ template("lwip_target") { if (lwip_netbiosns) { lwip_app("netbiosns") { - sources = [ "${lwip_root}/src/apps/netbiosns/netbiosns.c" ] + sources = [ "${_lwip_root}/src/apps/netbiosns/netbiosns.c" ] } lwip_apps += [ ":${lwip_target_name}_netbiosns" ] @@ -385,7 +384,7 @@ template("lwip_target") { if (lwip_tftp) { lwip_app("tftp") { - sources = [ "${lwip_root}/src/apps/tftp/tftp_server.c" ] + sources = [ "${_lwip_root}/src/apps/tftp/tftp_server.c" ] } lwip_apps += [ ":${lwip_target_name}_tftp" ] @@ -393,7 +392,7 @@ template("lwip_target") { if (lwip_mqtt) { lwip_app("mqtt") { - sources = [ "${lwip_root}/src/apps/mqtt/mqtt.c" ] + sources = [ "${_lwip_root}/src/apps/mqtt/mqtt.c" ] } lwip_apps += [ ":${lwip_target_name}_mqtt" ] diff --git a/third_party/nlfaultinjection/BUILD.gn b/third_party/nlfaultinjection/BUILD.gn index 98983a113d7d34..b1953bb02f2f7b 100644 --- a/third_party/nlfaultinjection/BUILD.gn +++ b/third_party/nlfaultinjection/BUILD.gn @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//build_overrides/nlassert.gni") + config("nlfaultinjection_config") { include_dirs = [ "repo/include" ] } @@ -22,7 +24,7 @@ static_library("nlfaultinjection") { "repo/src/nlfaultinjection.cpp", ] - deps = [ "//third_party/nlassert" ] + deps = [ "${nlassert_root}:nlassert" ] public_configs = [ ":nlfaultinjection_config" ] } diff --git a/third_party/nrf5_sdk/BUILD.gn b/third_party/nrf5_sdk/BUILD.gn index 07aeefba4f1f12..96247fc8ffebe6 100644 --- a/third_party/nrf5_sdk/BUILD.gn +++ b/third_party/nrf5_sdk/BUILD.gn @@ -12,10 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//build/device.gni") -import("//third_party/nrf5_sdk/nrf5_sdk.gni") +import("//build_overrides/nrf5_sdk.gni") -assert(device_platform == "nrf5") +import("${nrf5_sdk_build_root}/nrf5_sdk.gni") declare_args() { # Build target to use for nRF5 SDK. Use this to set global SDK defines. diff --git a/third_party/nrf5_sdk/nrf5_sdk.gni b/third_party/nrf5_sdk/nrf5_sdk.gni index 232881e9d53dab..65d7b610a42926 100644 --- a/third_party/nrf5_sdk/nrf5_sdk.gni +++ b/third_party/nrf5_sdk/nrf5_sdk.gni @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//build_overrides/nrf5_sdk.gni") + declare_args() { # Location of the nRF5 SDK. nrf5_sdk_root = "" From 09ace680357cb9f41d64b773d8d5dd649455af0f Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Tue, 16 Jun 2020 15:18:50 -0400 Subject: [PATCH 35/59] Add nRF5 lock example superproject build --- examples/lock-app/nrf5/.gn | 23 ++++++++++++++++ examples/lock-app/nrf5/build | 1 + .../lock-app/nrf5/build_overrides/chip.gni | 27 +++++++++++++++++++ .../lock-app/nrf5/build_overrides/lwip.gni | 18 +++++++++++++ .../lock-app/nrf5/build_overrides/mbedtls.gni | 18 +++++++++++++ .../nrf5/build_overrides/nlassert.gni | 18 +++++++++++++ .../nrf5/build_overrides/nlfaultinjection.gni | 18 +++++++++++++ .../lock-app/nrf5/build_overrides/nlio.gni | 18 +++++++++++++ .../nrf5/build_overrides/nlunit_test.gni | 18 +++++++++++++ .../nrf5/build_overrides/nrf5_lock_app.gni | 18 +++++++++++++ .../nrf5/build_overrides/nrf5_sdk.gni | 18 +++++++++++++ .../lock-app/nrf5/build_overrides/pigweed.gni | 20 ++++++++++++++ 12 files changed, 215 insertions(+) create mode 100644 examples/lock-app/nrf5/.gn create mode 120000 examples/lock-app/nrf5/build create mode 100644 examples/lock-app/nrf5/build_overrides/chip.gni create mode 100644 examples/lock-app/nrf5/build_overrides/lwip.gni create mode 100644 examples/lock-app/nrf5/build_overrides/mbedtls.gni create mode 100644 examples/lock-app/nrf5/build_overrides/nlassert.gni create mode 100644 examples/lock-app/nrf5/build_overrides/nlfaultinjection.gni create mode 100644 examples/lock-app/nrf5/build_overrides/nlio.gni create mode 100644 examples/lock-app/nrf5/build_overrides/nlunit_test.gni create mode 100644 examples/lock-app/nrf5/build_overrides/nrf5_lock_app.gni create mode 100644 examples/lock-app/nrf5/build_overrides/nrf5_sdk.gni create mode 100644 examples/lock-app/nrf5/build_overrides/pigweed.gni diff --git a/examples/lock-app/nrf5/.gn b/examples/lock-app/nrf5/.gn new file mode 100644 index 00000000000000..c3cfa5fd40318d --- /dev/null +++ b/examples/lock-app/nrf5/.gn @@ -0,0 +1,23 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# The location of the build configuration file. +buildconfig = "//build/config/BUILDCONFIG.gn" + +# CHIP uses angle bracket includes. +check_system_includes = true + +default_args = { + import("//args.gni") +} diff --git a/examples/lock-app/nrf5/build b/examples/lock-app/nrf5/build new file mode 120000 index 00000000000000..44735d58664596 --- /dev/null +++ b/examples/lock-app/nrf5/build @@ -0,0 +1 @@ +../../../build \ No newline at end of file diff --git a/examples/lock-app/nrf5/build_overrides/chip.gni b/examples/lock-app/nrf5/build_overrides/chip.gni new file mode 100644 index 00000000000000..6c6723229cd9a1 --- /dev/null +++ b/examples/lock-app/nrf5/build_overrides/chip.gni @@ -0,0 +1,27 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +declare_args() { + # Root directory for CHIP. + chip_root = "//third_party/connectedhomeip" +} + +import("lwip.gni") +import("mbedtls.gni") +import("nlassert.gni") +import("nlfaultinjection.gni") +import("nlio.gni") +import("nlunit_test.gni") +import("pigweed.gni") +import("nrf5_lock_app.gni") diff --git a/examples/lock-app/nrf5/build_overrides/lwip.gni b/examples/lock-app/nrf5/build_overrides/lwip.gni new file mode 100644 index 00000000000000..9a50a46bae6a8b --- /dev/null +++ b/examples/lock-app/nrf5/build_overrides/lwip.gni @@ -0,0 +1,18 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +declare_args() { + # Root directory for lwIP. + lwip_root = "//third_party/connectedhomeip/third_party/lwip" +} diff --git a/examples/lock-app/nrf5/build_overrides/mbedtls.gni b/examples/lock-app/nrf5/build_overrides/mbedtls.gni new file mode 100644 index 00000000000000..fff24c4f29f01f --- /dev/null +++ b/examples/lock-app/nrf5/build_overrides/mbedtls.gni @@ -0,0 +1,18 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +declare_args() { + # Root directory for mbedTLS. + mbedtls_root = "//third_party/connectedhomeip/third_party/mbedtls" +} diff --git a/examples/lock-app/nrf5/build_overrides/nlassert.gni b/examples/lock-app/nrf5/build_overrides/nlassert.gni new file mode 100644 index 00000000000000..30e8c701634664 --- /dev/null +++ b/examples/lock-app/nrf5/build_overrides/nlassert.gni @@ -0,0 +1,18 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +declare_args() { + # Root directory for nlassert. + nlassert_root = "//third_party/connectedhomeip/third_party/nlassert" +} diff --git a/examples/lock-app/nrf5/build_overrides/nlfaultinjection.gni b/examples/lock-app/nrf5/build_overrides/nlfaultinjection.gni new file mode 100644 index 00000000000000..f100f00da348cc --- /dev/null +++ b/examples/lock-app/nrf5/build_overrides/nlfaultinjection.gni @@ -0,0 +1,18 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +declare_args() { + # Root directory for nlfaultinjection. + nlfaultinjection_root = "//third_party/connectedhomeip/third_party/nlfaultinjection" +} diff --git a/examples/lock-app/nrf5/build_overrides/nlio.gni b/examples/lock-app/nrf5/build_overrides/nlio.gni new file mode 100644 index 00000000000000..f7d5ee6117e826 --- /dev/null +++ b/examples/lock-app/nrf5/build_overrides/nlio.gni @@ -0,0 +1,18 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +declare_args() { + # Root directory for nlio. + nlio_root = "//third_party/connectedhomeip/third_party/nlio" +} diff --git a/examples/lock-app/nrf5/build_overrides/nlunit_test.gni b/examples/lock-app/nrf5/build_overrides/nlunit_test.gni new file mode 100644 index 00000000000000..ed017adc65f04a --- /dev/null +++ b/examples/lock-app/nrf5/build_overrides/nlunit_test.gni @@ -0,0 +1,18 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +declare_args() { + # Root directory for nlunit-test. + nlunit_test_root = "//third_party/connectedhomeip/third_party/nlunit-test" +} diff --git a/examples/lock-app/nrf5/build_overrides/nrf5_lock_app.gni b/examples/lock-app/nrf5/build_overrides/nrf5_lock_app.gni new file mode 100644 index 00000000000000..3f8857c41f9ba7 --- /dev/null +++ b/examples/lock-app/nrf5/build_overrides/nrf5_lock_app.gni @@ -0,0 +1,18 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +declare_args() { + # Root directory for nRF5 lock app example. + nrf5_lock_app_root = "//" +} diff --git a/examples/lock-app/nrf5/build_overrides/nrf5_sdk.gni b/examples/lock-app/nrf5/build_overrides/nrf5_sdk.gni new file mode 100644 index 00000000000000..6729e7f082cfb6 --- /dev/null +++ b/examples/lock-app/nrf5/build_overrides/nrf5_sdk.gni @@ -0,0 +1,18 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +declare_args() { + # Root directory for nRF5 SDK. + nrf5_sdk_build_root = "//third_party/connectedhomeip/third_party/nrf5_sdk" +} diff --git a/examples/lock-app/nrf5/build_overrides/pigweed.gni b/examples/lock-app/nrf5/build_overrides/pigweed.gni new file mode 100644 index 00000000000000..ff0fb6516d9604 --- /dev/null +++ b/examples/lock-app/nrf5/build_overrides/pigweed.gni @@ -0,0 +1,20 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +declare_args() { + # Location of the Pigweed repository. + dir_pigweed = "//third_party/connectedhomeip/third_party/pigweed" +} + +import("$dir_pigweed/modules.gni") From 3acbb8ffb5dc2296d63e3f98e9d4374d4acfe6e2 Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Wed, 17 Jun 2020 01:28:29 -0400 Subject: [PATCH 36/59] Add support for combined build via target_os="all" This configures host_clang, host_gcc, and nRF5 lock app. To run a maximal build: gn gen out/debug --args='target_os="all"' ninja -C out/debug check --- BUILD.gn | 122 ++++++++++++++++--------- build/{examples.gni => chip_build.gni} | 20 +++- build/config/BUILDCONFIG.gn | 2 + examples/lock-app/nrf5/common_args.gni | 2 - 4 files changed, 98 insertions(+), 48 deletions(-) rename build/{examples.gni => chip_build.gni} (62%) diff --git a/BUILD.gn b/BUILD.gn index e683f31a72e795..1627bb55cca96d 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -14,63 +14,99 @@ import("//build_overrides/chip.gni") -import("${chip_root}/build/examples.gni") +# This build file should not be used in superproject builds. +assert(chip_root == "//") + import("${chip_root}/build/tests.gni") import("${chip_root}/build/tools.gni") -group("default") { - deps = [ - "${chip_root}/src", - "${chip_root}/src/app", - "${chip_root}/src/ble", - "${chip_root}/src/controller", - "${chip_root}/src/crypto", - "${chip_root}/src/inet", - "${chip_root}/src/lib/core", - "${chip_root}/src/lib/support", - "${chip_root}/src/lwip:all", - "${chip_root}/src/system", - "${chip_root}/src/transport", - "${mbedtls_root}:mbedtls", - "${nlassert_root}:nlassert", - "${nlio_root}:nlio", - "${nlunit_test_root}:nlunit-test", - ] - - if (chip_build_tests) { - deps += [ ":tests" ] +if (current_toolchain != "${dir_pw_toolchain}/dummy:dummy") { + # This is a real toolchain. Build CHIP. + group("default") { + deps = [ ":all" ] } - if (chip_build_tools) { - deps += [ - "${chip_root}/src/qrcodetool", - "${chip_root}/src/setup_payload", + group("all") { + deps = [ + "${chip_root}/src", + "${chip_root}/src/app", + "${chip_root}/src/ble", + "${chip_root}/src/controller", + "${chip_root}/src/crypto", + "${chip_root}/src/inet", + "${chip_root}/src/lib/core", + "${chip_root}/src/lib/support", + "${chip_root}/src/lwip:all", + "${chip_root}/src/system", + "${chip_root}/src/transport", + "${mbedtls_root}:mbedtls", + "${nlassert_root}:nlassert", + "${nlio_root}:nlio", + "${nlunit_test_root}:nlunit-test", ] + + if (chip_build_tests) { + deps += [ ":tests" ] + } + + if (chip_build_tools) { + deps += [ + "${chip_root}/src/qrcodetool", + "${chip_root}/src/setup_payload", + ] + } + } + + if (chip_build_tests) { + import("${chip_root}/build/chip_test_group.gni") + + chip_test_group("tests") { + deps = [ + "${chip_root}/src/app/plugin/tests", + "${chip_root}/src/ble/tests", + "${chip_root}/src/crypto/tests", + "${chip_root}/src/inet/tests", + "${chip_root}/src/lib/core/tests", + "${chip_root}/src/lib/support/tests", + "${chip_root}/src/lwip/tests", + "${chip_root}/src/setup_payload/tests", + "${chip_root}/src/system/tests", + ] + } + + group("check") { + deps = [ ":tests_run" ] + } } +} else { + # This is the dummy toolchain. Configure various real toolchains. + import("//build/chip_build.gni") - if (build_nrf5_lock_app) { - deps += [ "${nrf5_lock_app_root}:nrf5(${nrf5_lock_app_root}/toolchain:nrf5_lock_app)" ] + import("//build/toolchain/host_clang/toolchains.gni") + import("//build/toolchain/host_gcc/toolchains.gni") + chip_build("host_clang") { + toolchain = "//build/toolchain/host_clang:${host_os}_${host_cpu}_clang" } -} -if (chip_build_tests) { - import("${chip_root}/build/chip_test_group.gni") + chip_build("host_gcc") { + toolchain = "//build/toolchain/host_gcc:${host_os}_${host_cpu}_gcc" + } - chip_test_group("tests") { + group("default") { deps = [ - "${chip_root}/src/app/plugin/tests", - "${chip_root}/src/ble/tests", - "${chip_root}/src/crypto/tests", - "${chip_root}/src/inet/tests", - "${chip_root}/src/lib/core/tests", - "${chip_root}/src/lib/support/tests", - "${chip_root}/src/lwip/tests", - "${chip_root}/src/setup_payload/tests", - "${chip_root}/src/system/tests", + ":all_host_clang", + ":all_host_gcc", + "${nrf5_lock_app_root}:nrf5(${nrf5_lock_app_root}/toolchain:nrf5_lock_app)", ] } - group("check") { - deps = [ ":tests_run" ] + if (chip_build_tests) { + group("check") { + deps = [ + ":check_host_clang", + ":check_host_gcc", + ":default", + ] + } } } diff --git a/build/examples.gni b/build/chip_build.gni similarity index 62% rename from build/examples.gni rename to build/chip_build.gni index 115db6bf82e5a7..9a0fb57cfadb85 100644 --- a/build/examples.gni +++ b/build/chip_build.gni @@ -12,7 +12,21 @@ # See the License for the specific language governing permissions and # limitations under the License. -declare_args() { - # Enable nRF5 lock app example. - build_nrf5_lock_app = false +import("//build_overrides/chip.gni") + +import("${chip_root}/build/tests.gni") + +template("chip_build") { + _build_name = target_name + _toolchain = invoker.toolchain + + group("all_${_build_name}") { + deps = [ ":all(${_toolchain})" ] + } + + if (chip_build_tests) { + group("check_${_build_name}") { + deps = [ ":check(${_toolchain})" ] + } + } } diff --git a/build/config/BUILDCONFIG.gn b/build/config/BUILDCONFIG.gn index 72e57f9f11c29c..d5f85a6d9fc9a6 100644 --- a/build/config/BUILDCONFIG.gn +++ b/build/config/BUILDCONFIG.gn @@ -57,6 +57,8 @@ if (_chip_defaults.custom_toolchain != "") { _default_toolchain = _chip_defaults.custom_toolchain } else if (target_os == host_os) { _default_toolchain = host_toolchain +} else if (target_os == "all") { + _default_toolchain = "${_chip_directory.dir_pw_toolchain}/dummy" } else if (target_os == "freertos") { if (target_cpu == "arm") { _default_toolchain = "//build/toolchain/arm_gcc" diff --git a/examples/lock-app/nrf5/common_args.gni b/examples/lock-app/nrf5/common_args.gni index c90f5c70d7a35b..36d2a7e6bf68b3 100644 --- a/examples/lock-app/nrf5/common_args.gni +++ b/examples/lock-app/nrf5/common_args.gni @@ -14,8 +14,6 @@ import("//build_overrides/chip.gni") -build_nrf5_lock_app = true - device_platform = "nrf5" arm_arch = "armv7e-m" From a27c7c9b40687c87fd5a5970679cbddaca9eaad4 Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Fri, 19 Jun 2020 16:16:16 -0400 Subject: [PATCH 37/59] Remove shared imports Importing everything from chip.gni will require some dependencies to be present even if they are not used. Import overrides separately. Also add args to disable various builds at the top level. --- BUILD.gn | 54 +++++++++++++++---- build/chip_test.gni | 1 + build/config/BUILDCONFIG.gn | 12 +++-- build_overrides/chip.gni | 10 +--- build_overrides/lwip.gni | 1 + build_overrides/mbedtls.gni | 1 + build_overrides/nlassert.gni | 1 + build_overrides/nlfaultinjection.gni | 1 + build_overrides/nlio.gni | 1 + build_overrides/nlunit_test.gni | 1 + build_overrides/nrf5_lock_app.gni | 18 +++++++ examples/lock-app/nrf5/args.gni | 2 +- .../lock-app/nrf5/build_overrides/chip.gni | 9 ---- examples/lock-app/nrf5/common_args.gni | 2 +- examples/lock-app/nrf5/toolchain/BUILD.gn | 2 +- src/app/plugin/tests/BUILD.gn | 1 + src/ble/tests/BUILD.gn | 1 + src/crypto/BUILD.gn | 3 ++ src/crypto/tests/BUILD.gn | 1 + src/inet/BUILD.gn | 3 ++ src/inet/tests/BUILD.gn | 1 + src/lib/core/BUILD.gn | 1 + src/lib/core/tests/BUILD.gn | 1 + src/lib/support/BUILD.gn | 3 ++ src/lib/support/tests/BUILD.gn | 1 + src/lwip/BUILD.gn | 6 ++- src/platform/BUILD.gn | 1 + src/setup_payload/tests/BUILD.gn | 1 + src/system/BUILD.gn | 2 + src/system/tests/BUILD.gn | 1 + 30 files changed, 107 insertions(+), 36 deletions(-) create mode 100644 build_overrides/nrf5_lock_app.gni diff --git a/BUILD.gn b/BUILD.gn index 1627bb55cca96d..81891572cd0f9d 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -13,6 +13,11 @@ # limitations under the License. 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") # This build file should not be used in superproject builds. assert(chip_root == "//") @@ -81,6 +86,25 @@ if (current_toolchain != "${dir_pw_toolchain}/dummy:dummy") { } else { # This is the dummy toolchain. Configure various real toolchains. import("//build/chip_build.gni") + declare_args() { + # Set this to false to disable all builds by default. + enable_default_builds = true + } + + declare_args() { + # Enable building chip with clang. + enable_host_clang_build = enable_default_builds + + # Enable building chip with gcc. + enable_host_gcc_build = enable_default_builds + + # Build the nRF5 lock app example. + enable_nrf5_lock_app_build = false + } + + if (enable_nrf5_lock_app_build) { + import("//build_overrides/nrf5_lock_app.gni") + } import("//build/toolchain/host_clang/toolchains.gni") import("//build/toolchain/host_gcc/toolchains.gni") @@ -93,20 +117,30 @@ if (current_toolchain != "${dir_pw_toolchain}/dummy:dummy") { } group("default") { - deps = [ - ":all_host_clang", - ":all_host_gcc", - "${nrf5_lock_app_root}:nrf5(${nrf5_lock_app_root}/toolchain:nrf5_lock_app)", - ] + deps = [] + if (enable_host_clang_build) { + deps += [ ":all_host_clang" ] + } + if (enable_host_gcc_build) { + deps += [ ":all_host_gcc" ] + } + if (enable_nrf5_lock_app_build) { + deps += [ "${nrf5_lock_app_root}:nrf5(${nrf5_lock_app_root}/toolchain:nrf5_lock_app)" ] + } } if (chip_build_tests) { group("check") { - deps = [ - ":check_host_clang", - ":check_host_gcc", - ":default", - ] + deps = [] + if (enable_host_clang_build) { + deps += [ ":check_host_clang" ] + } + if (enable_host_gcc_build) { + deps += [ ":check_host_gcc" ] + } + if (enable_nrf5_lock_app_build) { + deps += [ ":default" ] + } } } } diff --git a/build/chip_test.gni b/build/chip_test.gni index 2c147df16e89dd..fbf1cc864c98b7 100644 --- a/build/chip_test.gni +++ b/build/chip_test.gni @@ -13,6 +13,7 @@ # limitations under the License. import("//build_overrides/chip.gni") +import("//build_overrides/pigweed.gni") import("${chip_root}/build/tests.gni") import("${dir_pw_unit_test}/test.gni") diff --git a/build/config/BUILDCONFIG.gn b/build/config/BUILDCONFIG.gn index d5f85a6d9fc9a6..ac573c4353e3e5 100644 --- a/build/config/BUILDCONFIG.gn +++ b/build/config/BUILDCONFIG.gn @@ -32,10 +32,14 @@ if (current_os == "") { current_os = target_os } -_chip_directory = { +_chip_overrides = { import("//build_overrides/chip.gni") } +_pigweed_overrides = { + import("//build_overrides/pigweed.gni") +} + _chip_defaults = { import("//build/config/defaults.gni") } @@ -47,9 +51,9 @@ declare_args() { if (host_toolchain == "") { if (_chip_defaults.is_clang) { - host_toolchain = "${_chip_directory.chip_root}/build/toolchain/host_clang:${host_os}_${host_cpu}_clang" + host_toolchain = "${_chip_overrides.chip_root}/build/toolchain/host_clang:${host_os}_${host_cpu}_clang" } else { - host_toolchain = "${_chip_directory.chip_root}/build/toolchain/host_gcc:${host_os}_${host_cpu}_gcc" + host_toolchain = "${_chip_overrides.chip_root}/build/toolchain/host_gcc:${host_os}_${host_cpu}_gcc" } } @@ -58,7 +62,7 @@ if (_chip_defaults.custom_toolchain != "") { } else if (target_os == host_os) { _default_toolchain = host_toolchain } else if (target_os == "all") { - _default_toolchain = "${_chip_directory.dir_pw_toolchain}/dummy" + _default_toolchain = "${_pigweed_overrides.dir_pw_toolchain}/dummy" } else if (target_os == "freertos") { if (target_cpu == "arm") { _default_toolchain = "//build/toolchain/arm_gcc" diff --git a/build_overrides/chip.gni b/build_overrides/chip.gni index f00dd7d13d14e4..26ac4812c0f797 100644 --- a/build_overrides/chip.gni +++ b/build_overrides/chip.gni @@ -13,14 +13,6 @@ # limitations under the License. declare_args() { + # Root directory for CHIP. chip_root = "//" - nrf5_lock_app_root = "//examples/lock-app/nrf5" } - -import("lwip.gni") -import("mbedtls.gni") -import("nlassert.gni") -import("nlfaultinjection.gni") -import("nlio.gni") -import("nlunit_test.gni") -import("pigweed.gni") diff --git a/build_overrides/lwip.gni b/build_overrides/lwip.gni index a61e407eb47073..a0a68d95a11dee 100644 --- a/build_overrides/lwip.gni +++ b/build_overrides/lwip.gni @@ -13,5 +13,6 @@ # limitations under the License. declare_args() { + # Root directory for lwIP. lwip_root = "//third_party/lwip" } diff --git a/build_overrides/mbedtls.gni b/build_overrides/mbedtls.gni index 4149ec197410a4..04f377ed99eabc 100644 --- a/build_overrides/mbedtls.gni +++ b/build_overrides/mbedtls.gni @@ -13,5 +13,6 @@ # limitations under the License. declare_args() { + # Root directory for mbedTLS. mbedtls_root = "//third_party/mbedtls" } diff --git a/build_overrides/nlassert.gni b/build_overrides/nlassert.gni index edddf80e35658d..e54060eb3aba06 100644 --- a/build_overrides/nlassert.gni +++ b/build_overrides/nlassert.gni @@ -13,5 +13,6 @@ # limitations under the License. declare_args() { + # Root directory for nlassert. nlassert_root = "//third_party/nlassert" } diff --git a/build_overrides/nlfaultinjection.gni b/build_overrides/nlfaultinjection.gni index 3071268214eaa4..581ba58ee5851e 100644 --- a/build_overrides/nlfaultinjection.gni +++ b/build_overrides/nlfaultinjection.gni @@ -13,5 +13,6 @@ # limitations under the License. declare_args() { + # Root directory for nlfaultinjection. nlfaultinjection_root = "//third_party/nlfaultinjection" } diff --git a/build_overrides/nlio.gni b/build_overrides/nlio.gni index 46d854e7e91fbe..c7f7ce61eb28f2 100644 --- a/build_overrides/nlio.gni +++ b/build_overrides/nlio.gni @@ -13,5 +13,6 @@ # limitations under the License. declare_args() { + # Root directory for nlio. nlio_root = "//third_party/nlio" } diff --git a/build_overrides/nlunit_test.gni b/build_overrides/nlunit_test.gni index d49ca9e0deea94..b3b729504b1be1 100644 --- a/build_overrides/nlunit_test.gni +++ b/build_overrides/nlunit_test.gni @@ -13,5 +13,6 @@ # limitations under the License. declare_args() { + # Root directory for nlunit-test. nlunit_test_root = "//third_party/nlunit-test" } diff --git a/build_overrides/nrf5_lock_app.gni b/build_overrides/nrf5_lock_app.gni new file mode 100644 index 00000000000000..ecb6a4c5f45c74 --- /dev/null +++ b/build_overrides/nrf5_lock_app.gni @@ -0,0 +1,18 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +declare_args() { + # Root directory for nRF5 lock app example. + nrf5_lock_app_root = "//examples/lock-app/nrf5" +} diff --git a/examples/lock-app/nrf5/args.gni b/examples/lock-app/nrf5/args.gni index 82c43f1aa82775..a8291bec008034 100644 --- a/examples/lock-app/nrf5/args.gni +++ b/examples/lock-app/nrf5/args.gni @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//build_overrides/chip.gni") +import("//build_overrides/nrf5_lock_app.gni") import("${nrf5_lock_app_root}/common_args.gni") # These values help set up the default toolchain in standalone sample app diff --git a/examples/lock-app/nrf5/build_overrides/chip.gni b/examples/lock-app/nrf5/build_overrides/chip.gni index 6c6723229cd9a1..23aafc1df7b3cd 100644 --- a/examples/lock-app/nrf5/build_overrides/chip.gni +++ b/examples/lock-app/nrf5/build_overrides/chip.gni @@ -16,12 +16,3 @@ declare_args() { # Root directory for CHIP. chip_root = "//third_party/connectedhomeip" } - -import("lwip.gni") -import("mbedtls.gni") -import("nlassert.gni") -import("nlfaultinjection.gni") -import("nlio.gni") -import("nlunit_test.gni") -import("pigweed.gni") -import("nrf5_lock_app.gni") diff --git a/examples/lock-app/nrf5/common_args.gni b/examples/lock-app/nrf5/common_args.gni index 36d2a7e6bf68b3..b3426f5cba12e8 100644 --- a/examples/lock-app/nrf5/common_args.gni +++ b/examples/lock-app/nrf5/common_args.gni @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//build_overrides/chip.gni") +import("//build_overrides/nrf5_lock_app.gni") device_platform = "nrf5" diff --git a/examples/lock-app/nrf5/toolchain/BUILD.gn b/examples/lock-app/nrf5/toolchain/BUILD.gn index dceae1f9ff5aca..b311daa63968ab 100644 --- a/examples/lock-app/nrf5/toolchain/BUILD.gn +++ b/examples/lock-app/nrf5/toolchain/BUILD.gn @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//build_overrides/chip.gni") +import("//build_overrides/nrf5_lock_app.gni") import("//build/toolchain/arm_gcc/arm_toolchain.gni") diff --git a/src/app/plugin/tests/BUILD.gn b/src/app/plugin/tests/BUILD.gn index 02a44e7a9aa9fd..3772b3a97a64da 100644 --- a/src/app/plugin/tests/BUILD.gn +++ b/src/app/plugin/tests/BUILD.gn @@ -13,6 +13,7 @@ # limitations under the License. import("//build_overrides/chip.gni") +import("//build_overrides/nlunit_test.gni") import("${chip_root}/build/chip_test_suite.gni") diff --git a/src/ble/tests/BUILD.gn b/src/ble/tests/BUILD.gn index ecf399b4e8b3c8..1a9d78a644703e 100644 --- a/src/ble/tests/BUILD.gn +++ b/src/ble/tests/BUILD.gn @@ -13,6 +13,7 @@ # limitations under the License. import("//build_overrides/chip.gni") +import("//build_overrides/nlunit_test.gni") import("${chip_root}/build/chip_test_suite.gni") diff --git a/src/crypto/BUILD.gn b/src/crypto/BUILD.gn index feee19b0c7d467..0dedc9f2e866f2 100644 --- a/src/crypto/BUILD.gn +++ b/src/crypto/BUILD.gn @@ -13,6 +13,7 @@ # limitations under the License. import("//build_overrides/chip.gni") +import("//build_overrides/nlassert.gni") import("crypto.gni") @@ -37,6 +38,8 @@ if (chip_crypto == "openssl") { "crypto", ] } +} else { + import("//build_overrides/mbedtls.gni") } source_set("crypto") { diff --git a/src/crypto/tests/BUILD.gn b/src/crypto/tests/BUILD.gn index d195709de0a33e..0bc4c69c48c40e 100644 --- a/src/crypto/tests/BUILD.gn +++ b/src/crypto/tests/BUILD.gn @@ -13,6 +13,7 @@ # limitations under the License. import("//build_overrides/chip.gni") +import("//build_overrides/nlunit_test.gni") import("${chip_root}/build/chip_test_suite.gni") diff --git a/src/inet/BUILD.gn b/src/inet/BUILD.gn index dfe29fb99ee922..b2bd419de8e083 100644 --- a/src/inet/BUILD.gn +++ b/src/inet/BUILD.gn @@ -13,6 +13,9 @@ # limitations under the License. import("//build_overrides/chip.gni") +import("//build_overrides/nlassert.gni") +import("//build_overrides/nlfaultinjection.gni") +import("//build_overrides/nlio.gni") import("${chip_root}/build/tests.gni") import("inet.gni") diff --git a/src/inet/tests/BUILD.gn b/src/inet/tests/BUILD.gn index 7f9c0922118b1e..49b1a12383e282 100644 --- a/src/inet/tests/BUILD.gn +++ b/src/inet/tests/BUILD.gn @@ -13,6 +13,7 @@ # limitations under the License. import("//build_overrides/chip.gni") +import("//build_overrides/nlunit_test.gni") import("${chip_root}/build/chip_test_suite.gni") diff --git a/src/lib/core/BUILD.gn b/src/lib/core/BUILD.gn index e4695d9d404a54..eeae7c5ac7c7fa 100644 --- a/src/lib/core/BUILD.gn +++ b/src/lib/core/BUILD.gn @@ -13,6 +13,7 @@ # limitations under the License. import("//build_overrides/chip.gni") +import("//build_overrides/nlio.gni") import("${chip_root}/build/tests.gni") import("${chip_root}/src/inet/inet.gni") diff --git a/src/lib/core/tests/BUILD.gn b/src/lib/core/tests/BUILD.gn index 09e8ea552e2537..323c39239d3dfd 100644 --- a/src/lib/core/tests/BUILD.gn +++ b/src/lib/core/tests/BUILD.gn @@ -13,6 +13,7 @@ # limitations under the License. import("//build_overrides/chip.gni") +import("//build_overrides/nlunit_test.gni") import("${chip_root}/build/chip_test_suite.gni") diff --git a/src/lib/support/BUILD.gn b/src/lib/support/BUILD.gn index 072aa4f208d249..429ef07a4d5f96 100644 --- a/src/lib/support/BUILD.gn +++ b/src/lib/support/BUILD.gn @@ -13,6 +13,9 @@ # limitations under the License. import("//build_overrides/chip.gni") +import("//build_overrides/nlassert.gni") +import("//build_overrides/nlfaultinjection.gni") +import("//build_overrides/nlio.gni") import("${chip_root}/build/chip_version.gni") import("${chip_root}/build/tests.gni") diff --git a/src/lib/support/tests/BUILD.gn b/src/lib/support/tests/BUILD.gn index ff8997dc688eb8..70e5a044967d62 100644 --- a/src/lib/support/tests/BUILD.gn +++ b/src/lib/support/tests/BUILD.gn @@ -13,6 +13,7 @@ # limitations under the License. import("//build_overrides/chip.gni") +import("//build_overrides/nlunit_test.gni") import("${chip_root}/build/chip_test_suite.gni") diff --git a/src/lwip/BUILD.gn b/src/lwip/BUILD.gn index 416094f25252b3..6eb7267b773f99 100644 --- a/src/lwip/BUILD.gn +++ b/src/lwip/BUILD.gn @@ -13,7 +13,7 @@ # limitations under the License. import("//build_overrides/chip.gni") -import("//build_overrides/nrf5_sdk.gni") +import("//build_overrides/lwip.gni") import("${lwip_root}/lwip.gni") @@ -35,6 +35,10 @@ assert(lwip_platform == "standalone" || lwip_platform == "nrf5" || lwip_platform == "efr32", "Unsupported lwIP platform: ${lwip_platform}") +if (lwip_platform == "nrf5") { + import("//build_overrides/nrf5_sdk.gni") +} + config("lwip_config") { # Automatically enable LWIP_DEBUG for internal is_debug builds. if (lwip_debug) { diff --git a/src/platform/BUILD.gn b/src/platform/BUILD.gn index b91283fa42f277..72201d4f951fa2 100644 --- a/src/platform/BUILD.gn +++ b/src/platform/BUILD.gn @@ -13,6 +13,7 @@ # limitations under the License. import("//build_overrides/chip.gni") +import("//build_overrides/nlio.gni") import("${chip_root}/build/device.gni") diff --git a/src/setup_payload/tests/BUILD.gn b/src/setup_payload/tests/BUILD.gn index 1ee0de764e6653..f66d10e0d1a300 100644 --- a/src/setup_payload/tests/BUILD.gn +++ b/src/setup_payload/tests/BUILD.gn @@ -13,6 +13,7 @@ # limitations under the License. import("//build_overrides/chip.gni") +import("//build_overrides/nlunit_test.gni") import("${chip_root}/build/chip_test_suite.gni") diff --git a/src/system/BUILD.gn b/src/system/BUILD.gn index 35e525ce0f9ffe..06ea4d188fa62c 100644 --- a/src/system/BUILD.gn +++ b/src/system/BUILD.gn @@ -13,6 +13,8 @@ # limitations under the License. import("//build_overrides/chip.gni") +import("//build_overrides/nlassert.gni") +import("//build_overrides/nlfaultinjection.gni") import("${chip_root}/build/tests.gni") import("system.gni") diff --git a/src/system/tests/BUILD.gn b/src/system/tests/BUILD.gn index 62ba300b9a1cb0..116bda12638d6e 100644 --- a/src/system/tests/BUILD.gn +++ b/src/system/tests/BUILD.gn @@ -13,6 +13,7 @@ # limitations under the License. import("//build_overrides/chip.gni") +import("//build_overrides/nlunit_test.gni") import("${chip_root}/build/chip_test_suite.gni") From 8c8ec10a2f8886dc92ae78dd1682609f68b637ac Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Mon, 29 Jun 2020 13:49:13 -0400 Subject: [PATCH 38/59] Add transport tests to GN build --- BUILD.gn | 1 + build/chip_test_suite.gni | 1 + src/inet/tests/BUILD.gn | 6 +++++ src/transport/tests/BUILD.gn | 49 ++++++++++++++++++++++++++++++++++++ 4 files changed, 57 insertions(+) create mode 100644 src/transport/tests/BUILD.gn diff --git a/BUILD.gn b/BUILD.gn index 81891572cd0f9d..5cc11f19c8bcfe 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -76,6 +76,7 @@ if (current_toolchain != "${dir_pw_toolchain}/dummy:dummy") { "${chip_root}/src/lwip/tests", "${chip_root}/src/setup_payload/tests", "${chip_root}/src/system/tests", + "${chip_root}/src/transport/tests", ] } diff --git a/build/chip_test_suite.gni b/build/chip_test_suite.gni index 3529416c40930d..728e3c342fd94f 100644 --- a/build/chip_test_suite.gni +++ b/build/chip_test_suite.gni @@ -28,6 +28,7 @@ template("chip_test_suite") { [ "deps", "public_deps", + "public_configs", ]) if (defined(invoker.common_sources)) { sources = invoker.common_sources diff --git a/src/inet/tests/BUILD.gn b/src/inet/tests/BUILD.gn index 49b1a12383e282..ae205fe7bdbdfa 100644 --- a/src/inet/tests/BUILD.gn +++ b/src/inet/tests/BUILD.gn @@ -17,6 +17,10 @@ import("//build_overrides/nlunit_test.gni") import("${chip_root}/build/chip_test_suite.gni") +config("tests_config") { + include_dirs = [ "." ] +} + chip_test_suite("tests") { common_sources = [ "TapAddrAutoconf.cpp", @@ -36,6 +40,8 @@ chip_test_suite("tests") { "TestLwIPDNS.cpp", ] + public_configs = [ ":tests_config" ] + public_deps = [ "${chip_root}/src/inet", "${chip_root}/src/lib/core", diff --git a/src/transport/tests/BUILD.gn b/src/transport/tests/BUILD.gn new file mode 100644 index 00000000000000..3759f0542a7188 --- /dev/null +++ b/src/transport/tests/BUILD.gn @@ -0,0 +1,49 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build_overrides/chip.gni") +import("//build_overrides/nlio.gni") +import("//build_overrides/nlunit_test.gni") + +import("${chip_root}/build/chip_test_suite.gni") + +chip_test_suite("tests") { + common_sources = [ + "NetworkTestHelpers.cpp", + "NetworkTestHelpers.h", + "TestMessageHeader.cpp", + "TestPeerConnections.cpp", + "TestSecureSession.cpp", + "TestSecureSessionMgr.cpp", + "TestTransportLayer.h", + "TestUDP.cpp", + "TestUDPDriver.cpp", + ] + + public_deps = [ + "${chip_root}/src/inet/tests:tests_common", + "${chip_root}/src/lib/core", + "${chip_root}/src/lib/support", + "${chip_root}/src/transport", + "${nlio_root}:nlio", + "${nlunit_test_root}:nlunit-test", + ] + + tests = [ + "TestMessageHeader", + "TestPeerConnections", + "TestSecureSession", + "TestSecureSessionMgr", + ] +} From 42e7b79893fc5c54b2b65136d07e6a6db2e8ca11 Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Wed, 17 Jun 2020 17:31:31 -0400 Subject: [PATCH 39/59] Add examples/chip-tool to GN build --- BUILD.gn | 1 + examples/chip-tool/BUILD.gn | 31 +++++++++++++++++++++++++ src/lib/support/BUILD.gn | 46 ++++++++++++++++++++++--------------- 3 files changed, 60 insertions(+), 18 deletions(-) create mode 100644 examples/chip-tool/BUILD.gn diff --git a/BUILD.gn b/BUILD.gn index 5cc11f19c8bcfe..fbc201e45744c2 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -56,6 +56,7 @@ if (current_toolchain != "${dir_pw_toolchain}/dummy:dummy") { if (chip_build_tools) { deps += [ + "${chip_root}/examples/chip-tool", "${chip_root}/src/qrcodetool", "${chip_root}/src/setup_payload", ] diff --git a/examples/chip-tool/BUILD.gn b/examples/chip-tool/BUILD.gn new file mode 100644 index 00000000000000..1c9318f111ebfe --- /dev/null +++ b/examples/chip-tool/BUILD.gn @@ -0,0 +1,31 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build_overrides/chip.gni") + +import("${chip_root}/build/tools.gni") + +assert(chip_build_tools) + +executable("chip-standalone-demo") { + sources = [ "main.cpp" ] + + public_deps = [ "${chip_root}/src:chip" ] + + output_dir = "${root_out_dir}/bin" +} + +group("chip-tool") { + deps = [ ":chip-standalone-demo" ] +} diff --git a/src/lib/support/BUILD.gn b/src/lib/support/BUILD.gn index 429ef07a4d5f96..ddbb8cd656b896 100644 --- a/src/lib/support/BUILD.gn +++ b/src/lib/support/BUILD.gn @@ -23,7 +23,7 @@ import("${chip_root}/build/tests.gni") action("gen_chip_version") { script = "${chip_root}/scripts/gen_chip_version.py" - version_file = "${target_gen_dir}/CHIPVersion.h" + version_file = "${target_gen_dir}/include/CHIPVersion.h" outputs = [ version_file ] args = [ "--output_file=" + rebase_path(version_file, root_build_dir), @@ -47,43 +47,49 @@ config("support_config") { "${chip_root}/src/system:system_config", ] - include_dirs = [ target_gen_dir ] + include_dirs = [ "${target_gen_dir}/include" ] } +support_headers = [ + "Base64.h", + "CHIPCounter.h", + "CodeUtils.h", + "DLLUtil.h", + "ErrorStr.h", + "FibonacciUtils.h", + "PersistedCounter.h", + "RandUtils.h", + "TestUtils.h", + "TimeUtils.h", + "logging/CHIPLogging.h", + "verhoeff/Verhoeff.h", +] + static_library("support") { sources = [ "Base64.cpp", - "Base64.h", "CHIPArgParser.cpp", "CHIPCounter.cpp", - "CHIPCounter.h", - "CodeUtils.h", - "DLLUtil.h", "ErrorStr.cpp", - "ErrorStr.h", "FibonacciUtils.cpp", - "FibonacciUtils.h", "PersistedCounter.cpp", - "PersistedCounter.h", "RandUtils.cpp", - "RandUtils.h", "TestUtils.cpp", - "TestUtils.h", "TimeUtils.cpp", - "TimeUtils.h", "logging/CHIPLogging.cpp", - "logging/CHIPLogging.h", "logging/CHIPLoggingLogV.cpp", "verhoeff/Verhoeff.cpp", - "verhoeff/Verhoeff.h", "verhoeff/Verhoeff10.cpp", "verhoeff/Verhoeff16.cpp", "verhoeff/Verhoeff32.cpp", "verhoeff/Verhoeff36.cpp", ] + public = support_headers + public_deps = [ ":chip_version_header", + ":support_headers", "${chip_root}/src/lib/core:chip_config_header", "${nlassert_root}:nlassert", ] @@ -91,10 +97,14 @@ static_library("support") { public_configs = [ ":support_config" ] if (chip_with_nlfaultinjection) { - sources += [ - "CHIPFaultInjection.cpp", - "CHIPFaultInjection.h", - ] + sources += [ "CHIPFaultInjection.cpp" ] + public += [ "CHIPFaultInjection.h" ] public_deps += [ "${nlfaultinjection_root}:nlfaultinjection" ] } } + +copy("support_headers") { + sources = support_headers + + outputs = [ "${target_gen_dir}/include/support/{{source_file_part}}" ] +} From 1f9fff833e513c94cb266f2bb885a29575d297c7 Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Mon, 29 Jun 2020 14:18:35 -0400 Subject: [PATCH 40/59] Add examples/shell to GN build --- BUILD.gn | 2 ++ examples/shell/BUILD.gn | 35 +++++++++++++++++++++++++++++++++++ src/lib/shell/BUILD.gn | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 examples/shell/BUILD.gn create mode 100644 src/lib/shell/BUILD.gn diff --git a/BUILD.gn b/BUILD.gn index fbc201e45744c2..98d658eca105c4 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -57,6 +57,8 @@ if (current_toolchain != "${dir_pw_toolchain}/dummy:dummy") { if (chip_build_tools) { deps += [ "${chip_root}/examples/chip-tool", + "${chip_root}/examples/shell", + "${chip_root}/src/lib/shell", "${chip_root}/src/qrcodetool", "${chip_root}/src/setup_payload", ] diff --git a/examples/shell/BUILD.gn b/examples/shell/BUILD.gn new file mode 100644 index 00000000000000..ee196f601729d7 --- /dev/null +++ b/examples/shell/BUILD.gn @@ -0,0 +1,35 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build_overrides/chip.gni") + +import("${chip_root}/build/tools.gni") + +assert(chip_build_tools) + +executable("chip-shell") { + sources = [ + "cmd_base64.cpp", + "cmd_misc.cpp", + "main.cpp", + ] + + public_deps = [ "${chip_root}/src/lib/shell" ] + + output_dir = "${root_out_dir}/bin" +} + +group("shell") { + deps = [ ":chip-shell" ] +} diff --git a/src/lib/shell/BUILD.gn b/src/lib/shell/BUILD.gn new file mode 100644 index 00000000000000..c2fb5ec4bb4be0 --- /dev/null +++ b/src/lib/shell/BUILD.gn @@ -0,0 +1,32 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build_overrides/chip.gni") + +source_set("shell") { + sources = [ + "commands.cpp", + "commands.h", + "shell.cpp", + "shell.h", + "streamer.cpp", + "streamer.h", + "streamer_stdio.cpp", + ] + + public_deps = [ + "${chip_root}/src/lib/core", + "${chip_root}/src/lib/support", + ] +} From f5a65bd8ff516e3b655f39a187155d0754399e00 Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Wed, 17 Jun 2020 16:44:54 -0400 Subject: [PATCH 41/59] Add GN build wrapper script This script does an end to end bootstrap & build with GN from a fresh clone. Usage: ./gn_build.sh --- gn_build.sh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 gn_build.sh diff --git a/gn_build.sh b/gn_build.sh new file mode 100755 index 00000000000000..75a6e36d9c5d17 --- /dev/null +++ b/gn_build.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +CHIP_ROOT="$(dirname "$0")" + +git -C "${CHIP_ROOT}" submodule update --init + +source "${CHIP_ROOT}/activate.sh" + +gn --root="${CHIP_ROOT}" gen --check "${CHIP_ROOT}/out/debug" +gn --root="${CHIP_ROOT}" gen --check "${CHIP_ROOT}/out/release" --args='is_debug=false' + +time ninja -C "${CHIP_ROOT}/out/debug" check + +# Release build. +# time ninja -C "${CHIP_ROOT}/out/release" check + +# Standalone example app. +# gn --root="${CHIP_ROOT}/examples/lock-app/nrf5" gen --check "${CHIP_ROOT}/out/nrf5_lock_app" --args='' +# time ninja -C "${CHIP_ROOT}/out/nrf5_lock_app" From 195e65edbf1786bf5527c6b67d8ff551c9dc6dce Mon Sep 17 00:00:00 2001 From: Keir Mierle Date: Wed, 17 Jun 2020 11:57:12 -0700 Subject: [PATCH 42/59] Make bootstrap display cleaner --- gn_build.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/gn_build.sh b/gn_build.sh index 75a6e36d9c5d17..fe55fc13b2e0eb 100755 --- a/gn_build.sh +++ b/gn_build.sh @@ -17,13 +17,33 @@ CHIP_ROOT="$(dirname "$0")" +_chip_red() { + echo -e "\033[0;31m$*\033[0m" +} + +_chip_yellow() { + echo -e "\033[0;33m$*\033[0m" +} + +_chip_banner() { + _chip_yellow '.--------------------------------' + _chip_yellow "-- $1" + _chip_yellow "'--------------------------------" +} + +_chip_banner "Environment bringup" + git -C "${CHIP_ROOT}" submodule update --init source "${CHIP_ROOT}/activate.sh" +_chip_banner "Build: GN configure" + gn --root="${CHIP_ROOT}" gen --check "${CHIP_ROOT}/out/debug" gn --root="${CHIP_ROOT}" gen --check "${CHIP_ROOT}/out/release" --args='is_debug=false' +_chip_banner "Build: Ninja build" + time ninja -C "${CHIP_ROOT}/out/debug" check # Release build. From 428cc48dc77003943f001e6776931b9a2d7a6867 Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Tue, 23 Jun 2020 00:00:40 -0400 Subject: [PATCH 43/59] Enable building with homebrew openssl on Mac via pkg-config --- build/config/linux/pkg-config.py | 266 ++++++++++++++++++++++++++++++ build/config/linux/pkg_config.gni | 115 +++++++++++++ src/crypto/BUILD.gn | 9 +- src/crypto/crypto.gni | 2 +- 4 files changed, 386 insertions(+), 6 deletions(-) create mode 100755 build/config/linux/pkg-config.py create mode 100644 build/config/linux/pkg_config.gni diff --git a/build/config/linux/pkg-config.py b/build/config/linux/pkg-config.py new file mode 100755 index 00000000000000..f0289cfc08909a --- /dev/null +++ b/build/config/linux/pkg-config.py @@ -0,0 +1,266 @@ +#!/usr/bin/env python +# Copyright (c) 2013 The Chromium Authors. All rights reserved. +# Copyright (c) 2020 Project CHIP Authors +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +from __future__ import print_function + +import json +import os +import subprocess +import sys +import re +from optparse import OptionParser + +# This script runs pkg-config, optionally filtering out some results, and +# returns the result. +# +# The result will be [ , , , , ] +# where each member is itself a list of strings. +# +# You can filter out matches using "-v " where all results from +# pkgconfig matching the given regular expression will be ignored. You can +# specify more than one regular expression my specifying "-v" more than once. +# +# You can specify a sysroot using "-s " where sysroot is the absolute +# system path to the sysroot used for compiling. This script will attempt to +# generate correct paths for the sysroot. +# +# When using a sysroot, you must also specify the architecture via +# "-a " where arch is either "x86" or "x64". +# +# CrOS systemroots place pkgconfig files at /usr/share/pkgconfig +# and one of /usr/lib/pkgconfig or /usr/lib64/pkgconfig +# depending on whether the systemroot is for a 32 or 64 bit architecture. They +# specify the 'lib' or 'lib64' of the pkgconfig path by defining the +# 'system_libdir' variable in the args.gn file. pkg_config.gni communicates this +# variable to this script with the "--system_libdir " flag. If no +# flag is provided, then pkgconfig files are assumed to come from +# /usr/lib/pkgconfig. +# +# Additionally, you can specify the option --atleast-version. This will skip +# the normal outputting of a dictionary and instead print true or false, +# depending on the return value of pkg-config for the given package. + + +def SetConfigPath(options): + """Set the PKG_CONFIG_LIBDIR environment variable. + + This takes into account any sysroot and architecture specification from the + options on the given command line. + """ + + sysroot = options.sysroot + assert sysroot + + # Compute the library path name based on the architecture. + arch = options.arch + if sysroot and not arch: + print("You must specify an architecture via -a if using a sysroot.") + sys.exit(1) + + libdir = sysroot + '/usr/' + options.system_libdir + '/pkgconfig' + libdir += ':' + sysroot + '/usr/share/pkgconfig' + os.environ['PKG_CONFIG_LIBDIR'] = libdir + return libdir + + +def GetPkgConfigPrefixToStrip(options, args): + """Returns the prefix from pkg-config where packages are installed. + + This returned prefix is the one that should be stripped from the beginning of + directory names to take into account sysroots. + """ + # Some sysroots, like the Chromium OS ones, may generate paths that are not + # relative to the sysroot. For example, + # /path/to/chroot/build/x86-generic/usr/lib/pkgconfig/pkg.pc may have all + # paths relative to /path/to/chroot (i.e. prefix=/build/x86-generic/usr) + # instead of relative to /path/to/chroot/build/x86-generic (i.e prefix=/usr). + # To support this correctly, it's necessary to extract the prefix to strip + # from pkg-config's |prefix| variable. + prefix = subprocess.check_output([options.pkg_config, + "--variable=prefix"] + args, env=os.environ).decode('utf-8') + if prefix[-4] == '/usr': + return prefix[4:] + return prefix + + +def MatchesAnyRegexp(flag, list_of_regexps): + """Returns true if the first argument matches any regular expression in the + given list.""" + for regexp in list_of_regexps: + if regexp.search(flag) != None: + return True + return False + + +def RewritePath(path, strip_prefix, sysroot): + """Rewrites a path by stripping the prefix and prepending the sysroot.""" + if os.path.isabs(path) and not path.startswith(sysroot): + if path.startswith(strip_prefix): + path = path[len(strip_prefix):] + path = path.lstrip('/') + return os.path.join(sysroot, path) + else: + return path + + +def main(): + parser = OptionParser() + parser.add_option('-d', '--debug', action='store_true') + parser.add_option('-p', action='store', dest='pkg_config', type='string', + default='pkg-config') + parser.add_option('-v', action='append', dest='strip_out', type='string') + parser.add_option('-s', action='store', dest='sysroot', type='string') + parser.add_option('-a', action='store', dest='arch', type='string') + parser.add_option('--system_libdir', action='store', dest='system_libdir', + type='string', default='lib') + parser.add_option('--atleast-version', action='store', + dest='atleast_version', type='string') + parser.add_option('--libdir', action='store_true', dest='libdir') + parser.add_option('--dridriverdir', action='store_true', dest='dridriverdir') + parser.add_option('--version-as-components', action='store_true', + dest='version_as_components') + (options, args) = parser.parse_args() + + # Make a list of regular expressions to strip out. + strip_out = [] + if options.strip_out != None: + for regexp in options.strip_out: + strip_out.append(re.compile(regexp)) + + if options.sysroot: + libdir = SetConfigPath(options) + if options.debug: + sys.stderr.write('PKG_CONFIG_LIBDIR=%s\n' % libdir) + prefix = GetPkgConfigPrefixToStrip(options, args) + else: + prefix = '' + + if options.atleast_version: + # When asking for the return value, just run pkg-config and print the return + # value, no need to do other work. + if not subprocess.call([options.pkg_config, + "--atleast-version=" + options.atleast_version] + + args): + print("true") + else: + print("false") + return 0 + + if options.version_as_components: + cmd = [options.pkg_config, "--modversion"] + args + try: + version_string = subprocess.check_output(cmd).decode('utf-8') + except: + sys.stderr.write('Error from pkg-config.\n') + return 1 + print(json.dumps(list(map(int, version_string.strip().split("."))))) + return 0 + + + if options.libdir: + cmd = [options.pkg_config, "--variable=libdir"] + args + if options.debug: + sys.stderr.write('Running: %s\n' % cmd) + try: + libdir = subprocess.check_output(cmd).decode('utf-8') + except: + print("Error from pkg-config.") + return 1 + sys.stdout.write(libdir.strip()) + return 0 + + if options.dridriverdir: + cmd = [options.pkg_config, "--variable=dridriverdir"] + args + if options.debug: + sys.stderr.write('Running: %s\n' % cmd) + try: + dridriverdir = subprocess.check_output(cmd).decode('utf-8') + except: + print("Error from pkg-config.") + return 1 + sys.stdout.write(dridriverdir.strip()) + return + + cmd = [options.pkg_config, "--cflags", "--libs"] + args + if options.debug: + sys.stderr.write('Running: %s\n' % ' '.join(cmd)) + + try: + flag_string = subprocess.check_output(cmd).decode('utf-8') + except: + sys.stderr.write('Could not run pkg-config.\n') + return 1 + + # For now just split on spaces to get the args out. This will break if + # pkgconfig returns quoted things with spaces in them, but that doesn't seem + # to happen in practice. + all_flags = flag_string.strip().split(' ') + + + sysroot = options.sysroot + if not sysroot: + sysroot = '' + + includes = [] + cflags = [] + libs = [] + lib_dirs = [] + + for flag in all_flags[:]: + if len(flag) == 0 or MatchesAnyRegexp(flag, strip_out): + continue; + + if flag[:2] == '-l': + libs.append(RewritePath(flag[2:], prefix, sysroot)) + elif flag[:2] == '-L': + lib_dirs.append(RewritePath(flag[2:], prefix, sysroot)) + elif flag[:2] == '-I': + includes.append(RewritePath(flag[2:], prefix, sysroot)) + elif flag[:3] == '-Wl': + # Don't allow libraries to control ld flags. These should be specified + # only in build files. + pass + elif flag == '-pthread': + # Many libs specify "-pthread" which we don't need since we always include + # this anyway. Removing it here prevents a bunch of duplicate inclusions + # on the command line. + pass + else: + cflags.append(flag) + + # Output a GN array, the first one is the cflags, the second are the libs. The + # JSON formatter prints GN compatible lists when everything is a list of + # strings. + print(json.dumps([includes, cflags, libs, lib_dirs])) + return 0 + + +if __name__ == '__main__': + sys.exit(main()) diff --git a/build/config/linux/pkg_config.gni b/build/config/linux/pkg_config.gni new file mode 100644 index 00000000000000..e44bc2541d50a3 --- /dev/null +++ b/build/config/linux/pkg_config.gni @@ -0,0 +1,115 @@ +# Copyright (c) 2013 The Chromium Authors. All rights reserved. +# Copyright (c) 2020 Project CHIP Authors +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# Defines a config specifying the result of running pkg-config for the given +# packages. Put the package names you want to query in the "packages" variable +# inside the template invocation. +# +# You can also add defines via the "defines" variable. This can be useful to +# add this to the config to pass defines that the library expects to get by +# users of its headers. +# +# Example: +# pkg_config("mything") { +# packages = [ "mything1", "mything2" ] +# defines = [ "ENABLE_AWESOME" ] +# } +# +# You can also use "extra args" to filter out results (see pkg-config.py): +# extra_args = [ "-v, "foo" ] +# To ignore libs and ldflags (only cflags/defines will be set, which is useful +# when doing manual dynamic linking), set: +# ignore_libs = true + +declare_args() { + # A pkg-config wrapper to call instead of trying to find and call the right + # pkg-config directly. Wrappers like this are common in cross-compilation + # environments. + # Leaving it blank defaults to searching PATH for 'pkg-config' and relying on + # the sysroot mechanism to find the right .pc files. + pkg_config = "" + + # A optional pkg-config wrapper to use for tools built on the host. + host_pkg_config = "" +} + +pkg_config_script = "//build/config/linux/pkg-config.py" + +# Define the args we pass to the pkg-config script for other build files that +# need to invoke it manually. +pkg_config_args = [] + +if (pkg_config != "") { + pkg_config_args += [ + "-p", + pkg_config, + ] +} + +if (host_pkg_config != "") { + host_pkg_config_args = [ + "-p", + host_pkg_config, + ] +} else { + host_pkg_config_args = pkg_config_args +} + +template("pkg_config") { + assert(defined(invoker.packages), + "Variable |packages| must be defined to be a list in pkg_config.") + config(target_name) { + if (host_toolchain == current_toolchain) { + args = host_pkg_config_args + invoker.packages + } else { + args = pkg_config_args + invoker.packages + } + if (defined(invoker.extra_args)) { + args += invoker.extra_args + } + + pkgresult = exec_script(pkg_config_script, args, "value") + cflags = pkgresult[1] + + foreach(include, pkgresult[0]) { + cflags += [ "-I$include" ] + } + + if (!defined(invoker.ignore_libs) || !invoker.ignore_libs) { + libs = pkgresult[2] + lib_dirs = pkgresult[3] + } + + forward_variables_from(invoker, + [ + "defines", + "visibility", + ]) + } +} diff --git a/src/crypto/BUILD.gn b/src/crypto/BUILD.gn index 0dedc9f2e866f2..f2b9dc97dd3759 100644 --- a/src/crypto/BUILD.gn +++ b/src/crypto/BUILD.gn @@ -32,11 +32,10 @@ config("crypto_config") { } if (chip_crypto == "openssl") { - config("openssl_config") { - libs = [ - "ssl", - "crypto", - ] + import("//build/config/linux/pkg_config.gni") + + pkg_config("openssl_config") { + packages = [ "openssl" ] } } else { import("//build_overrides/mbedtls.gni") diff --git a/src/crypto/crypto.gni b/src/crypto/crypto.gni index bf37682cffae58..26ddb3418fed5d 100644 --- a/src/crypto/crypto.gni +++ b/src/crypto/crypto.gni @@ -18,7 +18,7 @@ declare_args() { } if (chip_crypto == "") { - if (current_os == "freertos" || current_os == "mac") { + if (current_os == "freertos") { chip_crypto = "mbedtls" } else { chip_crypto = "openssl" From 6464f67b60cccb82c6f000a68872897c4c568834 Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Tue, 23 Jun 2020 00:19:48 -0400 Subject: [PATCH 44/59] Add mbedtls build to top level build --- BUILD.gn | 13 +++++++++++++ build/toolchain/host_gcc/toolchains.gni | 12 ++++++++++++ 2 files changed, 25 insertions(+) diff --git a/BUILD.gn b/BUILD.gn index 98d658eca105c4..cb16dafe378776 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -102,6 +102,9 @@ if (current_toolchain != "${dir_pw_toolchain}/dummy:dummy") { # Enable building chip with gcc. enable_host_gcc_build = enable_default_builds + # Build building chip with gcc & mbedtls. + enable_host_gcc_mbdtls_build = enable_default_builds + # Build the nRF5 lock app example. enable_nrf5_lock_app_build = false } @@ -120,6 +123,10 @@ if (current_toolchain != "${dir_pw_toolchain}/dummy:dummy") { toolchain = "//build/toolchain/host_gcc:${host_os}_${host_cpu}_gcc" } + chip_build("host_gcc_mbedtls") { + toolchain = "//build/toolchain/host_gcc:${host_os}_${host_cpu}_gcc_mbedtls" + } + group("default") { deps = [] if (enable_host_clang_build) { @@ -128,6 +135,9 @@ if (current_toolchain != "${dir_pw_toolchain}/dummy:dummy") { if (enable_host_gcc_build) { deps += [ ":all_host_gcc" ] } + if (enable_host_gcc_mbdtls_build) { + deps += [ ":all_host_gcc_mbedtls" ] + } if (enable_nrf5_lock_app_build) { deps += [ "${nrf5_lock_app_root}:nrf5(${nrf5_lock_app_root}/toolchain:nrf5_lock_app)" ] } @@ -142,6 +152,9 @@ if (current_toolchain != "${dir_pw_toolchain}/dummy:dummy") { if (enable_host_gcc_build) { deps += [ ":check_host_gcc" ] } + if (enable_host_gcc_mbdtls_build) { + deps += [ ":check_host_gcc_mbedtls" ] + } if (enable_nrf5_lock_app_build) { deps += [ ":default" ] } diff --git a/build/toolchain/host_gcc/toolchains.gni b/build/toolchain/host_gcc/toolchains.gni index 268d3ff3af1cdf..2a00fdf6b02fc0 100644 --- a/build/toolchain/host_gcc/toolchains.gni +++ b/build/toolchain/host_gcc/toolchains.gni @@ -41,6 +41,17 @@ pw_toolchain_host_gcc = { } } + mbedtls = { + name = "${host_os}_${host_cpu}_gcc_mbedtls" + forward_variables_from(_host_gcc_toolchain, "*") + defaults = { + default_configs_extra = _configs + current_os = host_os + is_clang = false + chip_crypto = "mbedtls" + } + } + debug = { name = "${host_os}_${host_cpu}_gcc_debug" forward_variables_from(_host_gcc_toolchain, "*") @@ -80,6 +91,7 @@ pw_toolchain_host_gcc = { # Describes host Linux GCC toolchains. pw_toolchain_host_gcc_list = [ pw_toolchain_host_gcc.default, + pw_toolchain_host_gcc.mbedtls, pw_toolchain_host_gcc.debug, pw_toolchain_host_gcc.speed_optimized, pw_toolchain_host_gcc.size_optimized, From 149ea2a4ad9df54dbceac86f0d901676593b1e91 Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Mon, 22 Jun 2020 22:17:35 -0400 Subject: [PATCH 45/59] Add tips to gn_build.sh To run a GN build of chip: ./gn_build.sh --- gn_build.sh | 58 ++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 42 insertions(+), 16 deletions(-) diff --git a/gn_build.sh b/gn_build.sh index fe55fc13b2e0eb..51f4447a3b9d17 100755 --- a/gn_build.sh +++ b/gn_build.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -e # # Copyright (c) 2020 Project CHIP Authors # @@ -18,37 +18,63 @@ CHIP_ROOT="$(dirname "$0")" _chip_red() { - echo -e "\033[0;31m$*\033[0m" + echo -e "\033[0;31m$*\033[0m" } _chip_yellow() { - echo -e "\033[0;33m$*\033[0m" + echo -e "\033[0;33m$*\033[0m" } _chip_banner() { - _chip_yellow '.--------------------------------' - _chip_yellow "-- $1" - _chip_yellow "'--------------------------------" + _chip_yellow '.--------------------------------' + _chip_yellow "-- $1" + _chip_yellow "'--------------------------------" } _chip_banner "Environment bringup" -git -C "${CHIP_ROOT}" submodule update --init +git -C "$CHIP_ROOT" submodule update --init -source "${CHIP_ROOT}/activate.sh" +set +e +source "$CHIP_ROOT/activate.sh" +set -e _chip_banner "Build: GN configure" -gn --root="${CHIP_ROOT}" gen --check "${CHIP_ROOT}/out/debug" -gn --root="${CHIP_ROOT}" gen --check "${CHIP_ROOT}/out/release" --args='is_debug=false' +gn --root="$CHIP_ROOT" gen --check "$CHIP_ROOT/out/debug" --args='target_os="all"' +gn --root="$CHIP_ROOT" gen --check "$CHIP_ROOT/out/release" --args='target_os="all" is_debug=false' _chip_banner "Build: Ninja build" -time ninja -C "${CHIP_ROOT}/out/debug" check +time ninja -C "$CHIP_ROOT/out/debug" check -# Release build. -# time ninja -C "${CHIP_ROOT}/out/release" check +echo +echo 'To re-bootstrap build environment in your shell, run:' +echo source "$CHIP_ROOT/bootstrap.sh" +echo -# Standalone example app. -# gn --root="${CHIP_ROOT}/examples/lock-app/nrf5" gen --check "${CHIP_ROOT}/out/nrf5_lock_app" --args='' -# time ninja -C "${CHIP_ROOT}/out/nrf5_lock_app" +echo 'To activate existing build environment in your shell, run (do this first):' +echo source "$CHIP_ROOT/activate.sh" + +echo +echo 'To build a debug build:' +echo gn gen "$CHIP_ROOT/out/debug" --args=\''target_os="all"'\' +echo ninja -C "$CHIP_ROOT/out/debug" + +echo +echo 'To run tests (idempotent):' +echo ninja -C "$CHIP_ROOT/out/debug" check + +echo +echo 'To build & test an optimized build:' +echo gn gen "$CHIP_ROOT/out/release" --args=\''target_os="all" is_debug=false'\' +echo ninja -C "$CHIP_ROOT/out/release" check + +echo +echo 'To build a custom build (for help run "gn args --list out/debug")' +echo gn args "$CHIP_ROOT/out/custom" +echo ninja -C "$CHIP_ROOT/out/custom" + +echo +echo 'To build the nRF5 lock sample as a standalone project': +echo "(cd $CHIP_ROOT/examples/lock-app/nrf5; gn gen out/debug; ninja -C out/debug)" From 39af23bab44503e3c3fb97dc59f85c978ecabafe Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Mon, 29 Jun 2020 13:28:02 -0400 Subject: [PATCH 46/59] Add nRF5 lock app back to example build But only if NRF5_SDK_ROOT is set in the environment. --- gn_build.sh | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/gn_build.sh b/gn_build.sh index 51f4447a3b9d17..5b891dfff065e5 100755 --- a/gn_build.sh +++ b/gn_build.sh @@ -41,8 +41,16 @@ set -e _chip_banner "Build: GN configure" -gn --root="$CHIP_ROOT" gen --check "$CHIP_ROOT/out/debug" --args='target_os="all"' -gn --root="$CHIP_ROOT" gen --check "$CHIP_ROOT/out/release" --args='target_os="all" is_debug=false' +nrf5_sdk_args="" +extra_args="" + +if [[ -d "$NRF5_SDK_ROOT/components/libraries" ]]; then + nrf5_sdk_args+="nrf5_sdk_root=\"$NRF5_SDK_ROOT\"" + extra_args+=" $nrf5_sdk_args enable_nrf5_lock_app_build=true" +fi + +gn --root="$CHIP_ROOT" gen --check "$CHIP_ROOT/out/debug" --args='target_os="all"'"$extra_args" +gn --root="$CHIP_ROOT" gen --check "$CHIP_ROOT/out/release" --args='target_os="all" is_debug=false'"$extra_args" _chip_banner "Build: Ninja build" @@ -58,7 +66,7 @@ echo source "$CHIP_ROOT/activate.sh" echo echo 'To build a debug build:' -echo gn gen "$CHIP_ROOT/out/debug" --args=\''target_os="all"'\' +echo gn gen "$CHIP_ROOT/out/debug" --args=\''target_os="all"'"$extra_args"\' echo ninja -C "$CHIP_ROOT/out/debug" echo @@ -67,7 +75,7 @@ echo ninja -C "$CHIP_ROOT/out/debug" check echo echo 'To build & test an optimized build:' -echo gn gen "$CHIP_ROOT/out/release" --args=\''target_os="all" is_debug=false'\' +echo gn gen "$CHIP_ROOT/out/release" --args=\''target_os="all" is_debug=false'"$extra_args"\' echo ninja -C "$CHIP_ROOT/out/release" check echo @@ -76,5 +84,9 @@ echo gn args "$CHIP_ROOT/out/custom" echo ninja -C "$CHIP_ROOT/out/custom" echo -echo 'To build the nRF5 lock sample as a standalone project': -echo "(cd $CHIP_ROOT/examples/lock-app/nrf5; gn gen out/debug; ninja -C out/debug)" +if [[ ! -d "$NRF5_SDK_ROOT/components/libraries" ]]; then + echo "Hint: Set \$NRF5_SDK_ROOT to enable building for nRF5" +else + echo 'To build the nRF5 lock sample as a standalone project': + echo "(cd $CHIP_ROOT/examples/lock-app/nrf5; gn gen out/debug --args='$nrf5_sdk_args'; ninja -C out/debug)" +fi From fa14181cf52568e32e8a9fe5ee033c6bb9e342fa Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Mon, 6 Jul 2020 21:14:28 -0400 Subject: [PATCH 47/59] Harmonize library outputs with automake This changes most libraries to match the names used by automake. --- BUILD.gn | 2 +- build/chip_test_suite.gni | 9 ++-- examples/chip-tool/BUILD.gn | 2 +- examples/lock-app/nrf5/BUILD.gn | 3 +- src/BUILD.gn | 25 ----------- src/app/BUILD.gn | 73 ++++++++++++++++++++++++++++++- src/app/chip-zcl/BUILD.gn | 35 --------------- src/app/gen/BUILD.gn | 44 ------------------- src/app/plugin/BUILD.gn | 52 ---------------------- src/app/plugin/tests/BUILD.gn | 8 +++- src/ble/BUILD.gn | 4 +- src/ble/tests/BUILD.gn | 4 +- src/controller/BUILD.gn | 4 +- src/crypto/BUILD.gn | 4 +- src/crypto/tests/BUILD.gn | 4 +- src/inet/BUILD.gn | 4 +- src/inet/tests/BUILD.gn | 4 +- src/lib/BUILD.gn | 21 +++++++++ src/lib/core/BUILD.gn | 4 +- src/lib/core/tests/BUILD.gn | 4 +- src/lib/shell/BUILD.gn | 4 +- src/lib/support/BUILD.gn | 2 + src/lib/support/tests/BUILD.gn | 4 +- src/platform/BUILD.gn | 4 +- src/setup_payload/BUILD.gn | 2 + src/setup_payload/tests/BUILD.gn | 4 +- src/system/BUILD.gn | 4 +- src/system/tests/BUILD.gn | 4 +- src/transport/BUILD.gn | 4 +- src/transport/tests/BUILD.gn | 4 +- third_party/nlunit-test/BUILD.gn | 4 +- third_party/nrf5_sdk/nrf5_sdk.gni | 2 +- 32 files changed, 164 insertions(+), 188 deletions(-) delete mode 100644 src/app/chip-zcl/BUILD.gn delete mode 100644 src/app/gen/BUILD.gn delete mode 100644 src/app/plugin/BUILD.gn diff --git a/BUILD.gn b/BUILD.gn index cb16dafe378776..a965c2643ba6c7 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -33,12 +33,12 @@ if (current_toolchain != "${dir_pw_toolchain}/dummy:dummy") { group("all") { deps = [ - "${chip_root}/src", "${chip_root}/src/app", "${chip_root}/src/ble", "${chip_root}/src/controller", "${chip_root}/src/crypto", "${chip_root}/src/inet", + "${chip_root}/src/lib", "${chip_root}/src/lib/core", "${chip_root}/src/lib/support", "${chip_root}/src/lwip:all", diff --git a/build/chip_test_suite.gni b/build/chip_test_suite.gni index 728e3c342fd94f..b38083510b7290 100644 --- a/build/chip_test_suite.gni +++ b/build/chip_test_suite.gni @@ -25,14 +25,11 @@ template("chip_test_suite") { static_library("${_suite_name}_common") { forward_variables_from(invoker, + "*", [ - "deps", - "public_deps", - "public_configs", + "tests", + "c_tests", ]) - if (defined(invoker.common_sources)) { - sources = invoker.common_sources - } } tests = [] diff --git a/examples/chip-tool/BUILD.gn b/examples/chip-tool/BUILD.gn index 1c9318f111ebfe..6378bc0faf175f 100644 --- a/examples/chip-tool/BUILD.gn +++ b/examples/chip-tool/BUILD.gn @@ -21,7 +21,7 @@ assert(chip_build_tools) executable("chip-standalone-demo") { sources = [ "main.cpp" ] - public_deps = [ "${chip_root}/src:chip" ] + public_deps = [ "${chip_root}/src/lib" ] output_dir = "${root_out_dir}/bin" } diff --git a/examples/lock-app/nrf5/BUILD.gn b/examples/lock-app/nrf5/BUILD.gn index 257d1a6d4e3b96..0ec33ac7d53b0d 100644 --- a/examples/lock-app/nrf5/BUILD.gn +++ b/examples/lock-app/nrf5/BUILD.gn @@ -53,8 +53,7 @@ nrf5_sdk("sdk") { executable("lock_app") { public_deps = [ ":sdk", - "${chip_root}/src:chip", - "${chip_root}/src/platform", + "${chip_root}/src/lib", ] sources = [ diff --git a/src/BUILD.gn b/src/BUILD.gn index 9a8ca0d15149cb..92d1b43b02e939 100644 --- a/src/BUILD.gn +++ b/src/BUILD.gn @@ -23,28 +23,3 @@ config("includes") { configs = [ ":public_includes" ] } - -static_library("chip") { - public_deps = [ - "${chip_root}/src/app/plugin:chip", - "${chip_root}/src/ble", - "${chip_root}/src/controller", - "${chip_root}/src/crypto", - "${chip_root}/src/inet", - "${chip_root}/src/lib/core", - "${chip_root}/src/lib/support", - "${chip_root}/src/platform", - "${chip_root}/src/system", - "${chip_root}/src/transport", - ] - - output_name = "libCHIP" - - output_dir = "${root_out_dir}/lib" - - complete_static_lib = true -} - -group("src") { - deps = [ ":chip" ] -} diff --git a/src/app/BUILD.gn b/src/app/BUILD.gn index 3dfc7f10eaa306..d8bf6362474134 100644 --- a/src/app/BUILD.gn +++ b/src/app/BUILD.gn @@ -12,6 +12,77 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//build_overrides/chip.gni") + +config("app_config") { + include_dirs = [ + "gen", + "chip-zcl", + ".", + ] +} + +static_library("common") { + output_name = "libCHIPDataModelCommon" + + sources = [ + "chip-zcl/chip-zcl-buffer.h", + "chip-zcl/chip-zcl-codec.h", + "chip-zcl/chip-zcl-struct.h", + "chip-zcl/chip-zcl.h", + "gen/gen-attribute-storage.h", + "gen/gen-attribute-type.h", + "gen/gen-callback-stubs.c", + "gen/gen-callbacks.h", + "gen/gen-cluster-id.h", + "gen/gen-command-handler.c", + "gen/gen-command-handler.h", + "gen/gen-command-id.h", + "gen/gen-endpoint-config.h", + "gen/gen-global-command-handler.c", + "gen/gen-global-command-handler.h", + "gen/gen-specs.c", + "gen/gen-types.h", + "gen/gen.h", + "plugin/cluster-server-basic/basic-server.c", + "plugin/cluster-server-identify/identify-server.c", + "plugin/cluster-server-level-control/level-control-server-tokens.h", + "plugin/cluster-server-level-control/level-control-server.c", + "plugin/cluster-server-level-control/level-control-server.h", + "plugin/cluster-server-on-off/on-off-server-tokens.h", + "plugin/cluster-server-on-off/on-off-server.c", + "plugin/cluster-server-on-off/on-off-server.h", + "plugin/codec-simple/codec-simple.c", + "plugin/core-api/core-api.c", + "plugin/core-data-model/zcl-data-model.c", + "plugin/core-message-dispatch/dispatch.c", + "plugin/core-message-dispatch/dispatch.h", + ] + + public_deps = [ + "${chip_root}/src/lib/support", + "${chip_root}/src/system", + ] + + public_configs = [ ":app_config" ] +} + +static_library("chip") { + output_name = "libCHIPDataModel" + + sources = [ "plugin/binding-chip/chip.cpp" ] + + public_deps = [ ":common" ] +} + +static_library("mock") { + output_name = "libCHIPDataModelMock" + + sources = [ "plugin/binding-mock/mock.c" ] + + public_deps = [ ":common" ] +} + group("app") { - public_deps = [ "plugin:chip" ] + public_deps = [ ":chip" ] } diff --git a/src/app/chip-zcl/BUILD.gn b/src/app/chip-zcl/BUILD.gn deleted file mode 100644 index 714289e55c14ce..00000000000000 --- a/src/app/chip-zcl/BUILD.gn +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright (c) 2020 Project CHIP Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//build_overrides/chip.gni") - -import("${chip_root}/build/tests.gni") - -config("chip-zcl_config") { - include_dirs = [ - ".", - "..", - ] -} - -source_set("chip-zcl") { - sources = [ - "chip-zcl-buffer.h", - "chip-zcl-codec.h", - "chip-zcl-struct.h", - "chip-zcl.h", - ] - - public_configs = [ ":chip-zcl_config" ] -} diff --git a/src/app/gen/BUILD.gn b/src/app/gen/BUILD.gn deleted file mode 100644 index 224960c95e5022..00000000000000 --- a/src/app/gen/BUILD.gn +++ /dev/null @@ -1,44 +0,0 @@ -# Copyright (c) 2020 Project CHIP Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//build_overrides/chip.gni") - -config("gen_config") { - include_dirs = [ "." ] -} - -static_library("gen") { - sources = [ - "gen-attribute-storage.h", - "gen-attribute-type.h", - "gen-callback-stubs.c", - "gen-callbacks.h", - "gen-cluster-id.h", - "gen-command-handler.c", - "gen-command-handler.h", - "gen-command-id.h", - "gen-endpoint-config.h", - "gen-global-command-handler.c", - "gen-global-command-handler.h", - "gen-specs.c", - "gen-types.h", - "gen.h", - ] - - check_includes = false - - public_configs = [ ":gen_config" ] - - public_deps = [ "${chip_root}/src/app/chip-zcl" ] -} diff --git a/src/app/plugin/BUILD.gn b/src/app/plugin/BUILD.gn deleted file mode 100644 index be937adc52a3e5..00000000000000 --- a/src/app/plugin/BUILD.gn +++ /dev/null @@ -1,52 +0,0 @@ -# Copyright (c) 2020 Project CHIP Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//build_overrides/chip.gni") - -source_set("common") { - sources = [ - "cluster-server-basic/basic-server.c", - "cluster-server-identify/identify-server.c", - "cluster-server-level-control/level-control-server-tokens.h", - "cluster-server-level-control/level-control-server.c", - "cluster-server-level-control/level-control-server.h", - "cluster-server-on-off/on-off-server-tokens.h", - "cluster-server-on-off/on-off-server.c", - "cluster-server-on-off/on-off-server.h", - "codec-simple/codec-simple.c", - "core-api/core-api.c", - "core-data-model/zcl-data-model.c", - "core-message-dispatch/dispatch.c", - "core-message-dispatch/dispatch.h", - ] - - public_deps = [ - "${chip_root}/src/app/chip-zcl", - "${chip_root}/src/app/gen", - "${chip_root}/src/lib/support", - "${chip_root}/src/system", - ] -} - -source_set("chip") { - sources = [ "binding-chip/chip.cpp" ] - - public_deps = [ ":common" ] -} - -source_set("mock") { - sources = [ "binding-mock/mock.c" ] - - public_deps = [ ":common" ] -} diff --git a/src/app/plugin/tests/BUILD.gn b/src/app/plugin/tests/BUILD.gn index 3772b3a97a64da..9ff0adff7349a9 100644 --- a/src/app/plugin/tests/BUILD.gn +++ b/src/app/plugin/tests/BUILD.gn @@ -18,7 +18,9 @@ import("//build_overrides/nlunit_test.gni") import("${chip_root}/build/chip_test_suite.gni") chip_test_suite("tests") { - common_sources = [ + output_name = "libChipZclUnitTests" + + sources = [ "ChipZclUnitTests.h", "cluster-cmd-on-off-test.c", "cluster-server-basic-test.c", @@ -31,11 +33,13 @@ chip_test_suite("tests") { ] public_deps = [ - "${chip_root}/src/app/plugin:mock", + "${chip_root}/src/app:mock", "${chip_root}/src/inet", "${chip_root}/src/system", "${nlunit_test_root}:nlunit-test", ] + public_configs = [ "${chip_root}/src/app:app_config" ] + c_tests = [ "ChipZclUnitTests" ] } diff --git a/src/ble/BUILD.gn b/src/ble/BUILD.gn index 158e716034969a..52d5f503b39836 100644 --- a/src/ble/BUILD.gn +++ b/src/ble/BUILD.gn @@ -50,7 +50,9 @@ source_set("ble_config_header") { public_deps = [ "${chip_root}/src/system:system_config_header" ] } -source_set("ble") { +static_library("ble") { + output_name = "libBleLayer" + sources = [ "BLEEndPoint.cpp", "BLEEndPoint.h", diff --git a/src/ble/tests/BUILD.gn b/src/ble/tests/BUILD.gn index 1a9d78a644703e..6b38937a04263d 100644 --- a/src/ble/tests/BUILD.gn +++ b/src/ble/tests/BUILD.gn @@ -18,7 +18,9 @@ import("//build_overrides/nlunit_test.gni") import("${chip_root}/build/chip_test_suite.gni") chip_test_suite("tests") { - common_sources = [ + output_name = "libBleLayerTests" + + sources = [ "TestBleErrorStr.cpp", "TestBleLayer.h", ] diff --git a/src/controller/BUILD.gn b/src/controller/BUILD.gn index ba630d8e383555..a52a68f71fe180 100644 --- a/src/controller/BUILD.gn +++ b/src/controller/BUILD.gn @@ -14,7 +14,9 @@ import("//build_overrides/chip.gni") -source_set("controller") { +static_library("controller") { + output_name = "libChipController" + sources = [ "CHIPDeviceController.cpp", "CHIPDeviceController.h", diff --git a/src/crypto/BUILD.gn b/src/crypto/BUILD.gn index f2b9dc97dd3759..f6636b307ce2d9 100644 --- a/src/crypto/BUILD.gn +++ b/src/crypto/BUILD.gn @@ -41,7 +41,9 @@ if (chip_crypto == "openssl") { import("//build_overrides/mbedtls.gni") } -source_set("crypto") { +static_library("crypto") { + output_name = "libChipCrypto" + sources = [ "CHIPCryptoPAL.h" ] public_deps = [ diff --git a/src/crypto/tests/BUILD.gn b/src/crypto/tests/BUILD.gn index 0bc4c69c48c40e..c923aa2f4ac879 100644 --- a/src/crypto/tests/BUILD.gn +++ b/src/crypto/tests/BUILD.gn @@ -18,7 +18,9 @@ import("//build_overrides/nlunit_test.gni") import("${chip_root}/build/chip_test_suite.gni") chip_test_suite("tests") { - common_sources = [ + output_name = "libChipCrypto" + + sources = [ "AES_CCM_128_test_vectors.h", "AES_CCM_256_test_vectors.h", "CHIPCryptoPALTest.cpp", diff --git a/src/inet/BUILD.gn b/src/inet/BUILD.gn index b2bd419de8e083..262ae03cb55970 100644 --- a/src/inet/BUILD.gn +++ b/src/inet/BUILD.gn @@ -89,7 +89,9 @@ source_set("inet_config_header") { public_deps = [ "${chip_root}/src/system:system_config_header" ] } -source_set("inet") { +static_library("inet") { + output_name = "libInetLayer" + sources = [ "AsyncDNSResolverSockets.cpp", "AsyncDNSResolverSockets.h", diff --git a/src/inet/tests/BUILD.gn b/src/inet/tests/BUILD.gn index ae205fe7bdbdfa..a598a9849b3f35 100644 --- a/src/inet/tests/BUILD.gn +++ b/src/inet/tests/BUILD.gn @@ -22,7 +22,9 @@ config("tests_config") { } chip_test_suite("tests") { - common_sources = [ + output_name = "libTestInetCommon" + + sources = [ "TapAddrAutoconf.cpp", "TapAddrAutoconf.h", "TestInetAddress.cpp", diff --git a/src/lib/BUILD.gn b/src/lib/BUILD.gn index 310ae29efbdcdb..e119fc3466ee0c 100644 --- a/src/lib/BUILD.gn +++ b/src/lib/BUILD.gn @@ -17,3 +17,24 @@ import("//build_overrides/chip.gni") config("includes") { include_dirs = [ "." ] } + +static_library("lib") { + public_deps = [ + "${chip_root}/src/app:chip", + "${chip_root}/src/ble", + "${chip_root}/src/controller", + "${chip_root}/src/crypto", + "${chip_root}/src/inet", + "${chip_root}/src/lib/core", + "${chip_root}/src/lib/support", + "${chip_root}/src/platform", + "${chip_root}/src/system", + "${chip_root}/src/transport", + ] + + output_name = "libCHIP" + + output_dir = "${root_out_dir}/lib" + + complete_static_lib = true +} diff --git a/src/lib/core/BUILD.gn b/src/lib/core/BUILD.gn index eeae7c5ac7c7fa..f4f2175ca84418 100644 --- a/src/lib/core/BUILD.gn +++ b/src/lib/core/BUILD.gn @@ -110,7 +110,9 @@ source_set("chip_config_header") { public_deps = [ "${chip_root}/src/system:system_config_header" ] } -source_set("core") { +static_library("core") { + output_name = "libChipCore" + sources = [ "CHIPCallback.h", "CHIPCircularTLVBuffer.cpp", diff --git a/src/lib/core/tests/BUILD.gn b/src/lib/core/tests/BUILD.gn index 323c39239d3dfd..e63d57f3e1da45 100644 --- a/src/lib/core/tests/BUILD.gn +++ b/src/lib/core/tests/BUILD.gn @@ -18,7 +18,9 @@ import("//build_overrides/nlunit_test.gni") import("${chip_root}/build/chip_test_suite.gni") chip_test_suite("tests") { - common_sources = [ + output_name = "libCoreTests" + + sources = [ "TestCHIPCallback.cpp", "TestCHIPErrorStr.cpp", "TestCHIPTLV.cpp", diff --git a/src/lib/shell/BUILD.gn b/src/lib/shell/BUILD.gn index c2fb5ec4bb4be0..8c3619e8a0aa48 100644 --- a/src/lib/shell/BUILD.gn +++ b/src/lib/shell/BUILD.gn @@ -14,7 +14,9 @@ import("//build_overrides/chip.gni") -source_set("shell") { +static_library("shell") { + output_name = "libCHIPShell" + sources = [ "commands.cpp", "commands.h", diff --git a/src/lib/support/BUILD.gn b/src/lib/support/BUILD.gn index ddbb8cd656b896..7eb355184d0d01 100644 --- a/src/lib/support/BUILD.gn +++ b/src/lib/support/BUILD.gn @@ -66,6 +66,8 @@ support_headers = [ ] static_library("support") { + output_name = "libSupportLayer" + sources = [ "Base64.cpp", "CHIPArgParser.cpp", diff --git a/src/lib/support/tests/BUILD.gn b/src/lib/support/tests/BUILD.gn index 70e5a044967d62..ce1d78c3594f1c 100644 --- a/src/lib/support/tests/BUILD.gn +++ b/src/lib/support/tests/BUILD.gn @@ -18,7 +18,9 @@ import("//build_overrides/nlunit_test.gni") import("${chip_root}/build/chip_test_suite.gni") chip_test_suite("tests") { - common_sources = [ + output_name = "libSupportTests" + + sources = [ "TestCHIPArgParser.cpp", "TestCHIPCounter.cpp", "TestErrorStr.cpp", diff --git a/src/platform/BUILD.gn b/src/platform/BUILD.gn index 72201d4f951fa2..072e713d158315 100644 --- a/src/platform/BUILD.gn +++ b/src/platform/BUILD.gn @@ -47,7 +47,9 @@ if (device_platform != "none") { } } - source_set("platform") { + static_library("platform") { + output_name = "libDeviceLayer" + sources = [ "GeneralUtils.cpp", "Globals.cpp", diff --git a/src/setup_payload/BUILD.gn b/src/setup_payload/BUILD.gn index afacb16da61cbb..760698c1eff5a7 100644 --- a/src/setup_payload/BUILD.gn +++ b/src/setup_payload/BUILD.gn @@ -19,6 +19,8 @@ config("setup_payload_config") { } static_library("setup_payload") { + output_name = "libSetupPayload" + sources = [ "Base41.cpp", "Base41.h", diff --git a/src/setup_payload/tests/BUILD.gn b/src/setup_payload/tests/BUILD.gn index f66d10e0d1a300..61121990eeef7f 100644 --- a/src/setup_payload/tests/BUILD.gn +++ b/src/setup_payload/tests/BUILD.gn @@ -18,7 +18,9 @@ import("//build_overrides/nlunit_test.gni") import("${chip_root}/build/chip_test_suite.gni") chip_test_suite("tests") { - common_sources = [ + output_name = "libSetupPayloadTests" + + sources = [ "TestManualCode.cpp", "TestManualCode.h", "TestQRCode.cpp", diff --git a/src/system/BUILD.gn b/src/system/BUILD.gn index 06ea4d188fa62c..3f7116ec88a9a8 100644 --- a/src/system/BUILD.gn +++ b/src/system/BUILD.gn @@ -120,7 +120,9 @@ source_set("system_config_header") { } } -source_set("system") { +static_library("system") { + output_name = "libSystemLayer" + sources = [ "SystemAlignSize.h", "SystemClock.cpp", diff --git a/src/system/tests/BUILD.gn b/src/system/tests/BUILD.gn index 116bda12638d6e..fad435c8a30e77 100644 --- a/src/system/tests/BUILD.gn +++ b/src/system/tests/BUILD.gn @@ -18,7 +18,9 @@ import("//build_overrides/nlunit_test.gni") import("${chip_root}/build/chip_test_suite.gni") chip_test_suite("tests") { - common_sources = [ + output_name = "libSystemLayerTests" + + sources = [ "TestSystemErrorStr.cpp", "TestSystemLayer.h", "TestSystemObject.cpp", diff --git a/src/transport/BUILD.gn b/src/transport/BUILD.gn index e662531cd439d5..08f5be2c4fe478 100644 --- a/src/transport/BUILD.gn +++ b/src/transport/BUILD.gn @@ -14,7 +14,9 @@ import("//build_overrides/chip.gni") -source_set("transport") { +static_library("transport") { + output_name = "libTransportLayer" + sources = [ "Base.h", "MessageHeader.cpp", diff --git a/src/transport/tests/BUILD.gn b/src/transport/tests/BUILD.gn index 3759f0542a7188..1ec6eddfcd5b09 100644 --- a/src/transport/tests/BUILD.gn +++ b/src/transport/tests/BUILD.gn @@ -19,7 +19,9 @@ import("//build_overrides/nlunit_test.gni") import("${chip_root}/build/chip_test_suite.gni") chip_test_suite("tests") { - common_sources = [ + output_name = "libTransportLayerTests" + + sources = [ "NetworkTestHelpers.cpp", "NetworkTestHelpers.h", "TestMessageHeader.cpp", diff --git a/third_party/nlunit-test/BUILD.gn b/third_party/nlunit-test/BUILD.gn index 9c2cc6edb33896..df627d3585b902 100644 --- a/third_party/nlunit-test/BUILD.gn +++ b/third_party/nlunit-test/BUILD.gn @@ -16,7 +16,9 @@ config("nlunit-test_config") { include_dirs = [ "repo/src" ] } -source_set("nlunit-test") { +static_library("nlunit-test") { + output_name = "libnlunit-test" + sources = [ "repo/src/nlunit-test.c", "repo/src/nlunit-test.h", diff --git a/third_party/nrf5_sdk/nrf5_sdk.gni b/third_party/nrf5_sdk/nrf5_sdk.gni index 65d7b610a42926..8b4d0e1381af3a 100644 --- a/third_party/nrf5_sdk/nrf5_sdk.gni +++ b/third_party/nrf5_sdk/nrf5_sdk.gni @@ -113,7 +113,7 @@ template("nrf5_sdk") { } # TODO - Break up this monolith and make it configurable. - source_set(sdk_target_name) { + static_library(sdk_target_name) { sources = [ "${nrf5_sdk_root}/components/ble/common/ble_advdata.c", "${nrf5_sdk_root}/components/ble/common/ble_srv_common.c", From 908aac8860f454522778c873d4a81e9f01da5692 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Tue, 7 Jul 2020 09:33:53 +0000 Subject: [PATCH 48/59] Restyled by shfmt --- gn_build.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gn_build.sh b/gn_build.sh index 5b891dfff065e5..59aa9109e37b2d 100755 --- a/gn_build.sh +++ b/gn_build.sh @@ -85,8 +85,8 @@ echo ninja -C "$CHIP_ROOT/out/custom" echo if [[ ! -d "$NRF5_SDK_ROOT/components/libraries" ]]; then - echo "Hint: Set \$NRF5_SDK_ROOT to enable building for nRF5" + echo "Hint: Set \$NRF5_SDK_ROOT to enable building for nRF5" else - echo 'To build the nRF5 lock sample as a standalone project': - echo "(cd $CHIP_ROOT/examples/lock-app/nrf5; gn gen out/debug --args='$nrf5_sdk_args'; ninja -C out/debug)" + echo 'To build the nRF5 lock sample as a standalone project': + echo "(cd $CHIP_ROOT/examples/lock-app/nrf5; gn gen out/debug --args='$nrf5_sdk_args'; ninja -C out/debug)" fi From 8febbbda0ba7fc7e0fbbdb797620ec57062902da Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Tue, 7 Jul 2020 16:23:01 -0400 Subject: [PATCH 49/59] Move the GN build files to //gn And use the secondary_source feature to still allow loading them via //build. This breaks using ${chip_root} in superproject builds, but that was unnecessary anyway. We should try to unwind this later as it causes some confusion about what path to specify. --- .gn | 5 ++- BUILD.gn | 6 +-- examples/chip-tool/BUILD.gn | 2 +- examples/lock-app/nrf5/.gn | 3 ++ .../nrf5/build_overrides/nlfaultinjection.gni | 3 +- examples/shell/BUILD.gn | 2 +- {build => gn/build}/chip_build.gni | 2 +- {build => gn/build}/chip_test.gni | 2 +- {build => gn/build}/chip_test_group.gni | 2 +- {build => gn/build}/chip_test_suite.gni | 4 +- {build => gn/build}/chip_version.gni | 0 {build => gn/build}/config/BUILDCONFIG.gn | 0 {build => gn/build}/config/arm.gni | 0 {build => gn/build}/config/compiler/BUILD.gn | 2 +- .../build}/config/compiler/compiler.gni | 0 .../build}/config/custom_toolchain.gni | 0 {build => gn/build}/config/defaults.gni | 43 ++++++++----------- .../build}/config/linux/pkg-config.py | 0 .../build}/config/linux/pkg_config.gni | 0 {build => gn/build}/device.gni | 0 {build => gn/build}/tests.gni | 0 .../build}/toolchain/arm_gcc/BUILD.gn | 0 .../toolchain/arm_gcc/arm_toolchain.gni | 0 .../build}/toolchain/host_clang/BUILD.gn | 0 .../toolchain/host_clang/toolchains.gni | 0 .../build}/toolchain/host_gcc/BUILD.gn | 0 .../build}/toolchain/host_gcc/toolchains.gni | 0 {build => gn/build}/tools.gni | 0 .../build_overrides}/chip.gni | 0 .../build_overrides}/lwip.gni | 0 .../build_overrides}/mbedtls.gni | 0 .../build_overrides}/nlassert.gni | 0 .../build_overrides}/nlfaultinjection.gni | 0 .../build_overrides}/nlio.gni | 0 .../build_overrides}/nlunit_test.gni | 0 .../build_overrides}/nrf5_lock_app.gni | 0 .../build_overrides}/nrf5_sdk.gni | 0 .../build_overrides}/pigweed.gni | 0 src/app/plugin/tests/BUILD.gn | 2 +- src/ble/tests/BUILD.gn | 2 +- src/crypto/tests/BUILD.gn | 2 +- src/inet/BUILD.gn | 2 +- src/inet/tests/BUILD.gn | 2 +- src/lib/core/BUILD.gn | 2 +- src/lib/core/tests/BUILD.gn | 2 +- src/lib/support/BUILD.gn | 4 +- src/lib/support/tests/BUILD.gn | 2 +- src/lwip/tests/BUILD.gn | 4 +- src/platform/BUILD.gn | 2 +- src/qrcodetool/BUILD.gn | 2 +- src/setup_payload/tests/BUILD.gn | 2 +- src/system/BUILD.gn | 2 +- src/system/tests/BUILD.gn | 2 +- src/transport/tests/BUILD.gn | 2 +- 54 files changed, 55 insertions(+), 57 deletions(-) rename {build => gn/build}/chip_build.gni (95%) rename {build => gn/build}/chip_test.gni (97%) rename {build => gn/build}/chip_test_group.gni (96%) rename {build => gn/build}/chip_test_suite.gni (95%) rename {build => gn/build}/chip_version.gni (100%) rename {build => gn/build}/config/BUILDCONFIG.gn (100%) rename {build => gn/build}/config/arm.gni (100%) rename {build => gn/build}/config/compiler/BUILD.gn (98%) rename {build => gn/build}/config/compiler/compiler.gni (100%) rename {build => gn/build}/config/custom_toolchain.gni (100%) rename {build => gn/build}/config/defaults.gni (60%) rename {build => gn/build}/config/linux/pkg-config.py (100%) rename {build => gn/build}/config/linux/pkg_config.gni (100%) rename {build => gn/build}/device.gni (100%) rename {build => gn/build}/tests.gni (100%) rename {build => gn/build}/toolchain/arm_gcc/BUILD.gn (100%) rename {build => gn/build}/toolchain/arm_gcc/arm_toolchain.gni (100%) rename {build => gn/build}/toolchain/host_clang/BUILD.gn (100%) rename {build => gn/build}/toolchain/host_clang/toolchains.gni (100%) rename {build => gn/build}/toolchain/host_gcc/BUILD.gn (100%) rename {build => gn/build}/toolchain/host_gcc/toolchains.gni (100%) rename {build => gn/build}/tools.gni (100%) rename {build_overrides => gn/build_overrides}/chip.gni (100%) rename {build_overrides => gn/build_overrides}/lwip.gni (100%) rename {build_overrides => gn/build_overrides}/mbedtls.gni (100%) rename {build_overrides => gn/build_overrides}/nlassert.gni (100%) rename {build_overrides => gn/build_overrides}/nlfaultinjection.gni (100%) rename {build_overrides => gn/build_overrides}/nlio.gni (100%) rename {build_overrides => gn/build_overrides}/nlunit_test.gni (100%) rename {build_overrides => gn/build_overrides}/nrf5_lock_app.gni (100%) rename {build_overrides => gn/build_overrides}/nrf5_sdk.gni (100%) rename {build_overrides => gn/build_overrides}/pigweed.gni (100%) diff --git a/.gn b/.gn index a4557d19977246..f0756bebc97d29 100644 --- a/.gn +++ b/.gn @@ -18,7 +18,10 @@ buildconfig = "//build/config/BUILDCONFIG.gn" # CHIP uses angle bracket includes. check_system_includes = true -import("//build_overrides/pigweed.gni") +# Allow loading paths relative to //gn. +secondary_source = "//gn/" + +import("//gn/build_overrides/pigweed.gni") default_args = { pw_unit_test_AUTOMATIC_RUNNER = "$dir_pigweed/targets/host/run_test" diff --git a/BUILD.gn b/BUILD.gn index a965c2643ba6c7..64ac63e9752c88 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -22,8 +22,8 @@ import("//build_overrides/pigweed.gni") # This build file should not be used in superproject builds. assert(chip_root == "//") -import("${chip_root}/build/tests.gni") -import("${chip_root}/build/tools.gni") +import("//build/tests.gni") +import("//build/tools.gni") if (current_toolchain != "${dir_pw_toolchain}/dummy:dummy") { # This is a real toolchain. Build CHIP. @@ -66,7 +66,7 @@ if (current_toolchain != "${dir_pw_toolchain}/dummy:dummy") { } if (chip_build_tests) { - import("${chip_root}/build/chip_test_group.gni") + import("//build/chip_test_group.gni") chip_test_group("tests") { deps = [ diff --git a/examples/chip-tool/BUILD.gn b/examples/chip-tool/BUILD.gn index 6378bc0faf175f..c6a6bbe6f1a38d 100644 --- a/examples/chip-tool/BUILD.gn +++ b/examples/chip-tool/BUILD.gn @@ -14,7 +14,7 @@ import("//build_overrides/chip.gni") -import("${chip_root}/build/tools.gni") +import("//build/tools.gni") assert(chip_build_tools) diff --git a/examples/lock-app/nrf5/.gn b/examples/lock-app/nrf5/.gn index c3cfa5fd40318d..2129e6fa50ebaa 100644 --- a/examples/lock-app/nrf5/.gn +++ b/examples/lock-app/nrf5/.gn @@ -18,6 +18,9 @@ buildconfig = "//build/config/BUILDCONFIG.gn" # CHIP uses angle bracket includes. check_system_includes = true +# Allow loading paths relative to //gn. +secondary_source = "//third_party/connectedhomeip/gn/" + default_args = { import("//args.gni") } diff --git a/examples/lock-app/nrf5/build_overrides/nlfaultinjection.gni b/examples/lock-app/nrf5/build_overrides/nlfaultinjection.gni index f100f00da348cc..155d765597d110 100644 --- a/examples/lock-app/nrf5/build_overrides/nlfaultinjection.gni +++ b/examples/lock-app/nrf5/build_overrides/nlfaultinjection.gni @@ -14,5 +14,6 @@ declare_args() { # Root directory for nlfaultinjection. - nlfaultinjection_root = "//third_party/connectedhomeip/third_party/nlfaultinjection" + nlfaultinjection_root = + "//third_party/connectedhomeip/third_party/nlfaultinjection" } diff --git a/examples/shell/BUILD.gn b/examples/shell/BUILD.gn index ee196f601729d7..e6c7dbcf4e7788 100644 --- a/examples/shell/BUILD.gn +++ b/examples/shell/BUILD.gn @@ -14,7 +14,7 @@ import("//build_overrides/chip.gni") -import("${chip_root}/build/tools.gni") +import("//build/tools.gni") assert(chip_build_tools) diff --git a/build/chip_build.gni b/gn/build/chip_build.gni similarity index 95% rename from build/chip_build.gni rename to gn/build/chip_build.gni index 9a0fb57cfadb85..786989fdcbe90d 100644 --- a/build/chip_build.gni +++ b/gn/build/chip_build.gni @@ -14,7 +14,7 @@ import("//build_overrides/chip.gni") -import("${chip_root}/build/tests.gni") +import("//build/tests.gni") template("chip_build") { _build_name = target_name diff --git a/build/chip_test.gni b/gn/build/chip_test.gni similarity index 97% rename from build/chip_test.gni rename to gn/build/chip_test.gni index fbf1cc864c98b7..b739aa3e915a05 100644 --- a/build/chip_test.gni +++ b/gn/build/chip_test.gni @@ -15,7 +15,7 @@ import("//build_overrides/chip.gni") import("//build_overrides/pigweed.gni") -import("${chip_root}/build/tests.gni") +import("//build/tests.gni") import("${dir_pw_unit_test}/test.gni") assert(chip_build_tests) diff --git a/build/chip_test_group.gni b/gn/build/chip_test_group.gni similarity index 96% rename from build/chip_test_group.gni rename to gn/build/chip_test_group.gni index b77ed3feb0464a..b6b3c5e9dc21c9 100644 --- a/build/chip_test_group.gni +++ b/gn/build/chip_test_group.gni @@ -14,7 +14,7 @@ import("//build_overrides/chip.gni") -import("${chip_root}/build/tests.gni") +import("//build/tests.gni") assert(chip_build_tests) diff --git a/build/chip_test_suite.gni b/gn/build/chip_test_suite.gni similarity index 95% rename from build/chip_test_suite.gni rename to gn/build/chip_test_suite.gni index b38083510b7290..42e1ba14db5836 100644 --- a/build/chip_test_suite.gni +++ b/gn/build/chip_test_suite.gni @@ -14,8 +14,8 @@ import("//build_overrides/chip.gni") -import("${chip_root}/build/chip_test.gni") -import("${chip_root}/build/tests.gni") +import("//build/chip_test.gni") +import("//build/tests.gni") import("${dir_pw_unit_test}/test.gni") assert(chip_build_tests) diff --git a/build/chip_version.gni b/gn/build/chip_version.gni similarity index 100% rename from build/chip_version.gni rename to gn/build/chip_version.gni diff --git a/build/config/BUILDCONFIG.gn b/gn/build/config/BUILDCONFIG.gn similarity index 100% rename from build/config/BUILDCONFIG.gn rename to gn/build/config/BUILDCONFIG.gn diff --git a/build/config/arm.gni b/gn/build/config/arm.gni similarity index 100% rename from build/config/arm.gni rename to gn/build/config/arm.gni diff --git a/build/config/compiler/BUILD.gn b/gn/build/config/compiler/BUILD.gn similarity index 98% rename from build/config/compiler/BUILD.gn rename to gn/build/config/compiler/BUILD.gn index 88b2144ff78dd3..fc50a216ab1d19 100644 --- a/build/config/compiler/BUILD.gn +++ b/gn/build/config/compiler/BUILD.gn @@ -18,7 +18,7 @@ import("//build_overrides/pigweed.gni") import("//build/config/compiler/compiler.gni") if (current_cpu == "arm") { - import("${chip_root}/build/config/arm.gni") + import("//build/config/arm.gni") } config("release") { diff --git a/build/config/compiler/compiler.gni b/gn/build/config/compiler/compiler.gni similarity index 100% rename from build/config/compiler/compiler.gni rename to gn/build/config/compiler/compiler.gni diff --git a/build/config/custom_toolchain.gni b/gn/build/config/custom_toolchain.gni similarity index 100% rename from build/config/custom_toolchain.gni rename to gn/build/config/custom_toolchain.gni diff --git a/build/config/defaults.gni b/gn/build/config/defaults.gni similarity index 60% rename from build/config/defaults.gni rename to gn/build/config/defaults.gni index 4f1dba4bce0470..cf0447900e9a70 100644 --- a/build/config/defaults.gni +++ b/gn/build/config/defaults.gni @@ -19,64 +19,55 @@ import("//build/config/custom_toolchain.gni") declare_args() { # Default configs for abi. - default_configs_abi = [ "${chip_root}/build/config/compiler:abi_default" ] + default_configs_abi = [ "//build/config/compiler:abi_default" ] # Default configs for debugging. - default_configs_debug = [ "${chip_root}/build/config/compiler:debug_default" ] + default_configs_debug = [ "//build/config/compiler:debug_default" ] # Default configs for specs. - default_configs_specs = [ "${chip_root}/build/config/compiler:specs_default" ] + default_configs_specs = [ "//build/config/compiler:specs_default" ] # Default configs for optimization. - default_configs_optimize = - [ "${chip_root}/build/config/compiler:optimize_default" ] + default_configs_optimize = [ "//build/config/compiler:optimize_default" ] # Default configs for language. - default_configs_std = [ "${chip_root}/build/config/compiler:std_default" ] + default_configs_std = [ "//build/config/compiler:std_default" ] # Defaults configs for symbols. - default_configs_symbols = - [ "${chip_root}/build/config/compiler:symbols_default" ] + default_configs_symbols = [ "//build/config/compiler:symbols_default" ] # Defaults configs for aliasing. - default_configs_aliasing = - [ "${chip_root}/build/config/compiler:aliasing_default" ] + default_configs_aliasing = [ "//build/config/compiler:aliasing_default" ] # Defaults configs for size. - default_configs_size = [ "${chip_root}/build/config/compiler:size_default" ] + default_configs_size = [ "//build/config/compiler:size_default" ] # Defaults configs for exceptions. - default_configs_exceptions = - [ "${chip_root}/build/config/compiler:exceptions_default" ] + default_configs_exceptions = [ "//build/config/compiler:exceptions_default" ] # Defaults configs for rtti. - default_configs_rtti = [ "${chip_root}/build/config/compiler:rtti_default" ] + default_configs_rtti = [ "//build/config/compiler:rtti_default" ] # Defaults configs for pic. - default_configs_pic = [ "${chip_root}/build/config/compiler:pic_default" ] + default_configs_pic = [ "//build/config/compiler:pic_default" ] # Defaults configs for pie. - default_configs_pie = [ "${chip_root}/build/config/compiler:pie_default" ] + default_configs_pie = [ "//build/config/compiler:pie_default" ] # Defaults configs for warnings. - default_configs_warnings = - [ "${chip_root}/build/config/compiler:warnings_default" ] + default_configs_warnings = [ "//build/config/compiler:warnings_default" ] # Defaults cosmetic configs. - default_configs_cosmetic = - [ "${chip_root}/build/config/compiler:cosmetic_default" ] + default_configs_cosmetic = [ "//build/config/compiler:cosmetic_default" ] # Default configs for runtime library. - default_configs_runtime = - [ "${chip_root}/build/config/compiler:runtime_default" ] + default_configs_runtime = [ "//build/config/compiler:runtime_default" ] # Defaults sanitizer configs. - default_configs_sanitize = - [ "${chip_root}/build/config/compiler:sanitize_default" ] + default_configs_sanitize = [ "//build/config/compiler:sanitize_default" ] # Defaults fuzzing configs. - default_configs_fuzzing = - [ "${chip_root}/build/config/compiler:fuzzing_default" ] + default_configs_fuzzing = [ "//build/config/compiler:fuzzing_default" ] # Extra default configs. default_configs_extra = [] diff --git a/build/config/linux/pkg-config.py b/gn/build/config/linux/pkg-config.py similarity index 100% rename from build/config/linux/pkg-config.py rename to gn/build/config/linux/pkg-config.py diff --git a/build/config/linux/pkg_config.gni b/gn/build/config/linux/pkg_config.gni similarity index 100% rename from build/config/linux/pkg_config.gni rename to gn/build/config/linux/pkg_config.gni diff --git a/build/device.gni b/gn/build/device.gni similarity index 100% rename from build/device.gni rename to gn/build/device.gni diff --git a/build/tests.gni b/gn/build/tests.gni similarity index 100% rename from build/tests.gni rename to gn/build/tests.gni diff --git a/build/toolchain/arm_gcc/BUILD.gn b/gn/build/toolchain/arm_gcc/BUILD.gn similarity index 100% rename from build/toolchain/arm_gcc/BUILD.gn rename to gn/build/toolchain/arm_gcc/BUILD.gn diff --git a/build/toolchain/arm_gcc/arm_toolchain.gni b/gn/build/toolchain/arm_gcc/arm_toolchain.gni similarity index 100% rename from build/toolchain/arm_gcc/arm_toolchain.gni rename to gn/build/toolchain/arm_gcc/arm_toolchain.gni diff --git a/build/toolchain/host_clang/BUILD.gn b/gn/build/toolchain/host_clang/BUILD.gn similarity index 100% rename from build/toolchain/host_clang/BUILD.gn rename to gn/build/toolchain/host_clang/BUILD.gn diff --git a/build/toolchain/host_clang/toolchains.gni b/gn/build/toolchain/host_clang/toolchains.gni similarity index 100% rename from build/toolchain/host_clang/toolchains.gni rename to gn/build/toolchain/host_clang/toolchains.gni diff --git a/build/toolchain/host_gcc/BUILD.gn b/gn/build/toolchain/host_gcc/BUILD.gn similarity index 100% rename from build/toolchain/host_gcc/BUILD.gn rename to gn/build/toolchain/host_gcc/BUILD.gn diff --git a/build/toolchain/host_gcc/toolchains.gni b/gn/build/toolchain/host_gcc/toolchains.gni similarity index 100% rename from build/toolchain/host_gcc/toolchains.gni rename to gn/build/toolchain/host_gcc/toolchains.gni diff --git a/build/tools.gni b/gn/build/tools.gni similarity index 100% rename from build/tools.gni rename to gn/build/tools.gni diff --git a/build_overrides/chip.gni b/gn/build_overrides/chip.gni similarity index 100% rename from build_overrides/chip.gni rename to gn/build_overrides/chip.gni diff --git a/build_overrides/lwip.gni b/gn/build_overrides/lwip.gni similarity index 100% rename from build_overrides/lwip.gni rename to gn/build_overrides/lwip.gni diff --git a/build_overrides/mbedtls.gni b/gn/build_overrides/mbedtls.gni similarity index 100% rename from build_overrides/mbedtls.gni rename to gn/build_overrides/mbedtls.gni diff --git a/build_overrides/nlassert.gni b/gn/build_overrides/nlassert.gni similarity index 100% rename from build_overrides/nlassert.gni rename to gn/build_overrides/nlassert.gni diff --git a/build_overrides/nlfaultinjection.gni b/gn/build_overrides/nlfaultinjection.gni similarity index 100% rename from build_overrides/nlfaultinjection.gni rename to gn/build_overrides/nlfaultinjection.gni diff --git a/build_overrides/nlio.gni b/gn/build_overrides/nlio.gni similarity index 100% rename from build_overrides/nlio.gni rename to gn/build_overrides/nlio.gni diff --git a/build_overrides/nlunit_test.gni b/gn/build_overrides/nlunit_test.gni similarity index 100% rename from build_overrides/nlunit_test.gni rename to gn/build_overrides/nlunit_test.gni diff --git a/build_overrides/nrf5_lock_app.gni b/gn/build_overrides/nrf5_lock_app.gni similarity index 100% rename from build_overrides/nrf5_lock_app.gni rename to gn/build_overrides/nrf5_lock_app.gni diff --git a/build_overrides/nrf5_sdk.gni b/gn/build_overrides/nrf5_sdk.gni similarity index 100% rename from build_overrides/nrf5_sdk.gni rename to gn/build_overrides/nrf5_sdk.gni diff --git a/build_overrides/pigweed.gni b/gn/build_overrides/pigweed.gni similarity index 100% rename from build_overrides/pigweed.gni rename to gn/build_overrides/pigweed.gni diff --git a/src/app/plugin/tests/BUILD.gn b/src/app/plugin/tests/BUILD.gn index 9ff0adff7349a9..aab73f9b2bfb6d 100644 --- a/src/app/plugin/tests/BUILD.gn +++ b/src/app/plugin/tests/BUILD.gn @@ -15,7 +15,7 @@ import("//build_overrides/chip.gni") import("//build_overrides/nlunit_test.gni") -import("${chip_root}/build/chip_test_suite.gni") +import("//build/chip_test_suite.gni") chip_test_suite("tests") { output_name = "libChipZclUnitTests" diff --git a/src/ble/tests/BUILD.gn b/src/ble/tests/BUILD.gn index 6b38937a04263d..5457098420d64b 100644 --- a/src/ble/tests/BUILD.gn +++ b/src/ble/tests/BUILD.gn @@ -15,7 +15,7 @@ import("//build_overrides/chip.gni") import("//build_overrides/nlunit_test.gni") -import("${chip_root}/build/chip_test_suite.gni") +import("//build/chip_test_suite.gni") chip_test_suite("tests") { output_name = "libBleLayerTests" diff --git a/src/crypto/tests/BUILD.gn b/src/crypto/tests/BUILD.gn index c923aa2f4ac879..fbc028aec45316 100644 --- a/src/crypto/tests/BUILD.gn +++ b/src/crypto/tests/BUILD.gn @@ -15,7 +15,7 @@ import("//build_overrides/chip.gni") import("//build_overrides/nlunit_test.gni") -import("${chip_root}/build/chip_test_suite.gni") +import("//build/chip_test_suite.gni") chip_test_suite("tests") { output_name = "libChipCrypto" diff --git a/src/inet/BUILD.gn b/src/inet/BUILD.gn index 262ae03cb55970..eb0cee2ae96404 100644 --- a/src/inet/BUILD.gn +++ b/src/inet/BUILD.gn @@ -17,7 +17,7 @@ import("//build_overrides/nlassert.gni") import("//build_overrides/nlfaultinjection.gni") import("//build_overrides/nlio.gni") -import("${chip_root}/build/tests.gni") +import("//build/tests.gni") import("inet.gni") declare_args() { diff --git a/src/inet/tests/BUILD.gn b/src/inet/tests/BUILD.gn index a598a9849b3f35..5df392fbdb0ef8 100644 --- a/src/inet/tests/BUILD.gn +++ b/src/inet/tests/BUILD.gn @@ -15,7 +15,7 @@ import("//build_overrides/chip.gni") import("//build_overrides/nlunit_test.gni") -import("${chip_root}/build/chip_test_suite.gni") +import("//build/chip_test_suite.gni") config("tests_config") { include_dirs = [ "." ] diff --git a/src/lib/core/BUILD.gn b/src/lib/core/BUILD.gn index f4f2175ca84418..a3b69b7630d9d4 100644 --- a/src/lib/core/BUILD.gn +++ b/src/lib/core/BUILD.gn @@ -15,7 +15,7 @@ import("//build_overrides/chip.gni") import("//build_overrides/nlio.gni") -import("${chip_root}/build/tests.gni") +import("//build/tests.gni") import("${chip_root}/src/inet/inet.gni") import("core.gni") diff --git a/src/lib/core/tests/BUILD.gn b/src/lib/core/tests/BUILD.gn index e63d57f3e1da45..486d4598fc9afe 100644 --- a/src/lib/core/tests/BUILD.gn +++ b/src/lib/core/tests/BUILD.gn @@ -15,7 +15,7 @@ import("//build_overrides/chip.gni") import("//build_overrides/nlunit_test.gni") -import("${chip_root}/build/chip_test_suite.gni") +import("//build/chip_test_suite.gni") chip_test_suite("tests") { output_name = "libCoreTests" diff --git a/src/lib/support/BUILD.gn b/src/lib/support/BUILD.gn index 7eb355184d0d01..444eca5c8518c3 100644 --- a/src/lib/support/BUILD.gn +++ b/src/lib/support/BUILD.gn @@ -17,8 +17,8 @@ import("//build_overrides/nlassert.gni") import("//build_overrides/nlfaultinjection.gni") import("//build_overrides/nlio.gni") -import("${chip_root}/build/chip_version.gni") -import("${chip_root}/build/tests.gni") +import("//build/chip_version.gni") +import("//build/tests.gni") action("gen_chip_version") { script = "${chip_root}/scripts/gen_chip_version.py" diff --git a/src/lib/support/tests/BUILD.gn b/src/lib/support/tests/BUILD.gn index ce1d78c3594f1c..24891da4eca8b8 100644 --- a/src/lib/support/tests/BUILD.gn +++ b/src/lib/support/tests/BUILD.gn @@ -15,7 +15,7 @@ import("//build_overrides/chip.gni") import("//build_overrides/nlunit_test.gni") -import("${chip_root}/build/chip_test_suite.gni") +import("//build/chip_test_suite.gni") chip_test_suite("tests") { output_name = "libSupportTests" diff --git a/src/lwip/tests/BUILD.gn b/src/lwip/tests/BUILD.gn index 18ddbd07e5ed8b..999ab150d21bc8 100644 --- a/src/lwip/tests/BUILD.gn +++ b/src/lwip/tests/BUILD.gn @@ -14,8 +14,8 @@ import("//build_overrides/chip.gni") -import("${chip_root}/build/chip_test.gni") -import("${chip_root}/build/chip_test_group.gni") +import("//build/chip_test.gni") +import("//build/chip_test_group.gni") chip_test("TestLwIP") { sources = [ "tests.c" ] diff --git a/src/platform/BUILD.gn b/src/platform/BUILD.gn index 072e713d158315..7f2c14db9cb6d0 100644 --- a/src/platform/BUILD.gn +++ b/src/platform/BUILD.gn @@ -15,7 +15,7 @@ import("//build_overrides/chip.gni") import("//build_overrides/nlio.gni") -import("${chip_root}/build/device.gni") +import("//build/device.gni") if (device_platform != "none") { declare_args() { diff --git a/src/qrcodetool/BUILD.gn b/src/qrcodetool/BUILD.gn index 0b033c86d217fc..d46177a7bb0721 100644 --- a/src/qrcodetool/BUILD.gn +++ b/src/qrcodetool/BUILD.gn @@ -14,7 +14,7 @@ import("//build_overrides/chip.gni") -import("${chip_root}/build/tools.gni") +import("//build/tools.gni") assert(chip_build_tools) diff --git a/src/setup_payload/tests/BUILD.gn b/src/setup_payload/tests/BUILD.gn index 61121990eeef7f..aa2c92b6be06ba 100644 --- a/src/setup_payload/tests/BUILD.gn +++ b/src/setup_payload/tests/BUILD.gn @@ -15,7 +15,7 @@ import("//build_overrides/chip.gni") import("//build_overrides/nlunit_test.gni") -import("${chip_root}/build/chip_test_suite.gni") +import("//build/chip_test_suite.gni") chip_test_suite("tests") { output_name = "libSetupPayloadTests" diff --git a/src/system/BUILD.gn b/src/system/BUILD.gn index 3f7116ec88a9a8..046aa3fbd1cff7 100644 --- a/src/system/BUILD.gn +++ b/src/system/BUILD.gn @@ -16,7 +16,7 @@ import("//build_overrides/chip.gni") import("//build_overrides/nlassert.gni") import("//build_overrides/nlfaultinjection.gni") -import("${chip_root}/build/tests.gni") +import("//build/tests.gni") import("system.gni") declare_args() { diff --git a/src/system/tests/BUILD.gn b/src/system/tests/BUILD.gn index fad435c8a30e77..567ba004f40117 100644 --- a/src/system/tests/BUILD.gn +++ b/src/system/tests/BUILD.gn @@ -15,7 +15,7 @@ import("//build_overrides/chip.gni") import("//build_overrides/nlunit_test.gni") -import("${chip_root}/build/chip_test_suite.gni") +import("//build/chip_test_suite.gni") chip_test_suite("tests") { output_name = "libSystemLayerTests" diff --git a/src/transport/tests/BUILD.gn b/src/transport/tests/BUILD.gn index 1ec6eddfcd5b09..226e8733fa3fb9 100644 --- a/src/transport/tests/BUILD.gn +++ b/src/transport/tests/BUILD.gn @@ -16,7 +16,7 @@ import("//build_overrides/chip.gni") import("//build_overrides/nlio.gni") import("//build_overrides/nlunit_test.gni") -import("${chip_root}/build/chip_test_suite.gni") +import("//build/chip_test_suite.gni") chip_test_suite("tests") { output_name = "libTransportLayerTests" From 714180c3189388787929cbdc11642f39e15ca872 Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Tue, 7 Jul 2020 16:44:47 -0400 Subject: [PATCH 50/59] Fix lint warning "Except block directly handles BaseException" --- gn/build/config/linux/pkg-config.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gn/build/config/linux/pkg-config.py b/gn/build/config/linux/pkg-config.py index f0289cfc08909a..1adbb520c83718 100755 --- a/gn/build/config/linux/pkg-config.py +++ b/gn/build/config/linux/pkg-config.py @@ -177,7 +177,7 @@ def main(): cmd = [options.pkg_config, "--modversion"] + args try: version_string = subprocess.check_output(cmd).decode('utf-8') - except: + except Exception: sys.stderr.write('Error from pkg-config.\n') return 1 print(json.dumps(list(map(int, version_string.strip().split("."))))) @@ -190,7 +190,7 @@ def main(): sys.stderr.write('Running: %s\n' % cmd) try: libdir = subprocess.check_output(cmd).decode('utf-8') - except: + except Exception: print("Error from pkg-config.") return 1 sys.stdout.write(libdir.strip()) @@ -202,7 +202,7 @@ def main(): sys.stderr.write('Running: %s\n' % cmd) try: dridriverdir = subprocess.check_output(cmd).decode('utf-8') - except: + except Exception: print("Error from pkg-config.") return 1 sys.stdout.write(dridriverdir.strip()) @@ -214,7 +214,7 @@ def main(): try: flag_string = subprocess.check_output(cmd).decode('utf-8') - except: + except Exception: sys.stderr.write('Could not run pkg-config.\n') return 1 From 2a2d95f6591c5cfb5e5fc259f2761fe7d69387d5 Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Tue, 7 Jul 2020 17:04:48 -0400 Subject: [PATCH 51/59] Move activate above bootstrap The usual case is to source activate.sh, not bootstrap.sh, so move that first. bootstrap.sh is only needed after an update. --- gn_build.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gn_build.sh b/gn_build.sh index 59aa9109e37b2d..a5c7708a351eaf 100755 --- a/gn_build.sh +++ b/gn_build.sh @@ -57,13 +57,13 @@ _chip_banner "Build: Ninja build" time ninja -C "$CHIP_ROOT/out/debug" check echo -echo 'To re-bootstrap build environment in your shell, run:' -echo source "$CHIP_ROOT/bootstrap.sh" -echo - echo 'To activate existing build environment in your shell, run (do this first):' echo source "$CHIP_ROOT/activate.sh" +echo +echo 'To re-create the build environment from scratch, run:' +echo source "$CHIP_ROOT/bootstrap.sh" + echo echo 'To build a debug build:' echo gn gen "$CHIP_ROOT/out/debug" --args=\''target_os="all"'"$extra_args"\' From b190e780b9be60e833b759eaa6ef98148e5fb851 Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Tue, 7 Jul 2020 17:44:21 -0400 Subject: [PATCH 52/59] Add github actions for GN --- .github/workflows/gn_build.yaml | 48 +++++++++++++++++++++++++++ activate.sh | 4 ++- gn/build/config/compiler/compiler.gni | 2 +- scripts/build/gn_bootstrap.sh | 21 ++++++++++++ scripts/build/gn_build.sh | 27 +++++++++++++++ scripts/build/gn_gen.sh | 27 +++++++++++++++ scripts/tests/gn_tests.sh | 27 +++++++++++++++ 7 files changed, 154 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/gn_build.yaml create mode 100755 scripts/build/gn_bootstrap.sh create mode 100755 scripts/build/gn_build.sh create mode 100755 scripts/build/gn_gen.sh create mode 100755 scripts/tests/gn_tests.sh diff --git a/.github/workflows/gn_build.yaml b/.github/workflows/gn_build.yaml new file mode 100644 index 00000000000000..536806976b0314 --- /dev/null +++ b/.github/workflows/gn_build.yaml @@ -0,0 +1,48 @@ +name: GN Builds + +on: + push: + pull_request: + +jobs: + build: + name: GN Build + + strategy: + matrix: + type: [main, clang, mbedtls] + env: + BUILD_TYPE: ${{ matrix.type }} + BUILD_VERSION: 0.2.14 + BUILD_IMAGE: chip-build-openssl + BUILD_ORG: connectedhomeip + + runs-on: ubuntu-latest + + container: + image: "connectedhomeip/chip-build-openssl:0.2.14" + volumes: + - "/tmp/log_output:/tmp/test_logs" + + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Checkout Submodules + run: make -f Makefile-bootstrap repos + - name: Bootstrap + run: scripts/build/gn_bootstrap.sh + - name: Setup Build + run: | + case $BUILD_TYPE in + "main") GN_ARGS='';; + "clang") GN_ARGS='is_clang=true';; + "linux-embedded") GN_ARGS='device_platform="linux"';; + "mbedtls") GN_ARGS='chip_crypto="mbedtls"';; + *) ;; + esac + + scripts/build/gn_gen.sh --args="$GN_ARGS" + - name: Run Build + run: scripts/build/gn_build.sh + - name: Run Tests + run: scripts/tests/gn_tests.sh diff --git a/activate.sh b/activate.sh index 8d65e052abfbe6..10a14c3960248e 100644 --- a/activate.sh +++ b/activate.sh @@ -14,7 +14,9 @@ # limitations under the License. # -CHIP_ROOT="$(dirname "$0")" +if [[ ! -d "${CHIP_ROOT}" ]]; then + CHIP_ROOT="$(dirname "$0")" +fi export PW_BRANDING_BANNER="$CHIP_ROOT/.chip-banner.txt" export PW_BRANDING_BANNER_COLOR="bold_white" diff --git a/gn/build/config/compiler/compiler.gni b/gn/build/config/compiler/compiler.gni index b03ea48a00f3cd..d71408442321e6 100644 --- a/gn/build/config/compiler/compiler.gni +++ b/gn/build/config/compiler/compiler.gni @@ -14,7 +14,7 @@ declare_args() { # Use clang to build. - is_clang = current_os != "freertos" + is_clang = false # Optimize for size by default. optimize_for_size = true diff --git a/scripts/build/gn_bootstrap.sh b/scripts/build/gn_bootstrap.sh new file mode 100755 index 00000000000000..03b64ee416cf23 --- /dev/null +++ b/scripts/build/gn_bootstrap.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +# +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +CHIP_ROOT="$(dirname "$0")/../.." + +source "$CHIP_ROOT/activate.sh" diff --git a/scripts/build/gn_build.sh b/scripts/build/gn_build.sh new file mode 100755 index 00000000000000..16bc22f34e1ce5 --- /dev/null +++ b/scripts/build/gn_build.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +# +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +CHIP_ROOT="$(dirname "$0")/../.." + +source "$CHIP_ROOT/activate.sh" + +set -e +set -x +env + +ninja -v -C "$CHIP_ROOT/out/$BUILD_TYPE" diff --git a/scripts/build/gn_gen.sh b/scripts/build/gn_gen.sh new file mode 100755 index 00000000000000..1c7a3cd1881924 --- /dev/null +++ b/scripts/build/gn_gen.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +# +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +CHIP_ROOT="$(dirname "$0")/../.." + +source "$CHIP_ROOT/activate.sh" + +set -e +set -x +env + +gn --root="$CHIP_ROOT" gen --check "$CHIP_ROOT/out/$BUILD_TYPE" "$@" diff --git a/scripts/tests/gn_tests.sh b/scripts/tests/gn_tests.sh new file mode 100755 index 00000000000000..ad63960a9cda68 --- /dev/null +++ b/scripts/tests/gn_tests.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +# +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +CHIP_ROOT="$(dirname "$0")/../.." + +source "$CHIP_ROOT/activate.sh" + +set -e +set -x +env + +ninja -v -C "$CHIP_ROOT/out/$BUILD_TYPE" check From 68257307764efad3724afb7f1464f6f706b39850 Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Tue, 7 Jul 2020 22:22:33 -0400 Subject: [PATCH 53/59] Move project specific build logic to gn/chip --- BUILD.gn | 8 ++++---- examples/chip-tool/BUILD.gn | 2 +- examples/shell/BUILD.gn | 2 +- gn/{build => chip}/chip_build.gni | 2 +- gn/{build => chip}/chip_test.gni | 2 +- gn/{build => chip}/chip_test_group.gni | 2 +- gn/{build => chip}/chip_test_suite.gni | 4 ++-- gn/{build => chip}/chip_version.gni | 0 gn/{build => chip}/device.gni | 0 gn/{build => chip}/tests.gni | 0 gn/{build => chip}/tools.gni | 0 src/app/plugin/tests/BUILD.gn | 2 +- src/ble/tests/BUILD.gn | 2 +- src/crypto/tests/BUILD.gn | 2 +- src/inet/BUILD.gn | 2 +- src/inet/tests/BUILD.gn | 2 +- src/lib/core/BUILD.gn | 2 +- src/lib/core/tests/BUILD.gn | 2 +- src/lib/support/BUILD.gn | 4 ++-- src/lib/support/tests/BUILD.gn | 2 +- src/lwip/tests/BUILD.gn | 4 ++-- src/platform/BUILD.gn | 2 +- src/qrcodetool/BUILD.gn | 2 +- src/setup_payload/tests/BUILD.gn | 2 +- src/system/BUILD.gn | 2 +- src/system/tests/BUILD.gn | 2 +- src/transport/tests/BUILD.gn | 2 +- 27 files changed, 29 insertions(+), 29 deletions(-) rename gn/{build => chip}/chip_build.gni (95%) rename gn/{build => chip}/chip_test.gni (97%) rename gn/{build => chip}/chip_test_group.gni (95%) rename gn/{build => chip}/chip_test_suite.gni (95%) rename gn/{build => chip}/chip_version.gni (100%) rename gn/{build => chip}/device.gni (100%) rename gn/{build => chip}/tests.gni (100%) rename gn/{build => chip}/tools.gni (100%) diff --git a/BUILD.gn b/BUILD.gn index 64ac63e9752c88..76facff41b6d78 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -22,8 +22,8 @@ import("//build_overrides/pigweed.gni") # This build file should not be used in superproject builds. assert(chip_root == "//") -import("//build/tests.gni") -import("//build/tools.gni") +import("${chip_root}/gn/chip/tests.gni") +import("${chip_root}/gn/chip/tools.gni") if (current_toolchain != "${dir_pw_toolchain}/dummy:dummy") { # This is a real toolchain. Build CHIP. @@ -66,7 +66,7 @@ if (current_toolchain != "${dir_pw_toolchain}/dummy:dummy") { } if (chip_build_tests) { - import("//build/chip_test_group.gni") + import("${chip_root}/gn/chip/chip_test_group.gni") chip_test_group("tests") { deps = [ @@ -89,7 +89,7 @@ if (current_toolchain != "${dir_pw_toolchain}/dummy:dummy") { } } else { # This is the dummy toolchain. Configure various real toolchains. - import("//build/chip_build.gni") + import("${chip_root}/gn/chip/chip_build.gni") declare_args() { # Set this to false to disable all builds by default. enable_default_builds = true diff --git a/examples/chip-tool/BUILD.gn b/examples/chip-tool/BUILD.gn index c6a6bbe6f1a38d..c935610a527f00 100644 --- a/examples/chip-tool/BUILD.gn +++ b/examples/chip-tool/BUILD.gn @@ -14,7 +14,7 @@ import("//build_overrides/chip.gni") -import("//build/tools.gni") +import("${chip_root}/gn/chip/tools.gni") assert(chip_build_tools) diff --git a/examples/shell/BUILD.gn b/examples/shell/BUILD.gn index e6c7dbcf4e7788..da409f3c0e9c0e 100644 --- a/examples/shell/BUILD.gn +++ b/examples/shell/BUILD.gn @@ -14,7 +14,7 @@ import("//build_overrides/chip.gni") -import("//build/tools.gni") +import("${chip_root}/gn/chip/tools.gni") assert(chip_build_tools) diff --git a/gn/build/chip_build.gni b/gn/chip/chip_build.gni similarity index 95% rename from gn/build/chip_build.gni rename to gn/chip/chip_build.gni index 786989fdcbe90d..3b46a74fb574f1 100644 --- a/gn/build/chip_build.gni +++ b/gn/chip/chip_build.gni @@ -14,7 +14,7 @@ import("//build_overrides/chip.gni") -import("//build/tests.gni") +import("${chip_root}/gn/chip/tests.gni") template("chip_build") { _build_name = target_name diff --git a/gn/build/chip_test.gni b/gn/chip/chip_test.gni similarity index 97% rename from gn/build/chip_test.gni rename to gn/chip/chip_test.gni index b739aa3e915a05..7650782dc67d5a 100644 --- a/gn/build/chip_test.gni +++ b/gn/chip/chip_test.gni @@ -15,7 +15,7 @@ import("//build_overrides/chip.gni") import("//build_overrides/pigweed.gni") -import("//build/tests.gni") +import("${chip_root}/gn/chip/tests.gni") import("${dir_pw_unit_test}/test.gni") assert(chip_build_tests) diff --git a/gn/build/chip_test_group.gni b/gn/chip/chip_test_group.gni similarity index 95% rename from gn/build/chip_test_group.gni rename to gn/chip/chip_test_group.gni index b6b3c5e9dc21c9..dd7bf31d3471db 100644 --- a/gn/build/chip_test_group.gni +++ b/gn/chip/chip_test_group.gni @@ -14,7 +14,7 @@ import("//build_overrides/chip.gni") -import("//build/tests.gni") +import("${chip_root}/gn/chip/tests.gni") assert(chip_build_tests) diff --git a/gn/build/chip_test_suite.gni b/gn/chip/chip_test_suite.gni similarity index 95% rename from gn/build/chip_test_suite.gni rename to gn/chip/chip_test_suite.gni index 42e1ba14db5836..dc7d0cd3c4a6e3 100644 --- a/gn/build/chip_test_suite.gni +++ b/gn/chip/chip_test_suite.gni @@ -14,8 +14,8 @@ import("//build_overrides/chip.gni") -import("//build/chip_test.gni") -import("//build/tests.gni") +import("${chip_root}/gn/chip/chip_test.gni") +import("${chip_root}/gn/chip/tests.gni") import("${dir_pw_unit_test}/test.gni") assert(chip_build_tests) diff --git a/gn/build/chip_version.gni b/gn/chip/chip_version.gni similarity index 100% rename from gn/build/chip_version.gni rename to gn/chip/chip_version.gni diff --git a/gn/build/device.gni b/gn/chip/device.gni similarity index 100% rename from gn/build/device.gni rename to gn/chip/device.gni diff --git a/gn/build/tests.gni b/gn/chip/tests.gni similarity index 100% rename from gn/build/tests.gni rename to gn/chip/tests.gni diff --git a/gn/build/tools.gni b/gn/chip/tools.gni similarity index 100% rename from gn/build/tools.gni rename to gn/chip/tools.gni diff --git a/src/app/plugin/tests/BUILD.gn b/src/app/plugin/tests/BUILD.gn index aab73f9b2bfb6d..515dc51e2681ff 100644 --- a/src/app/plugin/tests/BUILD.gn +++ b/src/app/plugin/tests/BUILD.gn @@ -15,7 +15,7 @@ import("//build_overrides/chip.gni") import("//build_overrides/nlunit_test.gni") -import("//build/chip_test_suite.gni") +import("${chip_root}/gn/chip/chip_test_suite.gni") chip_test_suite("tests") { output_name = "libChipZclUnitTests" diff --git a/src/ble/tests/BUILD.gn b/src/ble/tests/BUILD.gn index 5457098420d64b..30fa07a35c2acc 100644 --- a/src/ble/tests/BUILD.gn +++ b/src/ble/tests/BUILD.gn @@ -15,7 +15,7 @@ import("//build_overrides/chip.gni") import("//build_overrides/nlunit_test.gni") -import("//build/chip_test_suite.gni") +import("${chip_root}/gn/chip/chip_test_suite.gni") chip_test_suite("tests") { output_name = "libBleLayerTests" diff --git a/src/crypto/tests/BUILD.gn b/src/crypto/tests/BUILD.gn index fbc028aec45316..f6b83d3c1b38b1 100644 --- a/src/crypto/tests/BUILD.gn +++ b/src/crypto/tests/BUILD.gn @@ -15,7 +15,7 @@ import("//build_overrides/chip.gni") import("//build_overrides/nlunit_test.gni") -import("//build/chip_test_suite.gni") +import("${chip_root}/gn/chip/chip_test_suite.gni") chip_test_suite("tests") { output_name = "libChipCrypto" diff --git a/src/inet/BUILD.gn b/src/inet/BUILD.gn index eb0cee2ae96404..443a9be9dd67ac 100644 --- a/src/inet/BUILD.gn +++ b/src/inet/BUILD.gn @@ -17,7 +17,7 @@ import("//build_overrides/nlassert.gni") import("//build_overrides/nlfaultinjection.gni") import("//build_overrides/nlio.gni") -import("//build/tests.gni") +import("${chip_root}/gn/chip/tests.gni") import("inet.gni") declare_args() { diff --git a/src/inet/tests/BUILD.gn b/src/inet/tests/BUILD.gn index 5df392fbdb0ef8..fe968dbea03dde 100644 --- a/src/inet/tests/BUILD.gn +++ b/src/inet/tests/BUILD.gn @@ -15,7 +15,7 @@ import("//build_overrides/chip.gni") import("//build_overrides/nlunit_test.gni") -import("//build/chip_test_suite.gni") +import("${chip_root}/gn/chip/chip_test_suite.gni") config("tests_config") { include_dirs = [ "." ] diff --git a/src/lib/core/BUILD.gn b/src/lib/core/BUILD.gn index a3b69b7630d9d4..0d9d6c8830865b 100644 --- a/src/lib/core/BUILD.gn +++ b/src/lib/core/BUILD.gn @@ -15,7 +15,7 @@ import("//build_overrides/chip.gni") import("//build_overrides/nlio.gni") -import("//build/tests.gni") +import("${chip_root}/gn/chip/tests.gni") import("${chip_root}/src/inet/inet.gni") import("core.gni") diff --git a/src/lib/core/tests/BUILD.gn b/src/lib/core/tests/BUILD.gn index 486d4598fc9afe..06951cfe708f55 100644 --- a/src/lib/core/tests/BUILD.gn +++ b/src/lib/core/tests/BUILD.gn @@ -15,7 +15,7 @@ import("//build_overrides/chip.gni") import("//build_overrides/nlunit_test.gni") -import("//build/chip_test_suite.gni") +import("${chip_root}/gn/chip/chip_test_suite.gni") chip_test_suite("tests") { output_name = "libCoreTests" diff --git a/src/lib/support/BUILD.gn b/src/lib/support/BUILD.gn index 444eca5c8518c3..35c112f099cd49 100644 --- a/src/lib/support/BUILD.gn +++ b/src/lib/support/BUILD.gn @@ -17,8 +17,8 @@ import("//build_overrides/nlassert.gni") import("//build_overrides/nlfaultinjection.gni") import("//build_overrides/nlio.gni") -import("//build/chip_version.gni") -import("//build/tests.gni") +import("${chip_root}/gn/chip/chip_version.gni") +import("${chip_root}/gn/chip/tests.gni") action("gen_chip_version") { script = "${chip_root}/scripts/gen_chip_version.py" diff --git a/src/lib/support/tests/BUILD.gn b/src/lib/support/tests/BUILD.gn index 24891da4eca8b8..90913791da52f5 100644 --- a/src/lib/support/tests/BUILD.gn +++ b/src/lib/support/tests/BUILD.gn @@ -15,7 +15,7 @@ import("//build_overrides/chip.gni") import("//build_overrides/nlunit_test.gni") -import("//build/chip_test_suite.gni") +import("${chip_root}/gn/chip/chip_test_suite.gni") chip_test_suite("tests") { output_name = "libSupportTests" diff --git a/src/lwip/tests/BUILD.gn b/src/lwip/tests/BUILD.gn index 999ab150d21bc8..32a3bd9bd714de 100644 --- a/src/lwip/tests/BUILD.gn +++ b/src/lwip/tests/BUILD.gn @@ -14,8 +14,8 @@ import("//build_overrides/chip.gni") -import("//build/chip_test.gni") -import("//build/chip_test_group.gni") +import("${chip_root}/gn/chip/chip_test.gni") +import("${chip_root}/gn/chip/chip_test_group.gni") chip_test("TestLwIP") { sources = [ "tests.c" ] diff --git a/src/platform/BUILD.gn b/src/platform/BUILD.gn index 7f2c14db9cb6d0..440a748c0b915b 100644 --- a/src/platform/BUILD.gn +++ b/src/platform/BUILD.gn @@ -15,7 +15,7 @@ import("//build_overrides/chip.gni") import("//build_overrides/nlio.gni") -import("//build/device.gni") +import("${chip_root}/gn/chip/device.gni") if (device_platform != "none") { declare_args() { diff --git a/src/qrcodetool/BUILD.gn b/src/qrcodetool/BUILD.gn index d46177a7bb0721..455f6c6fc7aa24 100644 --- a/src/qrcodetool/BUILD.gn +++ b/src/qrcodetool/BUILD.gn @@ -14,7 +14,7 @@ import("//build_overrides/chip.gni") -import("//build/tools.gni") +import("${chip_root}/gn/chip/tools.gni") assert(chip_build_tools) diff --git a/src/setup_payload/tests/BUILD.gn b/src/setup_payload/tests/BUILD.gn index aa2c92b6be06ba..a25aab2957ae64 100644 --- a/src/setup_payload/tests/BUILD.gn +++ b/src/setup_payload/tests/BUILD.gn @@ -15,7 +15,7 @@ import("//build_overrides/chip.gni") import("//build_overrides/nlunit_test.gni") -import("//build/chip_test_suite.gni") +import("${chip_root}/gn/chip/chip_test_suite.gni") chip_test_suite("tests") { output_name = "libSetupPayloadTests" diff --git a/src/system/BUILD.gn b/src/system/BUILD.gn index 046aa3fbd1cff7..91436caf0f0147 100644 --- a/src/system/BUILD.gn +++ b/src/system/BUILD.gn @@ -16,7 +16,7 @@ import("//build_overrides/chip.gni") import("//build_overrides/nlassert.gni") import("//build_overrides/nlfaultinjection.gni") -import("//build/tests.gni") +import("${chip_root}/gn/chip/tests.gni") import("system.gni") declare_args() { diff --git a/src/system/tests/BUILD.gn b/src/system/tests/BUILD.gn index 567ba004f40117..c9486e8d69c4eb 100644 --- a/src/system/tests/BUILD.gn +++ b/src/system/tests/BUILD.gn @@ -15,7 +15,7 @@ import("//build_overrides/chip.gni") import("//build_overrides/nlunit_test.gni") -import("//build/chip_test_suite.gni") +import("${chip_root}/gn/chip/chip_test_suite.gni") chip_test_suite("tests") { output_name = "libSystemLayerTests" diff --git a/src/transport/tests/BUILD.gn b/src/transport/tests/BUILD.gn index 226e8733fa3fb9..abf50396256f72 100644 --- a/src/transport/tests/BUILD.gn +++ b/src/transport/tests/BUILD.gn @@ -16,7 +16,7 @@ import("//build_overrides/chip.gni") import("//build_overrides/nlio.gni") import("//build_overrides/nlunit_test.gni") -import("//build/chip_test_suite.gni") +import("${chip_root}/gn/chip/chip_test_suite.gni") chip_test_suite("tests") { output_name = "libTransportLayerTests" From 6658cb2bfae026d550d9c1e16dc5b3f8c77b7326 Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Wed, 8 Jul 2020 14:29:52 -0400 Subject: [PATCH 54/59] Add comments to GN build GitHub workflow helpers --- scripts/build/gn_bootstrap.sh | 5 +++++ scripts/build/gn_build.sh | 2 ++ scripts/build/gn_gen.sh | 2 ++ scripts/tests/gn_tests.sh | 2 ++ 4 files changed, 11 insertions(+) diff --git a/scripts/build/gn_bootstrap.sh b/scripts/build/gn_bootstrap.sh index 03b64ee416cf23..5681ac61ab72ec 100755 --- a/scripts/build/gn_bootstrap.sh +++ b/scripts/build/gn_bootstrap.sh @@ -16,6 +16,11 @@ # limitations under the License. # +# Bootstrap script for GN build GitHub workflow. + +# This is used to account bootstrap time in a dedicated workflow step; there's +# no need to use this script locally. + CHIP_ROOT="$(dirname "$0")/../.." source "$CHIP_ROOT/activate.sh" diff --git a/scripts/build/gn_build.sh b/scripts/build/gn_build.sh index 16bc22f34e1ce5..8609f08c09bc06 100755 --- a/scripts/build/gn_build.sh +++ b/scripts/build/gn_build.sh @@ -16,6 +16,8 @@ # limitations under the License. # +# Build script for GN build GitHub workflow. + CHIP_ROOT="$(dirname "$0")/../.." source "$CHIP_ROOT/activate.sh" diff --git a/scripts/build/gn_gen.sh b/scripts/build/gn_gen.sh index 1c7a3cd1881924..65a8098312b2ad 100755 --- a/scripts/build/gn_gen.sh +++ b/scripts/build/gn_gen.sh @@ -16,6 +16,8 @@ # limitations under the License. # +# GN gen script for GN build GitHub workflow. + CHIP_ROOT="$(dirname "$0")/../.." source "$CHIP_ROOT/activate.sh" diff --git a/scripts/tests/gn_tests.sh b/scripts/tests/gn_tests.sh index ad63960a9cda68..7dd863604d2aca 100755 --- a/scripts/tests/gn_tests.sh +++ b/scripts/tests/gn_tests.sh @@ -16,6 +16,8 @@ # limitations under the License. # +# Test script for GN GitHub workflow. + CHIP_ROOT="$(dirname "$0")/../.." source "$CHIP_ROOT/activate.sh" From 060f322bfbc5cc6d3fa01e76a34fe510eaa9d429 Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Wed, 8 Jul 2020 15:27:04 -0400 Subject: [PATCH 55/59] Fix the nRF5 lock app CI build Remove a broken link that was left behind after moving build files to //gn. --- examples/lock-app/nrf5/build | 1 - 1 file changed, 1 deletion(-) delete mode 120000 examples/lock-app/nrf5/build diff --git a/examples/lock-app/nrf5/build b/examples/lock-app/nrf5/build deleted file mode 120000 index 44735d58664596..00000000000000 --- a/examples/lock-app/nrf5/build +++ /dev/null @@ -1 +0,0 @@ -../../../build \ No newline at end of file From 80cd16bcb3d3aa02a44be59515bfd354f658f9de Mon Sep 17 00:00:00 2001 From: Justin Wood Date: Wed, 8 Jul 2020 12:58:51 -0700 Subject: [PATCH 56/59] Updating Build Version --- .github/workflows/gn_build.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/gn_build.yaml b/.github/workflows/gn_build.yaml index 536806976b0314..94c7fe49e1a04c 100644 --- a/.github/workflows/gn_build.yaml +++ b/.github/workflows/gn_build.yaml @@ -13,14 +13,14 @@ jobs: type: [main, clang, mbedtls] env: BUILD_TYPE: ${{ matrix.type }} - BUILD_VERSION: 0.2.14 + BUILD_VERSION: 0.2.18 BUILD_IMAGE: chip-build-openssl BUILD_ORG: connectedhomeip runs-on: ubuntu-latest container: - image: "connectedhomeip/chip-build-openssl:0.2.14" + image: "connectedhomeip/chip-build-openssl:0.2.18" volumes: - "/tmp/log_output:/tmp/test_logs" From aa9557b78e96cda342e501a425e9aa69a45fe783 Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Wed, 8 Jul 2020 16:18:19 -0400 Subject: [PATCH 57/59] Re-merge repos.conf with .gitmodules This was unmerged by a recent commit. --- .gitmodules | 2 +- repos.conf | 46 +--------------------------------------------- 2 files changed, 2 insertions(+), 46 deletions(-) mode change 100644 => 120000 repos.conf diff --git a/.gitmodules b/.gitmodules index 220f560519b95e..ec96bf28415e29 100644 --- a/.gitmodules +++ b/.gitmodules @@ -52,7 +52,7 @@ branch = master ignore = dirty commit = 5f0e36eeb236a507631e9c822e43f742b7b6738a -[submodule "third_party/ot-br-posix/repo"] +[submodule "ot-br-posix"] path = third_party/ot-br-posix/repo url = https://github.com/openthread/ot-br-posix.git branch = master diff --git a/repos.conf b/repos.conf deleted file mode 100644 index fecf19b5b20739..00000000000000 --- a/repos.conf +++ /dev/null @@ -1,45 +0,0 @@ -[submodule "nlassert"] - path = third_party/nlassert/repo - url = https://github.com/nestlabs/nlassert.git - branch = master - update = none -[submodule "nlfaultinjection"] - path = third_party/nlfaultinjection/repo - url = https://github.com/nestlabs/nlfaultinjection.git - branch = master - update = none -[submodule "nlio"] - path = third_party/nlio/repo - url = https://github.com/nestlabs/nlio.git - branch = master - update = none -[submodule "nlunit-test"] - path = third_party/nlunit-test/repo - url = https://github.com/nestlabs/nlunit-test.git - branch = master - update = none -[submodule "mbedtls"] - path = third_party/mbedtls/repo - url = https://github.com/ARMmbed/mbedtls.git - branch = mbedtls-2.18 - update = none -[submodule "qrcode"] - path = examples/common/QRCode/repo - url = https://github.com/nayuki/QR-Code-generator.git - branch = master - update = none -[submodule "m5stack-tft"] - path = examples/common/m5stack-tft/repo - url = https://github.com/jeremyjh/ESP32_TFT_library.git - branch = master - update = none -[submodule "openthread"] - path = third_party/openthread/repo - url = https://github.com/openthread/openthread.git - branch = master - update = none -[submodule "ot-br-posix"] - path = third_party/ot-br-posix/repo - url = https://github.com/openthread/ot-br-posix.git - branch = master - update = none diff --git a/repos.conf b/repos.conf new file mode 120000 index 00000000000000..7837f9c220680c --- /dev/null +++ b/repos.conf @@ -0,0 +1 @@ +.gitmodules \ No newline at end of file From ca4f91560ea4c1d9fd81bd1db113162710b5b359 Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Wed, 8 Jul 2020 16:44:44 -0400 Subject: [PATCH 58/59] Move bootstrap.sh & activate.sh to scripts --- gn_build.sh | 6 +++--- activate.sh => scripts/activate.sh | 0 bootstrap.sh => scripts/bootstrap.sh | 0 scripts/build/gn_bootstrap.sh | 2 +- scripts/build/gn_build.sh | 2 +- scripts/build/gn_gen.sh | 2 +- scripts/tests/gn_tests.sh | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) rename activate.sh => scripts/activate.sh (100%) rename bootstrap.sh => scripts/bootstrap.sh (100%) diff --git a/gn_build.sh b/gn_build.sh index a5c7708a351eaf..88bd9781f44d0e 100755 --- a/gn_build.sh +++ b/gn_build.sh @@ -36,7 +36,7 @@ _chip_banner "Environment bringup" git -C "$CHIP_ROOT" submodule update --init set +e -source "$CHIP_ROOT/activate.sh" +source "$CHIP_ROOT/scripts/activate.sh" set -e _chip_banner "Build: GN configure" @@ -58,11 +58,11 @@ time ninja -C "$CHIP_ROOT/out/debug" check echo echo 'To activate existing build environment in your shell, run (do this first):' -echo source "$CHIP_ROOT/activate.sh" +echo source "$CHIP_ROOT/scripts/activate.sh" echo echo 'To re-create the build environment from scratch, run:' -echo source "$CHIP_ROOT/bootstrap.sh" +echo source "$CHIP_ROOT/scripts/bootstrap.sh" echo echo 'To build a debug build:' diff --git a/activate.sh b/scripts/activate.sh similarity index 100% rename from activate.sh rename to scripts/activate.sh diff --git a/bootstrap.sh b/scripts/bootstrap.sh similarity index 100% rename from bootstrap.sh rename to scripts/bootstrap.sh diff --git a/scripts/build/gn_bootstrap.sh b/scripts/build/gn_bootstrap.sh index 5681ac61ab72ec..f7a8a0516db4bb 100755 --- a/scripts/build/gn_bootstrap.sh +++ b/scripts/build/gn_bootstrap.sh @@ -23,4 +23,4 @@ CHIP_ROOT="$(dirname "$0")/../.." -source "$CHIP_ROOT/activate.sh" +source "$CHIP_ROOT/scripts/activate.sh" diff --git a/scripts/build/gn_build.sh b/scripts/build/gn_build.sh index 8609f08c09bc06..55f5d81b7a66c0 100755 --- a/scripts/build/gn_build.sh +++ b/scripts/build/gn_build.sh @@ -20,7 +20,7 @@ CHIP_ROOT="$(dirname "$0")/../.." -source "$CHIP_ROOT/activate.sh" +source "$CHIP_ROOT/scripts/activate.sh" set -e set -x diff --git a/scripts/build/gn_gen.sh b/scripts/build/gn_gen.sh index 65a8098312b2ad..1fe94aef334343 100755 --- a/scripts/build/gn_gen.sh +++ b/scripts/build/gn_gen.sh @@ -20,7 +20,7 @@ CHIP_ROOT="$(dirname "$0")/../.." -source "$CHIP_ROOT/activate.sh" +source "$CHIP_ROOT/scripts/activate.sh" set -e set -x diff --git a/scripts/tests/gn_tests.sh b/scripts/tests/gn_tests.sh index 7dd863604d2aca..c19b13c1f82402 100755 --- a/scripts/tests/gn_tests.sh +++ b/scripts/tests/gn_tests.sh @@ -20,7 +20,7 @@ CHIP_ROOT="$(dirname "$0")/../.." -source "$CHIP_ROOT/activate.sh" +source "$CHIP_ROOT/scripts/activate.sh" set -e set -x From 4f3ed8411e47943070e46477e0aea401d3b7d7d3 Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Wed, 8 Jul 2020 18:11:30 -0400 Subject: [PATCH 59/59] Fixup activate.sh & bootstrap.sh after moving --- scripts/activate.sh | 2 +- scripts/bootstrap.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/activate.sh b/scripts/activate.sh index 10a14c3960248e..69953ce1d30a6f 100644 --- a/scripts/activate.sh +++ b/scripts/activate.sh @@ -15,7 +15,7 @@ # if [[ ! -d "${CHIP_ROOT}" ]]; then - CHIP_ROOT="$(dirname "$0")" + CHIP_ROOT="$(dirname "$0")/.." fi export PW_BRANDING_BANNER="$CHIP_ROOT/.chip-banner.txt" diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh index b682aa75023969..9ed9a85bc0304c 100644 --- a/scripts/bootstrap.sh +++ b/scripts/bootstrap.sh @@ -14,7 +14,7 @@ # limitations under the License. # -CHIP_ROOT="$(dirname "$0")" +CHIP_ROOT="$(dirname "$0")/.." export PW_BRANDING_BANNER="$CHIP_ROOT/.chip-banner.txt" export PW_BRANDING_BANNER_COLOR="bold_white"