diff --git a/examples/darwin-framework-tool/BUILD.gn b/examples/darwin-framework-tool/BUILD.gn index 231ebac679b240..55be770e1aae3c 100644 --- a/examples/darwin-framework-tool/BUILD.gn +++ b/examples/darwin-framework-tool/BUILD.gn @@ -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}", diff --git a/scripts/build/build_darwin_framework.py b/scripts/build/build_darwin_framework.py index 5b872dbaa891b1..2f8cc3ea334d9c 100644 --- a/scripts/build/build_darwin_framework.py +++ b/scripts/build/build_darwin_framework.py @@ -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) diff --git a/src/darwin/Framework/chip_xcode_build_connector.sh b/src/darwin/Framework/chip_xcode_build_connector.sh index 3843effbc4b52c..5e086aad5920f6 100755 --- a/src/darwin/Framework/chip_xcode_build_connector.sh +++ b/src/darwin/Framework/chip_xcode_build_connector.sh @@ -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() {