Skip to content

Commit 966f7c0

Browse files
authored
Merge branch 'master' into master
2 parents a0a7eee + 4a21a8d commit 966f7c0

15 files changed

+111
-20
lines changed

.devcontainer/Dockerfile

+11
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ RUN apt-get update \
3737
valgrind \
3838
docker.io \
3939
iputils-ping \
40+
icecc \
4041
&& :
4142

4243
RUN groupadd -g $USER_GID $USERNAME \
@@ -80,3 +81,13 @@ ENV TIZEN_ROOTFS /tizen_rootfs
8081

8182
# Fast Model GDB plugins path for debugging support
8283
ENV FAST_MODEL_PLUGINS_PATH /opt/FastModelsPortfolio_11.16/plugins/Linux64_GCC-9.3
84+
85+
# Set up ccache as a pigweed command launcher when using the scripts/build/build_examples.py
86+
# script. Also, set up icecc as the command prefix for ccache. Such setup allows to benefit
87+
# from compilation caching and distributed compilation at the same time.
88+
#
89+
# NOTE: In order to use distributed compilation with icecc, one should run
90+
# "scripts/icecc.sh start" before starting the build.
91+
ENV CHIP_PW_COMMAND_LAUNCHER ccache
92+
ENV CCACHE_PREFIX icecc
93+
ENV PATH /usr/lib/ccache:$PATH

.pullapprove.yml

-7
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,6 @@ overrides:
3333
status: success
3434
explanation: "Review not required unless merging to master"
3535

36-
############################################################
37-
# Required status checks
38-
############################################################
39-
- if: "'restyled' not in check_runs.successful"
40-
status: failure
41-
explanation: "Restyled workflow must be successful"
42-
4336
############################################################
4437
# Require Issues
4538
############################################################

scripts/build/build/__init__.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
from enum import Enum, auto
55
from typing import Sequence
66

7-
from .targets import BUILD_TARGETS
87
from builders.builder import BuilderOptions
98

9+
from .targets import BUILD_TARGETS
10+
1011

