ysulsky avatar ysulsky committed e1f704c

support for building packages

Comments (0)

Files changed (25)

 glob:base/bin-prot/lib/META
 glob:base/bin-prot/lib/bin_prot.mlpack
 glob:base/bin-prot/lib/libbin_prot.clib
+glob:base/bin-prot/lib/libbin_prot_stubs.clib
 glob:base/bin-prot/lib_test/example.pp.ml
 glob:base/bin-prot/lib_test/mac_test
 glob:base/bin-prot/lib_test/test_runner
 glob:base/core/extended/_tags
 glob:base/core/extended/configure
 glob:base/core/extended/lib/META
+glob:base/core/extended/lib/config.h
 glob:base/core/extended/lib/config.mlh
 glob:base/core/extended/lib/core-extended.mllib
 glob:base/core/extended/lib/core-extended.odocl
 glob:base/core/extended/lib/core_extended.mlpack
 glob:base/core/extended/lib/libcore_extended.clib
+glob:base/core/extended/lib/libcore_extended_stubs.clib
 glob:base/core/extended/lib/sexp_pos_parser.ml
 glob:base/core/extended/lib/sexp_pos_parser.mli
 glob:base/core/extended/lib/version_defaults.mlh
 glob:base/core/lib/core.mlpack
 glob:base/core/lib/core.odocl
 glob:base/core/lib/libcore.clib
+glob:base/core/lib/libcore_stubs.clib
 glob:base/core/myocamlbuild.ml
 glob:base/core/setup.data
 glob:base/core/setup.log
 glob:base/type_conv/_tags
 glob:base/type_conv/configure
 glob:base/type_conv/lib/META
-glob:base/type_conv/lib/core.mlpack
-glob:base/type_conv/lib/libpa_type_conv.clib
+glob:base/type_conv/lib/pa_type_conv.mllib
 glob:base/type_conv/lib/type_conv.odocl
 glob:base/type_conv/myocamlbuild.ml
 glob:base/type_conv/setup.data

base/async/core/oasis.sh

 
 source ../../../build-common.sh
 
-function list_mods {
-    find "$HERE/lib" -name "*.ml" -print | mod_names
-}
-
-MODULES="$(list_mods | sort -u | my_join)"
-
 cat >$HERE/_oasis <<EOF
 #AUTOGENERATED FILE; EDIT oasis.sh INSTEAD
 
 OASISFormat:  0.3
 OCamlVersion: >= 3.12
 Name:         async_core
-Version:      107.01
+Version:      $core_version
 Synopsis:     Jane Street Capital's asynchronous execution library (core)
 Authors:      Jane street capital
-Copyrights:   (C) 2008-2011 Jane Street Capital LLC
+Copyrights:   (C) 2008-2012 Jane Street Capital LLC
 License:      LGPL-2.1 with OCaml linking exception
 LicenseFile:  LICENSE
 Plugins:      StdFiles (0.3), DevFiles (0.3), META (0.3)
 XStdFilesINSTALLFilename: INSTALL
 XStdFilesREADME: false
 
-
 Library async_core
   Path:               lib
   FindlibName:        async_core
   Pack:               true
-  Modules:            ${MODULES}
+  Modules:            $(list_mods "$HERE/lib")
   BuildDepends:       sexplib.syntax,
                       sexplib,
                       pa_ounit,
 cd $HERE
 rm -f setup.ml
 oasis setup
-
-./configure "$@"
-

base/async/extra/oasis.sh

 
 source ../../../build-common.sh
 
-function list_mods {
-    find "$HERE/lib" -name "*.ml" -print | mod_names
-}
-
-MODULES=$(list_mods | sort -u | my_join)
-
 cat >$HERE/_oasis <<EOF
 #AUTOGENERATED FILE; EDIT oasis.sh INSTEAD
 
 OASISFormat:  0.3
 OCamlVersion: >= 3.12
-Name:         async
-Version:      107.01
+Name:         async_extra
+Version:      $core_version
 Synopsis:     Jane Street Capital's asynchronous execution library (extra)
 Authors:      Jane street capital
 Copyrights:   (C) 2008-2011 Jane Street Capital LLC
 XStdFilesINSTALLFilename: INSTALL
 XStdFilesREADME: false
 
-
 Library async_extra
   Path:               lib
   FindlibName:        async_extra
   Pack:               true
-  Modules:            ${MODULES}
+  Modules:            $(list_mods "$HERE/lib")
   BuildDepends:       sexplib.syntax,
                       sexplib,
                       fieldslib.syntax,
 cd $HERE
 rm -f setup.ml
 oasis setup
