Skip to content

Commit

Permalink
enable wokwi-CI
Browse files Browse the repository at this point in the history
  • Loading branch information
kassane committed Aug 11, 2024
1 parent b93af8f commit bda26e0
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 2,042 deletions.
42 changes: 21 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@ name: Wokwi-CI Build

on: [push, pull_request]

# jobs:
# build:
# strategy:
# fail-fast: false
# matrix:
# target: [esp32, esp32s2, esp32s3, esp32c3, esp32h2, esp32c6, esp32p4]
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: espressif/esp-idf-ci-action@v1
# with:
# esp_idf_version: v5.3
# target: ${{ matrix.target }}
# - name: Copy diagram ${{ matrix.target }}
# run: |
# cp .github/workflows/wokwi/diagram-${{ matrix.target }}.json diagram.json
# - uses: wokwi/wokwi-ci-action@v1
# with:
# token: ${{ secrets.WOKWI_CI_TOKEN }}
# timeout: 5000
# expect_text: 'Hello, world from C3!'
jobs:
build:
strategy:
fail-fast: false
matrix:
target: [esp32, esp32s2, esp32s3, esp32c3, esp32h2, esp32c6]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: espressif/esp-idf-ci-action@v1
with:
esp_idf_version: v5.3
target: ${{ matrix.target }}
- name: Copy diagram ${{ matrix.target }}
run: |
cp .github/workflows/wokwi/diagram-${{ matrix.target }}.json diagram.json
- uses: wokwi/wokwi-ci-action@v1
with:
token: ${{ secrets.WOKWI_CI_TOKEN }}
timeout: 5000
expect_text: 'Hello, world from C3!'
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ cmake_minimum_required(VERSION 3.5)

include($ENV{IDF_PATH}/tools/cmake/project.cmake)
set(BUILD_PATH ${CMAKE_CURRENT_SOURCE_DIR})
project(c3-sample-idf)
project(c3lang-esp32-example)
78 changes: 60 additions & 18 deletions main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,67 @@ idf_component_register(SRCS "placeholder.c"

# Based on zig-esp-idf-sample project

set(EXT "tar.xz")
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux")
if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64")
set(TARGET_ARCH "x86_64")
elseif(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86")
set(TARGET_ARCH "x86")
elseif(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "aarch64")
set(TARGET_ARCH "aarch64")
else()
message(FATAL_ERROR "linux: Unsupported architecture")
endif()
set(TARGET_PLATFORM "linux-musl")
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64")
set(TARGET_ARCH "x86_64")
elseif(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86")
set(TARGET_ARCH "x86")
elseif(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "aarch64")
set(TARGET_ARCH "aarch64")
else()
message(FATAL_ERROR "windows: Unsupported architecture")
endif()
set(TARGET_PLATFORM "windows-gnu")
set(EXT "zip")
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64")
set(TARGET_ARCH "x86_64")
elseif(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "arm64")
set(TARGET_ARCH "aarch64")
else()
message(FATAL_ERROR "macos: Unsupported architecture")
endif()
set(TARGET_PLATFORM "macos")
else()
message(FATAL_ERROR "Unsupported platform")
endif()

if(NOT EXISTS "${CMAKE_BINARY_DIR}/lib/c3")
file(DOWNLOAD "https://github.com/kassane/esp32-c3lang/releases/download/v0.0.0/c3c-espressif-${TARGET_ARCH}-${TARGET_PLATFORM}.${EXT}"
"${CMAKE_BINARY_DIR}/c3c.${EXT}")

if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
execute_process(
COMMAND powershell -Command "Expand-Archive -Path ${CMAKE_BINARY_DIR}/c3c.${EXT} -DestinationPath ${CMAKE_BINARY_DIR}"
)
else()
execute_process(
COMMAND ${CMAKE_COMMAND} -E tar xf ${CMAKE_BINARY_DIR}/c3c.${EXT}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
endif()
else()
message(STATUS "C3c already downloaded. Skipping C3 install.")
endif()

if(CONFIG_IDF_TARGET_ARCH_RISCV)
set(C3_TARGET "elf-riscv32") # generic
# if(CONFIG_IDF_TARGET_ESP32C6 OR CONFIG_IDF_TARGET_ESP32C5 OR CONFIG_IDF_TARGET_ESP32H2)
# set(TARGET_CPU_MODEL "generic_rv32+m+a+c")
# elseif(CONFIG_IDF_TARGET_ESP32P4)
# string(REGEX REPLACE "-none" "-eabihf" C3_TARGET ${C3_TARGET})
# set(TARGET_CPU_MODEL "generic_rv32+m+a+c+f")
# else()
# set(TARGET_CPU_MODEL "generic_rv32+m+c")
# endif()
# generic
set(C3_TARGET "elf-riscv32")
elseif(CONFIG_IDF_TARGET_ARCH_XTENSA)
set(C3_TARGET "elf-xtensa") # generic
# if(CONFIG_IDF_TARGET_ESP32)
# set(TARGET_CPU_MODEL "esp32")
# elseif(CONFIG_IDF_TARGET_ESP32S2)
# set(TARGET_CPU_MODEL "esp32s2")
# else(CONFIG_IDF_TARGET_ESP32S3)
# set(TARGET_CPU_MODEL "esp32s3")
# endif()
# esp32 (default)
set(C3_TARGET "elf-xtensa")
else()
message(FATAL_ERROR "Unsupported target ${CONFIG_IDF_TARGET}")
endif()
Expand All @@ -39,7 +81,7 @@ endif()
add_custom_target(c3_build
COMMAND ${CMAKE_COMMAND} -E env
"INCLUDE_DIRS=${include_dirs}"
c3c
${CMAKE_BINARY_DIR}/c3c
--no-entry
--use-stdlib=no
--link-libc=no
Expand Down
3 changes: 1 addition & 2 deletions main/app.c3
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

extern fn int printf(char* format, ...);

fn void app_main() @export("app_main")
{
printf("Hello World C3 language!\n");
printf("Hello, world from C3!\n");
}
Loading

0 comments on commit bda26e0

Please sign in to comment.