Skip to content

Commit

Permalink
[build] Allow to build Tizen apps with variants
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
arkq committed Mar 28, 2022
1 parent 3c56505 commit 8b3404f
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 23 deletions.
48 changes: 32 additions & 16 deletions scripts/build/build/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def AllVariants(self):
# Only a few are whitelisted for globs
name = '-'.join([o.name for o in subgroup])
if name not in self.glob_whitelist:
if not variant_target.glob_blacklist_reason:
if not variant_target.IsGlobBlacklisted:
variant_target = variant_target.GlobBlacklist(
'Reduce default build variants')

Expand All @@ -215,9 +215,9 @@ def AllVariants(self):

def HostTargets():
target = Target(HostBoard.NATIVE.PlatformName(), HostBuilder)
targets = [
target.Extend(HostBoard.NATIVE.BoardName(), board=HostBoard.NATIVE)
]
target_native = target.Extend(HostBoard.NATIVE.BoardName(), board=HostBoard.NATIVE)

targets = [target_native]

# x64 linux supports cross compile
if (HostBoard.NATIVE.PlatformName() == 'linux') and (
Expand All @@ -228,9 +228,9 @@ def HostTargets():

# Don't cross compile some builds
app_targets.append(
targets[0].Extend('rpc-console', app=HostApp.RPC_CONSOLE))
target_native.Extend('rpc-console', app=HostApp.RPC_CONSOLE))
app_targets.append(
targets[0].Extend('tv-app', app=HostApp.TV_APP))
target_native.Extend('tv-app', app=HostApp.TV_APP))

for target in targets:
app_targets.append(target.Extend(
Expand Down Expand Up @@ -277,14 +277,14 @@ def HostTargets():
yield target

# Without extra build variants
yield targets[0].Extend('chip-cert', app=HostApp.CERT_TOOL)
yield targets[0].Extend('address-resolve-tool', app=HostApp.ADDRESS_RESOLVE)
yield targets[0].Extend('address-resolve-tool-clang', app=HostApp.ADDRESS_RESOLVE,
use_clang=True).GlobBlacklist("Reduce default build variants")
yield targets[0].Extend('address-resolve-tool-platform-mdns', app=HostApp.ADDRESS_RESOLVE,
use_platform_mdns=True).GlobBlacklist("Reduce default build variants")
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")
yield target_native.Extend('chip-cert', app=HostApp.CERT_TOOL)
yield target_native.Extend('address-resolve-tool', app=HostApp.ADDRESS_RESOLVE)
yield target_native.Extend('address-resolve-tool-clang', app=HostApp.ADDRESS_RESOLVE,
use_clang=True).GlobBlacklist("Reduce default build variants")
yield target_native.Extend('address-resolve-tool-platform-mdns', app=HostApp.ADDRESS_RESOLVE,
use_platform_mdns=True).GlobBlacklist("Reduce default build variants")
yield target_native.Extend('address-resolve-tool-platform-mdns-ipv6only', app=HostApp.ADDRESS_RESOLVE,
use_platform_mdns=True, enable_ipv4=False).GlobBlacklist("Reduce default build variants")

test_target = Target(HostBoard.NATIVE.PlatformName(), HostBuilder)
for board in [HostBoard.NATIVE, HostBoard.FAKE]:
Expand Down Expand Up @@ -494,6 +494,23 @@ def QorvoTargets():
yield target.Extend('persistent-storage', board=QpgBoard.QPG6105, app=QpgApp.PERSISTENT_STORAGE)


def TizenTargets():

# Possible build variants.
# NOTE: The number of potential builds is exponential here.
builder = VariantBuilder()
builder.AppendVariant(name="no-ble", enable_ble=False)
builder.AppendVariant(name="no-wifi", enable_wifi=False)
builder.AppendVariant(name="asan", use_asan=True)

target = Target('tizen-arm', TizenBuilder, board=TizenBoard.ARM)

builder.targets.append(target.Extend('light', app=TizenApp.LIGHT))

for target in builder.AllVariants():
yield target


ALL = []

target_generators = [
Expand All @@ -508,6 +525,7 @@ def QorvoTargets():
K32WTargets(),
Cyw30739Targets(),
QorvoTargets(),
TizenTargets(),
]

for generator in target_generators:
Expand All @@ -517,8 +535,6 @@ def QorvoTargets():
# Simple targets added one by one
ALL.append(Target('telink-tlsr9518adk80d-light', TelinkBuilder,
board=TelinkBoard.TLSR9518ADK80D, app=TelinkApp.LIGHT))
ALL.append(Target('tizen-arm-light', TizenBuilder,
board=TizenBoard.ARM, app=TizenApp.LIGHT))

# have a consistent order overall
ALL.sort(key=lambda t: t.name)
27 changes: 20 additions & 7 deletions scripts/build/builders/tizen.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,30 +50,43 @@ def __init__(self,
root,
runner,
app: TizenApp = TizenApp.LIGHT,
board: TizenBoard = TizenBoard.ARM):
board: TizenBoard = TizenBoard.ARM,
enable_ble: bool = True,
enable_wifi: bool = True,
use_asan: bool = False,
use_tsan: bool = False,
):
super(TizenBuilder, self).__init__(
root=os.path.join(root, 'examples', app.ExampleName(), 'linux'),
runner=runner)

self.app = app
self.board = board
self.extra_gn_options = []

if not enable_ble:
self.extra_gn_options.append('chip_config_network_layer_ble=false')
if not enable_wifi:
self.extra_gn_options.append('chip_enable_wifi=false')
if use_asan:
self.extra_gn_options.append('is_asan=true')
if use_tsan:
raise Exception("TSAN sanitizer not supported by Tizen toolchain")

def GnBuildArgs(self):
if 'TIZEN_HOME' not in os.environ:
raise Exception(
"Environment TIZEN_HOME missing, cannot build tizen libraries")

return [
"Environment TIZEN_HOME missing, cannot build Tizen target")
return self.extra_gn_options + [
'target_os="tizen"',
'target_cpu="%s"' % self.board.TargetCpuName(),
'sysroot="%s"' % os.environ['TIZEN_HOME'],
]

def build_outputs(self):
items = {
return {
'%s' % self.app.AppName():
os.path.join(self.output_dir, self.app.AppName()),
'%s.map' % self.app.AppName():
os.path.join(self.output_dir, '%s.map' % self.app.AppName()),
}

return items

0 comments on commit 8b3404f

Please sign in to comment.