-
-./configure "$@"
-

base/async/oasis.sh

 
 source ../../build-common.sh
 
-function list_mods {
-    find "$HERE/lib" -name "*.ml" -print | mod_names
-}
-
-MODULES="$(list_mods | sort -u | my_join)"
-
 cat >$HERE/_oasis <<EOF
 #AUTOGENERATED FILE; EDIT oasis.sh INSTEAD
 
 OASISFormat:  0.3
 OCamlVersion: >= 3.12
 Name:         async
-Version:      107.01
+Version:      $core_version
 Synopsis:     Jane Street Capital's asynchronous execution library
 Authors:      Jane street capital
-Copyrights:   (C) 2008-2011 Jane Street Capital LLC
+Copyrights:   (C) 2008-2012 Jane Street Capital LLC
 License:      LGPL-2.1 with OCaml linking exception
 LicenseFile:  LICENSE
 Plugins:      StdFiles (0.3), DevFiles (0.3), META (0.3)
   Path:               lib
   FindlibName:        async
   Pack:               true
-  Modules:            ${MODULES}
+  Modules:            $(list_mods "$HERE/lib")
   BuildDepends:       async_core,
                       async_unix,
                       async_extra,
 cd $HERE
 rm -f setup.ml
 oasis setup
-
-./configure "$@"
-

base/async/unix/oasis.sh

 
 source ../../../build-common.sh
 
-function list_mods {
-    find "$HERE/lib" -name "*.ml" -print | mod_names
-}
-
-MODULES=$(list_mods | sort -u | my_join)
-
 cat >$HERE/_oasis <<EOF
 #AUTOGENERATED FILE; EDIT oasis.sh INSTEAD
 
 OASISFormat:  0.3
 OCamlVersion: >= 3.12
 Name:         async_unix
-Version:      107.01
+Version:      $core_version
 Synopsis:     Jane Street Capital's asynchronous execution library (unix)
 Authors:      Jane street capital
-Copyrights:   (C) 2008-2011 Jane Street Capital LLC
+Copyrights:   (C) 2008-2012 Jane Street Capital LLC
 License:      LGPL-2.1 with OCaml linking exception
 LicenseFile:  LICENSE
 Plugins:      StdFiles (0.3), DevFiles (0.3), META (0.3)
   Path:               lib
   FindlibName:        async_unix
   Pack:               true
-  Modules:            ${MODULES}
+  Modules:            $(list_mods "$HERE/lib")
   BuildDepends:       sexplib.syntax,
                       sexplib,
                       fieldslib.syntax,
 cd $HERE
 rm -f setup.ml
 oasis setup
-
-./configure "$@"
-

base/bin-prot/.hgignore.in

 configure
 lib/bin_prot.mlpack
 lib/libbin_prot.clib
+lib/libbin_prot_stubs.clib
 lib/META
 setup.ml
 setup.log

base/bin-prot/oasis.sh

 cd $HERE
 rm -f setup.ml
 oasis setup
-
-./configure "$@"

base/compare/oasis.sh

 
 cd $HERE
 oasis setup
-./configure "$@"
-

base/core/.hgignore.in

 _tags
 lib/META
 lib/libcore.clib
+lib/libcore_stubs.clib

base/core/extended/.hgignore.in

 lib/core-extended.odocl
 lib/core-extended.mllib
 lib/libcore_extended.clib
+lib/libcore_extended_stubs.clib
 lib/core_extended.mlpack
+lib/config.h
 lib/config.mlh
 lib/version_defaults.mlh

base/core/extended/lib/discover.sh

