Skip to content

Commit

Permalink
Revert "Separate out "GN builder" for the unified build script (#8381)"
Browse files Browse the repository at this point in the history
This reverts commit 8153dfe.
  • Loading branch information
mspang authored Jul 19, 2021
1 parent 369c743 commit 6ee6709
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 71 deletions.
29 changes: 22 additions & 7 deletions scripts/build/builders/efr32.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
from enum import Enum, auto

from .gn import GnBuilder
from .builder import Builder


class Efr32App(Enum):
Expand Down Expand Up @@ -49,21 +49,36 @@ def GnArgName(self):
return 'BRD4161A'


class Efr32Builder(GnBuilder):
class Efr32Builder(Builder):

def __init__(self,
root,
runner,
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 = {
Expand Down
38 changes: 0 additions & 38 deletions scripts/build/builders/gn.py

This file was deleted.

23 changes: 17 additions & 6 deletions scripts/build/builders/linux.py
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
22 changes: 16 additions & 6 deletions scripts/build/builders/qpg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
34 changes: 21 additions & 13 deletions scripts/build/expected_all_platform_commands.txt
Original file line number Diff line number Diff line change
@@ -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}"
Expand All @@ -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
Expand Down Expand Up @@ -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


2 changes: 1 addition & 1 deletion scripts/build/runner/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 6ee6709

Please sign in to comment.