Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate out "GN builder" for the unified build script #8381

Merged
merged 34 commits into from
Jul 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
380bdf9
Imported a general chip builder script, currently covering a few plat…
andy31415 Jul 8, 2021
38c0512
Move build requirements into global script/requirements.txt so that t…
andy31415 Jul 8, 2021
a7d619f
Update script to assume and require bootstrapping
andy31415 Jul 8, 2021
e0f7e91
Code review comments
andy31415 Jul 9, 2021
ba41920
Support building the lock app for ESP32
andy31415 Jul 9, 2021
7161ca7
Remove obsolete todo
andy31415 Jul 9, 2021
249144f
Fix the duplicated accept for efr32 lock app
andy31415 Jul 9, 2021
3a12596
Add a dry run option for the build runner, showing what commands woul…
andy31415 Jul 9, 2021
15690fd
Merge branch 'master' into unified_build_script
andy31415 Jul 12, 2021
0f5e71b
Merge branch 'unified_build_script' into 02_dry_run_build_script
andy31415 Jul 12, 2021
9f89f2a
Add gn builder as a generic build class, to make gn configuration uni…
andy31415 Jul 12, 2021
3ec0c97
Add support for a "test" to validate that the build generator execute…
andy31415 Jul 12, 2021
9f4e2ad
Update the command comparison: output directory of the build script h…
andy31415 Jul 12, 2021
e80f9f6
Fix some naming and use `get_target_outputs`
andy31415 Jul 12, 2021
c8c8e48
Address some code review comments
andy31415 Jul 13, 2021
24b0749
Rename chipbuild to build_examples
andy31415 Jul 13, 2021
04760bf
Merge branch 'unified_build_script' into 02_dry_run_build_script
andy31415 Jul 13, 2021
f864715
Fixup naming for the unit tests after build script renaming
andy31415 Jul 13, 2021
d6e154b
Fix names
andy31415 Jul 13, 2021
5a66c7a
Restyle
andy31415 Jul 13, 2021
7759751
Merge branch 'master' into unified_build_script
andy31415 Jul 14, 2021
c385777
Merge branch 'unified_build_script' into 02_dry_run_build_script
andy31415 Jul 14, 2021
8b3bb56
Use difflib instead of diff binary for checking changes
andy31415 Jul 14, 2021
0c0133d
Fix diffs (generator vs lines) and logging
andy31415 Jul 14, 2021
781e54a
Merge branch '02_dry_run_build_script' into 03_build_script_gn_builder
andy31415 Jul 14, 2021
db73f8c
Fix unit tests
andy31415 Jul 14, 2021
0c105ce
Start converting python logic from build into pw_python_module
andy31415 Jul 14, 2021
d348340
Tests pass
andy31415 Jul 14, 2021
fc5edcb
Restyle
andy31415 Jul 14, 2021
5ac796c
Code review comments
andy31415 Jul 15, 2021
5533864
Add comment for all_platform_commands.txt
andy31415 Jul 15, 2021
cc7bc88
Move expected txt data into inputs
andy31415 Jul 15, 2021
ed76b81
Merge branch 'master' into 02_dry_run_build_script
andy31415 Jul 16, 2021
61eb32b
Merge branch '02_dry_run_build_script' into 03_build_script_gn_builder
andy31415 Jul 16, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 7 additions & 22 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 .builder import Builder
from .gn import GnBuilder


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


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

def __init__(self,
root,
runner,
output_dir: str,
app: Efr32App = Efr32App.LIGHT,
board: Efr32Board = Efr32Board.BRD4161A):
super(Efr32Builder, self).__init__(root, runner, output_dir)
super(Efr32Builder, self).__init__(
root=os.path.join(root, 'examples', app.ExampleName(), 'efr32'),
runner=runner,
output_dir=output_dir)

self.app = app
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)
self.gn_build_args = ['efr32_board="%s"' % board.GnArgName()]

def outputs(self):
items = {
Expand Down
38 changes: 38 additions & 0 deletions scripts/build/builders/gn.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
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)
23 changes: 6 additions & 17 deletions scripts/build/builders/linux.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,16 @@
import logging
import os

from .builder import Builder
from .gn import GnBuilder


