| # 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/psoc6.gni") |
| import("${chip_root}/src/platform/device.gni") |
| import("psoc6_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("${psoc6_sdk_root}/build/${psoc6_board}/$debug_str/GCC_ARM.json", |
| "json") |
| |
| # Defines an psoc6 SDK build target. |
| # |
| # Parameters: |
| # sources - The sources files to build. |
| # |
| template("psoc6_sdk_sources") { |
| if (defined(invoker.psoc6_project_dir)) { |
| psoc6_project_dir = invoker.psoc6_project_dir |
| } |
| |
| if (defined(invoker.chip_enable_ota_requestor)) { |
| if (invoker.chip_enable_ota_requestor) { |
| chip_enable_ota_requestor = true |
| } |
| } |
| |
| # While most psoc6 sdk includes come from the psoc6_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 += [ "${psoc6_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 += [ "${psoc6_sdk_root}/${src}" ] |
| } |
| |
| # Pull out cpp sources from generated json |
| foreach(src, mtb_json_local.cxx_source) { |
| sources += [ "${psoc6_sdk_root}/${src}" ] |
| } |
| |
| # Pull out .S files from generated json |
| foreach(asm, mtb_json_local.asm_source) { |
| sources += [ "${psoc6_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 |
| } |
| } |
| } |