Skip to content
Open
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
38 changes: 18 additions & 20 deletions .github/workflows/ci-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ jobs:
submodules: true
- run: make -C apps/KhiCAS cleanall
- run: make KhiCAS_rebuild
- run: ./tool/archive KhiCAS.tar KhiCAS
- run: make KhiCAS_archive
- uses: actions/upload-artifact@master
with:
name: KhiCAS
path: KhiCAS.tar
path: apps.tar
BadApple:
runs-on: ubuntu-latest
steps:
Expand All @@ -30,11 +30,11 @@ jobs:
with:
submodules: true
- run: make BadApple_rebuild
- run: ./tool/archive BadApple.tar BadApple
- run: make BadApple_archive
- uses: actions/upload-artifact@master
with:
name: BadApple
path: BadApple.tar
path: apps.tar
CHIP-8:
runs-on: ubuntu-latest
steps:
Expand All @@ -44,11 +44,11 @@ jobs:
with:
submodules: true
- run: make CHIP-8_rebuild
- run: ./tool/archive CHIP-8.tar CHIP-8
- run: make CHIP-8_archive
- uses: actions/upload-artifact@master
with:
name: CHIP-8
path: CHIP-8.tar
path: apps.tar
Example:
runs-on: ubuntu-latest
steps:
Expand All @@ -58,11 +58,11 @@ jobs:
with:
submodules: true
- run: make Example_rebuild
- run: ./tool/archive Example.tar Example
- run: make Example_archive
- uses: actions/upload-artifact@master
with:
name: Example
path: Example.tar
path: apps.tar
Example-Cpp:
runs-on: ubuntu-latest
steps:
Expand All @@ -72,11 +72,11 @@ jobs:
with:
submodules: true
- run: make Example-Cpp_rebuild
- run: ./tool/archive Example-Cpp.tar Example-Cpp
- run: make Example-Cpp_archive
- uses: actions/upload-artifact@master
with:
name: Example-Cpp
path: Example-Cpp.tar
path: apps.tar
HexEdit:
runs-on: ubuntu-latest
steps:
Expand All @@ -86,11 +86,10 @@ jobs:
with:
submodules: true
- run: make HexEdit_rebuild
- run: ./tool/archive HexEdit.tar HexEdit
- uses: actions/upload-artifact@master
with:
name: HexEdit
path: HexEdit.tar
path: apps.tar
Nofrendo:
runs-on: ubuntu-latest
steps:
Expand All @@ -100,11 +99,10 @@ jobs:
with:
submodules: true
- run: make Nofrendo_rebuild
- run: ./tool/archive Nofrendo.tar Nofrendo
- uses: actions/upload-artifact@master
with:
name: Nofrendo
path: Nofrendo.tar
path: apps.tar
Peanut-GB:
runs-on: ubuntu-latest
steps:
Expand All @@ -114,11 +112,11 @@ jobs:
with:
submodules: true
- run: make Peanut-GB_rebuild
- run: ./tool/archive Peanut-GB.tar Peanut-GB
- run: make Peanut-GB_archive
- uses: actions/upload-artifact@master
with:
name: Peanut-GB
path: Peanut-GB.tar
path: apps.tar
Periodic:
runs-on: ubuntu-latest
steps:
Expand All @@ -128,11 +126,11 @@ jobs:
with:
submodules: true
- run: make Periodic_rebuild
- run: ./tool/archive Periodic.tar Periodic
- run: make Periodic_archive
- uses: actions/upload-artifact@master
with:
name: Periodic
path: Periodic.tar
path: apps.tar
UnitCircle:
runs-on: ubuntu-latest
steps:
Expand All @@ -142,11 +140,11 @@ jobs:
with:
submodules: true
- run: make UnitCircle_rebuild
- run: ./tool/archive UnitCircle.tar UnitCircle
- run: make UnitCircle_archive
- uses: actions/upload-artifact@master
with:
name: UnitCircle
path: UnitCircle.tar
path: apps.tar

