Skip to content

Instantly share code, notes, and snippets.

@bentxt
Created December 14, 2021 10:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bentxt/0bf4416a76a08919eed311575d6a14b9 to your computer and use it in GitHub Desktop.
Save bentxt/0bf4416a76a08919eed311575d6a14b9 to your computer and use it in GitHub Desktop.
Build.sh from cakelisp
#!/bin/sh
CAKELISP_BOOTSTRAP_BIN=bin/cakelisp_bootstrap
CC=g++
LINK=g++
echoerr () { echo "$@" 2>&1; }
warn (){
local msg="$1"
local code="$2"
case "$code" in
[1-9]|[0-9][0-9]|[0-9][0-9][0-9]) : ;;
*)
if [ -n "$code" ] ; then
echo "Err: invalid code"
exit 1
else
code=1
fi
;;
esac
echoerr "$msg (code:$code)"
}
die (){
local msg="$1"
local code="$2"
echoerr "$msg" "$code"
exit $code
}
# Note: If you make changes to the bootstrap process, you will need to delete
# $CAKELISP_BOOTSTRAP_BIN so that it is updated
if test -f "$CAKELISP_BOOTSTRAP_BIN"; then
echo "$CAKELISP_BOOTSTRAP_BIN exists. Building using Cakelisp"
$CAKELISP_BOOTSTRAP_BIN Bootstrap.cake || die "Err: could not bootstrap" "$?"
echo "Use ./bin/cakelisp to build your files"
else
echo "$CAKELISP_BOOTSTRAP_BIN does not exist. Building bootstrap executable manually"
mkdir -p bin
$CC -c \
src/Tokenizer.cpp \
src/Evaluator.cpp \
src/Utilities.cpp \
src/FileUtilities.cpp \
src/Converters.cpp \
src/Writer.cpp \
src/Generators.cpp \
src/GeneratorHelpers.cpp \
src/RunProcess.cpp \
src/OutputPreambles.cpp \
src/DynamicLoader.cpp \
src/ModuleManager.cpp \
src/Logging.cpp \
src/Build.cpp \
src/Metadata.cpp \
src/Main.cpp \
-DUNIX || die "Err: could not compile" "$?"
# Need -ldl for dynamic loading, --export-dynamic to let compile-time functions resolve to
# Cakelisp symbols
$LINK -o $CAKELISP_BOOTSTRAP_BIN *.o -ldl -Wl,--export-dynamic || die "Err: could not link" "$?"
rm *.o
echo "Built $CAKELISP_BOOTSTRAP_BIN successfully. Now building with Cakelisp"
$CAKELISP_BOOTSTRAP_BIN Bootstrap.cake || die "Err: could no build with cakelisp" "$?"
echo "Cakelisp successfully bootstrapped. Use ./bin/cakelisp to build your files"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment