From 12623449e662ee301fcaeffde3d1e84bb5f512b4 Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Wed, 6 Jul 2022 16:24:05 -0400 Subject: [PATCH] Add a way to disable openthread in build_examples.py (#20377) 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 --- examples/all-clusters-app/linux/main-common.cpp | 1 + scripts/build/build/targets.py | 5 +++++ scripts/build/builders/host.py | 11 ++++++++--- scripts/build/testdata/build_linux_on_x64.txt | 12 ++++++++++++ 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/examples/all-clusters-app/linux/main-common.cpp b/examples/all-clusters-app/linux/main-common.cpp index aa22bb0a3148d1..ea2b7e5094c95e 100644 --- a/examples/all-clusters-app/linux/main-common.cpp +++ b/examples/all-clusters-app/linux/main-common.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include diff --git a/scripts/build/build/targets.py b/scripts/build/build/targets.py index 3c588beab98ed8..46a44715d35b92 100644 --- a/scripts/build/build/targets.py +++ b/scripts/build/build/targets.py @@ -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=[ @@ -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) diff --git a/scripts/build/builders/host.py b/scripts/build/builders/host.py index 5e6a22aadf3379..1f487259ca2972 100644 --- a/scripts/build/builders/host.py +++ b/scripts/build/builders/host.py @@ -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()), @@ -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') diff --git a/scripts/build/testdata/build_linux_on_x64.txt b/scripts/build/testdata/build_linux_on_x64.txt index 8639b028349183..a6510e1fa9c76a 100644 --- a/scripts/build/testdata/build_linux_on_x64.txt +++ b/scripts/build/testdata/build_linux_on_x64.txt @@ -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 @@ -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 @@ -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 @@ -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