diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 39a01b9d163935..5793f4c34a4ea2 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -92,7 +92,7 @@ jobs: run: scripts/run_in_build_env.sh "ninja -C ./out" build_linux: name: Build on Linux (gcc_release, clang, mbedtls, simulated) - timeout-minutes: 60 + timeout-minutes: 90 runs-on: ubuntu-latest if: github.actor != 'restyled-io[bot]' @@ -158,12 +158,26 @@ jobs: scripts/tests/gn_tests.sh done - name: Build using build_examples.py - timeout-minutes: 30 - # NOTE: only vscode image contains the cross compile arm64 sysroot - # so the build command below only compiles x64 + timeout-minutes: 40 + run: | + ./scripts/run_in_build_env.sh \ + "./scripts/build/build_examples.py --no-log-timestamps \ + --target linux-x64-all-clusters \ + --target linux-x64-all-clusters-ipv6only \ + --target linux-x64-chip-tool \ + --target linux-x64-chip-tool-ipv6only \ + --target linux-x64-minmdns-ipv6only \ + --target linux-x64-rpc-console \ + --target linux-x64-thermostat-ipv6only \ + --target linux-x64-tv-app-ipv6only \ + build \ + " + + - name: Fun fake linux tests + timeout-minutes: 15 run: | ./scripts/run_in_build_env.sh \ - "./scripts/build/build_examples.py --no-log-timestamps --target-glob 'linux-x64-*' build" + "./scripts/build/build_examples.py --no-log-timestamps --target linux-fake-tests build" # TODO Log Upload https://github.com/project-chip/connectedhomeip/issues/2227 # TODO https://github.com/project-chip/connectedhomeip/issues/1512 diff --git a/scripts/build/build/targets.py b/scripts/build/build/targets.py index e5d25f1b3ae126..d89b2394887eba 100644 --- a/scripts/build/build/targets.py +++ b/scripts/build/build/targets.py @@ -195,6 +195,10 @@ def HostTargets(): yield variant_target + test_target = Target(HostBoard.NATIVE.PlatformName(), HostBuilder) + for board in [HostBoard.NATIVE, HostBoard.FAKE]: + yield test_target.Extend(board.BoardName() + '-tests', board=board, app=HostApp.TESTS) + def Esp32Targets(): esp32_target = Target('esp32', Esp32Builder) diff --git a/scripts/build/builders/gn.py b/scripts/build/builders/gn.py index 1499b8e5de10dd..ef4b67e9a4af28 100644 --- a/scripts/build/builders/gn.py +++ b/scripts/build/builders/gn.py @@ -29,6 +29,8 @@ def __init__(self, root, runner): """ super(GnBuilder, self).__init__(root, runner) + self.build_command = None + def GnBuildArgs(self): """Extra gn build `--args` @@ -73,5 +75,8 @@ def generate(self): self._Execute(cmd, title=title) def _build(self): - self._Execute(['ninja', '-C', self.output_dir], - title='Building ' + self.identifier) + cmd = ['ninja', '-C', self.output_dir] + if self.build_command: + cmd.append(self.build_command) + + self._Execute(cmd, title='Building ' + self.identifier) diff --git a/scripts/build/builders/host.py b/scripts/build/builders/host.py index cb6d3d84c1eb00..b57dc794be4f9b 100644 --- a/scripts/build/builders/host.py +++ b/scripts/build/builders/host.py @@ -27,6 +27,7 @@ class HostApp(Enum): RPC_CONSOLE = auto() MIN_MDNS = auto() TV_APP = auto() + TESTS = auto() def ExamplePath(self): if self == HostApp.ALL_CLUSTERS: @@ -37,10 +38,12 @@ def ExamplePath(self): return 'thermostat/linux' elif self == HostApp.RPC_CONSOLE: return 'common/pigweed/rpc_console' - if self == HostApp.MIN_MDNS: + elif self == HostApp.MIN_MDNS: return 'minimal-mdns' - if self == HostApp.TV_APP: + elif self == HostApp.TV_APP: return 'tv-app/linux' + elif self == HostApp.TESTS: + return '../' else: raise Exception('Unknown app type: %r' % self) @@ -66,6 +69,8 @@ def OutputNames(self): elif self == HostApp.TV_APP: yield 'chip-tv-app' yield 'chip-tv-app.map' + elif self == HostApp.TESTS: + pass else: raise Exception('Unknown app type: %r' % self) @@ -76,6 +81,9 @@ class HostBoard(Enum): # cross-compile support ARM64 = auto() + # for test support + FAKE = auto() + def BoardName(self): if self == HostBoard.NATIVE: uname_result = uname() @@ -92,12 +100,16 @@ def BoardName(self): return arch elif self == HostBoard.ARM64: return 'arm64' + elif self == HostBoard.FAKE: + return 'fake' else: raise Exception('Unknown host board type: %r' % self) def PlatformName(self): if self == HostBoard.NATIVE: return uname().system.lower() + elif self == HostBoard.FAKE: + return 'fake' else: # Cross compilation assumes linux currently return 'linux' @@ -135,6 +147,10 @@ def __init__(self, root, runner, app: HostApp, board=HostBoard.NATIVE, enable_ip self.extra_gn_options.append( 'chip_enable_group_messaging_tests=true') + if app == HostApp.TESTS: + self.extra_gn_options.append('chip_build_tests=true') + self.build_command = 'check' + def GnBuildArgs(self): if self.board == HostBoard.NATIVE: return self.extra_gn_options @@ -148,6 +164,15 @@ def GnBuildArgs(self): ] ) + return self.extra_gn_options + elif self.board == HostBoard.FAKE: + self.extra_gn_options.extend( + [ + 'custom_toolchain="//build/toolchain/fake:fake_x64_gcc"', + 'chip_link_tests=true', + 'chip_device_platform="fake"', + ] + ) return self.extra_gn_options else: raise Exception('Unknown host board type: %r' % self) @@ -155,6 +180,8 @@ def GnBuildArgs(self): def GnBuildEnv(self): if self.board == HostBoard.NATIVE: return None + elif self.board == HostBoard.FAKE: + return None elif self.board == HostBoard.ARM64: return { 'PKG_CONFIG_PATH': self.SysRootPath('SYSROOT_AARCH64') + '/lib/aarch64-linux-gnu/pkgconfig', diff --git a/scripts/build/testdata/build_linux_on_x64.txt b/scripts/build/testdata/build_linux_on_x64.txt index 2a204c91c51388..41b10c0023e829 100644 --- a/scripts/build/testdata/build_linux_on_x64.txt +++ b/scripts/build/testdata/build_linux_on_x64.txt @@ -41,6 +41,9 @@ 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/thermostat/linux '"'"'--args=chip_inet_config_enable_ipv4=false target_cpu="arm64" is_clang=true chip_crypto="mbedtls" sysroot="SYSROOT_AARCH64"'"'"' {out}/linux-arm64-thermostat-ipv6only' +# Generating linux-fake-tests +gn gen --check --fail-on-unused-args --export-compile-commands --root={root} '--args=chip_build_tests=true custom_toolchain="//build/toolchain/fake:fake_x64_gcc" chip_link_tests=true chip_device_platform="fake"' {out}/linux-fake-tests + # 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 @@ -62,6 +65,9 @@ gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/exa # 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 +# Generating linux-x64-tests +gn gen --check --fail-on-unused-args --export-compile-commands --root={root} --args=chip_build_tests=true {out}/linux-x64-tests + # Generating linux-x64-thermostat gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/thermostat/linux {out}/linux-x64-thermostat @@ -98,6 +104,9 @@ ninja -C {out}/linux-arm64-thermostat # Building linux-arm64-thermostat-ipv6only ninja -C {out}/linux-arm64-thermostat-ipv6only +# Building linux-fake-tests +ninja -C {out}/linux-fake-tests check + # Building linux-x64-all-clusters ninja -C {out}/linux-x64-all-clusters @@ -119,6 +128,9 @@ ninja -C {out}/linux-x64-minmdns-ipv6only # Building linux-x64-rpc-console ninja -C {out}/linux-x64-rpc-console +# Building linux-x64-tests +ninja -C {out}/linux-x64-tests check + # Building linux-x64-thermostat ninja -C {out}/linux-x64-thermostat