+#!/usr/bin/env bash
+set -e -u -o pipefail
+
+ML_OUTFILE="${1:?Usage: discover.sh ML_OUTFILE C_OUTFILE}"
+C_OUTFILE="${2:?Usage: discover.sh ML_OUTFILE C_OUTFILE}"
+shift 2
+
+if [[ -e setup.data ]]; then
+    . setup.data
+    if ${linux-false}; then set -- -DLINUX_EXT "$@"; fi
+    if ${posix_timers-false}; then set -- -DPOSIX_TIMERS "$@"; fi
+fi
+
+function cpp_test () {
+    local name="$1"
+    local cond="$2"
+    if [[ "$#" == 3 ]]; then
+        local warning="$3"
+    else
+        local warning="Feature $1 will not be availlable"
+    fi
+    cat <<EOF
+#if ${cond}
+printf ("DEFINE $name\n");
+EOF
+if [[ "$warning" != "" ]]; then
+cat <<EOF
+#else
+#  warning "cpp test --${cond}-- was false"
+#  warning "$warning"
+EOF
+fi
+echo "#endif"
+}
+
+WORD_SIZE="$(ocaml <( echo "print_int Sys.word_size;;"))"
+SRC="$(mktemp "./discover_src.XXXXXXX.c")"
+PGM="$(mktemp "./discover.XXXXXXX")"
+OUT="$(mktemp "./discover.out.XXXXXXX")"
+
+trap "rm -f $SRC $PGM $OUT" EXIT
+cat > "$SRC" <<EOF
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/socket.h>
+# $LINENO "$(basename "${BASH_SOURCE[0]}")"
+int main () {
+  $(cpp_test LINUX_EXT    "defined(LINUX_EXT)")
+  $(cpp_test POSIX_TIMERS "defined(POSIX_TIMERS)")
+  $(if [[ ${WORD_SIZE} = 64 ]]; then
+       echo 'printf ("DEFINE ARCH_SIXTYFOUR\n");';
+    fi)
+  $(if [[ $(uname -p) = "x86_64" ]]; then
+       echo 'printf ("DEFINE ARCH_x86_64\n");';
+    fi)
+  $(if [[ $(uname -p) = "i386" ]]; then
+       echo 'printf ("DEFINE ARCH_i386\n");';
+    fi)
+  $(cpp_test MSG_NOSIGNAL "defined MSG_NOSIGNAL" \
+     "Bigstring.(unsafe_|really_)?send(to)?(_noblocking)?_no_sigpipe\
+ will not be availlable")
+  $(cpp_test MUTEX_TIMED_LOCK \
+     "defined(_POSIX_TIMEOUTS) && (_POSIX_TIMEOUTS > 0)")
+
+  $(cpp_test FDATASYNC \
+     "defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0")
+
+  return 0;
+}
+EOF
+# Maybe we should leverage the ocaml compiler in here instead of hardcoding
+# gcc
+gcc "$SRC" -o "$PGM" "$@"
+rm "$SRC"
+"$PGM" > "$OUT"
+rm "$PGM"
+mv "$OUT" "$ML_OUTFILE"
+cat "$ML_OUTFILE" \
+    | sed -e 's|^DEFINE *|#define JSC_|' \
+    | sed -e 's|\(#define JSC_[^ ]*\) *=|\1 |' > "$C_OUTFILE"

base/core/extended/oasis.sh

 set -e -u -o pipefail
 
 source ../../../build-common.sh
-check_linux_enabled "$@"
-check_posix_timers_enabled "$@"
-
-function list_mods {
-    for mod in $(find "$HERE/lib" -name "*.ml" -print | mod_names); do
-        case "$mod" in
-            Malloc|Extended_linux)
-                if [[ "$enable_linux" == "true" ]]; then echo "$mod"; fi;;
-            Bench|Posix_clock)
-                if [[ "$enable_timers" == "true" ]]; then echo "$mod"; fi;;
-            *) echo "$mod";;
-        esac
-    done
-}
-
-function list_stubs {
-    for stub in $(find "$HERE/lib" -name "*.[ch]" -exec basename \{\} \;); do
-        case "${stub%%.[ch]}" in
-            malloc_stubs|extended_linux_stubs)
-                if [[ "$enable_linux" == "true" ]]; then echo "$stub"; fi;;
-            posix_clock_stubs)
-                if [[ "$enable_timers" == "true" ]]; then echo "$stub"; fi;;
-            *) echo "$stub";;
-        esac
-    done
-}
-
-MODULES="$(list_mods | sort -u | my_join)"
-CSOURCES="fork_exec.h,$(list_stubs | sort -u | my_join)"
 
 cat >$HERE/_oasis <<EOF
 #AUTOGENERATED FILE; EDIT oasis.sh INSTEAD
 OASISFormat:  0.3
 OCamlVersion: >= 3.12
 Name:         core_extended
-Version:      107.01
+Version:      $core_version
 Synopsis:     Jane Street Capital's standard library overlay
 Authors:      Jane street capital
-Copyrights:   (C) 2008-2011 Jane Street Capital LLC
+Copyrights:   (C) 2008-2012 Jane Street Capital LLC
 License:      LGPL-2.1 with OCaml linking exception
 LicenseFile:  LICENSE
 Plugins:      StdFiles (0.3), DevFiles (0.3), META (0.3)
 BuildTools:   ocamlbuild
 Description:  Jane Street Capital's standard library overlay
-FindlibVersion : >= 1.2.7
+FindlibVersion: >= 1.2.7
 XStdFilesAUTHORS: false
 XStdFilesINSTALLFilename: INSTALL
 XStdFilesREADME: false
 
 Flag linux
   Description: Enable linux specific extensions
