Skip to content

Commit 4e67392

Browse files
arkqwoody-applerestyled-commits
authored
Add possibility to build Tizen apps with various options (#16701)
* [build] Fix warnings reported by flake8 checker * [build] Allow to build Tizen apps with variants This change adds a possibility to build Tizen applications with e.g. ASAN sanitizer enabled. Please note, that with current Tizen SDK there is no TSAN library (TSAN for ARMv7) provided, so it's not possible to enable this sanitizer. * Restyled by autopep8 Co-authored-by: Justin Wood <[email protected]> Co-authored-by: Restyled.io <[email protected]>
1 parent f69dfe8 commit 4e67392

21 files changed

+222
-108
lines changed

.flake8

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[flake8]
2+
max-line-length = 132

scripts/build/README.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ followed by platform-specific instructions.
1414
The file BUILDING.md describes general requirements and examples. Typical usage
1515
is:
1616

17-
```
17+
```sh
1818
source scripts/activate
1919
gn gen out/host
2020
ninja -C out/host
@@ -34,37 +34,37 @@ Usage examples:
3434

3535
1. Compiles all targets
3636

37-
```
37+
```sh
3838
./scripts/build/build_examples.py --target all build
3939
```
4040

4141
2. Compile the all clusters app for a ESP32 DevKitC
4242

43-
```
43+
```sh
4444
./scripts/build/build_examples.py --target esp32-devkitc-all-clusters build
4545
```
4646

4747
3. Generate all the makefiles (but do not compile) using a specific output root
4848

49-
```
49+
```sh
5050
./scripts/build/build_examples.py --target linux-x64-chip-tool --out-prefix ./mydir gen
5151
```
5252

5353
4. Compile the qpg lock app and copy the output in a 'artifact' folder. Note the
5454
argument order (artifact copying is an argument for the build command)
5555

56-
```
56+
```sh
5757
./scripts/build/build_examples.py --target qpg-lock build --copy-artifacts-to /tmp/artifacts
5858
```
5959

6060
5. Find out all possible targets for compiling the 'light' app:
6161

62-
```
62+
```sh
6363
./scripts/build/build_examples.py --target-glob '*light' --log-level fatal targets
6464
```
6565

6666
6. Compile everything except linux or darwin:
6767

68-
```
68+
```sh
6969
./scripts/build/build_examples.py --skip-target-glob '{darwin,linux}-*' --log-level fatal build
7070
```

scripts/build/build/__init__.py

+13-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import logging
22
import os
33
import shutil
4-
54
from enum import Enum, auto
65
from typing import Sequence
76

8-
from .targets import Target, ALL
7+
from .targets import ALL, Target
98

109
ALL_TARGETS = ALL
1110

@@ -27,19 +26,27 @@ def __init__(self, runner, repository_path: str, output_prefix: str):
2726
self.output_prefix = output_prefix
2827
self.completed_steps = set()
2928

30-
def SetupBuilders(self, targets: Sequence[Target], enable_flashbundle: bool):
31-
"""Configures internal builders for the given platform/board/app combination. """
29+
def SetupBuilders(self, targets: Sequence[Target],
30+
enable_flashbundle: bool):
31+
"""
32+
Configures internal builders for the given platform/board/app
33+
combination.
34+
"""
3235

3336
self.builders = []
3437
for target in targets:
3538
self.builders.append(target.Create(
36-
self.runner, self.repository_path, self.output_prefix, enable_flashbundle))
39+
self.runner, self.repository_path, self.output_prefix,
40+
enable_flashbundle))
3741

3842
# whenever builders change, assume generation is required again
3943
self.completed_steps.discard(BuildSteps.GENERATED)
4044

4145
def Generate(self):
42-
"""Performs a build generation IFF code generation has not yet been performed."""
46+
"""
47+
Performs a build generation IF code generation has not yet been
48+
performed.
49+
"""
4350
if BuildSteps.GENERATED in self.completed_steps:
4451
return
4552

