From 5fb979ea053da0c735657d66d060df21a4e57f78 Mon Sep 17 00:00:00 2001 From: Enrico Pozzobon Date: Mon, 20 Jul 2020 17:13:18 +0200 Subject: [PATCH] unified compilation logic in a single file --- compile_all.py | 8 +------- process_zip.sh | 28 ++++------------------------ templates/bluepill/Makefile | 14 -------------- templates/bluepill/compile | 13 +++++++++++++ templates/bluepill/configure | 12 ------------ templates/esp32/compile | 13 +++++++++++++ templates/esp32/configure | 11 ----------- templates/f1-libopencm3/cleanup | 3 --- templates/f1-libopencm3/compile | 3 +++ templates/f1-libopencm3/configure | 3 --- templates/f7/cleanup | 5 ----- templates/f7/compile | 21 +++++++++++++++++++++ templates/f7/configure | 8 -------- templates/longan-nano/Makefile | 15 --------------- templates/longan-nano/cleanup | 4 ---- templates/longan-nano/compile | 13 +++++++++++++ templates/longan-nano/configure | 12 ------------ templates/maixduino/Makefile | 13 ------------- templates/maixduino/compile | 13 +++++++++++++ templates/maixduino/configure | 11 ----------- templates/uno/Makefile | 14 -------------- templates/uno/compile | 13 +++++++++++++ templates/uno/configure | 11 ----------- test-scheduler.py | 1 + 24 files changed, 95 insertions(+), 167 deletions(-) delete mode 100644 templates/bluepill/Makefile create mode 100755 templates/bluepill/compile delete mode 100755 templates/bluepill/configure create mode 100755 templates/esp32/compile delete mode 100755 templates/esp32/configure delete mode 100755 templates/f1-libopencm3/cleanup create mode 100755 templates/f1-libopencm3/compile delete mode 100755 templates/f1-libopencm3/configure delete mode 100755 templates/f7/cleanup create mode 100755 templates/f7/compile delete mode 100755 templates/f7/configure delete mode 100644 templates/longan-nano/Makefile delete mode 100755 templates/longan-nano/cleanup create mode 100755 templates/longan-nano/compile delete mode 100755 templates/longan-nano/configure delete mode 100644 templates/maixduino/Makefile create mode 100755 templates/maixduino/compile delete mode 100755 templates/maixduino/configure delete mode 100644 templates/uno/Makefile create mode 100755 templates/uno/compile delete mode 100755 templates/uno/configure diff --git a/compile_all.py b/compile_all.py index 09094d6..9c3d544 100755 --- a/compile_all.py +++ b/compile_all.py @@ -62,17 +62,11 @@ def build(algo_dir, template_dir, build_dir): wd = os.getcwd() os.chdir(build_dir) try: - if os.path.isfile('./configure'): - subprocess.check_call(["./configure"]) - stdout_path = 'make.stdout.log' stderr_path = 'make.stderr.log' with open(stdout_path, 'w') as outfile, \ open(stderr_path, 'w') as errfile: - subprocess.check_call(['make'], stdout=outfile, stderr=errfile) - - if os.path.isfile('./cleanup'): - subprocess.check_call(["./cleanup"]) + subprocess.check_call(['./compile'], stdout=outfile, stderr=errfile) finally: sys.stdout.flush() diff --git a/process_zip.sh b/process_zip.sh index a831223..8dc37c3 100755 --- a/process_zip.sh +++ b/process_zip.sh @@ -64,27 +64,7 @@ function run() { mv $cipher/*.log "$TEST_PATH" cp test_vectors/$VARIANT/LWC_AEAD_KAT_*.txt "$TEST_PATH/LWC_AEAD_KAT.txt" || exit 1 - - case $TEMPLATE in - f1-libopencm3) mv $cipher/firmware.{bin,elf} "$TEST_PATH" - ;; - - f7) mv $cipher/build/f7.* "$TEST_PATH" - ;; - - maixduino) mv $cipher/.pio/build/sipeed-maixduino/firmware.* "$TEST_PATH" - ;; - - bluepill) mv $cipher/.pio/build/bluepill_f103c8/firmware.* "$TEST_PATH" - ;; - - uno) mv $cipher/.pio/build/uno/firmware.* "$TEST_PATH" - ;; - - esp32) mv $cipher/.pio/build/esp32dev/firmware.* $cipher/.pio/build/esp32dev/partitions.bin "$TEST_PATH" - ;; - esac - + mv $TMPDIR/$CIPHER_SLUG/*{.elf,.bin,.hex,.map} "$TEST_PATH" curl \ --request 'POST' \ @@ -102,7 +82,7 @@ function run() { done - rm -rf "$TMPDIR" + #rm -rf "$TMPDIR" } if [[ $1 == "run" ]]; then @@ -119,13 +99,13 @@ else TMPDIR=$(mktemp -d -t submission-XXXXXXXXXX) echo "Extracting in $TMPDIR" unzip $ZIP_PATH -d $TMPDIR - for i in templates/{uno,bluepill,esp32,f7,maixduino}; do + for i in templates/{uno,bluepill,f7,longan-nano,esp32,maixduino}; do TEMPLATE="${i##*/}" echo "Template is $TEMPLATE" touch $MAINDIR/locky.lock flock $MAINDIR/locky.lock $0 run $TMPDIR $TEMPLATE $MAINDIR/$TEMPLATE done - rm -rf $TMPDIR + #rm -rf $TMPDIR fi diff --git a/templates/bluepill/Makefile b/templates/bluepill/Makefile deleted file mode 100644 index b1ae053..0000000 --- a/templates/bluepill/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -NISTGCCFLAGS=-std=c99 -Wall -Wextra -Wshadow -fsanitize=address,undefined -O2 -LFLAGS=-lm -all: bluepill_f103c8 - -bluepill_f103c8: .pioenvs/bluepill_f103c8/firmware.hex - -.pioenvs/bluepill_f103c8/firmware.hex: FORCE - platformio run -e bluepill_f103c8 - -FORCE: ; -.PHONY: clean - -clean: - -rm .pioenvs/uno/firmware.hex diff --git a/templates/bluepill/compile b/templates/bluepill/compile new file mode 100755 index 0000000..195015c --- /dev/null +++ b/templates/bluepill/compile @@ -0,0 +1,13 @@ +#!/bin/bash + +# Rename all *.s to *.S +for f in *.s; do + mv -- "$f" "${f%.s}.S" +done + +mv -n *.c *.S src/ +mv -n *.dat *.inc *.h include/ +sed -i src/encrypt.c -e "s/\(\s\)init(/\1encrypt_init(/g" + +platformio run -e bluepill_f103c8 || exit +mv .pio/build/bluepill_f103c8/firmware.* . diff --git a/templates/bluepill/configure b/templates/bluepill/configure deleted file mode 100755 index dfa9981..0000000 --- a/templates/bluepill/configure +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -# Rename all *.s to *.S -for f in *.s; do - mv -- "$f" "${f%.s}.S" -done - -mv -n *.c *.S src/ -mv -n *.dat *.inc *.h include/ -sed -i src/encrypt.c -e "s/\(\s\)init(/\1encrypt_init(/g" - -exit 0 diff --git a/templates/esp32/compile b/templates/esp32/compile new file mode 100755 index 0000000..b5fe767 --- /dev/null +++ b/templates/esp32/compile @@ -0,0 +1,13 @@ +#!/bin/bash + +# Rename all *.s to *.S +for f in *.s; do + mv -- "$f" "${f%.s}.S" +done + +mv -n *.c *.S src/ +mv -n *.dat *.inc *.h include/ +sed -i src/encrypt.c -e "s/\(\s\)init(/\1_init(/g" + +platformio run -e esp32dev || exit +mv .pio/build/esp32dev/*{.bin,.elf} . diff --git a/templates/esp32/configure b/templates/esp32/configure deleted file mode 100755 index 2e69c6b..0000000 --- a/templates/esp32/configure +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -# Rename all *.s to *.S -for f in *.s; do - mv -- "$f" "${f%.s}.S" -done - -mv -n *.c *.S src/ -mv -n *.dat *.inc *.h include/ -sed -i src/encrypt.c -e "s/\(\s\)init(/\1_init(/g" -exit 0 diff --git a/templates/f1-libopencm3/cleanup b/templates/f1-libopencm3/cleanup deleted file mode 100755 index 8c3cbfc..0000000 --- a/templates/f1-libopencm3/cleanup +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -exit 0 diff --git a/templates/f1-libopencm3/compile b/templates/f1-libopencm3/compile new file mode 100755 index 0000000..2aad486 --- /dev/null +++ b/templates/f1-libopencm3/compile @@ -0,0 +1,3 @@ +#!/bin/bash + +make diff --git a/templates/f1-libopencm3/configure b/templates/f1-libopencm3/configure deleted file mode 100755 index 8c3cbfc..0000000 --- a/templates/f1-libopencm3/configure +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -exit 0 diff --git a/templates/f7/cleanup b/templates/f7/cleanup deleted file mode 100755 index a83f262..0000000 --- a/templates/f7/cleanup +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -rm -rf ./Drivers/ -rm build/*.o -rm build/*.d -rm build/*.lst diff --git a/templates/f7/compile b/templates/f7/compile new file mode 100755 index 0000000..52b69fa --- /dev/null +++ b/templates/f7/compile @@ -0,0 +1,21 @@ +#!/bin/bash + +mv -n *.dat *.inc *.h Inc/ +[ -f ./build ] && rm ./build +[ -f src/encrypt.c ] && sed -i src/encrypt.c -e "s/\(\s\)init(/\1_init(/g" +mkdir -p /tmp/f7/Drivers +ln -s /tmp/f7/Drivers Drivers + +make +EXIT_CODE=$? + +mv build/f7.bin . +mv build/f7.hex . +mv build/f7.elf . + +rm ./Drivers +rm -rf ./build/ + +exit EXIT_CODE + + diff --git a/templates/f7/configure b/templates/f7/configure deleted file mode 100755 index d19e1a2..0000000 --- a/templates/f7/configure +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -mv -n *.dat *.inc *.h Inc/ -[ -f ./build ] && rm ./build -[ -f src/encrypt.c ] && sed -i src/encrypt.c -e "s/\(\s\)init(/\1_init(/g" -mkdir -p /tmp/f7/Drivers -ln -s /tmp/f7/Drivers Drivers -exit 0 diff --git a/templates/longan-nano/Makefile b/templates/longan-nano/Makefile deleted file mode 100644 index 41fc3b6..0000000 --- a/templates/longan-nano/Makefile +++ /dev/null @@ -1,15 +0,0 @@ -NISTGCCFLAGS=-std=c99 -Wall -Wextra -Wshadow -fsanitize=address,undefined -O2 -LFLAGS=-lm -PIO_ENV = sipeed-longan-nano-lite -all: ${PIO_ENV} - -${PIO_ENV}: .pioenvs/${PIO_ENV}/firmware.elf - -.pioenvs/${PIO_ENV}/firmware.elf: FORCE - platformio run -e ${PIO_ENV} - -FORCE: ; -.PHONY: clean - -clean: - -rm .pioenvs/${PIO_ENV}/firmware.elf diff --git a/templates/longan-nano/cleanup b/templates/longan-nano/cleanup deleted file mode 100755 index 4db6720..0000000 --- a/templates/longan-nano/cleanup +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -mv .pio/build/sipeed-longan-nano-lite/firmware.* . -exit 0 diff --git a/templates/longan-nano/compile b/templates/longan-nano/compile new file mode 100755 index 0000000..3b00919 --- /dev/null +++ b/templates/longan-nano/compile @@ -0,0 +1,13 @@ +#!/bin/bash + +# Rename all *.s to *.S +for f in *.s; do + mv -- "$f" "${f%.s}.S" +done + +mv -n *.c *.S src/ +mv -n *.dat *.inc *.h include/ +sed -i src/encrypt.c -e "s/\(\s\)init(/\1encrypt_init(/g" + +platformio run -e sipeed-longan-nano-lite || exit +mv .pio/build/sipeed-longan-nano-lite/firmware.* . diff --git a/templates/longan-nano/configure b/templates/longan-nano/configure deleted file mode 100755 index dfa9981..0000000 --- a/templates/longan-nano/configure +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -# Rename all *.s to *.S -for f in *.s; do - mv -- "$f" "${f%.s}.S" -done - -mv -n *.c *.S src/ -mv -n *.dat *.inc *.h include/ -sed -i src/encrypt.c -e "s/\(\s\)init(/\1encrypt_init(/g" - -exit 0 diff --git a/templates/maixduino/Makefile b/templates/maixduino/Makefile deleted file mode 100644 index 777637a..0000000 --- a/templates/maixduino/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -LFLAGS=-lm -all: sipeed-maixduino - -sipeed-maixduino: .pioenvs/sipeed-maixduino/firmware.bin - -.pioenvs/sipeed-maixduino/firmware.bin: FORCE - platformio run -e sipeed-maixduino - -FORCE: ; -.PHONY: clean - -clean: - -rm .pioenvs/sipeed-maixduino/firmware.bin diff --git a/templates/maixduino/compile b/templates/maixduino/compile new file mode 100755 index 0000000..7417239 --- /dev/null +++ b/templates/maixduino/compile @@ -0,0 +1,13 @@ +#!/bin/bash + +# Rename all *.s to *.S +for f in *.s; do + mv -- "$f" "${f%.s}.S" +done + +mv -n *.c *.S src/ +mv -n *.dat *.inc *.h include/ +sed -i src/encrypt.c -e "s/\(\s\)init(/\1_init(/g" + +platformio run -e sipeed-maixduino || exit +mv .pio/build/sipeed-maixduino/*.* . diff --git a/templates/maixduino/configure b/templates/maixduino/configure deleted file mode 100755 index 2e69c6b..0000000 --- a/templates/maixduino/configure +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -# Rename all *.s to *.S -for f in *.s; do - mv -- "$f" "${f%.s}.S" -done - -mv -n *.c *.S src/ -mv -n *.dat *.inc *.h include/ -sed -i src/encrypt.c -e "s/\(\s\)init(/\1_init(/g" -exit 0 diff --git a/templates/uno/Makefile b/templates/uno/Makefile deleted file mode 100644 index a971f16..0000000 --- a/templates/uno/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -NISTGCCFLAGS=-std=c99 -Wall -Wextra -Wshadow -fsanitize=address,undefined -O2 -LFLAGS=-lm -all: uno - -uno: .pioenvs/uno/firmware.hex - -.pioenvs/uno/firmware.hex: FORCE - platformio run -e uno - -FORCE: ; -.PHONY: clean - -clean: - -rm .pioenvs/uno/firmware.hex diff --git a/templates/uno/compile b/templates/uno/compile new file mode 100755 index 0000000..7a1d71e --- /dev/null +++ b/templates/uno/compile @@ -0,0 +1,13 @@ +#!/bin/bash + +# Rename all *.s to *.S +for f in *.s; do + mv -- "$f" "${f%.s}.S" +done + +mv -n *.c *.S src/ +mv -n *.dat *.inc *.h include/ +sed -i src/encrypt.c -e "s/\(\s\)init(/\1_init(/g" + +platformio run -e uno || exit +mv .pio/build/uno/firmware.* . diff --git a/templates/uno/configure b/templates/uno/configure deleted file mode 100755 index 2e69c6b..0000000 --- a/templates/uno/configure +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -# Rename all *.s to *.S -for f in *.s; do - mv -- "$f" "${f%.s}.S" -done - -mv -n *.c *.S src/ -mv -n *.dat *.inc *.h include/ -sed -i src/encrypt.c -e "s/\(\s\)init(/\1_init(/g" -exit 0 diff --git a/test-scheduler.py b/test-scheduler.py index e8480fe..8e657a8 100644 --- a/test-scheduler.py +++ b/test-scheduler.py @@ -325,6 +325,7 @@ def get_results_json(job_id): if __name__ == '__main__': runners.append(Runner('maixduino', 'Maixduino')) + runners.append(Runner('longan-nano', 'Longan Nano')) runners.append(Runner('f7', 'NUCLEO-F746ZG')) runners.append(Runner('uno', 'Arduino Uno')) runners.append(Runner('esp32', 'ESP32')) -- libgit2 0.26.0