Skip to content

Commit 42daedc

Browse files
committed
[NXP][scripts][build_examples] Adding differentiator to support both gn and cmake build systems
Signed-off-by: Dina Benamar <dina.benamarelmaaroufi@nxp.com>
1 parent 1864604 commit 42daedc

File tree

4 files changed

+36
-11
lines changed

4 files changed

+36
-11
lines changed

.github/workflows/examples-nxp.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ jobs:
229229
--target nxp-rw61x-freertos-all-clusters-wifi \
230230
--target nxp-rw61x-freertos-all-clusters-thread \
231231
--target nxp-rw61x-freertos-all-clusters-thread-wifi \
232+
--target nxp-rw61x-freertos-all-clusters-wifi-ota-cmake \
232233
build \
233234
--copy-artifacts-to out/artifacts \
234235
"

scripts/build/build/targets.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
from builders.mw320 import MW320App, MW320Builder
2929
from builders.nrf import NrfApp, NrfBoard, NrfConnectBuilder
3030
from builders.nuttx import NuttXApp, NuttXBoard, NuttXBuilder
31-
from builders.nxp import NxpApp, NxpBoard, NxpBuilder, NxpOsUsed
31+
from builders.nxp import NxpApp, NxpBoard, NxpBuilder, NxpOsUsed, NxpBuildSystem
3232
from builders.openiotsdk import OpenIotSdkApp, OpenIotSdkBuilder, OpenIotSdkCryptoBackend
3333
from builders.qpg import QpgApp, QpgBoard, QpgBuilder
3434
from builders.stm32 import stm32App, stm32Board, stm32Builder
@@ -540,6 +540,7 @@ def BuildNxpTarget():
540540
target.AppendModifier(name="matter-shell", enable_shell=True).ExceptIfRe('k32w0|k32w1')
541541
target.AppendModifier(name="factory-build", enable_factory_data_build=True).OnlyIfRe('rw61x')
542542
target.AppendModifier(name="frdm", board_variant="frdm").OnlyIfRe('rw61x')
543+
target.AppendModifier(name="cmake", build_system=NxpBuildSystem.CMAKE).OnlyIfRe('rw61x')
543544

544545
return target
545546

scripts/build/builders/nxp.py

+31-8
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,17 @@ def OsEnv(self):
3333
else:
3434
raise Exception('Unknown OS type: %r' % self)
3535

36+
class NxpBuildSystem(Enum):
37+
GN = auto()
38+
CMAKE = auto()
39+
40+
def BuildSystem(self):
41+
if self == NxpBuildSystem.GN:
42+
return 'gn'
43+
elif self == NxpBuildSystem.CMAKE:
44+
return 'cmake'
45+
else:
46+
raise Exception('Unknown build system: %r' % self)
3647

3748
class NxpBoard(Enum):
3849
K32W0 = auto()
@@ -118,6 +129,7 @@ def __init__(self,
118129
app: NxpApp = NxpApp.LIGHTING,
119130
board: NxpBoard = NxpBoard.K32W0,
120131
os_env: NxpOsUsed = NxpOsUsed.FREERTOS,
132+
build_system: NxpBuildSystem = NxpBuildSystem.GN,
121133
low_power: bool = False,
122134
smu2: bool = False,
123135
enable_factory_data: bool = False,
@@ -141,6 +153,7 @@ def __init__(self,
141153
self.app = app
142154
self.board = board
143155
self.os_env = os_env
156+
self.build_system = build_system
144157
self.low_power = low_power
145158
self.smu2 = smu2
146159
self.enable_factory_data = enable_factory_data
@@ -210,6 +223,7 @@ def GnBuildArgs(self):
210223

211224
def CmakeBuildFlags(self):
212225
flags = []
226+
213227
if self.enable_factory_data:
214228
if self.os_env == NxpOsUsed.ZEPHYR:
215229
flags.append('-DFILE_SUFFIX=fdata')
@@ -288,7 +302,7 @@ def generate(self):
288302
elif p.sdk_name == 'common':
289303
cmd += 'export NXP_SDK_ROOT="' + str(p.sdk_storage_location_abspath) + '" \n '
290304

291-
if self.board == NxpBoard.RW61X:
305+
if self.build_system == NxpBuildSystem.CMAKE:
292306
cmd += '''
293307
cmake -GNinja {build_flags} -H{example_folder} -B{out_folder}
294308
'''.format(
@@ -297,7 +311,7 @@ def generate(self):
297311
out_folder=self.output_dir).strip()
298312
self._Execute(['bash', '-c', cmd], title='Generating ' + self.identifier)
299313

300-
else:
314+
elif self.build_system == NxpBuildSystem.GN:
301315
# add empty space at the end to avoid concatenation issue when there is no --args
302316
cmd += 'gn gen --check --fail-on-unused-args --export-compile-commands --root=%s ' % self.root
303317

@@ -333,10 +347,19 @@ def build_outputs(self):
333347
os.path.join(self.output_dir, 'zephyr', 'zephyr.map'),
334348
f'{name}.map')
335349
else:
336-
yield BuilderOutput(
337-
os.path.join(self.output_dir, name),
338-
f'{name}.elf')
339-
if self.options.enable_link_map_file:
350+
if self.build_system == NxpBuildSystem.GN:
340351
yield BuilderOutput(
341-
os.path.join(self.output_dir, f'{name}.map'),
342-
f'{name}.map')
352+
os.path.join(self.output_dir, name),
353+
f'{name}.elf')
354+
if self.options.enable_link_map_file:
355+
yield BuilderOutput(
356+
os.path.join(self.output_dir, f'{name}.map'),
357+
f'{name}.map')
358+
elif self.build_system == NxpBuildSystem.CMAKE:
359+
yield BuilderOutput(
360+
os.path.join(self.output_dir, 'out/debug', name),
361+
f'{name}.elf')
362+
if self.options.enable_link_map_file:
363+
yield BuilderOutput(
364+
os.path.join(self.output_dir, 'out/debug', f'{name}.map'),
365+
f'{name}.map')