scripts/build/build/targets.py

+77-40
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,19 @@
1313
# limitations under the License.
1414

1515
import os
16-
17-
from typing import Any, List
1816
from itertools import combinations
17+
from typing import List
1918

2019
from builders.ameba import AmebaApp, AmebaBoard, AmebaBuilder
21-
from builders.android import AndroidBoard, AndroidApp, AndroidBuilder
20+
from builders.android import AndroidApp, AndroidBoard, AndroidBuilder
2221
from builders.cc13x2x7_26x2x7 import cc13x2x7_26x2x7App, cc13x2x7_26x2x7Builder
23-
from builders.cyw30739 import Cyw30739Builder, Cyw30739App, Cyw30739Board
24-
from builders.efr32 import Efr32Builder, Efr32App, Efr32Board
25-
from builders.esp32 import Esp32Builder, Esp32Board, Esp32App
26-
from builders.host import HostBuilder, HostApp, HostBoard
27-
from builders.infineon import InfineonBuilder, InfineonApp, InfineonBoard
22+
from builders.cyw30739 import Cyw30739App, Cyw30739Board, Cyw30739Builder
23+
from builders.efr32 import Efr32App, Efr32Board, Efr32Builder
24+
from builders.esp32 import Esp32App, Esp32Board, Esp32Builder
25+
from builders.host import HostApp, HostBoard, HostBuilder
26+
from builders.infineon import InfineonApp, InfineonBoard, InfineonBuilder
2827
from builders.k32w import K32WApp, K32WBuilder
29-
from builders.mbed import MbedApp, MbedBoard, MbedProfile, MbedBuilder
28+
from builders.mbed import MbedApp, MbedBoard, MbedBuilder, MbedProfile
3029
from builders.nrf import NrfApp, NrfBoard, NrfConnectBuilder
3130
from builders.qpg import QpgApp, QpgBoard, QpgBuilder
3231
from builders.telink import TelinkApp, TelinkBoard, TelinkBuilder
@@ -68,7 +67,8 @@ def Extend(self, suffix, **kargs):
6867
clone.create_kw_args.update(kargs)
6968
return clone
7069

71-
def Create(self, runner, repository_path: str, output_prefix: str, enable_flashbundle: bool):
70+
def Create(self, runner, repository_path: str, output_prefix: str,
71+
enable_flashbundle: bool):
7272
builder = self.builder_class(
7373
repository_path, runner=runner, **self.create_kw_args)
7474

@@ -115,7 +115,9 @@ def Accept(self, name: str):
115115

116116

117117
class BuildVariant:
118-
def __init__(self, name: str, validator=AcceptAnyName(), conflicts: List[str] = [], requires: List[str] = [], **buildargs):
118+
def __init__(self, name: str, validator=AcceptAnyName(),
119+
conflicts: List[str] = [], requires: List[str] = [],
120+
**buildargs):
119121
self.name = name
120122
self.validator = validator
121123
self.conflicts = conflicts
@@ -138,7 +140,7 @@ def AllRequirementsMet(items: List[BuildVariant]) -> bool:
138140

139141
for item in items:
140142
for requirement in item.requires:
141-
if not requirement in available:
143+
if requirement not in available:
142144
return False
143145

144146
return True
@@ -178,8 +180,8 @@ def AllVariants(self):
178180
"""
179181
Yields a list of acceptable variants for the given targets.
180182
181-
Handles conflict resolution between build variants and globbing whiltelist
182-
targets.
183+
Handles conflict resolution between build variants and globbing
184+
whitelist targets.
183185
"""
184186
for target in self.targets:
185187
yield target
@@ -204,8 +206,9 @@ def AllVariants(self):
204206
option.name, **option.buildargs)
205207

206208
# Only a few are whitelisted for globs
207-
if '-'.join([o.name for o in subgroup]) not in self.glob_whitelist:
208-
if not variant_target.glob_blacklist_reason:
209+
name = '-'.join([o.name for o in subgroup])
210+
if name not in self.glob_whitelist:
211+
if not variant_target.IsGlobBlacklisted:
209212
variant_target = variant_target.GlobBlacklist(
210213
'Reduce default build variants')
211214

