Skip to content

Commit

Permalink
Simplify telink build (#9639)
Browse files Browse the repository at this point in the history
* Update telink build instructions to work with latest vscode image.

Latest vscode image contains TELINK_ZEPHYR_SDK_DIR, no need
to hardcode the path to it in the build script anymore.

* Restyle fixes
  • Loading branch information
andy31415 authored and pull[bot] committed Oct 14, 2021
1 parent 9d358b3 commit 1066048
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 21 deletions.
36 changes: 16 additions & 20 deletions scripts/build/builders/telink.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,35 +60,31 @@ def __init__(self,
self.board = board

def generate(self):
if os.path.exists(self.output_dir):
return

if not os.path.exists(self.output_dir):
cmd = 'export ZEPHYR_BASE="$TELINK_ZEPHYR_BASE"\n'
if not self._runner.dry_run:
# Zephyr base
if 'TELINK_ZEPHYR_BASE' not in os.environ:
raise Exception("Telink builds require TELINK_ZEPHYR_BASE")

if not self._runner.dry_run:
cmd = 'export ZEPHYR_BASE="$TELINK_ZEPHYR_BASE"\n'

# Zephyr base
if 'TELINK_ZEPHYR_BASE' not in os.environ:
# TODO: remove once variable in all images
cmd = ''
if 'ZEPHYR_BASE' not in os.environ:
raise Exception(
"Telink builds require TELINK_ZEPHYR_BASE or ZEPHYR_BASE to be set")
if 'TELINK_ZEPHYR_SDK_DIR' in os.environ:
cmd += 'export ZEPHYR_SDK_INSTALL_DIR="$TELINK_ZEPHYR_SDK_DIR"\n'

# TODO: TELINK_ZEPHYR_SDK_DIR should be used for compilation and
# NOT hardcoding of zephyr-sdk-0.13.0
cmd += '''
cmd += '''
export ZEPHYR_TOOLCHAIN_VARIANT=zephyr
export ZEPHYR_SDK_INSTALL_DIR="$ZEPHYR_BASE/../../zephyr-sdk-0.13.0"
source "$ZEPHYR_BASE/zephyr-env.sh";
west build --cmake-only -d {outdir} -b {board} {sourcedir}
'''.format(
outdir=shlex.quote(
self.output_dir), board=self.board.GnArgName(), sourcedir=shlex.quote(
os.path.join(
self.root, 'examples', self.app.ExampleName(), 'telink'))).strip()
outdir=shlex.quote(
self.output_dir), board=self.board.GnArgName(), sourcedir=shlex.quote(
os.path.join(
self.root, 'examples', self.app.ExampleName(), 'telink'))).strip()

self._Execute(['bash', '-c', cmd],
title='Generating ' + self.identifier)
self._Execute(['bash', '-c', cmd],
title='Generating ' + self.identifier)

def _build(self):
logging.info('Compiling Telink at %s', self.output_dir)
Expand Down
2 changes: 1 addition & 1 deletion scripts/build/expected_all_platform_commands.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ gn gen --check --fail-on-unused-args --root={root}/examples/lock-app/p6 '--args=

# Generating telink-tlsr9518adk80d-light
bash -c 'export ZEPHYR_BASE="$TELINK_ZEPHYR_BASE"
export ZEPHYR_SDK_INSTALL_DIR="$TELINK_ZEPHYR_SDK_DIR"
export ZEPHYR_TOOLCHAIN_VARIANT=zephyr
export ZEPHYR_SDK_INSTALL_DIR="$ZEPHYR_BASE/../../zephyr-sdk-0.13.0"
source "$ZEPHYR_BASE/zephyr-env.sh";
west build --cmake-only -d {out}/telink-tlsr9518adk80d-light -b tlsr9518adk80d {root}/examples/lighting-app/telink'

Expand Down
1 change: 1 addition & 0 deletions scripts/build/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def build_actual_output(root: str, out: str) -> List[str]:
'ANDROID_NDK_HOME': 'TEST_ANDROID_NDK_HOME',
'ANDROID_HOME': 'TEST_ANDROID_HOME',
'TIZEN_HOME': 'TEST_TIZEN_HOME',
'TELINK_ZEPHYR_SDK_DIR': 'TELINK_ZEPHYR_SDK_DIR',
})

retval = subprocess.run([
Expand Down

0 comments on commit 1066048

Please sign in to comment.