Skip to content

Commit

Permalink
Add a way to disable openthread in build_examples.py (#20377)
Browse files Browse the repository at this point in the history
This enables a build that has no runtime dependencies other than libc:

 0x0000000000000001 (NEEDED)             Shared library: [libdl.so.2]
 0x0000000000000001 (NEEDED)             Shared library: [libpthread.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [librt.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libm.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]

This makes it easy to deploy on embedded Linux without installing other
libraries.

Tested via

 ./scripts/build/build_examples.py --target linux-arm64-chip-tool-ipv6only-no-ble-no-wifi-no-thread-asan-clang build
 ./scripts/build/build_examples.py --target linux-arm64-all-clusters-ipv6only-no-ble-no-wifi-no-thread-asan-clang build
  • Loading branch information
mspang authored and pull[bot] committed Aug 25, 2023
1 parent 2aabb71 commit 1262344
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
1 change: 1 addition & 0 deletions examples/all-clusters-app/linux/main-common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <new>
#include <platform/DiagnosticDataProvider.h>
#include <platform/PlatformManager.h>
#include <signal.h>
#include <system/SystemPacketBuffer.h>
#include <transport/SessionManager.h>
#include <transport/raw/PeerAddress.h>
Expand Down
5 changes: 5 additions & 0 deletions scripts/build/build/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ def HostTargets():
builder.AppendVariant(name="ipv6only", enable_ipv4=False),
builder.AppendVariant(name="no-ble", enable_ble=False),
builder.AppendVariant(name="no-wifi", enable_wifi=False),
builder.AppendVariant(name="no-thread", enable_thread=False),
builder.AppendVariant(name="tsan", conflicts=['asan'], use_tsan=True),
builder.AppendVariant(name="asan", conflicts=['tsan'], use_asan=True),
builder.AppendVariant(name="libfuzzer", requires=[
Expand Down Expand Up @@ -305,6 +306,10 @@ def HostTargets():
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")

nodeps_args = dict(enable_ipv4=False, enable_ble=False, enable_wifi=False, enable_thread=False)
yield target_native.Extend('chip-tool-nodeps', app=HostApp.CHIP_TOOL, **nodeps_args)
yield target_native.Extend('all-clusters-app-nodeps', app=HostApp.ALL_CLUSTERS, **nodeps_args)

test_target = Target(HostBoard.NATIVE.PlatformName(), HostBuilder)
yield test_target.Extend(HostBoard.NATIVE.BoardName() + '-tests', board=HostBoard.NATIVE, app=HostApp.TESTS)
yield test_target.Extend(HostBoard.NATIVE.BoardName() + '-tests-clang', board=HostBoard.NATIVE, app=HostApp.TESTS, use_clang=True)
Expand Down
11 changes: 8 additions & 3 deletions scripts/build/builders/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,11 @@ def PlatformName(self):

class HostBuilder(GnBuilder):

def __init__(self, root, runner, app: HostApp, board=HostBoard.NATIVE, enable_ipv4=True,
enable_ble=True, enable_wifi=True, use_tsan=False, use_asan=False, separate_event_loop=True,
use_libfuzzer=False, use_clang=False, interactive_mode=True, extra_tests=False,
def __init__(self, root, runner, app: HostApp, board=HostBoard.NATIVE,
enable_ipv4=True, enable_ble=True, enable_wifi=True,
enable_thread=True, use_tsan=False, use_asan=False,
separate_event_loop=True, use_libfuzzer=False, use_clang=False,
interactive_mode=True, extra_tests=False,
use_platform_mdns=False, enable_rpcs=False):
super(HostBuilder, self).__init__(
root=os.path.join(root, 'examples', app.ExamplePath()),
Expand All @@ -216,6 +218,9 @@ def __init__(self, root, runner, app: HostApp, board=HostBoard.NATIVE, enable_ip
if not enable_wifi:
self.extra_gn_options.append('chip_enable_wifi=false')

if not enable_thread:
self.extra_gn_options.append('chip_enable_openthread=false')

if use_tsan:
self.extra_gn_options.append('is_tsan=true')

Expand Down
12 changes: 12 additions & 0 deletions scripts/build/testdata/build_linux_on_x64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ gn gen --check --fail-on-unused-args --export-compile-commands --root={root} {ou
# Generating linux-x64-all-clusters
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/all-clusters-app/linux {out}/linux-x64-all-clusters

# Generating linux-x64-all-clusters-app-nodeps
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/all-clusters-app/linux '--args=chip_inet_config_enable_ipv4=false chip_config_network_layer_ble=false chip_enable_wifi=false chip_enable_openthread=false' {out}/linux-x64-all-clusters-app-nodeps

# Generating linux-x64-all-clusters-ipv6only
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/all-clusters-app/linux --args=chip_inet_config_enable_ipv4=false {out}/linux-x64-all-clusters-ipv6only

Expand Down Expand Up @@ -177,6 +180,9 @@ gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/exa
# Generating linux-x64-chip-tool-no-interactive-ipv6only
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/chip-tool '--args=chip_inet_config_enable_ipv4=false config_use_interactive_mode=false' {out}/linux-x64-chip-tool-no-interactive-ipv6only

# Generating linux-x64-chip-tool-nodeps
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/chip-tool '--args=chip_inet_config_enable_ipv4=false chip_config_network_layer_ble=false chip_enable_wifi=false chip_enable_openthread=false' {out}/linux-x64-chip-tool-nodeps

# Generating linux-x64-light
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/linux {out}/linux-x64-light

Expand Down Expand Up @@ -345,6 +351,9 @@ ninja -C {out}/linux-x64-address-resolve-tool src/lib/address_resolve:address-re
# Building linux-x64-all-clusters
ninja -C {out}/linux-x64-all-clusters

# Building linux-x64-all-clusters-app-nodeps
ninja -C {out}/linux-x64-all-clusters-app-nodeps

# Building linux-x64-all-clusters-ipv6only
ninja -C {out}/linux-x64-all-clusters-ipv6only

Expand Down Expand Up @@ -372,6 +381,9 @@ ninja -C {out}/linux-x64-chip-tool-ipv6only
# Building linux-x64-chip-tool-no-interactive-ipv6only
ninja -C {out}/linux-x64-chip-tool-no-interactive-ipv6only

# Building linux-x64-chip-tool-nodeps
ninja -C {out}/linux-x64-chip-tool-nodeps

# Building linux-x64-light
ninja -C {out}/linux-x64-light

Expand Down

0 comments on commit 1262344

Please sign in to comment.