Skip to content

Commit

Permalink
Cleanup p6 SDK compiler options (#20567)
Browse files Browse the repository at this point in the history
- Don't use -isystem for project configs as this suppresses warnings
- Use relative paths for options as is a best practice
  • Loading branch information
mspang authored and pull[bot] committed Feb 15, 2024
1 parent cf2872a commit 1549844
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 45 deletions.
8 changes: 4 additions & 4 deletions examples/all-clusters-app/p6/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ declare_args() {
}

config("p6_ota_config") {
ldflags = [ "-T/" + rebase_path(
"${chip_root}/third_party/p6/p6_sdk/ota/cy8c6xxa_cm4_dual_ota_int.ld",
"/",
"${p6_project_dir}") ]
linker_script =
"${chip_root}/third_party/p6/p6_sdk/ota/cy8c6xxa_cm4_dual_ota_int.ld"

ldflags = [ "-T" + rebase_path(linker_script, root_build_dir) ]

ldflags += [ "-Wl,--defsym,MCUBOOT_HEADER_SIZE=0x400,--defsym,MCUBOOT_BOOTLOADER_SIZE=0x18000,--defsym,CY_BOOT_PRIMARY_1_SIZE=0x1C0000" ]

Expand Down
8 changes: 4 additions & 4 deletions examples/all-clusters-minimal-app/p6/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ declare_args() {
}

config("p6_ota_config") {
ldflags = [ "-T/" + rebase_path(
"${chip_root}/third_party/p6/p6_sdk/ota/cy8c6xxa_cm4_dual_ota_int.ld",
"/",
"${p6_project_dir}") ]
linker_script =
"${chip_root}/third_party/p6/p6_sdk/ota/cy8c6xxa_cm4_dual_ota_int.ld"

ldflags = [ "-T" + rebase_path(linker_script, root_build_dir) ]

ldflags += [ "-Wl,--defsym,MCUBOOT_HEADER_SIZE=0x400,--defsym,MCUBOOT_BOOTLOADER_SIZE=0x18000,--defsym,CY_BOOT_PRIMARY_1_SIZE=0x1C0000" ]

Expand Down
8 changes: 4 additions & 4 deletions examples/lighting-app/p6/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ declare_args() {
}

config("p6_ota_config") {
ldflags = [ "-T/" + rebase_path(
"${chip_root}/third_party/p6/p6_sdk/ota/cy8c6xxa_cm4_dual_ota_int.ld",
"/",
"${p6_project_dir}") ]
linker_script =
"${chip_root}/third_party/p6/p6_sdk/ota/cy8c6xxa_cm4_dual_ota_int.ld"

ldflags = [ "-T" + rebase_path(linker_script, root_build_dir) ]

ldflags += [ "-Wl,--defsym,MCUBOOT_HEADER_SIZE=0x400,--defsym,MCUBOOT_BOOTLOADER_SIZE=0x18000,--defsym,CY_BOOT_PRIMARY_1_SIZE=0x1C0000" ]

Expand Down
8 changes: 4 additions & 4 deletions examples/lock-app/p6/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ declare_args() {
}

config("p6_ota_config") {
ldflags = [ "-T/" + rebase_path(
"${chip_root}/third_party/p6/p6_sdk/ota/cy8c6xxa_cm4_dual_ota_int.ld",
"/",
"${p6_project_dir}") ]
linker_script =
"${chip_root}/third_party/p6/p6_sdk/ota/cy8c6xxa_cm4_dual_ota_int.ld"

ldflags = [ "-T" + rebase_path(linker_script, root_build_dir) ]

ldflags += [ "-Wl,--defsym,MCUBOOT_HEADER_SIZE=0x400,--defsym,MCUBOOT_BOOTLOADER_SIZE=0x18000,--defsym,CY_BOOT_PRIMARY_1_SIZE=0x1C0000" ]

Expand Down
8 changes: 4 additions & 4 deletions examples/ota-requestor-app/p6/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ declare_args() {
}

config("p6_ota_config") {
ldflags = [ "-T/" + rebase_path(
"${chip_root}/third_party/p6/p6_sdk/ota/cy8c6xxa_cm4_dual_ota_int.ld",
"/",
"${p6_project_dir}") ]
linker_script =
"${chip_root}/third_party/p6/p6_sdk/ota/cy8c6xxa_cm4_dual_ota_int.ld"

ldflags = [ "-T" + rebase_path(linker_script, root_build_dir) ]

ldflags += [ "-Wl,--defsym,MCUBOOT_HEADER_SIZE=0x400,--defsym,MCUBOOT_BOOTLOADER_SIZE=0x18000,--defsym,CY_BOOT_PRIMARY_1_SIZE=0x1C0000" ]

Expand Down
42 changes: 26 additions & 16 deletions third_party/p6/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,26 @@ assert(p6_target_project != "", "p6_target_project must be specified")
config("p6_sdk_config") {
# Pull out includes from generated json
# Treat these includes as system includes, so warnings in them are not fatal.
_include_dirs = []
foreach(inc, mtb_json.includes) {
_system_include_dirs = []
foreach(include_dir, mtb_json.includes) {
# Strip off leading -I part
_include_dirs += [ "/" + rebase_path(string_replace(inc, "-I", "", 1),
"/",
"${p6_sdk_build_root}/p6_sdk/") ]
}
include_dir = string_replace(include_dir, "-I", "", 1)

# Also add project include path (passed in from project build)
proj_path = get_label_info(p6_target_project, "dir")
_include_dirs += [ "/" + rebase_path("${proj_path}/include", "/", ".") ]
# Path is relative to SDK
include_dir = "${p6_sdk_build_root}/p6_sdk/${include_dir}"

_system_include_dirs += [ include_dir ]
}

cflags = []
foreach(include_dir, _include_dirs) {
cflags += [ "-isystem" + include_dir ]
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) {
Expand All @@ -53,7 +56,10 @@ config("p6_sdk_config") {
# Pull out static libs (.a files) from generated json
libs = []
foreach(lib, mtb_json.libs) {
libs += [ "/" + rebase_path(lib, "/", "${p6_sdk_build_root}/p6_sdk/") ]
# Path is relative to SDK
lib = "${p6_sdk_build_root}/p6_sdk/${lib}"

libs += [ lib ]
}

cflags_c = mtb_json.cflags
Expand All @@ -65,10 +71,14 @@ config("p6_sdk_config") {
# OTA app provides it's own linker script
if (!chip_enable_ota_requestor) {
linker_script_flags = filter_include(mtb_json.ldflags, [ "-T*" ])
foreach(flag, linker_script_flags) {
ldflags += [ "-T/" + rebase_path(string_replace(flag, "-T", "", 1),
"/",
"${p6_sdk_build_root}/p6_sdk/") ]
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_build_root}/p6_sdk/${linker_script}"

ldflags += [ "-T" + rebase_path(linker_script, root_build_dir) ]
}
}

Expand Down
12 changes: 3 additions & 9 deletions third_party/p6/p6_sdk.gni
Original file line number Diff line number Diff line change
Expand Up @@ -85,23 +85,17 @@ template("p6_sdk_sources") {

# Pull out c sources from generated json
foreach(src, mtb_json_local.c_source) {
sources += [ rebase_path(src,
"${p6_project_dir}",
"${p6_sdk_build_root}/p6_sdk/") ]
sources += [ "${p6_sdk_build_root}/p6_sdk/${src}" ]
}

# Pull out cpp sources from generated json
foreach(src, mtb_json_local.cxx_source) {
sources += [ rebase_path(src,
"${p6_project_dir}",
"${p6_sdk_build_root}/p6_sdk/") ]
sources += [ "${p6_sdk_build_root}/p6_sdk/${src}" ]
}

# Pull out .S files from generated json
foreach(asm, mtb_json_local.asm_source) {
sources += [ rebase_path(asm,
"${p6_project_dir}",
"${p6_sdk_build_root}/p6_sdk/") ]
sources += [ "${p6_sdk_build_root}/p6_sdk/${asm}" ]
}

public_deps = []
Expand Down

0 comments on commit 1549844

Please sign in to comment.