Skip to content

Commit

Permalink
Build envelopes on request.
Browse files Browse the repository at this point in the history
  • Loading branch information
floitsch committed Jul 19, 2023
1 parent 4b27d31 commit 83e47c4
Show file tree
Hide file tree
Showing 18 changed files with 1,459 additions and 0 deletions.
160 changes: 160 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,170 @@ name: Build

on:
workflow_dispatch:
inputs:
toit-version:
description: Toit SDK version to check out
required: true
type: string
upload-release:
description: Whether to upload release artifacts
required: true
type: boolean
default: false
variant:
description: Variant to build
required: false
type: string

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

# Use Go 1.20
- name: Switch to Go 1.20
shell: bash
run:
echo "$GOROOT_1_20_X64"/bin >> $GITHUB_PATH

# Get values for cache paths to be used in later steps
- name: Get Go paths
id: go-cache-paths
shell: bash
run: |
echo "go-build=$(go env GOCACHE)" >> $GITHUB_OUTPUT
echo "go-mod=$(go env GOMODCACHE)" >> $GITHUB_OUTPUT
# Cache go build cache, used to speedup go test
- name: Go Build Cache
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-build }}
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-build-

# Cache go mod cache, used to speedup builds
- name: Go Mod Cache
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-mod }}
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-mod-

- name: Ccache cache
uses: actions/cache@v3
# Store and retrieve the cache with the given sha.
# The 'restore-keys' prefix finds the most recent cache in case there
# is no match (which should almost always be the case).
with:
path: ${{ github.workspace }}/.ccache
key: esp32-ccache-${{ github.sha }}
restore-keys: esp32-ccache-

