Skip to content

Commit

Permalink
- msc: litle code and build system enhancements.
Browse files Browse the repository at this point in the history
  • Loading branch information
Stéphane Gimenez committed Sep 21, 2011
1 parent 76e223b commit 45669bb
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 53 deletions.
55 changes: 17 additions & 38 deletions build
Expand Up @@ -13,40 +13,30 @@ export PROJECT_NAME=${PROJECT_NAME-unknown}
export PROJECT_VERSION=${PROJECT_VERSION-unknown}

export OCAMLFIND=${OCAMLFIND-ocamlfind}
export OCAMLC=${OCAMLC-ocamlc}
export OCAMLOPT=${OCAMLOPT-ocamlopt}
export OCAMLBUILD=${OCAMLBUILD-ocamlbuild}

export OCAML_VERSION=$(${OCAMLC} -version)
[ -n "${OCAML_VERSION}" ] || \
{ echo "compilation requires ocaml compilers"; exit 1; }
export OCAMLBUILD=${OCAMLBUID-ocamlbuild}

export OCAML_VERSION=$($OCAMLFIND ocamlc -version)
ocaml_config () {
${OCAMLC} -config | sed -n 's/^'"$1"': //p' | tr -c -d '[:alnum:]'
${OCAMLFIND} ocamlc -config | sed -n 's/^'"$1"': //p' | tr -c -d '[:alnum:]'
}

export OCAML_SYSTEM=$(ocaml_config system)
export OCAML_ARCH=$(ocaml_config architecture)

export PKG_VERSION="${OCAMLFIND} query -format %v"

SYSARCH="${OCAML_SYSTEM}-${OCAML_ARCH}"
BUILDDIR="_build-${SYSARCH}"

OCB="${OCAMLBUILD} -no-links -no-sanitize -no-hygiene -ocamlc ${OCAMLC} -ocamlopt ${OCAMLOPT} -build-dir ${BUILDDIR}"
[ -n "${OCAML_VERSION}" -a -n "${SYSARCH}" ] || \
{ echo "compilation requires ocaml compilers and ocamlfind"; exit 1; }

OFQ="${OCAMLFIND} query -r -format -I,%d"
export PKG_VERSION="${OCAMLFIND} query -format %v"

[ "${THREADS}" = "yes" ] && OCBF="${OCBF} -lflags -thread -cflags -thread"
[ "${DEBUG}" = "yes" ] && OCBF="${OCBF} -tag debug"
[ -n "${THREADS}" ] && OCBF="${OCBF} -tag thread"
[ -n "${TAGS}" ] && OCBF="${OCBF} -tags ${TAGS}"
[ -n "${TAGLINE}" ] && OCBF="${OCBF} -tag-line ${TAGLINE}"
[ -n "${JOBS}" ] && OCBF="${OCBF} -j ${JOBS}"

DIRS=$(${OFQ} ${PACKAGES})
for i in ${DIRS}; do OCBF="${OCBF} -cflags $i -lflags $i"; done
for i in ${DEPLIBS}; do OCBF="${OCBF} -lib $i"; done
for i in ${SRCDIRS}; do OCBF="${OCBF} -I $i"; done

OCBI="${OCB} ${OCBF}"
OCBF="${OCBF} -pkgs $PACKAGES -libs $LIBRARIES -Is $SRCDIRS"
OCBI="${OCAMLBUILD} -no-sanitize -no-hygiene -use-ocamlfind -build-dir ${BUILDDIR} ${OCBF}"

ACT="${1---all}"
shift
Expand All @@ -68,13 +58,11 @@ tclean () {
rm -rf $i
done
for i in ${BINTARGETS}; do
rm -rf "$i"
for j in byte native d.byte p.native ${BINEXT}
do rm -rf "$i-${SYSARCH}.$j"; done
rm -rf "$(basename $i)"
done
for i in ${LIBTARGETS}; do
for j in cma cmxa d.cma p.cmxa
do rm -rf "$i-${SYSARCH}.$j"; done
do rm -rf "$(basename $i).$j"; done
done
}

Expand Down Expand Up @@ -108,10 +96,10 @@ esac
TARGETS=""

for i in ${BINTARGETS}; do
for j in ${BINEXT}; do TARGETS="${TARGETS} ${DIR}/$i.$j"; done
for j in ${BINEXT}; do TARGETS="${TARGETS} $i.$j"; done
done
for i in ${LIBTARGETS}; do
for j in ${LIBEXT}; do TARGETS="${TARGETS} ${DIR}/$i.$j"; done
for j in ${LIBEXT}; do TARGETS="${TARGETS} $i.$j"; done
done

FILES="${BINTARGETS} ${LIBTARGETS}"
Expand All @@ -123,22 +111,13 @@ tclean

${OCBI} ${TARGETS} ${AUXTARGETS} || exit 1

for i in ${BINTARGETS}; do
for j in ${BINEXT}
do cp "${BUILDDIR}/${DIR}/$i.$j" "$i-${SYSARCH}.$j"; done
done
for i in ${LIBTARGETS}; do
for j in ${LIBEXT}
do cp "${BUILDDIR}/${DIR}/$i.$j" "$i-${SYSARCH}.$j"; done
done

# linking

[ -n ${LNK} ] &&
for i in ${BINTARGETS}; do ln -sf "$i-${SYSARCH}.${LNK}" "$i"; done
for i in ${BINTARGETS}; do cp "${BUILDDIR}/${i}.${LNK}" "$(basename $i)"; done

for i in ${LIBTARGETS}; do
for j in ${LIBEXT}; do ln -sf "$i-${SYSARCH}.$j" "$i.$j"; done
for j in ${LIBEXT}; do cp "${BUILDDIR}/$i.$j" "$(basename $i.$j)"; done
done

exit 0
Expand Down
13 changes: 5 additions & 8 deletions build.conf
@@ -1,10 +1,7 @@
PACKAGES="lablgtk2"
DEPLIBS="unix str lablgtk lablgtksourceview2"
SRCDIRS="src src/dtools"
CONF="src/config"
DEBUG="yes"

DIR="src"
BINS="laby"
LIBS=""
LIBRARIES="unix,str,lablgtk,lablgtksourceview2"
TAGS="debug"

SRCDIRS="src,src/dtools"
CONF="src/config"
BINS="src/laby"
2 changes: 1 addition & 1 deletion src/config.sh
Expand Up @@ -15,7 +15,7 @@ fi
BUILD_LABLGTK=$(${PKG_VERSION} lablgtk2)
[ "${THREADS}" = "yes" ] && echo "let threads = T_thread.main"
[ -n "${THREADS}" ] && echo "let threads = T_thread.main"
cat <<EOF
let project_name = "${PROJECT_NAME}"
Expand Down
12 changes: 6 additions & 6 deletions src/game.ml
Expand Up @@ -38,7 +38,7 @@ let play ~msg ~help ~draw =
end
in

object (self)
object

method chg_mod s =
!lmod#stop;
Expand All @@ -64,11 +64,11 @@ object (self)
!lmod#start msg

method next =
begin match Trace.next !trace with
| `None -> false
| `New t -> trace := t; draw_update (); effects (); true
| `Old t -> trace := t; draw_update (); true
end
begin match Trace.next !trace with
| `None -> false
| `New t -> trace := t; draw_update (); effects (); true
| `Old t -> trace := t; draw_update (); true
end

method prev =
begin match Trace.prev !trace with
Expand Down

0 comments on commit 45669bb

Please sign in to comment.