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 7, 2023
1 parent 6eded52 commit 9ece407
Showing 3 changed files with 61 additions and 5 deletions.
14 changes: 14 additions & 0 deletions examples/darwin-framework-tool/BUILD.gn
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@ import("//build_overrides/chip.gni")

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

if (config_use_interactive_mode) {
@@ -77,6 +78,19 @@ 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}",
40 changes: 35 additions & 5 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":
@@ -75,6 +70,39 @@ 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))
@@ -114,6 +142,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
@@ -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() {

0 comments on commit 9ece407

Please sign in to comment.