Skip to content

Commit

Permalink
Optimize compilation time (#27228)
Browse files Browse the repository at this point in the history
* Optimize compilation time

1. Do not to include cluster-objects.h if not needed as
   parsing such a large header significantly impacts the
   build time and in most cases it is enough to include
   ClusterEnums.h.
2. Do not build the controller library for embedded targets,
   by default. If needed, this can be overriden using the
   chip_build_controller argument from lib.gni.

* Fix build
  • Loading branch information
Damian-Nordic authored and pull[bot] committed Jan 19, 2024
1 parent 1d29a69 commit 3357355
Show file tree
Hide file tree
Showing 30 changed files with 53 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "DeviceCallbacks.h"

#include "CHIPDeviceManager.h"
#include <app-common/zap-generated/ids/Attributes.h>
#include <app-common/zap-generated/ids/Clusters.h>
#include <app/CommandHandler.h>
#include <app/server/Dnssd.h>
Expand Down
1 change: 1 addition & 0 deletions examples/bridge-app/asr/subdevice/SubDeviceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "SubDeviceManager.h"
#include "SubDevice.h"
#include <app-common/zap-generated/cluster-objects.h>
#include <app-common/zap-generated/ids/Attributes.h>
#include <app-common/zap-generated/ids/Clusters.h>
#include <app/ConcreteAttributePath.h>
Expand Down
1 change: 1 addition & 0 deletions examples/bridge-app/asr/subdevice/subdevice_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "SubDeviceManager.h"
#include <app-common/zap-generated/ids/Attributes.h>
#include <app-common/zap-generated/ids/Clusters.h>
#include <app-common/zap-generated/ids/Commands.h>
#include <app/ConcreteAttributePath.h>
#include <app/InteractionModelEngine.h>
#include <app/clusters/identify-server/identify-server.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "AppTask.h"
#include "ContactSensorManager.h"

#include <app-common/zap-generated/cluster-objects.h>
#include <app-common/zap-generated/ids/Attributes.h>
#include <app-common/zap-generated/ids/Clusters.h>
#include <app/ConcreteAttributePath.h>
Expand Down
1 change: 1 addition & 0 deletions examples/platform/silabs/efr32/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ source_set("efr32-common") {

public_deps += [
"${chip_root}/examples/providers:device_info_provider",
"${chip_root}/src/app/server",
"${chip_root}/src/lib",
"${chip_root}/src/setup_payload",
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#include <lib/support/JniReferences.h>
#include <lib/support/JniTypeWrappers.h>

#include <app-common/zap-generated/cluster-objects.h>

class CallbackBaseJNI
{
public:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

#include <controller/CHIPCluster.h>

#include <app-common/zap-generated/cluster-objects.h>

// SUBSCRIBER CLASSES
class VendorNameSubscriber : public MediaSubscriptionBase<chip::app::Clusters::ApplicationBasic::Attributes::VendorName::TypeInfo>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include <controller/CHIPCluster.h>
#include <functional>

#include <app-common/zap-generated/cluster-objects.h>

// COMMAND CLASSES
class LaunchAppCommand
: public MediaCommandBase<chip::app::Clusters::ApplicationLauncher::Commands::LaunchApp::Type,
Expand Down
2 changes: 2 additions & 0 deletions examples/tv-casting-app/tv-casting-common/include/Channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include <controller/CHIPCluster.h>
#include <functional>

#include <app-common/zap-generated/cluster-objects.h>

// COMMAND CLASSES
class ChangeChannelCommand : public MediaCommandBase<chip::app::Clusters::Channel::Commands::ChangeChannel::Type,
chip::app::Clusters::Channel::Commands::ChangeChannelResponse::DecodableType>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include <controller/CHIPCluster.h>
#include <functional>

#include <app-common/zap-generated/cluster-objects.h>

// COMMAND CLASSES
class LaunchURLCommand : public MediaCommandBase<chip::app::Clusters::ContentLauncher::Commands::LaunchURL::Type,
chip::app::Clusters::ContentLauncher::Commands::LauncherResponse::DecodableType>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#include <controller/CHIPCluster.h>
#include <functional>

#include <app-common/zap-generated/cluster-objects.h>

class SendKeyCommand : public MediaCommandBase<chip::app::Clusters::KeypadInput::Commands::SendKey::Type,
chip::app::Clusters::KeypadInput::Commands::SendKeyResponse::DecodableType>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include <controller/CHIPCluster.h>
#include <functional>

#include <app-common/zap-generated/cluster-objects.h>

// COMMAND CLASSES
class StepCommand
: public MediaCommandBase<chip::app::Clusters::LevelControl::Commands::Step::Type, chip::app::DataModel::NullObjectType>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include <controller/CHIPCluster.h>
#include <functional>

#include <app-common/zap-generated/cluster-objects.h>

// COMMAND CLASSES
class PlayCommand : public MediaCommandBase<chip::app::Clusters::MediaPlayback::Commands::Play::Type,
chip::app::Clusters::MediaPlayback::Commands::PlaybackResponse::DecodableType>
Expand Down
2 changes: 2 additions & 0 deletions examples/tv-casting-app/tv-casting-common/include/OnOff.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include <controller/CHIPCluster.h>
#include <functional>

#include <app-common/zap-generated/cluster-objects.h>

// COMMAND CLASSES
class OnCommand : public MediaCommandBase<chip::app::Clusters::OnOff::Commands::On::Type, chip::app::DataModel::NullObjectType>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include <controller/CHIPCluster.h>
#include <functional>

#include <app-common/zap-generated/cluster-objects.h>

// COMMAND CLASSES
class NavigateTargetCommand
: public MediaCommandBase<chip::app::Clusters::TargetNavigator::Commands::NavigateTarget::Type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#include <app/OperationalSessionSetup.h>
#include <platform/CHIPDeviceLayer.h>

#include <app-common/zap-generated/cluster-objects.h>

constexpr size_t kMaxNumberOfEndpoints = 5;

class TargetVideoPlayerInfo;
Expand Down
6 changes: 4 additions & 2 deletions src/app/chip_data_model.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,13 @@ function(chip_configure_data_model APP_TARGET)

if (ARG_INCLUDE_SERVER)
target_sources(${APP_TARGET} ${SCOPE}
${CHIP_APP_BASE_DIR}/server/EchoHandler.cpp
${CHIP_APP_BASE_DIR}/server/AclStorage.cpp
${CHIP_APP_BASE_DIR}/server/DefaultAclStorage.cpp
${CHIP_APP_BASE_DIR}/server/CommissioningWindowManager.cpp
${CHIP_APP_BASE_DIR}/server/Dnssd.cpp
${CHIP_APP_BASE_DIR}/server/EchoHandler.cpp
${CHIP_APP_BASE_DIR}/server/OnboardingCodesUtil.cpp
${CHIP_APP_BASE_DIR}/server/Server.cpp
${CHIP_APP_BASE_DIR}/server/CommissioningWindowManager.cpp
)

target_compile_options(${APP_TARGET} ${SCOPE}
Expand Down
2 changes: 1 addition & 1 deletion src/app/server/CommissioningWindowManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@

#pragma once

#include <app-common/zap-generated/cluster-objects.h>
#include <app/data-model/Nullable.h>
#include <app/server/AppDelegate.h>
#include <app/server/CommissioningModeProvider.h>
#include <lib/core/CHIPVendorIdentifiers.hpp>
#include <lib/core/ClusterEnums.h>
#include <lib/core/DataModelTypes.h>
#include <lib/dnssd/Advertiser.h>
#include <messaging/ExchangeDelegate.h>
Expand Down
1 change: 0 additions & 1 deletion src/app/util/generic-callbacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

#pragma once

#include <app-common/zap-generated/cluster-objects.h>
#include <app/util/af-types.h>
#include <app/util/attribute-metadata.h>
#include <app/util/basic-types.h>
Expand Down
1 change: 1 addition & 0 deletions src/controller/CommissioningDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/

#pragma once
#include <app-common/zap-generated/cluster-objects.h>
#include <app/OperationalSessionSetup.h>
#include <controller/CommissioneeDeviceProxy.h>
#include <credentials/attestation_verifier/DeviceAttestationDelegate.h>
Expand Down
2 changes: 1 addition & 1 deletion src/credentials/GroupDataProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
#include <stdint.h>
#include <sys/types.h>

#include <app-common/zap-generated/cluster-objects.h>
#include <app/util/basic-types.h>
#include <crypto/CHIPCryptoPAL.h>
#include <lib/core/CHIPError.h>
#include <lib/core/ClusterEnums.h>
#include <lib/support/CHIPMemString.h>
#include <lib/support/CommonIterator.h>

Expand Down
2 changes: 1 addition & 1 deletion src/include/platform/AttributeList.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

#pragma once

#include <app-common/zap-generated/cluster-objects.h>
#include <lib/core/CHIPError.h>
#include <lib/support/CodeUtils.h>

namespace chip {
namespace DeviceLayer {
Expand Down
2 changes: 1 addition & 1 deletion src/include/platform/ConfigurationManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include <setup_payload/CHIPAdditionalDataPayloadBuildConfig.h>
#endif

#include <app-common/zap-generated/cluster-objects.h>
#include <lib/core/ClusterEnums.h>
#include <lib/support/Span.h>
#include <platform/PersistedStorage.h>
#include <platform/internal/CHIPDeviceLayerInternal.h>
Expand Down
1 change: 0 additions & 1 deletion src/include/platform/ConnectivityManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include <platform/CHIPDeviceConfig.h>
#include <platform/CHIPDeviceEvent.h>

#include <app-common/zap-generated/cluster-objects.h>
#include <app/util/basic-types.h>

#if INET_CONFIG_ENABLE_TCP_ENDPOINT
Expand Down
1 change: 0 additions & 1 deletion src/include/platform/ThreadStackManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

#pragma once

#include <app-common/zap-generated/cluster-objects.h>
#include <app/AttributeAccessInterface.h>
#include <app/util/basic-types.h>
#include <inet/IPAddress.h>
Expand Down
7 changes: 6 additions & 1 deletion src/lib/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ static_library("lib") {
public_deps = [
"${chip_root}/src/app",
"${chip_root}/src/ble",
"${chip_root}/src/controller",
"${chip_root}/src/crypto",
"${chip_root}/src/inet",
"${chip_root}/src/lib/asn1",
Expand All @@ -28,11 +27,17 @@ static_library("lib") {
"${chip_root}/src/lib/support",
"${chip_root}/src/messaging",
"${chip_root}/src/platform",
"${chip_root}/src/protocols",
"${chip_root}/src/setup_payload",
"${chip_root}/src/system",
"${chip_root}/src/transport",
]

# See src/lib/lib.gni for declaration of this build arg.
if (chip_build_controller) {
public_deps += [ "${chip_root}/src/controller" ]
}

# Only include the shell if it is being used. The shell is
# a debug feature mostly useful for embedded examples.
# See src/lib/lib.gni for declaration of this build arg.
Expand Down
6 changes: 6 additions & 0 deletions src/lib/lib.gni
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import("//build_overrides/chip.gni")
import("${chip_root}/src/lib/core/core.gni")

declare_args() {
# Build controller library.
chip_build_controller = chip_target_style != "embedded"

# Enable libshell support.
chip_build_libshell = false

Expand Down
2 changes: 2 additions & 0 deletions src/platform/Linux/ThreadStackManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#include <platform/PlatformManager.h>
#include <platform/ThreadStackManager.h>

#include <app-common/zap-generated/ids/Attributes.h>

#include <nlbyteorder.hpp>
#include <nlio-byteorder.hpp>
#include <nlio.hpp>
Expand Down
2 changes: 2 additions & 0 deletions src/platform/webos/ThreadStackManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#include <platform/ThreadStackManager.h>
#include <platform/webos/NetworkCommissioningDriver.h>

#include <app-common/zap-generated/ids/Attributes.h>

#include <nlbyteorder.hpp>
#include <nlio-byteorder.hpp>
#include <nlio.hpp>
Expand Down
1 change: 1 addition & 0 deletions src/protocols/secure_channel/CASEDestinationId.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <credentials/FabricTable.h>
#include <credentials/GroupDataProvider.h>
#include <lib/core/CHIPError.h>
#include <lib/support/BufferWriter.h>
#include <lib/support/Span.h>

#include "CASEDestinationId.h"
Expand Down

0 comments on commit 3357355

Please sign in to comment.