From 6ee670969d455d2877710ecc6ddf890cc3f0a881 Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Mon, 19 Jul 2021 19:13:39 -0400 Subject: [PATCH] Revert "Separate out "GN builder" for the unified build script (#8381)" This reverts commit 8153dfeceb7b75fb6566848c7b5ec060b77d069e. --- scripts/build/builders/efr32.py | 29 ++++++++++---- scripts/build/builders/gn.py | 38 ------------------- scripts/build/builders/linux.py | 23 ++++++++--- scripts/build/builders/qpg.py | 22 ++++++++--- .../build/expected_all_platform_commands.txt | 34 ++++++++++------- scripts/build/runner/shell.py | 2 +- 6 files changed, 77 insertions(+), 71 deletions(-) delete mode 100644 scripts/build/builders/gn.py diff --git a/scripts/build/builders/efr32.py b/scripts/build/builders/efr32.py index 5cc44f5544f343..b8d3668876d1ce 100644 --- a/scripts/build/builders/efr32.py +++ b/scripts/build/builders/efr32.py @@ -2,7 +2,7 @@ import os from enum import Enum, auto -from .gn import GnBuilder +from .builder import Builder class Efr32App(Enum): @@ -49,7 +49,7 @@ def GnArgName(self): return 'BRD4161A' -class Efr32Builder(GnBuilder): +class Efr32Builder(Builder): def __init__(self, root, @@ -57,13 +57,28 @@ def __init__(self, output_dir: str, app: Efr32App = Efr32App.LIGHT, board: Efr32Board = Efr32Board.BRD4161A): - super(Efr32Builder, self).__init__( - root=os.path.join(root, 'examples', app.ExampleName(), 'efr32'), - runner=runner, - output_dir=output_dir) + super(Efr32Builder, self).__init__(root, runner, output_dir) self.app = app - self.gn_build_args = ['efr32_board="%s"' % board.GnArgName()] + self.board = board + self.identifier = None + + def generate(self): + if not os.path.exists(self.output_dir): + self._Execute([ + 'gn', 'gen', '--check', '--fail-on-unused-args', + '--root=%s' % + os.path.join(self.root, 'examples', self.app.ExampleName(), 'efr32'), + '--args=efr32_board="%s"' % self.board.GnArgName(), self.output_dir + ], + title='Generate %s' % self.identifier) + + def build(self): + logging.info('Compiling EFR32 at %s', self.output_dir) + + self.generate() + self._Execute(['ninja', '-C', self.output_dir], + title='Build %s' % self.identifier) def outputs(self): items = { diff --git a/scripts/build/builders/gn.py b/scripts/build/builders/gn.py deleted file mode 100644 index 591610265da54c..00000000000000 --- a/scripts/build/builders/gn.py +++ /dev/null @@ -1,38 +0,0 @@ -import logging -import os - -from .builder import Builder - - -class GnBuilder(Builder): - - def __init__(self, root, runner, output_dir): - """Creates a generic ninja builder. - - Args: - root: the root where to run GN into - runner: what to use to execute shell commands - output_dir: where ninja files are to be generated - """ - super(GnBuilder, self).__init__(root, runner, output_dir) - - self.gn_build_args = None - - def generate(self): - if not os.path.exists(self.output_dir): - cmd = [ - 'gn', 'gen', '--check', '--fail-on-unused-args', - '--root=%s' % self.root - ] - - if self.gn_build_args: - cmd += ['--args=%s' % ' '.join(self.gn_build_args)] - - cmd += [self.output_dir] - - self._Execute(cmd, title='Generating ' + self.identifier) - - def build(self): - self.generate() - self._Execute(['ninja', '-C', self.output_dir], - title='Building ' + self.identifier) diff --git a/scripts/build/builders/linux.py b/scripts/build/builders/linux.py index b37e32078b0c43..d528fdee9eb3ec 100644 --- a/scripts/build/builders/linux.py +++ b/scripts/build/builders/linux.py @@ -1,16 +1,27 @@ import logging import os -from .gn import GnBuilder +from .builder import Builder -class LinuxBuilder(GnBuilder): +class LinuxBuilder(Builder): def __init__(self, root, runner, output_dir): - super(LinuxBuilder, self).__init__( - root=os.path.join(root, 'examples/all-clusters-app/linux/'), - runner=runner, - output_dir=output_dir) + super(LinuxBuilder, self).__init__(root, runner, output_dir) + + def generate(self): + if not os.path.exists(self.output_dir): + self._Execute(['gn', 'gen', self.output_dir], + cwd=os.path.join(self.root, + 'examples/all-clusters-app/linux/'), + title='Generating ' + self.identifier) + + def build(self): + logging.info('Compiling Linux at %s', self.output_dir) + + self.generate() + self._Execute(['ninja', '-C', self.output_dir], + title='Building ' + self.identifier) def outputs(self): return { diff --git a/scripts/build/builders/qpg.py b/scripts/build/builders/qpg.py index e11fbb0fa5210c..0c91ff6ee3b999 100644 --- a/scripts/build/builders/qpg.py +++ b/scripts/build/builders/qpg.py @@ -3,16 +3,26 @@ import logging import os -from .gn import GnBuilder +from .builder import Builder -class QpgBuilder(GnBuilder): +class QpgBuilder(Builder): def __init__(self, root, runner, output_dir): - super(QpgBuilder, self).__init__( - root=os.path.join(root, 'examples/lock-app/qpg/'), - runner=runner, - output_dir=output_dir) + super(QpgBuilder, self).__init__(root, runner, output_dir) + + def generate(self): + if not os.path.exists(self.output_dir): + self._Execute(['gn', 'gen', self.output_dir], + cwd=os.path.join(self.root, 'examples/lock-app/qpg/'), + title='Generating ' + self.identifier) + + def build(self): + logging.info('Compiling QPG at %s', self.output_dir) + + self.generate() + self._Execute(['ninja', '-C', self.output_dir], + title='Building ' + self.identifier) def outputs(self): return { diff --git a/scripts/build/expected_all_platform_commands.txt b/scripts/build/expected_all_platform_commands.txt index 3220461d27fd08..d852e580bd63a4 100644 --- a/scripts/build/expected_all_platform_commands.txt +++ b/scripts/build/expected_all_platform_commands.txt @@ -1,8 +1,12 @@ # Generating linux-native-all_clusters -gn gen --check --fail-on-unused-args --root={root}/examples/all-clusters-app/linux {out}/linux-native-all_clusters +cd "{root}/examples/all-clusters-app/linux/" +gn gen {out}/linux-native-all_clusters +cd - # Generating qpg-qpg6100-lock -gn gen --check --fail-on-unused-args --root={root}/examples/lock-app/qpg {out}/qpg-qpg6100-lock +cd "{root}/examples/lock-app/qpg/" +gn gen {out}/qpg-qpg6100-lock +cd - # Generating esp32-m5stack-all_clusters cd "{root}" @@ -19,23 +23,27 @@ cd "{root}" bash -c 'source $IDF_PATH/export.sh; idf.py -C examples/lock-app/esp32 -B {out}/esp32-devkitc-lock reconfigure' cd - -# Generating efr32-brd4161a-light +# Generate efr32-brd4161a-light gn gen --check --fail-on-unused-args --root={root}/examples/lighting-app/efr32 '--args=efr32_board="BRD4161A"' {out}/efr32-brd4161a-light -# Generating efr32-brd4161a-lock +# Generate efr32-brd4161a-lock gn gen --check --fail-on-unused-args --root={root}/examples/lock-app/efr32 '--args=efr32_board="BRD4161A"' {out}/efr32-brd4161a-lock -# Generating efr32-brd4161a-window_covering +# Generate efr32-brd4161a-window_covering gn gen --check --fail-on-unused-args --root={root}/examples/window-app/efr32 '--args=efr32_board="BRD4161A"' {out}/efr32-brd4161a-window_covering # Generating linux-native-all_clusters -gn gen --check --fail-on-unused-args --root={root}/examples/all-clusters-app/linux {out}/linux-native-all_clusters +cd "{root}/examples/all-clusters-app/linux/" +gn gen {out}/linux-native-all_clusters +cd - # Building linux-native-all_clusters ninja -C {out}/linux-native-all_clusters # Generating qpg-qpg6100-lock -gn gen --check --fail-on-unused-args --root={root}/examples/lock-app/qpg {out}/qpg-qpg6100-lock +cd "{root}/examples/lock-app/qpg/" +gn gen {out}/qpg-qpg6100-lock +cd - # Building qpg-qpg6100-lock ninja -C {out}/qpg-qpg6100-lock @@ -64,22 +72,22 @@ cd - # Building esp32-devkitc-lock bash -c 'source $IDF_PATH/export.sh; ninja -C '"'"'{out}/esp32-devkitc-lock'"'"'' -# Generating efr32-brd4161a-light +# Generate efr32-brd4161a-light gn gen --check --fail-on-unused-args --root={root}/examples/lighting-app/efr32 '--args=efr32_board="BRD4161A"' {out}/efr32-brd4161a-light -# Building efr32-brd4161a-light +# Build efr32-brd4161a-light ninja -C {out}/efr32-brd4161a-light -# Generating efr32-brd4161a-lock +# Generate efr32-brd4161a-lock gn gen --check --fail-on-unused-args --root={root}/examples/lock-app/efr32 '--args=efr32_board="BRD4161A"' {out}/efr32-brd4161a-lock -# Building efr32-brd4161a-lock +# Build efr32-brd4161a-lock ninja -C {out}/efr32-brd4161a-lock -# Generating efr32-brd4161a-window_covering +# Generate efr32-brd4161a-window_covering gn gen --check --fail-on-unused-args --root={root}/examples/window-app/efr32 '--args=efr32_board="BRD4161A"' {out}/efr32-brd4161a-window_covering -# Building efr32-brd4161a-window_covering +# Build efr32-brd4161a-window_covering ninja -C {out}/efr32-brd4161a-window_covering diff --git a/scripts/build/runner/shell.py b/scripts/build/runner/shell.py index 13bc5e4d36d386..d1122060801018 100644 --- a/scripts/build/runner/shell.py +++ b/scripts/build/runner/shell.py @@ -50,4 +50,4 @@ def Run(self, cmd, cwd=None, title=None): if code != 0: raise Exception('Command %r failed: %d' % (cmd, code)) else: - logging.info('Command %r completed', cmd) + logging.info('Command %r completed' % cmd)