got ninja system working
This commit is contained in:
59
configure
vendored
59
configure
vendored
@@ -6,6 +6,8 @@ OCAMLDEP=ocamldep
|
||||
OCAMLC_ARGS=
|
||||
OCAMLDEP_ARGS=-bytecode
|
||||
OBJEXT=cmo
|
||||
OCAMLLD=ocamlc
|
||||
OCAMLLD_ARGS=
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
@@ -26,6 +28,8 @@ while [[ $# -gt 0 ]]; do
|
||||
echo " OCAMLDEP = $OCAMLDEP"
|
||||
echo " OCAMLC_ARGS = $OCAMLC_ARGS"
|
||||
echo " OCAMLDEP_ARGS = $OCAMLDEP_ARGS"
|
||||
echo " OCAMLLD = $OCAMLLD"
|
||||
echo " OCAMLLD_ARGS = $OCAMLLD_ARGS"
|
||||
exit 0
|
||||
;;
|
||||
|
||||
@@ -38,7 +42,7 @@ done
|
||||
|
||||
mkdir -p build
|
||||
|
||||
echo '# generated from ../configure
|
||||
echo '# generated by ../configure
|
||||
OCAMLDEP=$1
|
||||
shift
|
||||
echo ninja_dyndep_version = 1
|
||||
@@ -53,6 +57,45 @@ $OCAMLDEP -one-line $@ | while read d; do
|
||||
done
|
||||
' > build/deps.sh
|
||||
|
||||
echo "# generated by ../configure" > build/invokeld.sh
|
||||
echo "OCAMLDEP=\"$OCAMLDEP\"" >> build/invokeld.sh
|
||||
echo "OCAMLDEP_ARGS=\"$OCAMLDEP_ARGS\"" >> build/invokeld.sh
|
||||
echo "OCAMLLD=\"$OCAMLLD\"" >> build/invokeld.sh
|
||||
echo "OCAMLLD_ARGS=\"$OCAMLLD_ARGS\"" >> build/invokeld.sh
|
||||
echo "OBJEXT=\"$OBJEXT\"" >> build/invokeld.sh
|
||||
echo '
|
||||
set -e
|
||||
got=""
|
||||
get() {
|
||||
set -e
|
||||
got+=" $1"
|
||||
deps="$($OCAMLDEP $OCAMLDEP_ARGS -one-line -bytecode $1.ml | cut -d":" -f2)"
|
||||
fixdeps=""
|
||||
for dep in $deps; do
|
||||
dep="$(basename $dep .cmi)"
|
||||
if ! [ $dep = $1 ]; then
|
||||
fixdeps+=" $dep"
|
||||
fi
|
||||
done
|
||||
for dep in $fixdeps; do
|
||||
echo "$dep $1"
|
||||
done
|
||||
for dep in $fixdeps; do
|
||||
if ! [[ " $got " =~ " $dep " ]]; then
|
||||
get "$dep"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
files=""
|
||||
for dep in $(get "$(basename $1 .ml)" | tsort); do
|
||||
files+=" build/$dep.$OBJEXT"
|
||||
done
|
||||
shift
|
||||
$OCAMLLD $files $OCAMLLD_ARGS $@
|
||||
' >> build/invokeld.sh
|
||||
|
||||
|
||||
if ! [ -f project ]; then
|
||||
touch project
|
||||
echo "# ocaml project description" >> project
|
||||
@@ -60,7 +103,7 @@ if ! [ -f project ]; then
|
||||
echo "#" >> project
|
||||
echo "# functions:" >> project
|
||||
echo "# application [name]" >> project
|
||||
echo "# create module from \$name.ml" >> project
|
||||
echo "# create module from \$name.ml, which will be linked with it's dependencies to an executable" >> project
|
||||
echo "#" >> project
|
||||
echo "# module [name]" >> project
|
||||
echo "# create module from \$name.ml and \$name.mli" >> project
|
||||
@@ -92,11 +135,14 @@ 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 build.ninja | build/deps.sh build/invokeld.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 ocamlld" >> build.ninja
|
||||
echo " command = bash build/invokeld.sh \$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
|
||||
|
||||
@@ -110,8 +156,11 @@ module() {
|
||||
}
|
||||
|
||||
application() {
|
||||
echo > /dev/null
|
||||
# TODO
|
||||
echo "" >> build.ninja
|
||||
echo "build build/$1.dd : ocamldep $1.ml || build/deps.sh" >> build.ninja
|
||||
echo "build build/$1.$OBJEXT | build/$1.cmi : ocamlc $1.ml || build/$1.dd" >> build.ninja
|
||||
echo " dyndep = build/$1.dd" >> build.ninja
|
||||
echo "build build/$1 : ocamlld $1.ml | build/$1.$OBJEXT || build/invokeld.sh" >> build.ninja
|
||||
}
|
||||
|
||||
include() {
|
||||
|
Reference in New Issue
Block a user