-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 65bb005
Showing
10 changed files
with
161 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: tests | ||
|
||
on: push | ||
|
||
jobs: | ||
test: | ||
strategy: | ||
matrix: | ||
os: | ||
- ubuntu-latest | ||
- macos-latest | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- name: Checkout asdf-zephyr plugin | ||
uses: actions/checkout@v4 | ||
with: | ||
path: plugin | ||
- name: Install asdf | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: asdf-vm/asdf | ||
path: .asdf | ||
ref: v0.14.0 | ||
- name: Test asdf-zephyr plugin | ||
run: | | ||
source .asdf/asdf.sh | ||
asdf plugin test zephyr plugin "west --version" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Copyright 2024 Redwire Labs LLC | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# asdf-zephyr | ||
[![Test](https://github.com/redwirelabs/asdf-zephyr/actions/workflows/test.yml/badge.svg)](https://github.com/redwirelabs/asdf-zephyr/actions/workflows/test.yml) | ||
|
||
An [asdf](https://asdf-vm.com) plugin for managing | ||
[Zephyr RTOS](https://docs.zephyrproject.org/latest/) repositories. | ||
|
||
## Install | ||
|
||
**Note**: Ensure python3 and | ||
[python3-venv](https://docs.python.org/3/library/venv.html) are installed on | ||
your host system. | ||
|
||
```shell | ||
asdf plugin add zephyr https://github.com/redwirelabs/asdf-zephyr.git | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/usr/bin/env bash | ||
|
||
export ZEPHYR_VERSION=$ASDF_INSTALL_VERSION | ||
export ZEPHYR_BASE=$ASDF_INSTALL_PATH/zephyr | ||
export VIRTUAL_ENV=$ASDF_INSTALL_PATH/.venv | ||
|
||
sdk=$(asdf where zephyr-sdk) | ||
if [ $? -eq 0 ]; then | ||
export ZEPHYR_SDK_INSTALL_DIR=$sdk | ||
export ZEPHYR_TOOLCHAIN_VARIANT=zephyr | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
setup_venv() { | ||
local destination=$1 | ||
|
||
python3 -m venv $destination/.venv | ||
source $destination/.venv/bin/activate | ||
} | ||
|
||
install_west() { | ||
pip install west | ||
} | ||
|
||
install_zephyr() { | ||
local version=$1 | ||
local destination=$2 | ||
|
||
west init --mr "v${version}" $destination | ||
|
||
pushd $destination | ||
|
||
west update | ||
west zephyr-export | ||
pip install -r zephyr/scripts/requirements.txt | ||
|
||
popd | ||
} | ||
|
||
install_shims() { | ||
local source=$1 | ||
local destination=$2 | ||
|
||
mkdir $destination/bin/ | ||
cp $source/shims/* $destination/bin/ | ||
} | ||
|
||
setup_venv $ASDF_INSTALL_PATH | ||
install_west | ||
install_zephyr $ASDF_INSTALL_VERSION $ASDF_INSTALL_PATH | ||
install_shims "${BASH_SOURCE[0]%/*/*}" $ASDF_INSTALL_PATH |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
source $(dirname $0)/utils.bash | ||
|
||
get_latest_release() { | ||
curl -sD - "${GH_REPO}/releases/latest" \ | ||
| sed -n -e "s/^location: *//p" | ||
} | ||
|
||
latest_url=$(get_latest_release) | ||
|
||
if [[ "${latest_url}" == "${GH_REPO}/releases" ]]; then | ||
list_all_versions | tail -n1 | ||
else | ||
basename $latest_url | sed 's/^v//' | tr -d '[:space:]' | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
source $(dirname $0)/utils.bash | ||
|
||
list_all_versions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
GH_REPO="https://github.com/zephyrproject-rtos/zephyr" | ||
TOOL_NAME="zephyr" | ||
|
||
list_all_versions() { | ||
git ls-remote --tags --refs $GH_REPO \ | ||
| grep -o 'refs/tags/.*' \ | ||
| cut -d/ -f3- \ | ||
| grep -v '^zephyr' \ | ||
| grep -v '-' \ | ||
| sed 's/^v//' \ | ||
| sort -V \ | ||
| xargs echo | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/usr/bin/env bash | ||
|
||
sdk=$(asdf where zephyr-sdk) | ||
if [ $? -eq 0 ]; then | ||
export PATH=$sdk/sysroots/x86_64-pokysdk-linux/bin:$PATH | ||
fi | ||
|
||
export PATH=$VIRTUAL_ENV/bin:$PATH | ||
|
||
west $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0.1.0 |