blob: 54547cdd29044643f3d149a26dfe9125b90a34f2 [file] [log] [blame]
# Copyright (c) 2022 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//build_overrides/build.gni")
import("//build_overrides/chip.gni")
import("//build_overrides/jsoncpp.gni")
import("${chip_root}/build/chip/tools.gni")
import("${chip_root}/build/config/compiler/compiler.gni")
import("${chip_root}/examples//chip-tool/chip-tool.gni")
import("${chip_root}/src/inet/inet.gni")
if (config_use_interactive_mode) {
import("//build_overrides/editline.gni")
}
import("//build/args.gni")
assert(chip_build_tools)
declare_args() {
chip_codesign = false
# Enable automatic leak checks before the application exits
enable_leak_checking = !is_asan && target_os == "mac"
}
config("config") {
include_dirs = [
".",
"include",
"${chip_root}/examples/common",
"${chip_root}/examples/darwin-framework-tool/commands/common",
"${chip_root}/zzz_generated/darwin-framework-tool",
"${chip_root}/zzz_generated/controller-clusters",
"${chip_root}/examples/chip-tool",
"${chip_root}/zzz_generated/chip-tool",
"${root_out_dir}/${darwin_framework_products_dir}",
]
framework_dirs = [ "${root_out_dir}/${darwin_framework_products_dir}" ]
defines = [
"CHIP_ADDRESS_RESOLVE_IMPL_INCLUDE_HEADER=<lib/address_resolve/AddressResolve_DefaultImpl.h>",
"CONFIG_USE_INTERACTIVE_MODE=${config_use_interactive_mode}",
# Disable availability annotations in Matter.framework headers because we
# are not building against a system Matter.framework here anyway.
"MTR_NO_AVAILABILITY=1",
]
cflags = [ "-Wconversion" ]
}
executable("darwin-framework-tool") {
sources = [
"${chip_root}/examples/chip-tool/commands/common/Command.cpp",
"${chip_root}/examples/chip-tool/commands/common/Command.h",
"${chip_root}/examples/chip-tool/commands/common/Commands.cpp",
"${chip_root}/examples/chip-tool/commands/common/Commands.h",
"${chip_root}/examples/chip-tool/commands/common/HexConversion.h",
"${chip_root}/examples/chip-tool/commands/dcl/DCLClient.cpp",
"${chip_root}/examples/chip-tool/commands/dcl/DisplayTermsAndConditions.cpp",
"${chip_root}/examples/chip-tool/commands/dcl/JsonSchemaMacros.cpp",
"${chip_root}/examples/common/websocket-server/WebSocketServer.cpp",
"${chip_root}/examples/common/websocket-server/WebSocketServer.h",
"${chip_root}/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp",
"commands/bdx/Commands.h",
"commands/bdx/DownloadLogCommand.mm",
"commands/clusters/ClusterCommandBridge.h",
"commands/clusters/ModelCommandBridge.mm",
"commands/clusters/ReportCommandBridge.h",
"commands/clusters/WriteAttributeCommandBridge.h",
"commands/common/CHIPCommandBridge.mm",
"commands/common/CHIPCommandStorageDelegate.mm",
"commands/common/CertificateIssuer.h",
"commands/common/CertificateIssuer.mm",
"commands/common/ControllerStorage.h",
"commands/common/ControllerStorage.mm",
"commands/common/DFTKeypair.mm",
"commands/common/DeviceDelegate.h",
"commands/common/DeviceDelegate.mm",
"commands/common/MTRDevice_Externs.h",
"commands/common/MTRError.mm",
"commands/common/MTRError_Utils.h",
"commands/common/MTRLogging.h",
"commands/common/PreferencesStorage.h",
"commands/common/PreferencesStorage.mm",
"commands/common/RemoteDataModelLogger.h",
"commands/common/RemoteDataModelLogger.mm",
"commands/common/xpc/DeviceControllerServer.mm",
"commands/common/xpc/XPCServer.mm",
"commands/common/xpc/XPCServerRegistry.mm",
"commands/configuration/Commands.h",
"commands/configuration/ResetMRPParametersCommand.h",
"commands/configuration/ResetMRPParametersCommand.mm",
"commands/configuration/SetMRPParametersCommand.h",
"commands/configuration/SetMRPParametersCommand.mm",
"commands/dcl/HTTPSRequest.mm",
"commands/delay/Commands.h",
"commands/delay/SleepCommand.h",
"commands/delay/SleepCommand.mm",
"commands/delay/WaitForCommissioneeCommand.h",
"commands/delay/WaitForCommissioneeCommand.mm",
"commands/discover/Commands.h",
"commands/discover/DiscoverCommissionablesCommand.h",
"commands/discover/DiscoverCommissionablesCommand.mm",
"commands/memory/Commands.h",
"commands/memory/DumpMemoryGraphCommand.h",
"commands/memory/DumpMemoryGraphCommand.mm",
"commands/memory/LeaksTool.h",
"commands/memory/LeaksTool.mm",
"commands/pairing/Commands.h",
"commands/pairing/DeviceControllerDelegateBridge.mm",
"commands/pairing/GetCommissionerNodeIdCommand.h",
"commands/pairing/GetCommissionerNodeIdCommand.mm",
"commands/pairing/OpenCommissioningWindowCommand.h",
"commands/pairing/OpenCommissioningWindowCommand.mm",
"commands/pairing/PairingCommandBridge.mm",
"commands/payload/SetupPayloadParseCommand.mm",
"commands/provider/Commands.h",
"commands/provider/OTAProviderDelegate.mm",
"commands/provider/OTASoftwareUpdateInteractive.mm",
"commands/storage/Commands.h",
"commands/storage/StorageManagementCommand.mm",
"debug/LeakChecker.mm",
"logging/logging.mm",
"main.mm",
]
# TODO: this is WRONG however the darwin framework tool seems to manually
# include files instead of depending on them and does not include
# appropriate headers.
check_includes = false
deps = [
"${chip_root}/src/app/common:ids",
"${chip_root}/third_party/libwebsockets",
"//build/framework:framework",
jsoncpp_root,
]
if (config_use_interactive_mode) {
sources += [ "commands/interactive/InteractiveCommands.mm" ]
deps += [ "${editline_root}:editline" ]
}
ldflags = [
"-rpath",
"@executable_path/${darwin_framework_products_dir}",
]
frameworks = [
"Matter.framework",
"Security.framework",
"CoreFoundation.framework",
"Foundation.framework",
"CoreBluetooth.framework",
"Network.framework",
"IOKit.framework",
]
include_dirs = [
"${chip_root}/config/standalone/",
"${chip_root}/src/",
"${chip_root}/src/include/",
"${chip_root}/src/protocols/",
"${chip_root}/src/protocols/interaction_model",
"${chip_root}/third_party/nlassert/repo/include/",
"${chip_root}/third_party/nlio/repo/include/",
"${chip_root}/zzz_generated/app-common/",
"${root_gen_dir}/include",
"${root_out_dir}/${darwin_framework_intermediates_dir}/gen/include",
]
defines = [ "CHIP_HAVE_CONFIG_H=1" ]
if (enable_provisional_features) {
defines += [ "MTR_ENABLE_PROVISIONAL=1" ]
}
if (enable_leak_checking) {
defines += [ "DFT_ENABLE_LEAK_CHECKING=1" ]
}
# Other SDKs are linked statically to Matter.framework but the macosx SDK is linked dynamically but needs some symbols that are
# not exposed by the dylib.
if (target_sdk_is_macosx) {
libs = [
"${root_out_dir}/${darwin_framework_intermediates_dir}/lib/libCHIP.a",
]
}
public_configs = [ ":config" ]
output_dir = root_out_dir
}
# Make sure we only build darwin-framework-tool, and not extraneous
# things like address-resolve, by default.
group("default") {
deps = [ ":darwin-framework-tool" ]
if (chip_codesign) {
deps += [ "//build/codesign:codesign" ]
}
}