Skip to content

Commit

Permalink
Add python building build capabilities to build_examples.py (#17341)
Browse files Browse the repository at this point in the history
* Add python build support into build_examples.py

* Ensure CI will also build python

* Updated unit tests

* Restyle
  • Loading branch information
andy31415 authored Apr 14, 2022
1 parent 01e54b2 commit ea4c3dd
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 10 deletions.
1 change: 1 addition & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ jobs:
./scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py \
--target linux-x64-all-clusters-${BUILD_VARIANT} \
--target linux-x64-python-bindings \
build \
--copy-artifacts-to objdir-clone \
"
Expand Down
5 changes: 3 additions & 2 deletions scripts/build/build/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ def HostTargets():
'ota-provider', app=HostApp.OTA_PROVIDER, enable_ble=False))
app_targets.append(target.Extend(
'ota-requestor', app=HostApp.OTA_REQUESTOR, enable_ble=False))
app_targets.append(target.Extend('python-bindings', app=HostApp.PYTHON_BINDINGS))

builder = VariantBuilder()

Expand All @@ -270,8 +271,8 @@ def HostTargets():
builder.WhitelistVariantNameForGlob('ipv6only')

for target in app_targets:
if 'rpc-console' in target.name:
# rpc console has only one build variant right now
if ('-rpc-console' in target.name) or ('-python-bindings' in target.name):
# Single-variant builds
yield target
else:
builder.targets.append(target)
Expand Down
18 changes: 10 additions & 8 deletions scripts/build/builders/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class HostApp(Enum):
CERT_TOOL = auto()
OTA_PROVIDER = auto()
OTA_REQUESTOR = auto()
PYTHON_BINDINGS = auto()

def ExamplePath(self):
if self == HostApp.ALL_CLUSTERS:
Expand All @@ -45,22 +46,18 @@ def ExamplePath(self):
return 'common/pigweed/rpc_console'
elif self == HostApp.MIN_MDNS:
return 'minimal-mdns'
elif self == HostApp.ADDRESS_RESOLVE:
return '../'
elif self == HostApp.TV_APP:
return 'tv-app/linux'
elif self == HostApp.LOCK:
return 'door-lock-app/linux'
elif self == HostApp.TESTS:
return '../'
elif self == HostApp.SHELL:
return 'shell/standalone'
elif self == HostApp.CERT_TOOL:
return '..'
elif self == HostApp.OTA_PROVIDER:
return 'ota-provider-app/linux'
elif self == HostApp.OTA_REQUESTOR:
return 'ota-requestor-app/linux'
elif self in [HostApp.ADDRESS_RESOLVE, HostApp.TESTS, HostApp.PYTHON_BINDINGS, HostApp.CERT_TOOL]:
return '../'
else:
raise Exception('Unknown app type: %r' % self)

Expand Down Expand Up @@ -106,6 +103,8 @@ def OutputNames(self):
elif self == HostApp.OTA_REQUESTOR:
yield 'chip-ota-requestor-app'
yield 'chip-ota-requestor-app.map'
elif self == HostApp.PYTHON_BINDINGS:
yield 'controller/python' # Directory containing WHL files
else:
raise Exception('Unknown app type: %r' % self)

Expand Down Expand Up @@ -211,9 +210,12 @@ def __init__(self, root, runner, app: HostApp, board=HostBoard.NATIVE, enable_ip
"Cannot cross compile CERT TOOL: ssl library conflict")
self.extra_gn_options.append('chip_crypto="openssl"')
self.build_command = 'src/tools/chip-cert'

if app == HostApp.ADDRESS_RESOLVE:
elif app == HostApp.ADDRESS_RESOLVE:
self.build_command = 'src/lib/address_resolve:address-resolve-tool'
elif app == HostApp.PYTHON_BINDINGS:
self.extra_gn_options.append('enable_rtti=false')
self.extra_gn_options.append('chip_project_config_include_dirs=["//config/python"]')
self.build_command = 'python'

def GnBuildArgs(self):
if self.board == HostBoard.NATIVE:
Expand Down
14 changes: 14 additions & 0 deletions scripts/build/testdata/build_linux_on_x64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ bash -c '
PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/ota-requestor-app/linux '"'"'--args=chip_inet_config_enable_ipv4=false chip_config_network_layer_ble=false target_cpu="arm64" is_clang=true chip_crypto="mbedtls" sysroot="SYSROOT_AARCH64"'"'"' {out}/linux-arm64-ota-requestor-ipv6only'

# Generating linux-arm64-python-bindings
bash -c '
PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \
gn gen --check --fail-on-unused-args --export-compile-commands --root={root} '"'"'--args=enable_rtti=false chip_project_config_include_dirs=["//config/python"] target_cpu="arm64" is_clang=true chip_crypto="mbedtls" sysroot="SYSROOT_AARCH64"'"'"' {out}/linux-arm64-python-bindings'

# Generating linux-arm64-shell
bash -c '
PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \
Expand Down Expand Up @@ -124,6 +129,9 @@ gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/exa
# Generating linux-x64-ota-requestor-ipv6only
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/ota-requestor-app/linux '--args=chip_inet_config_enable_ipv4=false chip_config_network_layer_ble=false' {out}/linux-x64-ota-requestor-ipv6only

# Generating linux-x64-python-bindings
gn gen --check --fail-on-unused-args --export-compile-commands --root={root} '--args=enable_rtti=false chip_project_config_include_dirs=["//config/python"]' {out}/linux-x64-python-bindings

# Generating linux-x64-rpc-console
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/common/pigweed/rpc_console {out}/linux-x64-rpc-console

Expand Down Expand Up @@ -181,6 +189,9 @@ ninja -C {out}/linux-arm64-ota-requestor
# Building linux-arm64-ota-requestor-ipv6only
ninja -C {out}/linux-arm64-ota-requestor-ipv6only

# Building linux-arm64-python-bindings
ninja -C {out}/linux-arm64-python-bindings python

# Building linux-arm64-shell
ninja -C {out}/linux-arm64-shell

Expand Down Expand Up @@ -241,6 +252,9 @@ ninja -C {out}/linux-x64-ota-requestor
# Building linux-x64-ota-requestor-ipv6only
ninja -C {out}/linux-x64-ota-requestor-ipv6only

# Building linux-x64-python-bindings
ninja -C {out}/linux-x64-python-bindings python

# Building linux-x64-rpc-console
ninja -C {out}/linux-x64-rpc-console

Expand Down

0 comments on commit ea4c3dd

Please sign in to comment.