Skip to content

Commit

Permalink
[darwin-framework-tool] Add is_asan and is_tsan proper supports
Browse files Browse the repository at this point in the history
  • Loading branch information
vivien-apple committed Apr 7, 2023
1 parent 6eded52 commit 6b519f9
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 5 deletions.
13 changes: 13 additions & 0 deletions examples/darwin-framework-tool/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -77,6 +78,18 @@ action("build-darwin-framework") {
args += [ "--no-ipv4" ]
}

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

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

output_name = "Matter.framework"
outputs = [
"${root_out_dir}/macos_framework_output/Build/Products/${output_sdk_type}/${output_name}",
Expand Down
39 changes: 34 additions & 5 deletions scripts/build/build_darwin_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand All @@ -75,6 +70,38 @@ def build_darwin_framework(args):
command += [
"CHIP_INET_CONFIG_ENABLE_IPV4=NO",
]

if not args.asan and not args.tsan:
# 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?
command += [
"OTHER_CFLAGS=${inherited} -Wno-unguarded-availability-new",
]

if args.asan:
command += [
"CHIP_IS_ASAN=YES",
"OTHER_LDFLAGS=${inherited} -fsanitize=address -fno-omit-frame-pointer",
"OTHER_CFLAGS=${inherited} -Wno-unguarded-availability-new -fsanitize=address -fno-omit-frame-pointer",
]
else:
command += [
"CHIP_IS_ASAN=NO",
]

if args.tsan:
command += [
"CHIP_IS_TSAN=YES",
"OTHER_LDFLAGS=${inherited} -fsanitize=thread",
"OTHER_CFLAGS=${inherited} -Wno-unguarded-availability-new -fsanitize=thread",
]
else:
command += [
"CHIP_IS_TSAN=NO",
]

command_result = run_command(command)

print("Build Framework Result: {}".format(command_result))
Expand Down Expand Up @@ -114,6 +141,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)
12 changes: 12 additions & 0 deletions src/darwin/Framework/chip_xcode_build_connector.sh
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,18 @@ declare -a args=(
)
}

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

[[ $CHIP_IS_TSAN == YES ]] && {
args+=(
'is_tsan=true'
)
}

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

0 comments on commit 6b519f9

Please sign in to comment.