Skip to content

Commit

Permalink
Fix telink examples on vscode image (#22911)
Browse files Browse the repository at this point in the history
* Fix telink builds on vscode: force more env variables set

* Fix unit tests
  • Loading branch information
andy31415 authored and pull[bot] committed Sep 26, 2023
1 parent bcf3f3b commit 1688700
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 17 deletions.
21 changes: 13 additions & 8 deletions scripts/build/builders/telink.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,26 @@ def __init__(self,
self.app = app
self.board = board

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

def get_cmd_prefixes(self):
if not self._runner.dry_run:
# Zephyr base
if 'TELINK_ZEPHYR_BASE' not in os.environ:
raise Exception("Telink builds require TELINK_ZEPHYR_BASE")

cmd = 'export ZEPHYR_BASE="$TELINK_ZEPHYR_BASE"\n'
cmd = 'export ZEPHYR_TOOLCHAIN_VARIANT=zephyr\n'
cmd += 'export ZEPHYR_BASE="$TELINK_ZEPHYR_BASE"\n'

if 'TELINK_ZEPHYR_SDK_DIR' in os.environ:
cmd += 'export ZEPHYR_SDK_INSTALL_DIR="$TELINK_ZEPHYR_SDK_DIR"\n'

return cmd

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

cmd = self.get_cmd_prefixes()
cmd += '''
export ZEPHYR_TOOLCHAIN_VARIANT=zephyr
source "$ZEPHYR_BASE/zephyr-env.sh";
west build --cmake-only -d {outdir} -b {board} {sourcedir}
'''.format(
Expand All @@ -97,8 +101,9 @@ def generate(self):
def _build(self):
logging.info('Compiling Telink at %s', self.output_dir)

self._Execute(['ninja', '-C', self.output_dir],
title='Building ' + self.identifier)
cmd = self.get_cmd_prefixes() + ("ninja -C %s" % self.output_dir)

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

def build_outputs(self):
return {
Expand Down
27 changes: 18 additions & 9 deletions scripts/build/testdata/build_all_except_host.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1163,23 +1163,23 @@ gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/exa
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/shell/qpg '--args=qpg_target_ic="qpg6105"' {out}/qpg-shell

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

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

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

Expand Down Expand Up @@ -2402,13 +2402,22 @@ ninja -C {out}/qpg-persistent-storage
ninja -C {out}/qpg-shell

# Building telink-tlsr9518adk80d-light
ninja -C {out}/telink-tlsr9518adk80d-light
bash -c 'export ZEPHYR_TOOLCHAIN_VARIANT=zephyr
export ZEPHYR_BASE="$TELINK_ZEPHYR_BASE"
export ZEPHYR_SDK_INSTALL_DIR="$TELINK_ZEPHYR_SDK_DIR"
ninja -C {out}/telink-tlsr9518adk80d-light'

# Building telink-tlsr9518adk80d-light-switch
ninja -C {out}/telink-tlsr9518adk80d-light-switch
bash -c 'export ZEPHYR_TOOLCHAIN_VARIANT=zephyr
export ZEPHYR_BASE="$TELINK_ZEPHYR_BASE"
export ZEPHYR_SDK_INSTALL_DIR="$TELINK_ZEPHYR_SDK_DIR"
ninja -C {out}/telink-tlsr9518adk80d-light-switch'

# Building telink-tlsr9518adk80d-ota-requestor
ninja -C {out}/telink-tlsr9518adk80d-ota-requestor
bash -c 'export ZEPHYR_TOOLCHAIN_VARIANT=zephyr
export ZEPHYR_BASE="$TELINK_ZEPHYR_BASE"
export ZEPHYR_SDK_INSTALL_DIR="$TELINK_ZEPHYR_SDK_DIR"
ninja -C {out}/telink-tlsr9518adk80d-ota-requestor'

# Building tizen-arm-all-clusters
ninja -C {out}/tizen-arm-all-clusters
Expand Down

0 comments on commit 1688700

Please sign in to comment.