Skip to content

Commit

Permalink
[nxp fromtree] Add support for log control variants to NXP build targ…
Browse files Browse the repository at this point in the history
…ets (project-chip#36122)

* Add support for controlling logging amount in NXP builds

* Remove the many reformat issues

* Restyled by isort

* Update scripts/build/builders/nxp.py

Co-authored-by: Arkadiusz Bokowy <[email protected]>

---------

Co-authored-by: Restyled.io <[email protected]>
Co-authored-by: Arkadiusz Bokowy <[email protected]>
(cherry picked from commit 8fa33f0)
  • Loading branch information
andy31415 authored Oct 18, 2024
1 parent c6185b2 commit cbbea37
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 4 deletions.
6 changes: 5 additions & 1 deletion scripts/build/build/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from builders.mw320 import MW320App, MW320Builder
from builders.nrf import NrfApp, NrfBoard, NrfConnectBuilder
from builders.nuttx import NuttXApp, NuttXBoard, NuttXBuilder
from builders.nxp import NxpApp, NxpBoard, NxpBoardVariant, NxpBuilder, NxpBuildSystem, NxpOsUsed
from builders.nxp import NxpApp, NxpBoard, NxpBoardVariant, NxpBuilder, NxpBuildSystem, NxpLogLevel, NxpOsUsed
from builders.openiotsdk import OpenIotSdkApp, OpenIotSdkBuilder, OpenIotSdkCryptoBackend
from builders.qpg import QpgApp, QpgBoard, QpgBuilder
from builders.stm32 import stm32App, stm32Board, stm32Builder
Expand Down Expand Up @@ -561,6 +561,10 @@ def BuildNxpTarget():
target.AppendModifier(name="iw416", iw416_transceiver=True).OnlyIfRe('rt1060')
target.AppendModifier(name="w8801", w8801_transceiver=True).OnlyIfRe('rt1060')
target.AppendModifier(name="iwx12", iwx12_transceiver=True).OnlyIfRe('rt1060|rt1170')
target.AppendModifier(name="log-all", log_level=NxpLogLevel.ALL).ExceptIfRe("-log-(progress|error|none)")
target.AppendModifier(name="log-progress", log_level=NxpLogLevel.PROGRESS).ExceptIfRe("-log-(all|error|none)")
target.AppendModifier(name="log-error", log_level=NxpLogLevel.ERROR).ExceptIfRe("-log-(progress|all|none)")
target.AppendModifier(name="log-none", log_level=NxpLogLevel.NONE).ExceptIfRe("-log-(progress|error|all)")

return target

Expand Down
43 changes: 41 additions & 2 deletions scripts/build/builders/nxp.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,14 @@ def BuildRoot(self, root, board, os_env):
return os.path.join(root, 'examples', self.ExampleName(), 'nxp', board.FolderName(os_env))


class NxpLogLevel(Enum):
DEFAULT = auto() # default everything
ALL = auto() # enable all logging
PROGRESS = auto() # progress and above
ERROR = auto() # error and above
NONE = auto() # no chip_logging at all


class NxpBuilder(GnBuilder):

def __init__(self,
Expand Down Expand Up @@ -187,7 +195,9 @@ def __init__(self,
disable_pairing_autostart: bool = False,
iw416_transceiver: bool = False,
w8801_transceiver: bool = False,
iwx12_transceiver: bool = False):
iwx12_transceiver: bool = False,
log_level: NxpLogLevel = NxpLogLevel.DEFAULT,
):
super(NxpBuilder, self).__init__(
root=app.BuildRoot(root, board, os_env),
runner=runner)
Expand Down Expand Up @@ -217,12 +227,16 @@ def __init__(self,
self.iw416_transceiver = iw416_transceiver
self.w8801_transceiver = w8801_transceiver
self.iwx12_transceiver = iwx12_transceiver
if self.low_power and log_level != NxpLogLevel.NONE:
logging.warning("Switching log level to 'NONE' for low power build")
log_level = NxpLogLevel.NONE
self.log_level = log_level

def GnBuildArgs(self):
args = []

if self.low_power:
args.append('chip_with_low_power=1 chip_logging=false')
args.append('chip_with_low_power=1')
if self.board == NxpBoard.K32W0:
args.append('chip_pw_tokenizer_logging=false chip_with_OM15082=0')

Expand All @@ -244,6 +258,31 @@ def GnBuildArgs(self):
if self.enable_rotating_id:
args.append('chip_enable_rotating_device_id=1 chip_enable_additional_data_advertising=1')

if self.log_level == NxpLogLevel.DEFAULT:
pass
elif self.log_level == NxpLogLevel.ALL:
args.append("chip_logging=true")
args.append("chip_error_logging=true")
args.append("chip_progress_logging=true")
args.append("chip_detail_logging=true")
args.append("chip_automation_logging=true")
elif self.log_level == NxpLogLevel.PROGRESS:
args.append("chip_logging=true")
args.append("chip_error_logging=true")
args.append("chip_progress_logging=true")
args.append("chip_detail_logging=false")
args.append("chip_automation_logging=false")
elif self.log_level == NxpLogLevel.ERROR:
args.append("chip_logging=true")
args.append("chip_error_logging=true")
args.append("chip_progress_logging=false")
args.append("chip_detail_logging=false")
args.append("chip_automation_logging=false")
elif self.log_level == NxpLogLevel.NONE:
args.append("chip_logging=false")
else:
raise Exception("Unknown log level: %r", self.log_level)

if self.has_sw_version_2:
args.append('nxp_software_version=2')

Expand Down
2 changes: 1 addition & 1 deletion scripts/build/testdata/all_targets_linux_x64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ linux-{x64,arm64}-{rpc-console,all-clusters,all-clusters-minimal,chip-tool,therm
linux-x64-efr32-test-runner[-clang]
imx-{chip-tool,lighting-app,thermostat,all-clusters-app,all-clusters-minimal-app,ota-provider-app}[-release]
infineon-psoc6-{lock,light,all-clusters,all-clusters-minimal}[-ota][-updateimage][-trustm]
nxp-{k32w0,k32w1,rt1060,rt1170,rw61x,rw61x_eth,mcxw71}-{zephyr,freertos}-{lighting,contact-sensor,lock-app,all-clusters,laundry-washer,thermostat}[-factory][-low-power][-lit][-fro32k][-smu2][-dac-conversion][-rotating-id][-sw-v2][-ota][-wifi][-ethernet][-thread][-matter-shell][-data-model-disabled][-data-model-enabled][-factory-build][-frdm][-cmake][-evkc][-iw416][-w8801][-iwx12]
nxp-{k32w0,k32w1,rt1060,rt1170,rw61x,rw61x_eth,mcxw71}-{zephyr,freertos}-{lighting,contact-sensor,lock-app,all-clusters,laundry-washer,thermostat}[-factory][-low-power][-lit][-fro32k][-smu2][-dac-conversion][-rotating-id][-sw-v2][-ota][-wifi][-ethernet][-thread][-matter-shell][-data-model-disabled][-data-model-enabled][-factory-build][-frdm][-cmake][-evkc][-iw416][-w8801][-iwx12][-log-all][-log-progress][-log-error][-log-none]
mbed-cy8cproto_062_4343w-{lock,light,all-clusters,all-clusters-minimal,pigweed,ota-requestor,shell}[-release][-develop][-debug][-data-model-disabled][-data-model-enabled]
mw320-all-clusters-app
nrf-{nrf5340dk,nrf52840dk,nrf52840dongle}-{all-clusters,all-clusters-minimal,lock,light,light-switch,shell,pump,pump-controller,window-covering}[-rpc][-data-model-disabled][-data-model-enabled]
Expand Down

0 comments on commit cbbea37

Please sign in to comment.