Skip to content

Commit

Permalink
[darwin-framework-tool] Do not build Matter SDK twice when config_ena…
Browse files Browse the repository at this point in the history
…ble_yaml_tests=false
  • Loading branch information
vivien-apple committed Nov 18, 2022
1 parent 26e3636 commit c937c04
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 21 deletions.
1 change: 0 additions & 1 deletion examples/chip-tool/commands/common/Command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
*/

#include "Command.h"
#include "platform/PlatformManager.h"

#include <netdb.h>
#include <sstream>
Expand Down
1 change: 0 additions & 1 deletion examples/chip-tool/commands/common/Command.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include <app/data-model/Nullable.h>
#include <commands/clusters/ComplexArgument.h>
#include <commands/clusters/CustomArgument.h>
#include <controller/CHIPDeviceController.h>
#include <inet/InetInterface.h>
#include <lib/core/Optional.h>
#include <lib/support/Span.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,18 @@
#pragma once

#include <app/util/basic-types.h>
#include <controller/CHIPDeviceControllerFactory.h>
#include <credentials/attestation_verifier/DeviceAttestationVerifier.h>
#include <lib/core/CHIPCore.h>
#include <lib/core/CHIPPersistentStorageDelegate.h>
#include <vector>

namespace chip {
namespace Controller {
struct SetupParams;
class OperationalCredentialsDelegate;
} // namespace Controller
} // namespace chip

class CredentialIssuerCommands
{
public:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "DiscoverCommissionersCommand.h"
#include <arpa/inet.h>
#include <controller/CHIPDeviceController.h>

using namespace ::chip;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#pragma once

#include <commands/common/CredentialIssuerCommands.h>
#include <controller/CHIPDeviceControllerFactory.h>
#include <controller/ExampleOperationalCredentialsIssuer.h>
#include <credentials/DeviceAttestationCredsProvider.h>
#include <credentials/attestation_verifier/DefaultDeviceAttestationVerifier.h>
Expand Down
68 changes: 54 additions & 14 deletions examples/darwin-framework-tool/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -143,20 +143,6 @@ executable("darwin-framework-tool") {

deps = [
":build-darwin-framework",
"${chip_root}/src/app/tests/suites/commands/delay",

# IM is needed for MTRError
"${chip_root}/src/app/tests/suites/commands/interaction_model",

# Log is needed by tests UserPrompt and Log
"${chip_root}/src/app/tests/suites/commands/log",

# System is needed by tests FactoryReset etc..
"${chip_root}/src/app/tests/suites/commands/system",

# pics is needed by tests
"${chip_root}/src/app/tests/suites/pics",
"${chip_root}/third_party/inipp",
"${chip_root}/third_party/jsoncpp",
]

Expand All @@ -175,6 +161,60 @@ executable("darwin-framework-tool") {
"Security.framework",
]

# When config_enable_yaml_tests=true the Matter SDK is pulled in as a dependency because the code of the test suite
# uses some helpers from the Matter SDK. As a result, the SDK is built twice. Once because of this dependency and once
# when the Matter.framework is built.
# It may results into different versions of the Matter SDK between the output binary and the linked Matter.framework.
#
# When config_enable_yaml_tests=false the Matter SDK is built once when the Matter.framework is built and the resulting
# libCHIP.a library is linked statically to the output binary.
if (config_enable_yaml_tests) {
deps += [
"${chip_root}/src/app/tests/suites/commands/delay",

# IM is needed for MTRError
"${chip_root}/src/app/tests/suites/commands/interaction_model",

# Log is needed by tests UserPrompt and Log
"${chip_root}/src/app/tests/suites/commands/log",

# System is needed by tests FactoryReset etc..
"${chip_root}/src/app/tests/suites/commands/system",

# pics is needed by tests
"${chip_root}/src/app/tests/suites/pics",
]
} else {
include_dirs = [
"${chip_root}/config/standalone/",
"${chip_root}/src/",
"${chip_root}/src/include/",
"${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}/macos_framework_output/Build/Intermediates.noindex/Matter.build/${output_sdk_type}/Matter.build/out/gen/include",
]

defines = [
"CHIP_HAVE_CONFIG_H=1",
"CHIP_SYSTEM_CONFIG_USE_SOCKETS=1",
]

frameworks += [
"CoreFoundation.framework",
"Foundation.framework",
"CoreBluetooth.framework",
"Network.framework",
]

# 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 (sdk == "macosx") {
libs = [ "${root_out_dir}/macos_framework_output/Build/Intermediates.noindex/Matter.build/${output_sdk_type}/Matter.build/out/lib/libCHIP.a" ]
}
}

public_configs = [ ":config" ]

output_dir = root_out_dir
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
class ModelCommand : public CHIPCommandBridge
{
public:
using ChipDevice = ::chip::OperationalDeviceProxy;

ModelCommand(const char * _Nonnull commandName) : CHIPCommandBridge(commandName) {}

void AddArguments()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <commands/common/Command.h>
#include <commands/common/CredentialIssuerCommands.h>
#include <map>
#include <set>
#include <string>

#include "../provider/OTAProviderDelegate.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ class OpenCommissioningWindowCommand : public CHIPCommandBridge
"1 to use Enhanced Commissioning Method.\n 0 to use Basic Commissioning Method.");
AddArgument("window-timeout", 0, UINT16_MAX, &mCommissioningWindowTimeoutMs,
"Time, in seconds, before the commissioning window closes.");
AddArgument("iteration", chip::kSpake2p_Min_PBKDF_Iterations, chip::kSpake2p_Max_PBKDF_Iterations, &mIteration,
"Number of PBKDF iterations to use to derive the verifier. Ignored if 'option' is 0.");
AddArgument("iteration", chip::Crypto::kSpake2p_Min_PBKDF_Iterations, chip::Crypto::kSpake2p_Max_PBKDF_Iterations,
&mIteration, "Number of PBKDF iterations to use to derive the verifier. Ignored if 'option' is 0.");
AddArgument("discriminator", 0, 4096, &mDiscriminator, "Discriminator to use for advertising. Ignored if 'option' is 0.");
AddArgument("timeout", 0, UINT16_MAX, &mTimeout, "Time, in seconds, before this command is considered to have timed out.");
}
Expand Down
2 changes: 2 additions & 0 deletions scripts/build/build_darwin_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ def build_darwin_framework(args):
# Build Matter.framework as a static library
"SUPPORTS_TEXT_BASED_API=NO",
"MACH_O_TYPE=staticlib",
"GCC_INLINES_ARE_PRIVATE_EXTERN=NO",
"GCC_SYMBOLS_PRIVATE_EXTERN=NO",
]
command_result = run_command(command)

Expand Down

0 comments on commit c937c04

Please sign in to comment.