env:
ACCEPT_OFFICIAL_TOS: 1
20 changes: 13 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
.PHONY: %_flash
%_flash: %_rebuild
./tool/archive apps.tar $@
%_flash: %_archive
@echo "Flashing..."
@echo "Waiting for the calculator to be connected, use the bootloader to flash on Upsilon if your app is bigger than 2MB"
@until dfu-util -l | grep -E "0483:a291|0483:df11" > /dev/null 2>&1; do sleep 2;done
dfu-util -i 0 -a 0 -s 0x90200000 -D apps.tar

%_archive: %_build
@echo "Archiving..."
./tool/archive.sh apps.tar $@

.PHONY: %_build
%_build: api/libapi.a
@echo "Building..."
./tool/build.sh $@

.PHONY: %_rebuild
%_rebuild: api/libapi.a
%_rebuild: %_clean api/libapi.a
@echo "Rebuilding..."
# Because the Makefile can't interpret the `%` operator, we have
# to use the following command to rebuild the application.
./tool/rebuild.sh $@
./tool/build.sh $@

.PHONE: %_clean
%_clean:
@echo "Cleaning..."
rm -rf apps.tar
rm -rf api/libapi.a
./tool/clean.sh $@

api/libapi.a:
Expand Down
1 change: 0 additions & 1 deletion apps/Example/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "inc/selector.h"

void extapp_main(void) {

// Wait for the key to be released before starting the application
waitForKeyReleased();
// Draw a white background
Expand Down
36 changes: 0 additions & 36 deletions tool/archive

This file was deleted.

51 changes: 51 additions & 0 deletions tool/archive.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env bash

set -e

LD=arm-none-eabi-ld
OBJCOPY=arm-none-eabi-objcopy

echo "Building archive..."
echo " - ld: $LD"
echo " - objcopy: $OBJCOPY"
echo " - arguments: $*"
echo "Input files:"

OUTPUT="$1"
shift 1
rm -f "${OUTPUT}"

POS=0

while [[ -n "$1" ]]; do
# Remove the suffix from $1
FILENAME="$(echo "$1" | sed -e 's/_flash//')"
FILENAME="$(echo "$1" | sed -e 's/_archive//')"
# If filename doesn't exist, interpret it as a application name
if [[ -n "${FILENAME}" ]]; then
NAME="${FILENAME}"
FILENAME="apps/${FILENAME}/app.elf"
fi
echo " - ${FILENAME}"
NAME="$(basename "$(dirname "${FILENAME}")")"
sed "s/\+ (0)/+ (${POS})/" apps/external.ld > temp.ld
"${LD}" "${FILENAME}" -o "${NAME}_linked.elf" -Ttemp.ld
"${OBJCOPY}" -O binary "${NAME}_linked.elf" "${NAME}"
tar -rf "${OUTPUT}" "${NAME}"
POS=$(( POS + (($(stat --printf="%s" "${NAME}") + 1023)/512)*512 ))
rm -f temp.ld "${NAME}" "${NAME}_linked.elf"
# Add the icon if it exists to the archive (Icon is the app.icon file in the app directory)
if [[ -f "apps/${NAME}/app.icon" ]]; then
ICON="apps/${NAME}/app.icon"
echo " - ${ICON}"
# Copy temporary the icon to the current directory
cp "${ICON}" "${NAME}.icon"
# Add the icon to the archive
tar -rf "${OUTPUT}" "${NAME}.icon"
# Increase the position of the icon
POS=$(( POS + (($(stat --printf="%s" "${NAME}.icon") + 1023)/512)*512 ))
# Remove the temporary icon
rm -f "${NAME}.icon"
fi
shift 1
done
7 changes: 3 additions & 4 deletions tool/rebuild.sh → tool/build.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
#!/usr/bin/sh
# Rebuild the given application with the _rebuild suffix
# Build the given application with the _(re)build suffix
# $1: application to rebuild

# Get the application name
application="$1"
# Remove the suffix
application_without_suffix="$(echo "${application}" | sed -e 's/_rebuild//')"
echo "Rebuilding ${application_without_suffix}"
# Clean the application
./tool/clean.sh "${application_without_suffix}"
application_without_suffix="$(echo "${application_without_suffix}" | sed -e 's/_build//')"
echo "Building ${application_without_suffix}"
# Rebuild the application
make -C "apps/${application_without_suffix}"