1112
class BuildSteps(Enum):
1213
GENERATED = auto()
@@ -18,11 +19,12 @@ class Context:
1819
to generate make/ninja instructions and to compile.
1920
"""
2021

21-
def __init__(self, runner, repository_path: str, output_prefix: str):
22+
def __init__(self, runner, repository_path: str, output_prefix: str, ninja_jobs: int):
2223
self.builders = []
2324
self.runner = runner
2425
self.repository_path = repository_path
2526
self.output_prefix = output_prefix
27+
self.ninja_jobs = ninja_jobs
2628
self.completed_steps = set()
2729

2830
def SetupBuilders(self, targets: Sequence[str], options: BuilderOptions):
@@ -36,7 +38,7 @@ def SetupBuilders(self, targets: Sequence[str], options: BuilderOptions):
3638
found = False
3739
for choice in BUILD_TARGETS:
3840
builder = choice.Create(target, self.runner, self.repository_path,
39-
self.output_prefix, options)
41+
self.output_prefix, self.ninja_jobs, options)
4042
if builder:
4143
self.builders.append(builder)
4244
found = True

scripts/build/build/target.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ def StringIntoTargetParts(self, value: str):
389389
return _StringIntoParts(value, suffix, self.fixed_targets, self.modifiers)
390390

391391
def Create(self, name: str, runner, repository_path: str, output_prefix: str,
392-
builder_options: BuilderOptions):
392+
ninja_jobs: int, builder_options: BuilderOptions):
393393

394394
parts = self.StringIntoTargetParts(name)
395395

@@ -406,6 +406,7 @@ def Create(self, name: str, runner, repository_path: str, output_prefix: str,
406406
builder.target = self
407407
builder.identifier = name
408408
builder.output_dir = os.path.join(output_prefix, name)
409+
builder.ninja_jobs = ninja_jobs
409410
builder.chip_dir = os.path.abspath(repository_path)
410411
builder.options = builder_options
411412

scripts/build/build_examples.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,13 @@ def ValidateTargetNames(context, parameter, values):
104104
default='./out',
105105
type=click.Path(file_okay=False, resolve_path=True),
106106
help='Prefix for the generated file output.')
107+
@click.option(
108+
'--ninja-jobs',
109+
type=int,
110+
is_flag=False,
111+
flag_value=0,
112+
default=None,
113+
help='Number of ninja jobs')
107114
@click.option(
108115
'--pregen-dir',
109116
default=None,
@@ -136,8 +143,8 @@ def ValidateTargetNames(context, parameter, values):
136143
'for using ccache when building examples.'))
137144
@click.pass_context
138145
def main(context, log_level, target, enable_link_map_file, repo,
139-
out_prefix, pregen_dir, clean, dry_run, dry_run_output, enable_flashbundle,
140-
no_log_timestamps, pw_command_launcher):
146+
out_prefix, ninja_jobs, pregen_dir, clean, dry_run, dry_run_output,
147+
enable_flashbundle, no_log_timestamps, pw_command_launcher):
141148
# Ensures somewhat pretty logging of what is going on
142149
log_fmt = '%(asctime)s %(levelname)-7s %(message)s'
143150
if no_log_timestamps:
@@ -161,7 +168,7 @@ def main(context, log_level, target, enable_link_map_file, repo,
161168
logging.info('Building targets: %s', CommaSeparate(requested_targets))
162169

163170
context.obj = build.Context(
164-
repository_path=repo, output_prefix=out_prefix, runner=runner)
171+
repository_path=repo, output_prefix=out_prefix, ninja_jobs=ninja_jobs, runner=runner)
165172
context.obj.SetupBuilders(targets=requested_targets, options=BuilderOptions(
166173
enable_link_map_file=enable_link_map_file,
167174
enable_flashbundle=enable_flashbundle,

scripts/build/builders/ameba.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,12 @@ def generate(self):
8585
title='Generating ' + self.identifier)
8686

8787
def _build(self):
88-
self._Execute(['ninja', '-C', self.output_dir],
89-
title='Building ' + self.identifier)
88+
cmd = ['ninja', '-C', self.output_dir]
89+
90+
if self.ninja_jobs is not None:
91+
cmd.append('-j' + str(self.ninja_jobs))
92+
93+
self._Execute(cmd, title='Building ' + self.identifier)
9094

9195
def build_outputs(self):
9296
yield BuilderOutput(

scripts/build/builders/android.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -466,8 +466,13 @@ def _build(self):
466466
title="Building APP " + self.identifier,
467467
)
468468
else:
469+
cmd = ["ninja", "-C", self.output_dir]
470+
471+
if self.ninja_jobs is not None:
472+
cmd.append('-j' + str(self.ninja_jobs))
473+
469474
self._Execute(
470-
["ninja", "-C", self.output_dir],
475+
cmd,
471476
title="Building JNI " + self.identifier,
472477
)
473478

scripts/build/builders/gn.py

+2
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ def _build(self):
9595
self.PreBuildCommand()
9696

9797
cmd = ['ninja', '-C', self.output_dir]
98+
if self.ninja_jobs is not None:
99+
cmd.append('-j' + str(self.ninja_jobs))
98100
if self.build_command:
99101
cmd.append(self.build_command)
100102

scripts/build/builders/host.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,14 @@ def generate(self):
570570

571571
def PreBuildCommand(self):
572572
if self.app == HostApp.TESTS and self.use_coverage:
573-
self._Execute(['ninja', '-C', self.output_dir, 'default'], title="Build-only")
573+
cmd = ['ninja', '-C', self.output_dir]
574+
575+
if self.ninja_jobs is not None:
576+
cmd.append('-j' + str(self.ninja_jobs))
577+
578+
cmd.append('default')
579+
580+
self._Execute(cmd, title="Build-only")
574581
self._Execute(['lcov', '--initial', '--capture', '--directory', os.path.join(self.output_dir, 'obj'),
575582
'--exclude', os.path.join(self.chip_dir, '**/tests/*'),
576583
'--exclude', os.path.join(self.chip_dir, 'zzz_generated/*'),

scripts/build/builders/nrf.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,12 @@ def generate(self):
215215
def _build(self):
216216
logging.info('Compiling NrfConnect at %s', self.output_dir)
217217

218-
self._Execute(['ninja', '-C', self.output_dir],
219-
title='Building ' + self.identifier)
218+
cmd = ['ninja', '-C', self.output_dir]
219+
220+
if self.ninja_jobs is not None:
221+
cmd.append('-j' + str(self.ninja_jobs))
222+
223+
self._Execute(cmd, title='Building ' + self.identifier)
220224

221225
if self.app == NrfApp.UNIT_TESTS:
222226
# Note: running zephyr/zephyr.elf has the same result except it creates

scripts/build/builders/telink.py

+3
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,9 @@ def _build(self):
238238

239239
cmd = self.get_cmd_prefixes() + ("ninja -C %s" % self.output_dir)
240240

241+
if self.ninja_jobs is not None:
242+
cmd += " -j%s" % str(self.ninja_jobs)
243+
241244
self._Execute(['bash', '-c', cmd], title='Building ' + self.identifier)
242245

243246
def build_outputs(self):

scripts/icecc.sh

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Copyright (c) 2024 Project CHIP Authors
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
# This scripts starts or stops the iceccd.
19+
# It's meant to be use within devcontainer.
20+
21+
if [ "$1" = "start" ]; then
22+
IFS='.' read -ra PARTS <<<"$HOSTNAME"
23+
if iceccd -d -m 0 -N "devcontainer-${PARTS[0]}"; then
24+
echo "iceccd started"
25+
else
26+
echo "Failed to start iceccd"
27+
fi
28+
fi
29+
30+
if [ "$1" = "stop" ]; then
31+
if pkill icecc; then
32+
echo "iceccd stopped"
33+
else
34+
echo "Failed to stop iceccd"
35+
fi
36+
fi

src/app/InteractionModelEngine.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ CHIP_ERROR InteractionModelEngine::Init(Messaging::ExchangeManager * apExchangeM
8989
VerifyOrReturnError(apExchangeMgr != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
9090
VerifyOrReturnError(reportScheduler != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
9191

92+
mState = State::kInitializing;
9293
mpExchangeMgr = apExchangeMgr;
9394
mpFabricTable = apFabricTable;
9495
mpCASESessionMgr = apCASESessionMgr;
@@ -111,11 +112,14 @@ CHIP_ERROR InteractionModelEngine::Init(Messaging::ExchangeManager * apExchangeM
111112
ChipLogError(InteractionModel, "WARNING └────────────────────────────────────────────────────");
112113
#endif
113114

115+
mState = State::kInitialized;
114116
return CHIP_NO_ERROR;
115117
}
116118

117119
void InteractionModelEngine::Shutdown()
118120
{
121+
VerifyOrReturn(State::kUninitialized != mState);
122+
119123
mpExchangeMgr->GetSessionManager()->SystemLayer()->CancelTimer(ResumeSubscriptionsTimerCallback, this);
120124

121125
// TODO: individual object clears the entire command handler interface registry.
@@ -187,6 +191,8 @@ void InteractionModelEngine::Shutdown()
187191
//
188192
// mpFabricTable = nullptr;
189193
// mpExchangeMgr = nullptr;
194+
195+
mState = State::kUninitialized;
190196
}
191197

192198
uint32_t InteractionModelEngine::GetNumActiveReadHandlers() const

src/app/InteractionModelEngine.h

+8
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,14 @@ class InteractionModelEngine : public Messaging::UnsolicitedMessageHandler,
713713
DataModel::Provider * mDataModelProvider = nullptr;
714714
Messaging::ExchangeContext * mCurrentExchange = nullptr;
715715

716+
enum class State : uint8_t
717+
{
718+
kUninitialized, // The object has not been initialized.
719+
kInitializing, // Initial setup is in progress (e.g. setting up mpExchangeMgr).
720+
kInitialized // The object has been fully initialized and is ready for use.
721+
};
722+
State mState = State::kUninitialized;
723+
716724
// Changes the current exchange context of a InteractionModelEngine to a given context
717725
class CurrentExchangeValueScope
718726
{

src/app/server/CommissioningWindowManager.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ void CommissioningWindowManager::OnPlatformEvent(const DeviceLayer::ChipDeviceEv
111111

112112
void CommissioningWindowManager::Shutdown()
113113
{
114+
VerifyOrReturn(nullptr != mServer);
115+
114116
StopAdvertisement(/* aShuttingDown = */ true);
115117

116118
ResetState();

0 commit comments

Comments
 (0)