-  Default\$:   $enable_linux
+  Default\$:   false   # actually, the default is detected
 
 Flag "posix-timers"
   Description: Enable POSIX timers
-  Default\$:   $enable_timers
+  Default\$:   false   # actually, the default is detected
 
-PreBuildCommand: mkdir -p _build/lib; cp lib/*.mlh _build/; cp ../lib/*.h _build/lib/
-PreDistCleanCommand: \$rm lib/version_defaults.mlh lib/config.mlh
+PostConfCommand: lib/discover.sh lib/config.mlh lib/config.h
+
+PreDistCleanCommand: \$rm lib/version_defaults.mlh lib/config.mlh lib/config.h
 
 Library core_extended
   Path:               lib
   FindlibName:        core_extended
   Pack:               true
-  Modules:            ${MODULES}
-  CSources:           ${CSOURCES}
+  Modules:            $(list_mods  "$HERE/lib")
+  CSources:           $(list_stubs "$HERE/lib"),config.h
   CCOpt+:             -Ilib
-
   BuildDepends:       sexplib.syntax,
                       sexplib,
                       fieldslib.syntax,
                       unix,
                       threads
 
-$(declare_tests_flag)
-
 Executable core_extended_hello
   Path:               lib_test
   MainIs:             core_extended_hello.ml
 
 EOF
 
-make_tags "$HERE/_tags" <<EOF
-<lib/*.ml{,i}>: syntax_camlp4o
-"lib/std.ml": pkg_camlp4.macro
-"lib/command.ml": pkg_camlp4.macro
-"lib/console.ml": pkg_camlp4.macro
-"lib/core_command.ml": pkg_camlp4.macro
-EOF
-
 if [[ ! -e $HERE/lib/version_defaults.mlh ]]; then
     cat >$HERE/lib/version_defaults.mlh <<EOF
 DEFINE DEFAULT_VERSION = "No version info."
 EOF
 fi
 
-cat >$HERE/lib/config.mlh <<EOF
-$(if [[ "$enable_linux"  == "true" ]]; then echo "DEFINE LINUX_EXT"; fi)
-$(if [[ "$enable_timers" == "true" ]]; then echo "DEFINE POSIX_TIMERS"; fi)
+make_tags "$HERE/_tags" <<EOF
+<lib/*.ml{,i}>          : syntax_camlp4o
+"lib/command.ml"        : mlh, pkg_camlp4.macro
+"lib/console.ml"        : mlh, pkg_camlp4.macro
+"lib/core_command.ml"   : mlh, pkg_camlp4.macro
+"lib/extended_linux.ml" : mlh, pkg_camlp4.macro
+"lib/malloc.ml"         : mlh, pkg_camlp4.macro
+"lib/posix_clock.ml"    : mlh, pkg_camlp4.macro
+EOF
+
+make_myocamlbuild "$HERE/myocamlbuild.ml" <<EOF
+let endswith x s =
+  let len_x = String.length x and len_s = String.length s in
+  (len_x <= len_s) && x = String.sub s (len_s - len_x) len_x
+
+let select_files dir ext =
+  List.map (Pathname.concat dir)
+    (List.filter (endswith ext)
+      (Array.to_list (Sys.readdir dir)))
+
+let mlh_files = select_files "lib/" ".mlh"
+
+let dispatch = function
+  | After_rules as e ->
+    dep  ["ocaml"; "ocamldep"; "mlh"] mlh_files;
+    List.iter (fun tag ->
+      flag ["mlh"; "ocaml"; tag] (S[A"-ppopt"; A"-Ilib/"]))
+      ["ocamldep"; "compile"];
+    dispatch_default e
+  | e -> dispatch_default e
+
+let () = Ocamlbuild_plugin.dispatch dispatch
+EOF
+
+make_setup_ml "$HERE/setup.ml" <<EOF
+let test cmd =
+  match Sys.command (cmd ^ " 2>/dev/null") with
+  | 0 -> true
+  | 1 -> false
+  | _ -> failwith ("command '"^cmd^"' failed.")
+
+let getconf var =
+  let f_exit_code = ignore in
+  let ctxt = !BaseContext.default in
+  OASISExec.run_read_output ~f_exit_code ~ctxt "getconf" [var]
+
+let linux_possible = test "uname | grep -q -i linux"
+let timers_possible =
+  match getconf "_POSIX_TIMERS" with
+  | [x] -> (try int_of_string x >= 200112 with _ -> false)
+  |  _  -> false
+
+let map_section = function
+  | Flag (cs, flag) when cs.cs_name = "linux" ->
+    Flag (cs, { flag with
+                flag_default = [OASISExpr.EBool true,      linux_possible;
+                                OASISExpr.EBool false, not linux_possible] })
+  | Flag (cs, flag) when cs.cs_name = "posix-timers" ->
+    Flag (cs, { flag with
+                flag_default = [OASISExpr.EBool true,      timers_possible;
+                                OASISExpr.EBool false, not timers_possible] })
+  | section -> section
+
+let setup_t = { setup_t with
+  BaseSetup.package = { setup_t.BaseSetup.package with
+    sections = List.map map_section setup_t.BaseSetup.package.sections;
+  }
+}
 EOF
 
 cd $HERE
-rm -f setup.ml
 oasis setup
-
-./configure "$enable_timers_default" "$enable_linux_default" "$@"

base/core/lib/discover.sh

 C_OUTFILE="${2:?Usage: discover.sh ML_OUTFILE C_OUTFILE}"
 shift 2
 
+if [[ -e setup.data ]]; then
+    . setup.data
+    if ${linux-false}; then set -- -DLINUX_EXT "$@"; fi
+    if ${posix_timers-false}; then set -- -DPOSIX_TIMERS "$@"; fi
+fi
+
 function cpp_test () {
     local name="$1"
     local cond="$2"
   $(if [[ ${WORD_SIZE} = 64 ]]; then
        echo 'printf ("DEFINE ARCH_SIXTYFOUR\n");';
     fi)
-  $(if [[ $(uname -p) = "x86_64" ]]; then 
+  $(if [[ $(uname -p) = "x86_64" ]]; then
        echo 'printf ("DEFINE ARCH_x86_64\n");';
     fi)
-  $(if [[ $(uname -p) = "i386" ]]; then 
+  $(if [[ $(uname -p) = "i386" ]]; then
        echo 'printf ("DEFINE ARCH_i386\n");';
     fi)
   $(cpp_test MSG_NOSIGNAL "defined MSG_NOSIGNAL" \

base/core/oasis.sh

 set -e -u -o pipefail
 
 source ../../build-common.sh
-check_linux_enabled "$@"
-check_posix_timers_enabled "$@"
 
-use_librt=
-if ld -lrt -shared -o /dev/null 2>/dev/null; then
-    use_librt=-lrt
-fi
-
-function list_mods {
-    for mod in $(find "$HERE/lib" -name "*.ml" -print | mod_names); do
-        case "$mod" in
-            *) echo "$mod";;
-        esac
-    done
-}
-
-function list_stubs {
-    for stub in $(find "$HERE/lib" -name "*.[ch]" -exec basename \{\} \;); do
-        case "${stub%%.[ch]}" in
-            linux_ext_stubs|bigstring_marshal_stubs)
-                if [[ "$enable_linux" == "true" ]]; then echo "$stub"; fi;;
-	    backtrace_stubs)
-		if [[ "$(uname -p)" == "x86_64" ]]; then echo "$stub"; fi;;
-            *) echo "$stub";;
-        esac
-    done
-}
-
-MODULES="$(list_mods | sort -u | my_join)"
-CSOURCES="config.h,$(list_stubs | sort -u | my_join)"
-CCLIB="$use_librt"
-
-cat >$HERE/_oasis<<EOF
+cat >$HERE/_oasis <<EOF
 #AUTOGENERATED FILE; EDIT oasis.sh INSTEAD
 
 OASISFormat:  0.3
 OCamlVersion: >= 3.12
 Name:         core
-Version:      107.01
+Version:      $core_version
 Synopsis:     Jane Street Capital's standard library overlay
 Authors:      Jane street capital
-Copyrights:   (C) 2008-2010 Jane Street Capital LLC
+Copyrights:   (C) 2008-2012 Jane Street Capital LLC
 License:      LGPL-2.1 with OCaml linking exception
 LicenseFile:  LICENSE
 Plugins:      StdFiles (0.3), DevFiles (0.3), META (0.3)
 XStdFilesINSTALLFilename: INSTALL
 XStdFilesREADME: false
 
-
 Flag linux
   Description: Enable linux specific extensions
-  Default\$:   $enable_linux
+  Default\$:   false   # actually, the default is detected
 
 Flag "posix-timers"
   Description: Enable POSIX timers
-  Default\$:   $enable_timers
+  Default\$:   false   # actually, the default is detected
 
-PostConfCommand: lib/discover.sh lib/config.mlh lib/config.h $(
-  if [[ "$enable_linux"  == "true" ]]; then echo -n " -DLINUX_EXT"; fi
-  if [[ "$enable_timers" == "true" ]]; then echo -n " -DPOSIX_TIMERS"; fi
-  echo
-)
+PostConfCommand: lib/discover.sh lib/config.mlh lib/config.h
 
-PreBuildCommand:     mkdir -p _build/; cp lib/*.mlh _build/
-PreDistCleanCommand: \$rm "lib/config.mlh" "lib/config.h"
+PreDistCleanCommand: \$rm lib/config.mlh lib/config.h
 
 Library core
   Path:               lib
   FindlibName:        core
   Pack:               true
-  Modules:${MODULES}
-  CCOpt:              $(getconf LFS64_CFLAGS 2>/dev/null)
-  CSources:           ${CSOURCES}
-  CCLib:              ${CCLIB}
+  Modules:            $(list_mods  "$HERE/lib")
+  CSources:           $(list_stubs "$HERE/lib"),config.h
   BuildDepends:       variantslib,
                       variantslib.syntax,
                       sexplib.syntax,
 Executable test_runner
   Path:               lib_test
   MainIs:             test_runner.ml
-  Build$:             flag(tests)
+  Build\$:            flag(tests)
   Custom:             true
 #  CompiledObject:     best
   Install:            false
 EOF
 
 make_tags "$HERE/_tags" <<EOF
-<lib{,_test}/*.ml{,i}>: syntax_camlp4o
-<lib/{core_int63,bigstring,core_mutex,core_unix,bigstring_marshal,linux_ext,backtrace}.ml{,i}>:pkg_camlp4.macro
+<lib{,_test}/*.ml{,i}>     : syntax_camlp4o
+"lib/backtrace.ml"         : mlh, pkg_camlp4.macro
+"lib/bigstring.ml"         : mlh, pkg_camlp4.macro
+"lib/bigstring_marshal.ml" : mlh, pkg_camlp4.macro
+"lib/core_int63.ml"        : mlh, pkg_camlp4.macro
+"lib/core_mutex.ml"        : mlh, pkg_camlp4.macro
+"lib/core_unix.ml"         : mlh, pkg_camlp4.macro
+"lib/linux_ext.ml"         : mlh, pkg_camlp4.macro
+EOF
+
+make_myocamlbuild "$HERE/myocamlbuild.ml" <<EOF
+let endswith x s =
+  let len_x = String.length x and len_s = String.length s in
+  (len_x <= len_s) && x = String.sub s (len_s - len_x) len_x
+
+let select_files dir ext =
+  List.map (Pathname.concat dir)
+    (List.filter (endswith ext)
+      (Array.to_list (Sys.readdir dir)))
+
+let mlh_files = select_files "lib/" ".mlh"
+
+let dispatch = function
+  | After_rules as e ->
+    dep  ["ocaml"; "ocamldep"; "mlh"] mlh_files;
+    List.iter (fun tag ->
+      flag ["mlh"; "ocaml"; tag] (S[A"-ppopt"; A"-Ilib/"]))
+      ["ocamldep"; "compile"];
+    dispatch_default e
+  | e -> dispatch_default e
+
+let () = Ocamlbuild_plugin.dispatch dispatch
+EOF
+
+make_setup_ml "$HERE/setup.ml" <<EOF
+let test cmd =
+  match Sys.command (cmd ^ " 2>/dev/null") with
+  | 0 -> true
+  | 1 -> false
+  | _ -> failwith ("command '"^cmd^"' failed.")
+
+let getconf var =
+  let f_exit_code = ignore in
+  let ctxt = !BaseContext.default in
+  OASISExec.run_read_output ~f_exit_code ~ctxt "getconf" [var]
+
+let use_librt = test "ld -lrt -shared -o /dev/null"
+let linux_possible = test "uname | grep -q -i linux"
+let timers_possible =
+  match getconf "_POSIX_TIMERS" with
+  | [x] -> (try int_of_string x >= 200112 with _ -> false)
+  |  _  -> false
+
+let cc_libs =
+  if use_librt then ["-lrt"] else []
+
+let cc_opts =
+  getconf "LFS64_CFLAGS"
+
+let map_section = function
+  | Library (cs, bs, libs) when cs.cs_name = "core" ->
+    Library (cs, { bs with
+                   bs_ccopt     = [(OASISExpr.EBool true, cc_opts)];
+                   bs_cclib     = [(OASISExpr.EBool true, cc_libs)]; },
+             libs)
+  | Flag (cs, flag) when cs.cs_name = "linux" ->
+    Flag (cs, { flag with
+                flag_default = [OASISExpr.EBool true,      linux_possible;
+                                OASISExpr.EBool false, not linux_possible] })
+  | Flag (cs, flag) when cs.cs_name = "posix-timers" ->
+    Flag (cs, { flag with
+                flag_default = [OASISExpr.EBool true,      timers_possible;
+                                OASISExpr.EBool false, not timers_possible] })
+  | section -> section
+
+let setup_t = { setup_t with
+  BaseSetup.package = { setup_t.BaseSetup.package with
+    sections = List.map map_section setup_t.BaseSetup.package.sections;
+  }
+}
 EOF
 
 cd $HERE
-rm -f setup.ml
 oasis setup
-
-./configure "$enable_linux_default" "$enable_timers_default" "$@"

base/fieldslib/oasis.sh

 OASISFormat:  0.3
 OCamlVersion: >= 3.12
 Name:         fieldslib
-Version:      107.01
+Version:      $core_version
 Synopsis:     OCaml record fields as first class values.
 Authors:      Jane street capital
 Copyrights:   (C) 2009-2011 Jane Street Capital LLC
 cd $HERE
 rm -f setup.ml
 oasis setup
-
-./configure "$@"
-

base/pa_ounit/oasis.sh

 
 cd $HERE
 oasis setup
-./configure "$@"
-

base/pipebang/oasis.sh

 
 cd $HERE
 oasis setup
-./configure "$@"
-

base/sexplib/oasis.sh

 cd $HERE
 rm -f setup.ml
 oasis setup
-
-./configure "$@"

base/type_conv/.hgignore.in

 Makefile
 myocamlbuild.ml
 configure
-lib/core.mlpack
 setup.ml
 setup.log
 setup.data
 _build
 _tags
 lib/META
-lib/libpa_type_conv.clib
+lib/pa_type_conv.mllib
 lib/type_conv.odocl

base/type_conv/oasis.sh

 
 cd $HERE
 oasis setup
-./configure "$@"
-

base/typehash/oasis.sh

 
 cd $HERE
 oasis setup
-./configure "$@"
-

base/variantslib/oasis.sh

 OASISFormat:  0.3
 OCamlVersion: >= 3.12
 Name:         variantslib
-Version:      107.01
+Version:      $core_version
 Synopsis:     OCaml variants as first class values.
 Authors:      Jane street capital
 Copyrights:   (C) 2009-2011 Jane Street Capital LLC
 cd $HERE
 rm -f setup.ml
 oasis setup
-
-./configure "$@"
-

build-and-install

 #!/usr/bin/env bash
 set -u -o pipefail
 
+. build-common.sh
+
 function usage {
     echo "usage: ${BASH_SOURCE[0]} [-j <JOBS>] [tree]"
     echo "         -h, --help       Display this help"
     *) echo "too many anonymous arguments: $@"; exit 1 ;;
 esac
 
-# in dependency topological order
-libraries="
-type_conv
-pipebang
-compare
-typehash
-fieldslib
-variantslib
-pa_ounit
-bin-prot
-sexplib
-core
-core/extended
-async/core
-async/unix
-async/extra
-async
-"
-
-# tac is non-standard
-function tac { cat -n | sort -nr | cut -f2; }
-
 if $uninstall; then
-  libraries=$(echo "$libraries" | gtac)
+  rev_build_order=( )
+  for i in `seq $(( ${#build_order[@]} - 1 )) -1 0`; do
+      rev_build_order+=( "${build_order[$i]}" )
+  done
+  build_order=( "${rev_build_order[@]}" )
 fi
 
 cd "$tree"
-for dir in $libraries; do
+
+function findlibname {
+    local dir="$1"
+    (grep FindlibParent: "$dir"/oasis.sh || grep FindlibName: "$dir"/oasis.sh) \
+    | awk '{print $2}' | head -1
+}
+
+function uninstall {
+    local lib=$(findlibname "$1")
+    ocamlfind remove "$lib" || true;
+}
+
+for dir in "${build_order[@]}"; do
   echo "------ base/$dir ------"
   pushd base/$dir
   optflags=
-  
+
   if $uninstall; then
-    make uninstall || true
+    uninstall .
     popd; continue
   fi
-  
+
   case $dir in
       core|core/extended) optflags="$linuxflag $timerflag" ;;
       async/scheduler)    optflags="$linuxflag" ;;
           trap "rm -r '$dest'" EXIT
           ;;
   esac
-  ./oasis.sh $optflags "${configopts[@]:+${configopts[@]}}"
+  ./oasis.sh
+  ./configure $optflags "${configopts[@]:+${configopts[@]}}"
   make build BUILDFLAGS="$makeflags"
-  make install || true
+  uninstall .
+  make install
 
   case $dir in
       async) # copy the generated setup.ml and setup.data back
-        cp -rp "$dest"/base/async/{Makefile,setup.ml,setup.data,myocamlbuild.ml} "$src"/
+        cp -rp "$dest"/base/async/{configure,Makefile,setup.ml,setup.data,myocamlbuild.ml} "$src"/
       ;;
   esac
   popd
 #!/bin/bash
 
+core_version=108.00-pre1
+
+# in dependency-topological order
+build_order=(
+    type_conv
+    pipebang
+    compare
+    typehash
+    fieldslib
+    variantslib
+    pa_ounit
+    bin-prot
+    sexplib
+    core
+    core/extended
+    async/core
+    async/unix
+    async/extra
+    async
+)
+
 function my_join {
     sep=","
     if [[ $# -gt 0 ]]; then sep="$1"; fi
     done
 }
 
+function list_mods {
+    find "$1" -name '*.ml' -print | mod_names | sort -u | my_join
+}
+
+function list_stubs {
+    find "$1" -name "*.[ch]" -exec basename \{\} \; | sort -u | my_join
+}
+
 function make_tags {
     cat >"$1" <<EOF
 # OASIS_START
     cat >>"$1"
 }
 
-function check_linux_enabled {
-    enable_linux=false
-    enable_linux_default="--disable-linux"
-    case $(ocamlc -config | awk '$1 == "system:" {print $2}') in
-        linux|linux_elf)
-            enable_linux=true
-            enable_linux_default="--enable-linux"
-            ;;
-    esac
+function make_setup_ml {
+    cat >"$1" <<EOF
+(* OASIS_START *)
+(* OASIS_STOP *)
+let _ = setup
 
-    for opt in "$@"; do
-        case "$opt" in
-            --enable-linux)  enable_linux=true;  enable_linux_default= ;;
-            --disable-linux) enable_linux=false; enable_linux_default= ;;
-        esac
-    done
+EOF
+    cat >> "$1"
+    cat >> "$1" <<EOF
+
+let () = BaseSetup.setup setup_t
+EOF
 }
 
-function getconf_or_zero {
-    local ret=$(getconf "$@" 2>/dev/null)
-    case "$ret" in
-	[0-9][0-9]*) echo "$ret" ;;
-	*) echo 0 ;;
-    esac
-}
+HERE=$(dirname -- "$0")
 
-function check_posix_timers_enabled {
-    enable_timers=false
-    enable_timers_default="--disable-posix-timers"
-    if [[ $(getconf_or_zero _POSIX_TIMERS) -ge 200112 ]]; then
-        enable_timers=true
-        enable_timers_default="--enable-posix-timers"
-    fi
-
-    for opt in "$@"; do
-        case "$opt" in
-            --enable-posix-timers)  enable_timers=true;  enable_timers_default= ;;
-            --disable-posix-timers) enable_timers=false; enable_timers_default= ;;
-        esac
-    done
-}
-
-function declare_tests_flag {
-  # prior to oasis version 0.3.0, the "tests" flag is not built in
-  # and, the "version" argument is not supported.
-  if ! oasis version 2>/dev/null >/dev/null; then
-    cat <<EOF
-Flag tests
-  Description: Build and run tests
-  Default:     false
-EOF
-  fi
-}
-
-HERE=$(dirname "$0")
+#!/usr/bin/env bash
+set -e -u -o pipefail
+
+. build-common.sh
+
+function usage {
+    echo "usage: ${BASH_SOURCE[0]} <dest-dir> [packages...]"
+}
+
+if [[ $# -lt 1 ]]; then usage; exit 1; fi
+
+destdir="$1"
+shift
+if [[ $# -gt 0 ]]; then
+    packages="$@"
+else
+    packages="${build_order[@]}"
+fi
+
+function file_included {
+    case "$1" in
+        oasis.sh)             false;;
+        _build)               false;;
+        setup.log|setup.data) false;;
+        *) [[ ! -e "$1"/oasis.sh ]];;
+    esac
+}
+excluded=(
+    oasis.sh
+    _build
+    setup.log
+    setup.data
+)
+
+hgroot=$(hg root)
+
+for dir in $packages; do
+    pushd "base/$dir"
+
+    ./oasis.sh
+    name=$(oasis query name)
+    version=$(oasis query version)
+    dest="$destdir/${name}-${version}"
+    mkdir "$dest"
+
+    for f in *; do
+        if file_included "$f"; then
+            cp -rp "$f" "$dest/$f"
+        fi
+    done
+    cp -p "$hgroot/licensing/"* "$dest/"
+
+    popd
+done
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.