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

Simplify telink build #9639

Merged
merged 3 commits into from
Sep 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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],
andy31415 marked this conversation as resolved.
Show resolved Hide resolved
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