blob: cc89205365813680f259a56715b8e3ce9c86b5b0 [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/p6.gni")
import("${p6_sdk_build_root}/p6_sdk.gni")
declare_args() {
# Build target to use for p6 SDK. Use this to set global SDK defines.
p6_target_project = ""
}
assert(p6_target_project != "", "p6_target_project must be specified")
# Add includes, cflags, asmflags, etc in config
config("p6_sdk_config") {
# Pull out includes from generated json
# Treat these includes as system includes, so warnings in them are not fatal.
_system_include_dirs = []
foreach(include_dir, mtb_json.includes) {
# Strip off leading -I part
include_dir = string_replace(include_dir, "-I", "", 1)
# Path is relative to SDK
include_dir = "${p6_sdk_root}/${include_dir}"
_system_include_dirs += [ include_dir ]
}
cflags = []
foreach(include_dir, _system_include_dirs) {
cflags += [ "-isystem" + rebase_path(include_dir, root_build_dir) ]
}
# Also add project include path (passed in from project build)
proj_path = get_label_info(p6_target_project, "dir")
include_dirs = [ "${proj_path}/include" ]
# Pull out defines from generated json
defines = []
foreach(def, mtb_json.defines) {
# Strip off leading -D part
defines += [ string_replace(def, "-D", "", 1) ]
}
# Pull out static libs (.a files) from generated json
libs = []
foreach(lib, mtb_json.libs) {
# Path is relative to SDK
lib = "${p6_sdk_root}/${lib}"
libs += [ lib ]
}
cflags_c = mtb_json.cflags
cflags_cc = mtb_json.cxxflags
asmflags = mtb_json.asflags
ldflags = filter_exclude(mtb_json.ldflags, [ "-T*" ])
# Pull out linker flags with paths (-T flags) and make paths absolute
# OTA app provides it's own linker script
if (!chip_enable_ota_requestor) {
linker_script_flags = filter_include(mtb_json.ldflags, [ "-T*" ])
foreach(linker_script, linker_script_flags) {
# Strip off leading -T part
linker_script = string_replace(linker_script, "-T", "", 1)
# Path is relative to SDK
linker_script = "${p6_sdk_root}/${linker_script}"
ldflags += [ "-T" + rebase_path(linker_script, root_build_dir) ]
}
}
# --specs=nano.specs is getting added twice and causing compile issues so remove from cxx flags here.
cflags_c -= [ "--specs=nano.specs" ]
cflags_cc -= [ "--specs=nano.specs" ]
asmflags -= [ "--specs=nano.specs" ]
ldflags -= [ "--specs=nano.specs" ]
}
group("p6_build") {
public_configs = [ ":p6_sdk_config" ]
public_deps = [ p6_target_project ]
}