class LinuxBuilder(Builder):
class LinuxBuilder(GnBuilder):

def __init__(self, root, runner, 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)
super(LinuxBuilder, self).__init__(
root=os.path.join(root, 'examples/all-clusters-app/linux/'),
runner=runner,
output_dir=output_dir)

def outputs(self):
return {
Expand Down
22 changes: 6 additions & 16 deletions scripts/build/builders/qpg.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,16 @@
import logging
import os

from .builder import Builder
from .gn import GnBuilder


class QpgBuilder(Builder):
class QpgBuilder(GnBuilder):

def __init__(self, root, runner, 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)
super(QpgBuilder, self).__init__(
root=os.path.join(root, 'examples/lock-app/qpg/'),
runner=runner,
output_dir=output_dir)

def outputs(self):
return {
Expand Down
34 changes: 13 additions & 21 deletions scripts/build/expected_all_platform_commands.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
# Generating linux-native-all_clusters
cd "{root}/examples/all-clusters-app/linux/"
gn gen {out}/linux-native-all_clusters
cd -
gn gen --check --fail-on-unused-args --root={root}/examples/all-clusters-app/linux {out}/linux-native-all_clusters

# Generating qpg-qpg6100-lock
cd "{root}/examples/lock-app/qpg/"
gn gen {out}/qpg-qpg6100-lock
cd -
gn gen --check --fail-on-unused-args --root={root}/examples/lock-app/qpg {out}/qpg-qpg6100-lock

# Generating esp32-m5stack-all_clusters
cd "{root}"
Expand All @@ -23,27 +19,23 @@ cd "{root}"
bash -c 'source $IDF_PATH/export.sh; idf.py -C examples/lock-app/esp32 -B {out}/esp32-devkitc-lock reconfigure'
cd -

# Generate efr32-brd4161a-light
# Generating efr32-brd4161a-light
gn gen --check --fail-on-unused-args --root={root}/examples/lighting-app/efr32 '--args=efr32_board="BRD4161A"' {out}/efr32-brd4161a-light

# Generate efr32-brd4161a-lock
# Generating efr32-brd4161a-lock
gn gen --check --fail-on-unused-args --root={root}/examples/lock-app/efr32 '--args=efr32_board="BRD4161A"' {out}/efr32-brd4161a-lock

# Generate efr32-brd4161a-window_covering
# Generating 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
cd "{root}/examples/all-clusters-app/linux/"
gn gen {out}/linux-native-all_clusters
cd -
gn gen --check --fail-on-unused-args --root={root}/examples/all-clusters-app/linux {out}/linux-native-all_clusters

# Building linux-native-all_clusters
ninja -C {out}/linux-native-all_clusters

# Generating qpg-qpg6100-lock
cd "{root}/examples/lock-app/qpg/"
gn gen {out}/qpg-qpg6100-lock
cd -
gn gen --check --fail-on-unused-args --root={root}/examples/lock-app/qpg {out}/qpg-qpg6100-lock

# Building qpg-qpg6100-lock
ninja -C {out}/qpg-qpg6100-lock
Expand Down Expand Up @@ -72,22 +64,22 @@ cd -
# Building esp32-devkitc-lock
bash -c 'source $IDF_PATH/export.sh; ninja -C '"'"'{out}/esp32-devkitc-lock'"'"''

# Generate efr32-brd4161a-light
# Generating efr32-brd4161a-light
gn gen --check --fail-on-unused-args --root={root}/examples/lighting-app/efr32 '--args=efr32_board="BRD4161A"' {out}/efr32-brd4161a-light

# Build efr32-brd4161a-light
# Building efr32-brd4161a-light
ninja -C {out}/efr32-brd4161a-light

# Generate efr32-brd4161a-lock
# Generating efr32-brd4161a-lock
gn gen --check --fail-on-unused-args --root={root}/examples/lock-app/efr32 '--args=efr32_board="BRD4161A"' {out}/efr32-brd4161a-lock

# Build efr32-brd4161a-lock
# Building efr32-brd4161a-lock
ninja -C {out}/efr32-brd4161a-lock

# Generate efr32-brd4161a-window_covering
# Generating 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

# Build efr32-brd4161a-window_covering
# Building 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)