| # 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 |
| } |
| |
| _build_overrides = { |
| import("//build_overrides/build.gni") |
| } |
| |
| _pigweed_overrides = { |
| import("//build_overrides/pigweed.gni") |
| } |
| |
| _chip_defaults = { |
| import("${_build_overrides.build_root}/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 = "${_build_overrides.build_root}/toolchain/host:${host_os}_${host_cpu}_clang" |
| } else { |
| host_toolchain = "${_build_overrides.build_root}/toolchain/host:${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 if (target_os == "all") { |
| _default_toolchain = "${_pigweed_overrides.dir_pw_toolchain}/dummy" |
| } else if (target_os == "freertos") { |
| if (target_cpu == "arm") { |
| _default_toolchain = "${_build_overrides.build_root}/toolchain/arm_gcc" |
| } else { |
| assert(false, "Unsupported target_cpu: ${target_cpu}") |
| } |
| } else if (target_os == "android") { |
| if (current_cpu == "arm") { |
| _default_toolchain = |
| "${_build_overrides.build_root}/toolchain/android:android_arm" |
| } else if (current_cpu == "arm64") { |
| _default_toolchain = |
| "${_build_overrides.build_root}/toolchain/android:android_arm64" |
| } else if (current_cpu == "x64") { |
| _default_toolchain = |
| "${_build_overrides.build_root}/toolchain/android:android_x64" |
| } else if (current_cpu == "x86") { |
| _default_toolchain = |
| "${_build_overrides.build_root}/toolchain/android:android_x86" |
| } else { |
| assert(false, "Unsupported target_cpu: ${current_cpu}") |
| } |
| } else if (target_os == "ios") { |
| _default_toolchain = |
| "${_build_overrides.build_root}/toolchain/ios:ios_${target_cpu}" |
| } 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 |
| } |