1# Copyright 2024 The Pigweed Authors 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); you may not 4# use this file except in compliance with the License. You may obtain a copy of 5# the License at 6# 7# https://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12# License for the specific language governing permissions and limitations under 13# the License. 14"""Zephyr SDK pw_env_setup action plugin. 15 16This action triggers `cmake -P <cache_path>/cmake/zephyr_sdk_export.cmake` after 17CIPD setup. 18""" 19import os 20import pathlib 21import shutil 22import subprocess 23 24 25def run_action(env=None): 26 """Project action to install the Zephyr SDK.""" 27 if not env: 28 raise ValueError(f"Missing 'env', got %{env}") 29 30 with env(): 31 cmake = shutil.which('cmake') 32 33 zephyr_sdk = list( 34 pathlib.Path(os.environ['PW_CIPD_CIPD_INSTALL_DIR']).glob( 35 '**/cmake/zephyr_sdk_export.cmake' 36 ) 37 )[0] 38 subprocess.check_call( 39 [cmake, '-P', str(zephyr_sdk)], 40 stdout=subprocess.DEVNULL, 41 stderr=subprocess.DEVNULL, 42 ) 43