Skip to content
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
7 changes: 5 additions & 2 deletions .github/workflows/build-rootfs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ jobs:
echo "describe=$(git describe --tags --always || echo 0)"
| tee $GITHUB_OUTPUT
- name: Setup and build
run: |
ARCH=${{ matrix.arch }} ./scripts/build-rootfs.sh
run: >-
ARCH=${{ matrix.arch }}
UNIFYSDK_GIT_REPOSITORY=${{ secrets.UNIFYSDK_GIT_REPOSITORY }}
UNIFYSDK_GIT_TAG=${{ secrets.UNIFYSDK_GIT_TAG }}
./scripts/build-rootfs.sh
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ jobs:
echo "describe=$(git describe --tags --always || echo 0)"
| tee $GITHUB_OUTPUT
- name: Build Docker image from sources
run: docker build --tag "${{ env.project-name }}:latest" .
run: >-
docker build
--tag "${{ env.project-name }}:latest"
--build-arg UNIFYSDK_GIT_REPOSITORY=${{ secrets.UNIFYSDK_GIT_REPOSITORY }}
--build-arg UNIFYSDK_GIT_TAG=${{ secrets.UNIFYSDK_GIT_TAG }}
.
- name: Extract artifacts
run: >-
container=$(docker create "${{ env.project-name }}:latest")
Expand Down
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ ENV DEBIAN_FRONTEND noninteractive
ENV LC_ALL en_US.UTF-8
ENV LANG ${LC_ALL}

ARG UNIFYSDK_GIT_REPOSITORY https://github.com/SiliconLabs/UnifySDK
ARG UNIFYSDK_GIT_TAG main

RUN echo "# log: Configuring locales" \
&& set -x \
&& apt-get update -y \
Expand Down
48 changes: 48 additions & 0 deletions cmake/modules/FindUnifySDK.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# SPDX-FileCopyrightText: Silicon Laboratories Inc. <https://www.silabs.com/>
# SPDX-License-Identifier: Zlib
#
# Origin: https://github.com/SiliconLabs/UnifySDK/pull/51
#
# This recipe allows to download Unify Core
# It can be used by projects which are depending on it
# Feel free to copy this (up to date) file everywhere it is needed

include(FetchContent)

if(NOT DEFINED UNIFYSDK_GIT_REPOSITORY)
if(DEFINED ENV{UNIFYSDK_GIT_REPOSITORY})
set(UNIFYSDK_GIT_REPOSITORY $ENV{UNIFYSDK_GIT_REPOSITORY})
endif()
endif()
if("${UNIFYSDK_GIT_REPOSITORY}" STREQUAL "")
set(UNIFYSDK_GIT_REPOSITORY "https://github.com/SiliconLabs/UnifySDK")
endif()

if(NOT DEFINED UNIFYSDK_GIT_TAG)
if(DEFINED ENV{UNIFYSDK_GIT_TAG})
set(UNIFYSDK_GIT_TAG $ENV{UNIFYSDK_GIT_TAG})
endif()
endif()
if("${UNIFYSDK_GIT_TAG}" STREQUAL "")
set(UNIFYSDK_GIT_TAG "main") # Override CMake default ("master")
endif()

FetchContent_Declare(
UnifySDK
GIT_REPOSITORY ${UNIFYSDK_GIT_REPOSITORY}
GIT_TAG ${UNIFYSDK_GIT_TAG}
GIT_SUBMODULES_RECURSE True
GIT_SHALLOW 1
)

message(STATUS "${CMAKE_PROJECT_NAME}: Depends: ${UNIFYSDK_GIT_REPOSITORY}#${UNIFYSDK_GIT_TAG}")
string(REGEX MATCH ".*/?main/?.*" UNIFYSDK_UNSTABLE_GIT_TAG "${UNIFYSDK_GIT_TAG}")
if(UNIFYSDK_GIT_TAG STREQUAL "" OR UNIFYSDK_UNSTABLE_GIT_TAG)
message(WARNING "${CMAKE_PROJECT_NAME}: Declare UNIFYSDK_GIT_TAG to stable version not: ${UNIFYSDK_UNSTABLE_GIT_TAG}")
endif()

set(FETCHCONTENT_QUIET FALSE)
FetchContent_MakeAvailable(UnifySDK)

# message(STATUS "UnifySDK Sources: ${unifysdk_SOURCE_DIR}")
# message(STATUS "UnifySDK Binaries: ${unifysdk_BINARY_DIR}")
17 changes: 17 additions & 0 deletions scripts/build-rootfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,28 @@ if [ ! -d "${rootfs_dir}" ] ; then
${sudo} chmod -v u+rX "${rootfs_dir}"
fi

### Environement to pass

[ "" = "$UNIFYSDK_GIT_REPOSITORY" ] \
|| env_vars="$env_vars UNIFYSDK_GIT_REPOSITORY=${UNIFYSDK_GIT_REPOSITORY}"
[ "" = "$UNIFYSDK_GIT_TAG" ] \
|| env_vars="$env_vars UNIFYSDK_GIT_TAG=${UNIFYSDK_GIT_TAG}"
export UNIFYSDK_GIT_TAG


# TODO: https://github.com/rust-lang/cargo/issues/8719#issuecomment-1516492970
env_vars="$env_vars CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse"

# TODO: https://github.com/rust-lang/cargo/issues/10583
env_vars="$env_vars CARGO_NET_GIT_FETCH_WITH_CLI=true"

env_vars_options=""
for i in $env_vars; do
env_vars_options="$env_vars_options --setenv=$i"
done

### Workarounds/Optimizations

cargo_dir="/tmp/$USER/${machine}/${HOME}/.cargo"
${sudo} mkdir -pv "${cargo_dir}"

Expand All @@ -91,6 +107,7 @@ case ${chroot} in
--machine="${machine}" \
--bind="${CURDIR}:${CURDIR}" \
--bind="${cargo_dir}:/root/.cargo" \
$env_vars_options
"
if [ -e "${qemu_file}" ] ; then
rootfs_shell="$rootfs_shell --bind ${qemu_file}"
Expand Down