Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[darwin-framework-tool] Add is_asan and is_tsan proper supports
Browse files Browse the repository at this point in the history
vivien-apple committed Apr 11, 2023

Verified

This commit was signed with the committer’s verified signature.
jessesquires Jesse Squires
1 parent 6eded52 commit 9b3f66c
Showing 3 changed files with 38 additions and 11 deletions.
11 changes: 10 additions & 1 deletion examples/darwin-framework-tool/BUILD.gn
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@ import("//build_overrides/build.gni")
import("//build_overrides/chip.gni")

import("${chip_root}/build/chip/tools.gni")
import("${chip_root}/build/config/compiler/compiler.gni")
import("${chip_root}/build/config/mac/mac_sdk.gni")
import("${chip_root}/examples//chip-tool/chip-tool.gni")

@@ -73,10 +74,18 @@ action("build-darwin-framework") {
]
}

if (defined(chip_inet_config_enable_ipv4) && !chip_inet_config_enable_ipv4) {
if (defined(chip_inet_config_enable_ipv4) && chip_inet_config_enable_ipv4) {
args += [ "--ipv4" ]
} else {
args += [ "--no-ipv4" ]
}

if (defined(is_asan) && is_asan) {
args += [ "--asan" ]
} else {
args += [ "--no-asan" ]
}

output_name = "Matter.framework"
outputs = [
"${root_out_dir}/macos_framework_output/Build/Products/${output_sdk_type}/${output_name}",
32 changes: 22 additions & 10 deletions scripts/build/build_darwin_framework.py
Original file line number Diff line number Diff line change
@@ -53,11 +53,6 @@ def build_darwin_framework(args):
'-derivedDataPath',
abs_path,
"ARCHS={}".format(args.target_arch),
# For now disable unguarded-availability-new warnings because we
# internally use APIs that we are annotating as only available on
# new enough versions. Maybe we should change out deployment
# target versions instead?
"OTHER_CFLAGS=${inherited} -Wno-unguarded-availability-new",
]

if args.target_sdk != "macosx":
@@ -71,12 +66,27 @@ def build_darwin_framework(args):
"GCC_SYMBOLS_PRIVATE_EXTERN=NO",
]

if not args.ipv4:
command += [
"CHIP_INET_CONFIG_ENABLE_IPV4=NO",
]
command_result = run_command(command)
options = {
'CHIP_INET_CONFIG_ENABLE_IPV4': args.ipv4,
'CHIP_IS_ASAN': args.asan,
}
for option in options:
command += ["{}={}".format(option, "YES" if options[option] else "NO")]

# For now disable unguarded-availability-new warnings because we
# internally use APIs that we are annotating as only available on
# new enough versions. Maybe we should change out deployment
# target versions instead?
cflags = ["${inherited}", "-Wno-unguarded-availability-new"]
ldflags = ["${inherited}"]

if args.asan:
flags = ["-fsanitize=address", "-fno-omit-frame-pointer"]
cflags += flags
ldflags += flags

command += ["OTHER_CFLAGS=" + ' '.join(cflags), "OTHER_LDFLAGS=" + ' '.join(ldflags)]
command_result = run_command(command)
print("Build Framework Result: {}".format(command_result))
exit(command_result)

@@ -114,6 +124,8 @@ def build_darwin_framework(args):
help="Output log file destination",
required=True)
parser.add_argument('--ipv4', action=argparse.BooleanOptionalAction)
parser.add_argument('--asan', action=argparse.BooleanOptionalAction)
parser.add_argument('--tsan', action=argparse.BooleanOptionalAction)

args = parser.parse_args()
build_darwin_framework(args)
6 changes: 6 additions & 0 deletions src/darwin/Framework/chip_xcode_build_connector.sh
Original file line number Diff line number Diff line change
@@ -123,6 +123,12 @@ declare -a args=(
)
}

[[ $CHIP_IS_ASAN == YES ]] && {
args+=(
'is_asan=true'
)
}

# search current (or $2) and its parent directories until
# a name match is found, which is output on stdout
find_in_ancestors() {

0 comments on commit 9b3f66c

Please sign in to comment.