@@ -214,9 +217,9 @@ def AllVariants(self):
214217

215218
def HostTargets():
216219
target = Target(HostBoard.NATIVE.PlatformName(), HostBuilder)
217-
targets = [
218-
target.Extend(HostBoard.NATIVE.BoardName(), board=HostBoard.NATIVE)
219-
]
220+
target_native = target.Extend(HostBoard.NATIVE.BoardName(), board=HostBoard.NATIVE)
221+
222+
targets = [target_native]
220223

221224
# x64 linux supports cross compile
222225
if (HostBoard.NATIVE.PlatformName() == 'linux') and (
@@ -227,9 +230,9 @@ def HostTargets():
227230

228231
# Don't cross compile some builds
229232
app_targets.append(
230-
targets[0].Extend('rpc-console', app=HostApp.RPC_CONSOLE))
233+
target_native.Extend('rpc-console', app=HostApp.RPC_CONSOLE))
231234
app_targets.append(
232-
targets[0].Extend('tv-app', app=HostApp.TV_APP))
235+
target_native.Extend('tv-app', app=HostApp.TV_APP))
233236

234237
for target in targets:
235238
app_targets.append(target.Extend(
@@ -276,11 +279,14 @@ def HostTargets():
276279
yield target
277280

278281
# Without extra build variants
279-
yield targets[0].Extend('chip-cert', app=HostApp.CERT_TOOL)
280-
yield targets[0].Extend('address-resolve-tool', app=HostApp.ADDRESS_RESOLVE)
281-
yield targets[0].Extend('address-resolve-tool-clang', app=HostApp.ADDRESS_RESOLVE, use_clang=True).GlobBlacklist("Reduce default build variants")
282-
yield targets[0].Extend('address-resolve-tool-platform-mdns', app=HostApp.ADDRESS_RESOLVE, use_platform_mdns=True).GlobBlacklist("Reduce default build variants")
283-
yield targets[0].Extend('address-resolve-tool-platform-mdns-ipv6only', app=HostApp.ADDRESS_RESOLVE, use_platform_mdns=True, enable_ipv4=False).GlobBlacklist("Reduce default build variants")
282+
yield target_native.Extend('chip-cert', app=HostApp.CERT_TOOL)
283+
yield target_native.Extend('address-resolve-tool', app=HostApp.ADDRESS_RESOLVE)
284+
yield target_native.Extend('address-resolve-tool-clang', app=HostApp.ADDRESS_RESOLVE,
285+
use_clang=True).GlobBlacklist("Reduce default build variants")
286+
yield target_native.Extend('address-resolve-tool-platform-mdns', app=HostApp.ADDRESS_RESOLVE,
287+
use_platform_mdns=True).GlobBlacklist("Reduce default build variants")
288+
yield target_native.Extend('address-resolve-tool-platform-mdns-ipv6only', app=HostApp.ADDRESS_RESOLVE,
289+
use_platform_mdns=True, enable_ipv4=False).GlobBlacklist("Reduce default build variants")
284290

285291
test_target = Target(HostBoard.NATIVE.PlatformName(), HostBuilder)
286292
for board in [HostBoard.NATIVE, HostBoard.FAKE]:
@@ -291,9 +297,12 @@ def Esp32Targets():
291297
esp32_target = Target('esp32', Esp32Builder)
292298

293299
yield esp32_target.Extend('m5stack-all-clusters', board=Esp32Board.M5Stack, app=Esp32App.ALL_CLUSTERS)
294-
yield esp32_target.Extend('m5stack-all-clusters-ipv6only', board=Esp32Board.M5Stack, app=Esp32App.ALL_CLUSTERS, enable_ipv4=False)
295-
yield esp32_target.Extend('m5stack-all-clusters-rpc', board=Esp32Board.M5Stack, app=Esp32App.ALL_CLUSTERS, enable_rpcs=True)
296-
yield esp32_target.Extend('m5stack-all-clusters-rpc-ipv6only', board=Esp32Board.M5Stack, app=Esp32App.ALL_CLUSTERS, enable_rpcs=True, enable_ipv4=False)
300+
yield esp32_target.Extend('m5stack-all-clusters-ipv6only', board=Esp32Board.M5Stack, app=Esp32App.ALL_CLUSTERS,
301+
enable_ipv4=False)
302+
yield esp32_target.Extend('m5stack-all-clusters-rpc', board=Esp32Board.M5Stack, app=Esp32App.ALL_CLUSTERS,
303+
enable_rpcs=True)
304+
yield esp32_target.Extend('m5stack-all-clusters-rpc-ipv6only', board=Esp32Board.M5Stack, app=Esp32App.ALL_CLUSTERS,
305+
enable_rpcs=True, enable_ipv4=False)
297306

298307
yield esp32_target.Extend('c3devkit-all-clusters', board=Esp32Board.C3DevKit, app=Esp32App.ALL_CLUSTERS)
299308

@@ -381,7 +390,8 @@ def NrfTargets():
381390

382391
if '-nrf5340dk-' in rpc.name:
383392
rpc = rpc.GlobBlacklist(
384-
'Compile failure due to pw_build args not forwarded to proto compiler. https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/66760')
393+
'Compile failure due to pw_build args not forwarded to proto compiler. '
394+
'https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/66760')
385395

386396
yield rpc
387397

@@ -423,8 +433,12 @@ def MbedTargets():
423433

424434
for target in app_targets:
425435
yield target.Extend('release', profile=MbedProfile.RELEASE)
426-
yield target.Extend('develop', profile=MbedProfile.DEVELOP).GlobBlacklist('Compile only for debugging purpose - https://os.mbed.com/docs/mbed-os/latest/program-setup/build-profiles-and-rules.html')
427-
yield target.Extend('debug', profile=MbedProfile.DEBUG).GlobBlacklist('Compile only for debugging purpose - https://os.mbed.com/docs/mbed-os/latest/program-setup/build-profiles-and-rules.html')
436+
yield target.Extend('develop', profile=MbedProfile.DEVELOP).GlobBlacklist(
437+
'Compile only for debugging purpose - '
438+
'https://os.mbed.com/docs/mbed-os/latest/program-setup/build-profiles-and-rules.html')
439+
yield target.Extend('debug', profile=MbedProfile.DEBUG).GlobBlacklist(
440+
'Compile only for debugging purpose - '
441+
'https://os.mbed.com/docs/mbed-os/latest/program-setup/build-profiles-and-rules.html')
428442

429443

430444
def InfineonTargets():
@@ -453,10 +467,12 @@ def K32WTargets():
453467
yield target.Extend('light', app=K32WApp.LIGHT).GlobBlacklist("Debug builds broken due to LWIP_DEBUG redefition")
454468

455469
yield target.Extend('light-release', app=K32WApp.LIGHT, release=True)
456-
yield target.Extend('light-tokenizer-release', app=K32WApp.LIGHT, tokenizer=True, release=True).GlobBlacklist("Only on demand build")
470+
yield target.Extend('light-tokenizer-release', app=K32WApp.LIGHT,
471+
tokenizer=True, release=True).GlobBlacklist("Only on demand build")
457472
yield target.Extend('shell-release', app=K32WApp.SHELL, release=True)
458473
yield target.Extend('lock-release', app=K32WApp.LOCK, release=True)
459-
yield target.Extend('lock-low-power-release', app=K32WApp.LOCK, low_power=True, release=True).GlobBlacklist("Only on demand build")
474+
yield target.Extend('lock-low-power-release', app=K32WApp.LOCK,
475+
low_power=True, release=True).GlobBlacklist("Only on demand build")
460476

461477

462478
def cc13x2x7_26x2x7Targets():
@@ -469,10 +485,15 @@ def cc13x2x7_26x2x7Targets():
469485

470486

471487
def Cyw30739Targets():
472-
yield Target('cyw30739-cyw930739m2evb_01-light', Cyw30739Builder, board=Cyw30739Board.CYW930739M2EVB_01, app=Cyw30739App.LIGHT)
473-
yield Target('cyw30739-cyw930739m2evb_01-lock', Cyw30739Builder, board=Cyw30739Board.CYW930739M2EVB_01, app=Cyw30739App.LOCK)
474-
yield Target('cyw30739-cyw930739m2evb_01-ota-requestor', Cyw30739Builder, board=Cyw30739Board.CYW930739M2EVB_01, app=Cyw30739App.OTA_REQUESTOR).GlobBlacklist("Running out of XIP flash space")
475-
yield Target('cyw30739-cyw930739m2evb_01-ota-requestor-no-progress-logging', Cyw30739Builder, board=Cyw30739Board.CYW930739M2EVB_01, app=Cyw30739App.OTA_REQUESTOR, progress_logging=False)
488+
yield Target('cyw30739-cyw930739m2evb_01-light', Cyw30739Builder,
489+
board=Cyw30739Board.CYW930739M2EVB_01, app=Cyw30739App.LIGHT)
490+
yield Target('cyw30739-cyw930739m2evb_01-lock', Cyw30739Builder,
491+
board=Cyw30739Board.CYW930739M2EVB_01, app=Cyw30739App.LOCK)
492+
yield Target('cyw30739-cyw930739m2evb_01-ota-requestor', Cyw30739Builder,
493+
board=Cyw30739Board.CYW930739M2EVB_01, app=Cyw30739App.OTA_REQUESTOR).GlobBlacklist(
494+
"Running out of XIP flash space")
495+
yield Target('cyw30739-cyw930739m2evb_01-ota-requestor-no-progress-logging', Cyw30739Builder,
496+
board=Cyw30739Board.CYW930739M2EVB_01, app=Cyw30739App.OTA_REQUESTOR, progress_logging=False)
476497

477498

478499
def QorvoTargets():
@@ -484,6 +505,23 @@ def QorvoTargets():
484505
yield target.Extend('persistent-storage', board=QpgBoard.QPG6105, app=QpgApp.PERSISTENT_STORAGE)
485506

486507

508+
def TizenTargets():
509+
510+
# Possible build variants.
511+
# NOTE: The number of potential builds is exponential here.
512+
builder = VariantBuilder()
513+
builder.AppendVariant(name="no-ble", enable_ble=False)
514+
builder.AppendVariant(name="no-wifi", enable_wifi=False)
515+
builder.AppendVariant(name="asan", use_asan=True)
516+
517+
target = Target('tizen-arm', TizenBuilder, board=TizenBoard.ARM)
518+
519+
builder.targets.append(target.Extend('light', app=TizenApp.LIGHT))
520+
521+
for target in builder.AllVariants():
522+
yield target
523+
524+
487525
def Bl602Targets():
488526
target = Target('bl602', Bl602Builder)
489527

@@ -505,6 +543,7 @@ def Bl602Targets():
505543
cc13x2x7_26x2x7Targets(),
506544
Cyw30739Targets(),
507545
QorvoTargets(),
546+
TizenTargets(),
508547
Bl602Targets(),
509548
]
510549

@@ -515,8 +554,6 @@ def Bl602Targets():
515554
# Simple targets added one by one
516555
ALL.append(Target('telink-tlsr9518adk80d-light', TelinkBuilder,
517556
board=TelinkBoard.TLSR9518ADK80D, app=TelinkApp.LIGHT))
518-
ALL.append(Target('tizen-arm-light', TizenBuilder,
519-
board=TizenBoard.ARM, app=TizenApp.LIGHT))
520557

521558
# have a consistent order overall
522559
ALL.sort(key=lambda t: t.name)

0 commit comments

Comments
 (0)