Skip to content

Commit

Permalink
fix: CI/CD Testing
Browse files Browse the repository at this point in the history
  • Loading branch information
kassane committed Mar 22, 2024
1 parent 754cced commit 023d987
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 34 deletions.
34 changes: 4 additions & 30 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,11 @@ jobs:
fail-fast: false
matrix:
runs-on: [ubuntu-latest]
target: [esp32, esp32s2, esp32s3, esp32c3, esp32h2, esp32p4]
runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@v4
- uses: korandoru/setup-zig@v1
- uses: espressif/esp-idf-ci-action@v1
with:
zig-version: master

- name: prepare-linux
run: |
sudo apt-get update
sudo apt-get install -y cmake
git clone --recursive https://github.com/espressif/esp-idf -b v5.3-dev --depth 1
cd esp-idf && chmod +x ./install.sh && ./install.sh
chmod +x ./export.sh && source ./export.sh
cd ..
- name: Build for esp32-c3
run: |
idf.py set-target esp32c3
idf.py build
idf.py size
idf.py fullclean
- name: Build for esp32-h2
run: |
idf.py set-target esp32h2
idf.py build
idf.py size
idf.py fullclean
- name: Build for esp32-p4
run: |
idf.py --preview set-target esp32p4
idf.py build
idf.py size
idf.py fullclean
esp_idf_version: v5.2
target: ${{ matrix.target }}
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
cmake_minimum_required(VERSION 3.5)

include($ENV{IDF_PATH}/tools/cmake/project.cmake)
set(SDKCONFIG_DEFAULTS sdkconfig.defaults)
set(BUILD_PATH ${CMAKE_CURRENT_SOURCE_DIR})
project(zig-sample-idf)
45 changes: 42 additions & 3 deletions main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,45 @@ idf_component_register(SRCS "placeholder.c"
set(include_dirs $<TARGET_PROPERTY:${COMPONENT_LIB},INCLUDE_DIRECTORIES> ${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES})
set(link_libs $<TARGET_PROPERTY:${COMPONENT_LIB},LINK_LIBRARIES> ${CMAKE_C_IMPLICIT_LINK_LIBRARIES})


# Detect target architecture and platform
if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64")
set(TARGET_ARCH "x86_64")
elseif(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "aarch64")
set(TARGET_ARCH "aarch64")
else()
message(FATAL_ERROR "Unsupported architecture")
endif()

if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux")
set(TARGET_PLATFORM "linux-musl")
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
set(TARGET_PLATFORM "windows-gnu")
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
set(TARGET_PLATFORM "macos-none")
else()
message(FATAL_ERROR "Unsupported platform")
endif()

if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/zig-${TARGET_ARCH}-relsafe-espressif-${TARGET_PLATFORM}-baseline")
file(DOWNLOAD "https://github.com/kassane/zig-espressif-bootstrap/releases/download/0.12.0-dev/zig-${TARGET_ARCH}-relsafe-espressif-${TARGET_PLATFORM}-baseline.tar.xz"
"${CMAKE_CURRENT_BINARY_DIR}/zig.tar.xz")

if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
execute_process(
COMMAND powershell -Command "Expand-Archive -Path ${CMAKE_CURRENT_BINARY_DIR}/zig.tar.xz -DestinationPath ${CMAKE_CURRENT_BINARY_DIR}"
)
else()
execute_process(
COMMAND ${CMAKE_COMMAND} -E tar xf ${CMAKE_CURRENT_BINARY_DIR}/zig.tar.xz
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
endif()
else()
message(STATUS "Zig already downloaded. Skipping zig install.")
endif()
set(ZIG_INSTALL ${CMAKE_CURRENT_BINARY_DIR}/zig-${TARGET_ARCH}-relsafe-espressif-${TARGET_PLATFORM}-baseline)

if(CONFIG_IDF_TARGET_ARCH_RISCV)
set(ZIG_TARGET "riscv32-freestanding-none")
if(CONFIG_IDF_TARGET_ESP32C6 OR CONFIG_IDF_TARGET_ESP32C5 OR CONFIG_IDF_TARGET_ESP32H2)
Expand All @@ -32,15 +71,15 @@ endif()
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(ZIG_BUILD_TYPE "Debug")
else()
set(ZIG_BUILD_TYPE "ReleaseSmall")
set(ZIG_BUILD_TYPE "ReleaseSafe")
endif()

add_custom_target(zig_build
COMMAND ${CMAKE_COMMAND} -E env
"INCLUDE_DIRS=${include_dirs}"
"LIBRARIES=${link_libs}"
zig build
--build-file ${CMAKE_CURRENT_SOURCE_DIR}/../build.zig
${ZIG_INSTALL}/zig build
--build-file ${BUILD_PATH}/build.zig
-Doptimize=${ZIG_BUILD_TYPE}
-Dtarget=${ZIG_TARGET}
-Dcpu=${TARGET_CPU_MODEL}
Expand Down

0 comments on commit 023d987

Please sign in to comment.