finish splitting modules, and start using ninja
This commit is contained in:
129
configure
vendored
Normal file
129
configure
vendored
Normal file
@@ -0,0 +1,129 @@
|
||||
#!/bin/bash
|
||||
args="$@" # backup for ninja regen
|
||||
|
||||
OCAMLC=ocamlc
|
||||
OCAMLDEP=ocamldep
|
||||
OCAMLC_ARGS=
|
||||
OCAMLDEP_ARGS=-bytecode
|
||||
OBJEXT=cmo
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
*=*)
|
||||
eval "$1"
|
||||
shift 1
|
||||
;;
|
||||
|
||||
--help|-help|-h|--h)
|
||||
echo "Usage: ./configure [options] key=value ..."
|
||||
echo ""
|
||||
echo "Options:"
|
||||
echo " --help"
|
||||
echo ""
|
||||
echo "Varaibles:"
|
||||
echo " OBJEXT = $OBJEXT"
|
||||
echo " OCAMLC = $OCAMLC"
|
||||
echo " OCAMLDEP = $OCAMLDEP"
|
||||
echo " OCAMLC_ARGS = $OCAMLC_ARGS"
|
||||
echo " OCAMLDEP_ARGS = $OCAMLDEP_ARGS"
|
||||
exit 0
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Unexpected argument: $1"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
mkdir -p build
|
||||
|
||||
echo '# generated from ../configure
|
||||
OCAMLDEP=$1
|
||||
shift
|
||||
echo ninja_dyndep_version = 1
|
||||
$OCAMLDEP -one-line $@ | while read d; do
|
||||
outs="$(echo "$d" | cut -d":" -f1)"
|
||||
ins="$(echo "$d" | cut -d":" -f2)"
|
||||
echo -ne "build build/$outs : dyndep |"
|
||||
for f in $ins; do
|
||||
echo -ne " build/$f"
|
||||
done
|
||||
echo
|
||||
done
|
||||
' > build/deps.sh
|
||||
|
||||
if ! [ -f project ]; then
|
||||
touch project
|
||||
echo "# ocaml project description" >> project
|
||||
echo "# (this is a bash script)" >> project
|
||||
echo "#" >> project
|
||||
echo "# functions:" >> project
|
||||
echo "# application [name]" >> project
|
||||
echo "# create module from \$name.ml" >> project
|
||||
echo "#" >> project
|
||||
echo "# module [name]" >> project
|
||||
echo "# create module from \$name.ml and \$name.mli" >> project
|
||||
echo "#" >> project
|
||||
echo "# include [path]" >> project
|
||||
echo "# include other config path." >> project
|
||||
echo "# prefer this over regular 'source', because this also adds" >> project
|
||||
echo "# a dependency to the ninja build file" >> project
|
||||
echo ""
|
||||
echo "# put in project configuration here" >> project
|
||||
fi
|
||||
|
||||
project_files=""
|
||||
module() {
|
||||
true
|
||||
}
|
||||
application() {
|
||||
true
|
||||
}
|
||||
include() {
|
||||
project_files+=" $1"
|
||||
source "$1"
|
||||
}
|
||||
include "project"
|
||||
|
||||
rm -f build.ninja
|
||||
touch build.ninja
|
||||
|
||||
echo "rule regen" >> build.ninja
|
||||
echo " command = ./configure $args" >> build.ninja
|
||||
echo " generator = 1" >> build.ninja
|
||||
echo "build build.ninja | build/deps.sh: regen | configure $project_files" >> build.ninja
|
||||
echo "" >> build.ninja
|
||||
echo "rule ocamlc" >> build.ninja
|
||||
echo " command = $OCAMLC $OCAMLC_ARGS -nocwd -I build -c \$in -o \$out" >> build.ninja
|
||||
echo "" >> build.ninja
|
||||
echo "rule ocamldep" >> build.ninja
|
||||
echo " command = sh build/deps.sh $OCAMLDEP $OCAMLDEP_ARGS \$in > \$out" >> build.ninja
|
||||
|
||||
module() {
|
||||
echo "" >> build.ninja
|
||||
echo "build build/$1.dd : ocamldep $1.ml $1.mli || build/deps.sh" >> build.ninja
|
||||
echo "build build/$1.cmi : ocamlc $1.mli || build/$1.dd" >> build.ninja
|
||||
echo " dyndep = build/$1.dd" >> build.ninja
|
||||
echo "build build/$1.$OBJEXT : ocamlc $1.ml | build/$1.cmi || build/$1.dd " >> build.ninja
|
||||
echo " dyndep = build/$1.dd" >> build.ninja
|
||||
}
|
||||
|
||||
application() {
|
||||
echo > /dev/null
|
||||
# TODO
|
||||
}
|
||||
|
||||
include() {
|
||||
project_files+=" $1"
|
||||
source "$1"
|
||||
}
|
||||
|
||||
for f in $project_files; do
|
||||
source "$f"
|
||||
done
|
||||
|
||||
|
||||
echo Configuration Done!
|
||||
echo Run \"ninja\" to start build
|
||||
|
Reference in New Issue
Block a user