- name: Install dependencies - Linux
run: |
sudo apt-get update
sudo apt-get install ninja-build ccache
ninja --version
cmake --version
gcc --version
- name: Fetch the Toit repository
run: |
make TOIT_VERSION=${{ github.event.inputs.toit-version }} download-toit
- name: Patch Toit
run: |
# Temporary patch until upstream is fixed.
(cd toit && patch -p1 < ../patches/toit.patch)
- name: Build the host SDK
env:
IDF_CCACHE_ENABLE: 1
CCACHE_DIR: ${{ github.workspace }}/.ccache
CCACHE_BASEDIR: ${{ github.workspace }}
CCACHE_COMPRESS: true
CCACHE_COMPRESSLEVEL: '6'
CCACHE_MAXSIZE: 400M
run: |
ccache -s
make build-host
ccache -s
- name: Build the envelope tool
run: |
build/host/sdk/bin/toit.pkg install --project-root=tools
build/host/sdk/bin/toit.compile -o build/envelope-tool tools/main.toit
- name: Install ESP32 tools
run: |
toit/third_party/esp-idf/install.sh
- name: Setting the variants
run: |
VARIANTS=${{ github.event.inputs.variant }}
if [ -z "$VARIANTS" ]; then
VARIANTS=$(build/envelope-tool list)
if [ $? -ne 0 ]; then
echo "Failed to list variants"
exit 1
fi
fi
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "VARIANTS<<$EOF" >> $GITHUB_ENV
echo "$VARIANTS" >> $GITHUB_ENV
echo "$EOF" >> $GITHUB_ENV
- name: Synthesize the variants
run: |
build/envelope-tool synthesize \
--toit-root=toit \
--output-root=synthesized \
--sdk-path=build/host/sdk \
--variants-root=variants \
--build-root=build \
$VARIANTS
- name: Build the variants
env:
IDF_CCACHE_ENABLE: 1
CCACHE_DIR: ${{ github.workspace }}/.ccache
CCACHE_BASEDIR: ${{ github.workspace }}
CCACHE_COMPRESS: true
CCACHE_COMPRESSLEVEL: '6'
CCACHE_MAXSIZE: 400M
run: |
ccache -s
for variant in $VARIANTS; do
(cd synthesized/$variant && make)
done
ccache -s
- name: Prepare envelopes for upload
run: |
mkdir envelopes
for variant in $VARIANTS; do
cp build/$variant/firmware.envelope envelopes/$variant.envelope
done
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: artifacts
path: |
envelopes
- name: Release
if: ${{ github.event.inputs.upload-release }}
uses: ncipollo/release-action@v1
with:
artifacts: |
envelopes/*
body: |
Envelopes for Toit SDK ${{ github.event.inputs.toit-version }}
allowUpdates: true
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.event.inputs.toit-version }}
commit: main
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.packages/
.jaguar
/build/
/synthesized/
/toit/
84 changes: 84 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Copyright (C) 2023 Toitware ApS.
#
# Use of this source code is governed by an MIT-style license that can be
# found in the tools/LICENSE file.

SHELL := bash
.SHELLFLAGS := -eu -o pipefail -c

ifeq ($(OS),Windows_NT)
EXE_SUFFIX := .exe
else
EXE_SUFFIX :=
endif

TOIT_EXEC := toit.run$(EXE_SUFFIX)

TOIT_DIRECTORY := toit
BUILD_DIRECTORY := build
VARIANTS_DIRECTORY := variants
SYNTHESIZED_DIRECTORY := synthesized
TOIT_SDK_DIRECTORY := $(BUILD_DIRECTORY)/host/sdk

TOOL_ENTRY := tools/main.toit
TOOL_RUN := "$(TOIT_EXEC)" "$(TOOL_ENTRY)"

TOIT_GIT_URL := https://github.com/toitlang/toit.git

.PHONY: all
all:
@echo "Please specify a target to build."

.PHONY: download-toit
download-toit: | check-toit-version create-toit-directory
@# If this is not yet a git repository initial it:
if [ ! -d $(TOIT_DIRECTORY)/.git ] ; then \
cd "$(TOIT_DIRECTORY)"; \
git init; \
git remote add origin "$(TOIT_GIT_URL)"; \
fi
@# Fetch.
(cd "$(TOIT_DIRECTORY)" && git fetch origin)
@# Checkout the version of the toit repo that we want to use, and initialize
@# the submodules.
(cd "$(TOIT_DIRECTORY)" && git checkout "${TOIT_VERSION}")
(cd "$(TOIT_DIRECTORY)" && git submodule update --init --recursive)

.PHONY: check-toit-version
check-toit-version:
@if [ -z "$(TOIT_VERSION)" ]; then \
echo "TOIT_VERSION is not set"; \
exit 1; \
fi

.PHONY: create-toit-directory
create-toit-directory:
mkdir -p "$(TOIT_DIRECTORY)"

.PHONY: synthesize-all
synthesize-all: | create-build-directory create-synthesized-directory
$(TOOL_RUN) synthesize \
--toit-root="$(TOIT_DIRECTORY)" \
--build-root="$(BUILD_DIRECTORY)" \
--output-root="$(SYNTHESIZED_DIRECTORY)" \
--sdk-path="$(TOIT_SDK_DIRECTORY)" \
--variants-root="$(VARIANTS_DIRECTORY)" \
$(shell $(TOOL_RUN) list variants)

.PHONY: create-build-directory
create-build-directory:
mkdir -p "$(BUILD_DIRECTORY)"

.PHONY: create-synthesized-directory
create-synthesized-directory:
mkdir -p "$(SYNTHESIZED_DIRECTORY)"

.PHONY: build-all
build-all:
for variant in $(shell $(TOOL_RUN) list variants); do \
$(MAKE) -C "$(SYNTHESIZED_DIRECTORY)/$$variant"; \
done

.PHONY: build-host
build-host:
$(MAKE) -C "$(TOIT_DIRECTORY)" BUILD=$(abspath $(BUILD_DIRECTORY)) sdk
67 changes: 67 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,68 @@
# Envelopes

Envelopes for Toit.

This repository contains a tool to generate envelopes for Toit. It
also automatically builds envelopes for the variants that are stored in
this repository.

For the tool see [the Envelope Tool README](tools/README.md).

We call "variant" configurations (mostly `sdkconfig`) that produce
different builds of firmwares. For example, the `esp32-eth-clk-out17`
variant is for a firmware that uses Ethernet and has the clock output
on pin 17 (like the Olimex Ethernet boards).

Compiled envelopes for specific SDK versions are found in the
release page of this repository. For example, envelopes that are
compiled with and for SDK v2.0.0-alpha.90 are found on the
[v2.0.0-alpha.90 release](https://github.com/toitlang/envelopes/releases/tag/v2.0.0-alpha.90)
page.

## Contributing

Feel free to open issues and pull requests with new variants. Make sure
they have a description (README.md) with the purpose and the changes.
We will automatically build them whenever a new Toit version is released.

Note that some variants are featured here. Consult the
Toit team before adding new variants to this README.

## Variants

### esp32

A generic ESP32 variant. This is the default variant when using Toit.
It is built for maximum compatibility.

This variant supports Ethernet, but without the clock output.

### esp32-eth-clk-out17

A variant for ESP32 boards with Ethernet and a clock output on pin 17.

Olimex boards with Ethernet should use this variant.

### esp32c3

A generic [ESP32-C3 variant](variants/esp32c). This is the default variant
when using Toit on ESP32-C3 boards.

### esp32s2

A generic [ESP32-S2 variant](variants/esp32s2). This is the default variant
when using Toit on ESP32-S2 boards.

### esp32s3

A generic [ESP32-S3 variant](variants/esp32s3). This is the default variant
when using Toit on ESP32-S3 boards.

This variant is configured for external Quad PSRAM.

### esp32s3-spiram-octo

A [variant](variants/esp32s3-spiram-octo/) for ESP32-S3 boards with external
octal PSRAM.

These boards are faster, but often more expensive.
Loading

0 comments on commit 83e47c4

Please sign in to comment.