scripts/build/testdata/all_targets_linux_x64.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ efr32-{brd2704b,brd4316a,brd4317a,brd4318a,brd4319a,brd4186a,brd4187a,brd2601b,b
99
esp32-{m5stack,c3devkit,devkitc,qemu}-{all-clusters,all-clusters-minimal,energy-management,ota-provider,ota-requestor,shell,light,lock,bridge,temperature-measurement,ota-requestor,tests}[-rpc][-ipv6only][-tracing]
1010
genio-lighting-app
1111
linux-fake-tests[-mbedtls][-boringssl][-asan][-tsan][-ubsan][-libfuzzer][-ossfuzz][-pw-fuzztest][-coverage][-dmalloc][-clang]
12-
linux-{x64,arm64}-{rpc-console,all-clusters,all-clusters-minimal,chip-tool,thermostat,java-matter-controller,kotlin-matter-controller,minmdns,light,light-data-model-no-unique-id,lock,shell,ota-provider,ota-requestor,simulated-app1,simulated-app2,python-bindings,tv-app,tv-casting-app,bridge,fabric-admin,fabric-bridge,tests,chip-cert,address-resolve-tool,contact-sensor,dishwasher,microwave-oven,refrigerator,rvc,air-purifier,lit-icd,air-quality-sensor,network-manager,energy-management}[-nodeps][-nlfaultinject][-platform-mdns][-minmdns-verbose][-libnl][-same-event-loop][-no-interactive][-ipv6only][-no-ble][-no-wifi][-no-thread][-mbedtls][-boringssl][-asan][-tsan][-ubsan][-libfuzzer][-ossfuzz][-pw-fuzztest][-coverage][-dmalloc][-clang][-test][-rpc][-with-ui][-evse-test-event][-enable-dnssd-tests][-disable-dnssd-tests][-chip-casting-simplified][-data-model-check][-data-model-disabled][-data-model-enabled][-check-failure-die]
12+
linux-{x64,arm64}-{rpc-console,all-clusters,all-clusters-minimal,chip-tool,thermostat,java-matter-controller,kotlin-matter-controller,minmdns,light,light-data-model-no-unique-id,lock,shell,ota-provider,ota-requestor,simulated-app1,simulated-app2,python-bindings,tv-app,tv-casting-app,bridge,fabric-admin,fabric-bridge,tests,chip-cert,address-resolve-tool,contact-sensor,dishwasher,microwave-oven,refrigerator,rvc,air-purifier,lit-icd,air-quality-sensor,network-manager,energy-management}[-nodeps][-nlfaultinject][-platform-mdns][-minmdns-verbose][-libnl][-same-event-loop][-no-interactive][-ipv6only][-no-ble][-no-wifi][-no-thread][-mbedtls][-boringssl][-asan][-tsan][-ubsan][-libfuzzer][-ossfuzz][-pw-fuzztest][-coverage][-dmalloc][-clang][-test][-rpc][-with-ui][-evse-test-event][-enable-dnssd-tests][-disable-dnssd-tests][-chip-casting-simplified][-data-model-check][-data-model-disabled][-data-model-enabled]
1313
linux-x64-efr32-test-runner[-clang]
1414
imx-{chip-tool,lighting-app,thermostat,all-clusters-app,all-clusters-minimal-app,ota-provider-app}[-release]
1515
infineon-psoc6-{lock,light,all-clusters,all-clusters-minimal}[-ota][-updateimage][-trustm]
16-
nxp-{k32w0,k32w1,rw61x,mcxw71}-{zephyr,freertos}-{lighting,contact-sensor,all-clusters,laundry-washer,thermostat}[-factory][-low-power][-lit][-fro32k][-smu2][-dac-conversion][-rotating-id][-sw-v2][-ota][-wifi][-thread][-matter-shell]
16+
nxp-{k32w0,k32w1,rw61x,mcxw71}-{zephyr,freertos}-{lighting,contact-sensor,all-clusters,laundry-washer,thermostat}[-factory][-low-power][-lit][-fro32k][-smu2][-dac-conversion][-rotating-id][-sw-v2][-ota][-wifi][-thread][-matter-shell][-factory-build][-frdm][-cmake]
1717
mbed-cy8cproto_062_4343w-{lock,light,all-clusters,all-clusters-minimal,pigweed,ota-requestor,shell}[-release][-develop][-debug]
1818
mw320-all-clusters-app
1919
nrf-{nrf5340dk,nrf52840dk,nrf52840dongle}-{all-clusters,all-clusters-minimal,lock,light,light-switch,shell,pump,pump-controller,window-covering}[-rpc]

0 commit comments

Comments
 (0)