blob: fb86bb34937030d1ca4cc519da24fe88a2262894 [file] [log] [blame]
# Copyright (c) 2021 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/jlink.gni")
import("//build_overrides/mbedtls.gni")
import("//build_overrides/p6.gni")
import("${chip_root}/src/platform/device.gni")
import("p6_board.gni")
# TODO: Don't hardcode config/toolchain
# TODO: Convert to GN action?
if (is_debug) {
debug_str = "Debug"
} else {
debug_str = "Release"
}
mtb_json = read_file("${p6_sdk_root}/build/${p6_board}/$debug_str/GCC_ARM.json",
"json")
# Defines an p6 SDK build target.
#
# Parameters:
# sources - The sources files to build.
#
template("p6_sdk_sources") {
if (defined(invoker.p6_project_dir)) {
p6_project_dir = invoker.p6_project_dir
}
if (defined(invoker.chip_enable_ota_requestor)) {
if (invoker.chip_enable_ota_requestor) {
chip_enable_ota_requestor = true
}
}
# While most p6 sdk includes come from the p6_sdk_config config (in
# BUILD.gn), this template gets instantiated by each project each of which
# provides a few extra includes/defines. Handle those here.
config("project_configs") {
include_dirs = []
if (defined(invoker.include_dirs)) {
include_dirs += invoker.include_dirs
}
include_dirs += [ "${p6_project_dir}/include" ]
defines = []
if (defined(invoker.defines)) {
defines += invoker.defines
}
}
sdk_target_name = target_name
# Add sources here
source_set(sdk_target_name) {
sources = []
if (defined(invoker.sources)) {
sources += invoker.sources
}
# This is ugly. See note in BUILD.gn for reasoning
mtb_json_local = mtb_json # Can't modify without copying into current scope
if (chip_enable_ota_requestor == true) {
mtb_json_local.c_source -= [
"./libs/psoc6cm0p/COMPONENT_CM0P_SLEEP/psoc6_01_cm0p_sleep.c",
"./libs/psoc6cm0p/COMPONENT_CM0P_SLEEP/psoc6_02_cm0p_sleep.c",
"./libs/psoc6cm0p/COMPONENT_CM0P_SLEEP/psoc6_03_cm0p_sleep.c",
"./libs/psoc6cm0p/COMPONENT_CM0P_SLEEP/psoc6_04_cm0p_sleep.c",
]
}
# Pull out c sources from generated json
foreach(src, mtb_json_local.c_source) {
sources += [ "${p6_sdk_root}/${src}" ]
}
# Pull out cpp sources from generated json
foreach(src, mtb_json_local.cxx_source) {
sources += [ "${p6_sdk_root}/${src}" ]
}
# Pull out .S files from generated json
foreach(asm, mtb_json_local.asm_source) {
sources += [ "${p6_sdk_root}/${asm}" ]
}
public_deps = []
if (defined(invoker.public_deps)) {
public_deps += invoker.public_deps
}
public_deps += [ "${chip_root}/src/lwip:lwip" ]
public_configs = [ ":project_configs" ]
if (defined(invoker.public_configs)) {
public_configs += invoker.public_configs
}
}
}