2016-10-06 22:40:56 +00:00
|
|
|
#!/bin/sh
|
2018-03-13 15:32:48 +00:00
|
|
|
# Alternative to build0 that supports a --until flag to include only a subset
|
|
|
|
# of layers.
|
2018-03-13 15:37:19 +00:00
|
|
|
# $ ./build1 --until 050
|
|
|
|
UNTIL_LAYER=${2:-zzz}
|
2017-07-10 18:08:54 +00:00
|
|
|
|
2018-03-13 15:32:48 +00:00
|
|
|
set -v
|
2016-10-06 22:40:56 +00:00
|
|
|
set -e # stop immediately on error
|
|
|
|
|
2018-03-13 06:24:53 +00:00
|
|
|
# Some environment variables that can be passed in. For example, to turn off
|
|
|
|
# optimization:
|
2018-03-13 15:32:48 +00:00
|
|
|
# $ CFLAGS=-g ./build1
|
2018-03-13 06:24:53 +00:00
|
|
|
test "$CXX" || export CXX=c++
|
|
|
|
test "$CC" || export CC=cc
|
2018-03-23 04:52:35 +00:00
|
|
|
test "$CFLAGS" || export CFLAGS="-g -O2"
|
2018-03-13 06:24:53 +00:00
|
|
|
export CFLAGS="$CFLAGS -Wall -Wextra -ftrapv -fno-strict-aliasing"
|
2019-07-25 20:40:42 +00:00
|
|
|
export CXXFLAGS="-std=c++98 $CFLAGS" # CI has an ancient version; don't expect recent dialects
|
2018-03-13 06:24:53 +00:00
|
|
|
|
|
|
|
# Outline:
|
2018-03-13 15:32:48 +00:00
|
|
|
# [0-9]*.cc -> mu.cc -> mu_bin
|
|
|
|
# (layers) | |
|
|
|
|
# tangle $CXX
|
2016-10-06 22:40:56 +00:00
|
|
|
|
2020-04-17 08:33:51 +00:00
|
|
|
$CXX $CFLAGS ../../tools/enumerate.cc -o ../../tools/enumerate
|
2018-03-13 15:32:48 +00:00
|
|
|
|
2020-04-17 08:33:51 +00:00
|
|
|
cd ../../tools
|
2018-03-13 16:04:07 +00:00
|
|
|
# auto-generate various lists (ending in '_list' by convention) {
|
|
|
|
# list of function declarations, so I can define them in any order
|
2020-04-17 08:33:51 +00:00
|
|
|
grep -h "^[^ #].*) {" tangle.cc |sed 's/ {.*/;/' > tangle.function_list
|
2018-03-13 16:04:07 +00:00
|
|
|
# list of tests to run
|
2020-04-17 08:33:51 +00:00
|
|
|
grep -h "^[[:space:]]*void test_" tangle.cc |sed 's/^\s*void \(.*\)() {$/\1,/' > tangle.test_list
|
|
|
|
grep -h "^\s*void test_" tangle.cc |sed 's/^\s*void \(.*\)() {.*/"\1",/' > tangle.test_name_list
|
2018-03-13 16:04:07 +00:00
|
|
|
# }
|
2020-04-17 08:33:51 +00:00
|
|
|
$CXX $CXXFLAGS tangle.cc -o tangle
|
2018-07-25 19:24:00 +00:00
|
|
|
./tangle test
|
2020-04-17 08:33:51 +00:00
|
|
|
cd ../archive/1.vm
|
2018-03-13 15:32:48 +00:00
|
|
|
|
|
|
|
cd termbox
|
|
|
|
$CC $CFLAGS -c termbox.c
|
|
|
|
$CC $CFLAGS -c utf8.c
|
|
|
|
ar rcs libtermbox.a *.o
|
|
|
|
cd ..
|
2016-10-06 22:40:56 +00:00
|
|
|
|
2020-04-17 08:33:51 +00:00
|
|
|
LAYERS=$(../../tools/enumerate --until $UNTIL_LAYER |grep '\.cc$')
|
|
|
|
../../tools/tangle $LAYERS > mu.cc
|
2018-03-13 16:04:07 +00:00
|
|
|
# auto-generate function declarations, so I can define them in any order
|
|
|
|
# functions start out unindented, have all args on the same line, and end in ') {'
|
|
|
|
#
|
2019-03-15 04:23:40 +00:00
|
|
|
# \/ ignore struct/class methods
|
2018-03-13 15:32:48 +00:00
|
|
|
grep -h "^[^[:space:]#].*) {$" mu.cc |grep -v ":.*(" |sed 's/ {.*/;/' > function_list
|
2018-03-13 16:04:07 +00:00
|
|
|
# auto-generate list of tests to run
|
2018-03-13 15:32:48 +00:00
|
|
|
grep -h "^\s*void test_" mu.cc |sed 's/^\s*void \(.*\)() {.*/\1,/' > test_list
|
2018-06-06 16:02:40 +00:00
|
|
|
grep -h "^\s*void test_" mu.cc |sed 's/^\s*void \(.*\)() {.*/"\1",/' > test_name_list
|
2019-07-25 20:40:42 +00:00
|
|
|
$CXX $CXXFLAGS mu.cc termbox/libtermbox.a -o mu_bin
|
2016-10-06 22:40:56 +00:00
|
|
|
|
|
|
|
## [0-9]*.mu -> core.mu
|
|
|
|
|
2020-04-17 08:33:51 +00:00
|
|
|
MU_LAYERS=$(../../tools/enumerate --until $UNTIL_LAYER |grep '\.mu$') || exit 0 # ok if no .mu files
|
2018-03-13 15:32:48 +00:00
|
|
|
cat $MU_LAYERS > core.mu
|