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
60 changes: 56 additions & 4 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
name: Cross-Platform PiCo Build
name: Cieto CI

on: [push, pull_request]
on:
push:
pull_request:
workflow_dispatch:

jobs:
build:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
timeout-minutes: 20

strategy:
fail-fast: false
Expand All @@ -14,14 +18,16 @@ jobs:
- name: Linux Release
os: ubuntu-latest
preset: release
package: cieto-linux-x86_64

- name: Windows Release
os: windows-latest
preset: release-windows
package: cieto-windows-x86_64

steps:
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@v7
with:
submodules: recursive

Expand All @@ -32,4 +38,50 @@ jobs:
run: cmake --build --preset ${{ matrix.preset }}

- name: Run tests
run: ctest --preset ${{ matrix.preset }} --output-on-failure
run: ctest --preset ${{ matrix.preset }} --output-on-failure

- name: Stage install tree
run: cmake --install build/${{ matrix.preset }} --prefix package/cieto

- name: Create ZIP package
working-directory: package
run: |
cmake -E tar cf ../${{ matrix.package }}.zip cieto
cmake -E tar tf ../${{ matrix.package }}.zip

- name: Upload ZIP artifact
uses: actions/upload-artifact@v7
with:
path: ${{ matrix.package }}.zip
archive: false
if-no-files-found: error
retention-days: 14

sanitizers:
name: Linux ASan + UBSan
runs-on: ubuntu-latest
timeout-minutes: 20
env:
ASAN_OPTIONS: detect_leaks=1:halt_on_error=1
UBSAN_OPTIONS: halt_on_error=1:print_stacktrace=1

steps:
- name: Checkout code
uses: actions/checkout@v7
with:
submodules: recursive

- name: Configure sanitizers
run: >-
cmake -S . -B build/sanitizers -G Ninja
-DCMAKE_BUILD_TYPE=Debug
-DCMAKE_C_COMPILER=gcc
-DBUILD_TESTING=ON
"-DCMAKE_C_FLAGS=-fsanitize=address,undefined -fno-omit-frame-pointer -fno-sanitize-recover=all"
"-DCMAKE_EXE_LINKER_FLAGS=-fsanitize=address,undefined"

- name: Build with sanitizers
run: cmake --build build/sanitizers

- name: Run sanitizer tests
run: ctest --test-dir build/sanitizers --output-on-failure --timeout 180
128 changes: 64 additions & 64 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
cmake_minimum_required(VERSION 3.21)

project(PiCo VERSION 0.1.0 LANGUAGES C)
project(Cieto VERSION 0.2.0 LANGUAGES C)

include(GNUInstallDirs)

if(NOT CMAKE_C_COMPILER_ID MATCHES "GNU")
message(FATAL_ERROR
"PiCo requires GCC because it uses GNU C extensions. "
"Cieto requires GCC because it uses GNU C extensions. "
"Configure CMake with a GCC-based toolchain or preset."
)
endif()
Expand All @@ -21,7 +21,7 @@ file(GLOB_RECURSE COMPILER_SRC CONFIGURE_DEPENDS "compiler/*.c")
file(GLOB_RECURSE STD_SRC CONFIGURE_DEPENDS "std/*.c")
file(GLOB_RECURSE CMD_SRC CONFIGURE_DEPENDS "cmd/*.c")

