-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
5 changed files
with
264 additions
and
13 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,106 @@ | ||
# Copyright (C) 2023 Toitware ApS. All rights reserved. | ||
|
||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- "*" | ||
- "*/*" | ||
|
||
env: | ||
TOIT_VERSION: v2.0.0-alpha.114 | ||
|
||
jobs: | ||
build: | ||
strategy: | ||
matrix: | ||
os: [ ubuntu-latest, macos-latest, windows-latest ] | ||
|
||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Setup Toit | ||
shell: bash | ||
run: | | ||
if [[ "$RUNNER_OS" = "Windows" ]]; then | ||
BIN_EXTENSION=".exe" | ||
fi | ||
echo "BIN_EXTENSION=$BIN_EXTENSION" >> $GITHUB_ENV | ||
export NATIVE_DOWNLOAD_DIR="${{ github.workspace }}/downloads" | ||
echo "NATIVE_DOWNLOAD_DIR=$NATIVE_DOWNLOAD_DIR" >> $GITHUB_ENV | ||
export DOWNLOAD_DIR="$PWD/downloads" | ||
echo "DOWNLOAD_DIR=$DOWNLOAD_DIR" >> $GITHUB_ENV | ||
TOIT_SDK_DIR=$DOWNLOAD_DIR/toit | ||
echo "TOIT_EXEC=$TOIT_SDK_DIR/bin/toit.run$BIN_EXTENSION" >> $GITHUB_ENV | ||
echo "TOITC_EXEC=$TOIT_SDK_DIR/bin/toit.compile$BIN_EXTENSION" >> $GITHUB_ENV | ||
echo "TPKG_EXEC=$TOIT_SDK_DIR/bin/toit.pkg$BIN_EXTENSION" >> $GITHUB_ENV | ||
TOIT_SDK_FILE=toit-$(echo $RUNNER_OS | tr '[:upper:]' '[:lower:]').tar.gz | ||
TOIT_SDK_BASE_URL=https:/toitlang/toit/releases | ||
echo "TOIT_SDK_URL=$TOIT_SDK_BASE_URL/download/$TOIT_VERSION/$TOIT_SDK_FILE" >> $GITHUB_ENV | ||
- uses: suisei-cn/[email protected] | ||
name: Download Toit | ||
with: | ||
url: ${{ env.TOIT_SDK_URL }} | ||
target: ${{ env.NATIVE_DOWNLOAD_DIR }} | ||
|
||
- name: Extract Toit | ||
shell: bash | ||
run: | | ||
cd "$DOWNLOAD_DIR" | ||
for f in *.tar.gz; do | ||
tar x -f $f | ||
done | ||
ls $TOIT_EXEC | ||
ls $TOITC_EXEC | ||
ls $TPKG_EXEC | ||
# Fetch the dependencies. Different for each platform. | ||
- name: Install dependencies - Linux | ||
if: runner.os == 'Linux' | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install ninja-build | ||
ninja --version | ||
cmake --version | ||
- name: Install dependencies - macOS | ||
if: runner.os == 'macOS' | ||
run: | | ||
brew install ninja | ||
ninja --version | ||
cmake --version | ||
- name: Install dependencies - Windows | ||
if: runner.os == 'Windows' | ||
run: | | ||
choco install ninja | ||
ninja --version | ||
cmake --version | ||
- name: Run cmake | ||
shell: bash | ||
run: | | ||
make rebuild-cmake | ||
cmake \ | ||
-DTOITC="$TOITC_EXEC" \ | ||
-DTOITPKG="$TPKG_EXEC" \ | ||
-DTOITRUN="$TOIT_EXEC" \ | ||
build | ||
- name: Build binaries | ||
shell: bash | ||
run: | | ||
make | ||
- name: Upload binary artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: binaries-${{ runner.os }} | ||
path: build/partitions |
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
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
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
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,118 @@ | ||
# Copyright (C) 2019 Toitware ApS. | ||
# | ||
# This library is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU Lesser General Public | ||
# License as published by the Free Software Foundation; version | ||
# 2.1 only. | ||
# | ||
# This library is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
# Lesser General Public License for more details. | ||
# | ||
# The license can be found in the file `LICENSE` in the top level | ||
# directory of this repository. | ||
|
||
# This file serves as normal cmake include, as well as a cmake-script, run with | ||
# `cmake -P`. | ||
# In the latter case the `EXECUTING_SCRIPT` variable is defined, and we only | ||
# process the command that we should execute. | ||
set(TOIT_DOWNLOAD_PACKAGE_SCRIPT "${CMAKE_CURRENT_LIST_DIR}/toit.cmake") | ||
if (DEFINED EXECUTING_SCRIPT) | ||
if ("${SCRIPT_COMMAND}" STREQUAL "install_packages") | ||
if (NOT DEFINED TOIT_PROJECT) | ||
message(FATAL_ERROR "Missing TOIT_PROJECT") | ||
endif() | ||
if (NOT DEFINED TOITPKG) | ||
message(FATAL_ERROR "Missing TOITPKG") | ||
endif() | ||
|
||
if (EXISTS "${TOIT_PROJECT}/package.yaml" OR EXISTS "${TOIT_PROJECT}/package.lock") | ||
execute_process( | ||
COMMAND "${TOITPKG}" install --auto-sync=false "--project-root=${TOIT_PROJECT}" | ||
COMMAND_ERROR_IS_FATAL ANY | ||
) | ||
endif() | ||
else() | ||
message(FATAL_ERROR "Unknown script command ${SCRIPT_COMMAND}") | ||
endif() | ||
|
||
# End the execution of this file. | ||
return() | ||
endif() | ||
|
||
# Creates a custom command to build ${TARGET} with correct dependencies. | ||
function(ADD_TOIT_SNAPSHOT SOURCE TARGET DEP_FILE ENV) | ||
if (NOT DEFINED TOITC) | ||
set(TOITC "$ENV{TOITC}") | ||
if ("${TOITC}" STREQUAL "") | ||
# TOITC is normally set to the toit.compile executable. | ||
# However, for cross-compilation the compiler must be provided manually. | ||
message(FATAL_ERROR "TOITC not provided") | ||
endif() | ||
endif() | ||
if(POLICY CMP0116) | ||
cmake_policy(SET CMP0116 NEW) | ||
endif() | ||
add_custom_command( | ||
OUTPUT "${TARGET}" | ||
DEPFILE ${DEP_FILE} | ||
DEPENDS download_packages "${SOURCE}" | ||
COMMAND ${CMAKE_COMMAND} -E env ${ENV} ASAN_OPTIONS=detect_leaks=false "${TOITC}" --dependency-file "${DEP_FILE}" --dependency-format ninja -w "${TARGET}" "${SOURCE}" | ||
) | ||
endfunction(ADD_TOIT_SNAPSHOT) | ||
|
||
# Creates a custom command to build ${TARGET} with correct dependencies. | ||
function(ADD_TOIT_EXE SOURCE TARGET DEP_FILE ENV) | ||
if (NOT DEFINED TOITC) | ||
set(TOITC "$ENV{TOITC}") | ||
if ("${TOITC}" STREQUAL "") | ||
# TOITC is normally set to the toit.compile executable. | ||
# However, for cross-compilation the compiler must be provided manually. | ||
message(FATAL_ERROR "TOITC not provided") | ||
endif() | ||
endif() | ||
if(POLICY CMP0116) | ||
cmake_policy(SET CMP0116 NEW) | ||
endif() | ||
add_custom_command( | ||
OUTPUT "${TARGET}" | ||
DEPFILE ${DEP_FILE} | ||
DEPENDS download_packages "${SOURCE}" | ||
COMMAND ${CMAKE_COMMAND} -E env ${ENV} ASAN_OPTIONS=detect_leaks=false "${TOITC}" --dependency-file "${DEP_FILE}" --dependency-format ninja -o "${TARGET}" "${SOURCE}" | ||
) | ||
endfunction(ADD_TOIT_EXE) | ||
|
||
macro(toit_project NAME PATH) | ||
if (NOT DEFINED TOITPKG) | ||
set(TOITPKG "$ENV{TOITPKG}") | ||
if ("${TOITPKG}" STREQUAL "") | ||
# TOITPKG is normally set to the toit.pkg executable. | ||
# However, for cross-compilation the compiler must be provided manually. | ||
message(FATAL_ERROR "TOITPKG not provided") | ||
endif() | ||
endif() | ||
|
||
if (NOT TARGET download_packages) | ||
add_custom_target( | ||
download_packages | ||
) | ||
add_custom_target( | ||
sync_packages | ||
COMMAND "${TOITPKG}" sync | ||
) | ||
endif() | ||
|
||
set(DOWNLOAD_TARGET_NAME "download-${NAME}-packages") | ||
add_custom_target( | ||
"${DOWNLOAD_TARGET_NAME}" | ||
COMMAND "${CMAKE_COMMAND}" | ||
-DEXECUTING_SCRIPT=true | ||
-DSCRIPT_COMMAND=install_packages | ||
"-DTOIT_PROJECT=${PATH}" | ||
"-DTOITPKG=${TOITPKG}" | ||
-P "${TOIT_DOWNLOAD_PACKAGE_SCRIPT}" | ||
) | ||
add_dependencies(download_packages "${DOWNLOAD_TARGET_NAME}") | ||
add_dependencies("${DOWNLOAD_TARGET_NAME}" sync_packages) | ||
endmacro() |