set(PICO_INTERNAL_INCLUDE_DIRS
set(CIETO_INTERNAL_INCLUDE_DIRS
cmd
core
vm
Expand All @@ -30,17 +30,17 @@ set(PICO_INTERNAL_INCLUDE_DIRS
vendor/xxhash
)

set(PICO_API_SRC
api/pico.c
set(CIETO_API_SRC
api/cieto.c
)

set(PICO_VENDOR_SRC
set(CIETO_VENDOR_SRC
vendor/xxhash/xxhash.c
)

set(PICO_RUNTIME_SRC
${PICO_API_SRC}
${PICO_VENDOR_SRC}
set(CIETO_RUNTIME_SRC
${CIETO_API_SRC}
${CIETO_VENDOR_SRC}
${CORE_SRC}
${VM_SRC}
${COMPILER_SRC}
Expand All @@ -53,39 +53,39 @@ add_compile_options(
$<$<CONFIG:Release>:-O3>
)

add_library(picort STATIC
${PICO_RUNTIME_SRC}
add_library(libcieto STATIC
${CIETO_RUNTIME_SRC}
)

target_include_directories(picort
target_include_directories(libcieto
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
PRIVATE
${PICO_INTERNAL_INCLUDE_DIRS}
${CIETO_INTERNAL_INCLUDE_DIRS}
)

set_target_properties(picort PROPERTIES
OUTPUT_NAME pico
set_target_properties(libcieto PROPERTIES
OUTPUT_NAME cieto
)

target_link_libraries(picort
target_link_libraries(libcieto
PRIVATE
m
)

add_executable(pico
add_executable(cieto
${CMD_SRC}
)

target_include_directories(pico
target_include_directories(cieto
PRIVATE
${PICO_INTERNAL_INCLUDE_DIRS}
${CIETO_INTERNAL_INCLUDE_DIRS}
)

target_link_libraries(pico
target_link_libraries(cieto
PRIVATE
picort
libcieto
)

if(NOT WIN32)
Expand All @@ -98,68 +98,68 @@ if(NOT WIN32)
vendor/linenoise
)

target_compile_definitions(pico
target_compile_definitions(cieto
PRIVATE
USE_LINENOISE
)

target_link_libraries(pico
target_link_libraries(cieto
PRIVATE
linenoise_lib
)
endif()

add_executable(pico_embed_basic
add_executable(cieto_embed_basic
examples/embedding/basic.c
)

target_link_libraries(pico_embed_basic
target_link_libraries(cieto_embed_basic
PRIVATE
picort
libcieto
)

add_executable(pico_embed_exit_policy
add_executable(cieto_embed_exit_policy
tests/embedding_exit_policy.c
)

target_link_libraries(pico_embed_exit_policy
target_link_libraries(cieto_embed_exit_policy
PRIVATE
picort
libcieto
)

add_executable(pico_embed_native_function
add_executable(cieto_embed_native_function
tests/embedding_native_function.c
)

target_link_libraries(pico_embed_native_function
target_link_libraries(cieto_embed_native_function
PRIVATE
picort
libcieto
)

add_executable(pico_embed_output_callback
add_executable(cieto_embed_output_callback
tests/embedding_output_callback.c
)

target_link_libraries(pico_embed_output_callback
target_link_libraries(cieto_embed_output_callback
PRIVATE
picort
libcieto
)

add_executable(pico_embed_call_script
add_executable(cieto_embed_call_script
tests/embedding_call_script.c
)

target_link_libraries(pico_embed_call_script
target_link_libraries(cieto_embed_call_script
PRIVATE
picort
libcieto
)

include(CTest)

if(BUILD_TESTING)
if(WIN32)
find_program(
PICO_BASH_EXECUTABLE
CIETO_BASH_EXECUTABLE
NAMES bash.exe
PATHS
"$ENV{ProgramFiles}/Git/bin"
Expand All @@ -171,72 +171,72 @@ if(BUILD_TESTING)
)
else()
find_program(
PICO_BASH_EXECUTABLE
CIETO_BASH_EXECUTABLE
NAMES bash
)
endif()

if(NOT PICO_BASH_EXECUTABLE)
if(NOT CIETO_BASH_EXECUTABLE)
message(FATAL_ERROR
"Bash was not found. On Windows, install Git for Windows or MSYS2."
)
endif()

add_test(
NAME pico_script_tests
NAME cieto_script_tests
COMMAND
"${PICO_BASH_EXECUTABLE}"
"${CIETO_BASH_EXECUTABLE}"
"${CMAKE_SOURCE_DIR}/tests/run_tests.sh"
"$<TARGET_FILE:pico>"
"$<TARGET_FILE:cieto>"
"60"
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/tests"
)

add_test(
NAME pico_embedding_basic
COMMAND $<TARGET_FILE:pico_embed_basic>
NAME cieto_embedding_basic
COMMAND $<TARGET_FILE:cieto_embed_basic>
)

add_test(
NAME pico_embedding_exit_policy
COMMAND $<TARGET_FILE:pico_embed_exit_policy>
NAME cieto_embedding_exit_policy
COMMAND $<TARGET_FILE:cieto_embed_exit_policy>
)

add_test(
NAME pico_embedding_native_function
COMMAND $<TARGET_FILE:pico_embed_native_function>
NAME cieto_embedding_native_function
COMMAND $<TARGET_FILE:cieto_embed_native_function>
)

add_test(
NAME pico_embedding_call_script
COMMAND $<TARGET_FILE:pico_embed_call_script>
NAME cieto_embedding_call_script
COMMAND $<TARGET_FILE:cieto_embed_call_script>
)

add_test(
NAME pico_embedding_output_callback
COMMAND $<TARGET_FILE:pico_embed_output_callback>
NAME cieto_embedding_output_callback
COMMAND $<TARGET_FILE:cieto_embed_output_callback>
)
endif()

add_custom_target(check
COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure
DEPENDS
pico
pico_embed_basic
pico_embed_exit_policy
pico_embed_native_function
pico_embed_call_script
pico_embed_output_callback
cieto
cieto_embed_basic
cieto_embed_exit_policy
cieto_embed_native_function
cieto_embed_call_script
cieto_embed_output_callback
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)

install(TARGETS pico picort
install(TARGETS cieto libcieto
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
)

install(FILES include/pico.h
install(FILES include/cieto.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)

Expand All @@ -247,9 +247,9 @@ install(FILES README.md manual.md LICENSE gpl-3.0.txt
install(DIRECTORY examples/
DESTINATION ${CMAKE_INSTALL_DOCDIR}/examples
FILES_MATCHING
PATTERN "*.pcs"
PATTERN "*.cies"
PATTERN "*.c"
PATTERN "README.md"
)

message(STATUS "Project 'PiCo' configured to use C Compiler: ${CMAKE_C_COMPILER}")
message(STATUS "Project 'Cieto' configured to use C Compiler: ${CMAKE_C_COMPILER}")
Loading