ysulsky avatar ysulsky committed 7145d1b Merge

merge from jane-108.00

Comments (0)

Files changed (31)

 mycaml$
 \.DS_Store$
 tmtags$
+\.rnc$
 
 ^\.git/.*$
 ^\.transdeps/.*$
 \#*
 .\#*
 
+# Please do not add directory-specific files to ignore here.  Instead, add them to the
+# .hgignore.in file in the directory where the file you want to ignore lives.
 glob:base/async/INSTALL
 glob:base/async/Makefile
 glob:base/async/_build
 glob:base/compare/configure
 glob:base/compare/lib/META
 glob:base/compare/lib/comparelib.mllib
+glob:base/compare/lib/comparelib_dummy.ml
 glob:base/compare/myocamlbuild.ml
 glob:base/compare/sample_output/generated_test.ml
 glob:base/compare/sample_output/generated_test.mli

base/async/core/oasis.sh

-#!/bin/bash
+#!/usr/bin/env bash
 set -e -u -o pipefail
 
-here="$(dirname "${BASH_SOURCE[0]}")"
+source ../../../build-common.sh
 
-my_join () {
-    local FIRST="true"
-    while read line; do
-        if [[ "$FIRST" != "true" ]]; then
-            echo -n ","
-        else
-            FIRST="false"
-        fi
-        echo -n "$line"
-    done
-    echo
+function list_mods {
+    find "$HERE/lib" -name "*.ml" -print | mod_names
 }
 
-list_mods () {
-    echo Std
-    for i in $here/$1/*.ml; do
-        bname="$(basename $i)"
-        j=${bname%%.ml*};
-        case $j in
-            inline_tests_runner) continue;;
-            *);;
-        esac
-        echo -n "${j:0:1}" | tr "[:lower:]" "[:upper:]"; echo ${j:1};
-    done
-}
+MODULES="$(list_mods | sort -u | my_join)"
 
-list_stubs () {
-    for i in "$here"/lib/*.{c,h} "$here"/lib/*.{c,h}; do
-        bname="$(basename $i)"
-        j=${bname%%.?};
-        case $j in
-            *);;
-        esac
-        echo "$bname"
-    done
-}
-
-cat >$here/_oasis <<EOF
+cat >$HERE/_oasis <<EOF
 #AUTOGENERATED FILE; EDIT oasis.sh INSTEAD
 
 OASISFormat:  0.2
 Library async_core
   Path:               lib
   FindlibName:        async_core
-  Pack:               true
-  Modules:$(list_mods lib | sort -u | my_join)
+  #Pack:               true
+  Modules:            ${MODULES}
   BuildDepends:       sexplib.syntax,
                       sexplib,
                       fieldslib.syntax,
 
 EOF
 
-cat >$here/_tags <<EOF
-# OASIS_START
-# OASIS_STOP
+make_tags "$HERE/_tags" <<EOF
+# remove this part when oasis supports Pack: true
+$(tag_for_pack Async_core $HERE/lib/*.ml)
+
 <lib/*.ml{,i}>: syntax_camlp4o
 EOF
 
-cd $here
+cd $HERE
+rm -f setup.ml
 oasis setup
+enable_pack_in_setup_ml async_core
+
 ./configure "$@"
 

base/async/extra/oasis.sh

-#!/bin/bash
+#!/usr/bin/env bash
 set -e -u -o pipefail
 
-here="$(dirname "${BASH_SOURCE[0]}")"
+source ../../../build-common.sh
 
-my_join () {
-    local FIRST="true"
-    while read line; do
-        if [[ "$FIRST" != "true" ]]; then
-            echo -n ","
-        else
-            FIRST="false"
-        fi
-        echo -n "$line"
-    done
-    echo
+function list_mods {
+    find "$HERE/lib" -name "*.ml" -print | mod_names
 }
 
-list_mods () {
-    echo Std
-    for i in $here/$1/*.ml; do
-        bname="$(basename $i)"
-        j=${bname%%.ml*};
-        case $j in
-            inline_tests_runner) continue;;
-            *);;
-        esac
-        echo -n "${j:0:1}" | tr "[:lower:]" "[:upper:]"; echo ${j:1};
-    done
-}
+MODULES=$(list_mods | sort -u | my_join)
 
-list_stubs () {
-    for i in "$here"/lib/*.{c,h} "$here"/lib/*.{c,h}; do
-        bname="$(basename $i)"
-        j=${bname%%.?};
-        case $j in
-            *);;
-        esac
-        echo "$bname"
-    done
-}
-
-cat >$here/_oasis <<EOF
+cat >$HERE/_oasis <<EOF
 #AUTOGENERATED FILE; EDIT oasis.sh INSTEAD
 
 OASISFormat:  0.2
 Library async_extra
   Path:               lib
   FindlibName:        async_extra
-  Pack:               true
-  Modules:$(list_mods lib | sort -u | my_join)
+  #Pack:               true
+  Modules:            ${MODULES}
   BuildDepends:       sexplib.syntax,
                       sexplib,
                       fieldslib.syntax,
 
 EOF
 
-cat >$here/_tags <<EOF
-# OASIS_START
-# OASIS_STOP
+make_tags "$HERE/_tags" <<EOF
+# remove this part when oasis supports Pack: true
+$(tag_for_pack Async_extra $HERE/lib/*.ml)
+
 <lib/*.ml{,i}>: syntax_camlp4o
 EOF
 
-cd $here
+cd $HERE
+rm -f setup.ml
 oasis setup
+enable_pack_in_setup_ml async_extra
+
 ./configure "$@"
 

base/async/oasis.sh

-#!/bin/bash
+#!/usr/bin/env bash
 set -e -u -o pipefail
 
-here="$(dirname "${BASH_SOURCE[0]}")"
+source ../../build-common.sh
 
-my_join () {
-    local FIRST="true"
-    while read line; do
-        if [[ "$FIRST" != "true" ]]; then
-            echo -n ","
-        else
-            FIRST="false"
-        fi
-        echo -n "$line"
-    done
-    echo
+function list_mods {
+    find "$HERE/lib" -name "*.ml" -print | mod_names
 }
 
-list_mods () {
-    echo Std
-    for i in $here/$1/*.ml; do
-        bname="$(basename $i)"
-        j=${bname%%.ml*};
-        case $j in
-            *);;
-        esac
-        echo -n "${j:0:1}" | tr "[:lower:]" "[:upper:]"; echo ${j:1};
-    done
-}
+MODULES="$(list_mods | sort -u | my_join)"
 
-cat >$here/_oasis <<EOF
+cat >$HERE/_oasis <<EOF
 #AUTOGENERATED FILE; EDIT oasis.sh INSTEAD
 
 OASISFormat:  0.2
 Library async
   Path:               lib
   FindlibName:        async
-  Pack:               true
-  Modules:$(list_mods lib | sort -u | my_join)
+  #Pack:               true
+  Modules:            ${MODULES}
   BuildDepends:       async_core,
                       async_unix,
                       async_extra,
 
 EOF
 
-cat >$here/_tags <<EOF
-# OASIS_START
-# OASIS_STOP
+make_tags $HERE/_tags <<EOF
+# remove this part when oasis supports Pack: true
+$(tag_for_pack Async $HERE/lib/*.ml)
+
 # <lib_test/*.ml{,i}>: syntax_camlp4o
 EOF
 
-cd $here
+cd $HERE
+rm -f setup.ml
 oasis setup
+enable_pack_in_setup_ml async
+
 ./configure "$@"
 

base/async/unix/oasis.sh

-#!/bin/bash
+#!/usr/bin/env bash
 set -e -u -o pipefail
 
-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
+source ../../../build-common.sh
 
-opts=( "$@" )
-for ((i=0; i<$#; i++)); do
-    case ${opts[$i]} in
-        --enable-linux)  enable_linux=true;  enable_linux_default= ;;
-        --disable-linux) enable_linux=false; enable_linux_default= ;;
-    esac
-done
-
-here="$(dirname "${BASH_SOURCE[0]}")"
-
-my_join () {
-    local FIRST="true"
-    while read line; do
-        if [[ "$FIRST" != "true" ]]; then
-            echo -n ","
-        else
-            FIRST="false"
-        fi
-        echo -n "$line"
-    done
-    echo
+function list_mods {
+    find "$HERE/lib" -name "*.ml" -print | mod_names
 }
 
-list_mods () {
-    echo Std
-    for i in $here/$1/*.ml; do
-        bname="$(basename $i)"
-        j=${bname%%.ml*};
-        case $j in
-            inline_tests_runner) continue;;
-            *);;
-        esac
-        echo -n "${j:0:1}" | tr "[:lower:]" "[:upper:]"; echo ${j:1};
-    done
-}
+MODULES=$(list_mods | sort -u | my_join)
 
-list_stubs () {
-    for i in "$here"/lib/*.{c,h} "$here"/lib/*.{c,h}; do
-        bname="$(basename $i)"
-        j=${bname%%.?};
-        case $j in
-            *);;
-        esac
-        echo "$bname"
-    done
-}
-
-cat >$here/_oasis <<EOF
+cat >$HERE/_oasis <<EOF
 #AUTOGENERATED FILE; EDIT oasis.sh INSTEAD
 
 OASISFormat:  0.2
 XStdFilesINSTALLFilename: INSTALL
 XStdFilesREADME: false
 
-Flag linux
-  Description: Enable linux specific extensions
-  Default$:    $enable_linux
-
-PreBuildCommand: mkdir -p _build; cp lib/*mlh _build/
-PreDistCleanCommand: \$rm lib/version_defaults.mlh lib/config.mlh
-
 Library async_unix
   Path:               lib
   FindlibName:        async_unix
-  Pack:               true
-  Modules:$(list_mods lib | sort -u | my_join)
+  #Pack:               true
+  Modules:            ${MODULES}
   BuildDepends:       sexplib.syntax,
                       sexplib,
                       fieldslib.syntax,
 
 EOF
 
-cat >$here/_tags <<EOF
-# OASIS_START
-# OASIS_STOP
+make_tags "$HERE/_tags" <<EOF
+# remove this part when oasis supports Pack: true
+$(tag_for_pack Async_unix $HERE/lib/*.ml)
+
 <lib/*.ml{,i}>: syntax_camlp4o
-"lib/async_unix.ml": pkg_camlp4.macro
-"lib/raw_scheduler.ml": pkg_camlp4.macro
-<lib/writer.ml{,i}>: pkg_camlp4.macro
 EOF
 
-cat >$here/lib/config.mlh <<EOF
-$(if [[ "$enable_linux" == "true" ]]; then echo "DEFINE LINUX_EXT"; fi)
-EOF
+cd $HERE
+rm -f setup.ml
+oasis setup
+enable_pack_in_setup_ml async_unix
 
-cd $here
-oasis setup
-./configure "$enable_linux_default" "$@"
+./configure "$@"
 

base/bin-prot/oasis.sh

-#!/bin/bash
+#!/usr/bin/env bash
 set -e -u -o pipefail
 
-here="$(dirname "${BASH_SOURCE[0]}")"
+source ../../build-common.sh
 
-cat >$here/_oasis <<EOF
+cat >$HERE/_oasis <<EOF
 #AUTOGENERATED FILE; EDIT oasis.sh INSTEAD
 OASISFormat:  0.2
 OCamlVersion: >= 3.12
 XStdFilesREADME: false
 
 
-PreBuildCommand: mkdir -p _build; cp lib/*.{mlh,h} _build/
+PreBuildCommand: mkdir -p _build; cp lib/*.mlh lib/*.h _build/
 
 Library bin_prot
   Path:               lib
-  Pack:               true
+  #Pack:               true
   Modules:            Binable,
                       Nat0,
                       Common,
   XMETARequires:      type-conv
   XMETADescription:   Syntax extension for binary protocol generator
 
-Flag tests
-  Description:        Build and run tests
-  Default:            false
+$(declare_tests_flag)
 
 Executable test_runner
   Path:               lib_test
   XOCamlbuildLibraries: bin_prot
 EOF
 
-cat >$here/_tags <<EOF
-# OASIS_START
-# OASIS_STOP
+make_tags $HERE/_tags <<EOF
+# remove this part when oasis supports Pack: true
+$(tag_for_pack Bin_prot $HERE/lib/*.ml)
+
 <lib/read_ml.ml{i,}>: pp(cpp -undef -traditional -Werror -I.)
 <lib/size.ml{i,}>: pp(cpp -undef -traditional -Werror -I.)
 <lib/type_class.ml{i,}>: pp(cpp -undef -traditional -Werror -I.)
 <syntax/pa_bin_prot.ml>: syntax_camlp4o
 EOF
 
-cd $here
+cd $HERE
+rm -f setup.ml
 oasis setup
+enable_pack_in_setup_ml bin_prot
+
 ./configure "$@"
 

base/compare/oasis.sh

-#!/bin/bash
+#!/usr/bin/env bash
 set -e -u -o pipefail
 
-here="$(dirname "${BASH_SOURCE[0]}")"
+source ../../build-common.sh
 
-cat >$here/_oasis <<EOF
+cat >$HERE/_oasis <<EOF
 #AUTOGENERATED FILE; EDIT oasis.sh INSTEAD
 OASISFormat:  0.2
 OCamlVersion: >= 3.12
 
 Library comparelib
   Path:               lib
-  Modules:
+  Modules:            Comparelib_dummy
   FindlibName:        comparelib
   XMETAType:          library
 
   XMETADescription:   Syntax extension for "with compare"
 EOF
 
-cat >$here/_tags <<EOF
-# OASIS_START
-# OASIS_STOP
+make_tags $HERE/_tags <<EOF
 <syntax/pa_compare.ml>: syntax_camlp4o
 EOF
 
-mkdir -p $here/lib
+mkdir -p $HERE/lib
+echo >$HERE/lib/comparelib_dummy.ml
 
-cd $here
+cd $HERE
 oasis setup
 ./configure "$@"
 

base/compare/preprocess.sh

-#!/bin/bash
+#!/usr/bin/env bash
 set -e -u
 [[ "$#" != 1 ]] && { echo "usage: $0  FILE_TO_PREPROCESS" >&2; exit 1; }
 [[ -f "$(hg root)/lib/pa_compare.cmo" ]] || {

base/core/extended/lib/service-template.sh

-#!/bin/bash
+#!/usr/bin/env bash
 #
 #	/etc/rc.d/init.d/foo
 #

base/core/extended/oasis.sh

-#!/bin/bash
+#!/usr/bin/env bash
 set -e -u -o pipefail
 
-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
+source ../../../build-common.sh
+check_linux_enabled "$@"
+check_posix_timers_enabled "$@"
 
-enable_timers=false
-enable_timers_default="--disable-posix-timers"
-if [[ $(getconf _POSIX_TIMERS 2>/dev/null) -ge 200112 ]]; then
-    enable_timers=true
-    enable_timers_default="--enable-posix-timers"
-fi
-
-opts=( "$@" )
-for ((i=0; i<$#; i++)); do
-    case ${opts[$i]} in
-        --enable-linux)  enable_linux=true;  enable_linux_default= ;;
-        --disable-linux) enable_linux=false; enable_linux_default= ;;
-        --enable-posix-timers)  enable_timers=true;  enable_timers_default= ;;
-        --disable-posix-timers) enable_timers=false; enable_timers_default= ;;
-    esac
-done
-
-here="$(dirname "${BASH_SOURCE[0]}")"
-my_join () {
-    FIRST="true"
-    while read line; do
-        if [[ "$FIRST" != "true" ]]; then
-            echo -n ","
-        else
-            FIRST="false"
-        fi
-        echo -n "$line"
-    done
-    echo
-}
-
-list_mods () {
-    for i in $here/lib/*.ml; do
-        bname="$(basename $i)"
-        j=${bname%%.ml*};
-        case $j in
-            malloc|extended_linux)
-                if [ "$enable_linux" == "false" ]; then continue; fi;;
-            bench|posix_clock)
-                if [ "$enable_timers" == "false" ]; then continue; fi;;
-            inline_tests_runner) continue;;
-            *);;
+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
-        echo -n "${j:0:1}" | tr "[:lower:]" "[:upper:]"; echo ${j:1};
     done
 }
 
-list_stubs () {
-    for i in $here/lib/*.c; do
-        bname="$(basename $i)"
-        j=${bname%%.?};
-        case $j in
+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" == "false" ]; then continue; fi;;
+                if [[ "$enable_linux" == "true" ]]; then echo "$stub"; fi;;
             posix_clock_stubs)
-                if [ "$enable_timers" == "false" ]; then continue; fi;;
-            *);;
+                if [[ "$enable_timers" == "true" ]]; then echo "$stub"; fi;;
+            *) echo "$stub";;
         esac
-        echo "$bname"
     done
 }
 
 MODULES="$(list_mods | sort -u | my_join)"
 CSOURCES="fork_exec.h,$(list_stubs | sort -u | my_join)"
 
-cat >$here/_oasis <<EOF
+cat >$HERE/_oasis <<EOF
 #AUTOGENERATED FILE; EDIT oasis.sh INSTEAD
 
 OASISFormat:  0.2
 Library core_extended
   Path:               lib
   FindlibName:        core_extended
-  Pack:               true
+  #Pack:               true
   Modules:            ${MODULES}
   CSources:           ${CSOURCES}
   CCOpt+:             -Ilib
                       unix,
                       threads
 
-Flag tests
-  Description:        Build and run tests
-  Default:            false
+$(declare_tests_flag)
 
 Executable core_extended_hello
   Path:               lib_test
 
 EOF
 
-cat >$here/_tags <<EOF
-# OASIS_START
-# OASIS_STOP
+make_tags "$HERE/_tags" <<EOF
+# remove this part when oasis supports Pack: true
+$(tag_for_pack Core_extended $HERE/lib/*.ml)
+
 <lib/*.ml{,i}>: syntax_camlp4o
 "lib/std.ml": pkg_camlp4.macro
 "lib/command.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
+if [[ ! -e $HERE/lib/version_defaults.mlh ]]; then
+    cat >$HERE/lib/version_defaults.mlh <<EOF
 DEFINE DEFAULT_VERSION = "No version info."
 DEFINE DEFAULT_BUILDINFO = "No build info."
 EOF
 fi
 
-cat >$here/lib/config.mlh <<EOF
+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)
 EOF
 
-cd $here
+cd $HERE
+rm -f setup.ml
 oasis setup
+enable_pack_in_setup_ml core_extended
+
 ./configure "$enable_timers_default" "$enable_linux_default" "$@"

base/core/lib/backtrace.ml

+open Std_internal
+
 module Sexp = Sexplib.Sexp
-module List = Core_list
-module String = Core_string
 
 type t = string
 
   Sexp.List (List.drop l 2)
 ;;
 
-external get : unit -> string = "backtrace_get"
+
+INCLUDE "config.mlh"
+IFDEF ARCH_x86_64 THEN
+external backtrace_get : unit -> string = "backtrace_get"
+let get = Ok backtrace_get
+ELSE
+let get = Or_error.error "unimplemented" "Backtrace.get" <:sexp_of< string >>
+ENDIF

base/core/lib/backtrace.mli

    frames, but [to_string] does not. *)
 type t with sexp_of
 
-val get : unit -> t
+val get : (unit -> string) Or_error.t
 
 val to_string : t -> string
Add a comment to this file

base/core/lib/core_unix.ml

File contents unchanged.

Add a comment to this file

base/core/lib/core_unix.mli

File contents unchanged.

base/core/lib/discover.sh

-#!/bin/bash
+#!/usr/bin/env bash
 set -e -u -o pipefail
 
 ML_OUTFILE="${1:?Usage: discover.sh ML_OUTFILE C_OUTFILE}"
   $(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")
 "$PGM" > "$OUT"
 rm "$PGM"
 mv "$OUT" "$ML_OUTFILE"
-sed -e 's|^DEFINE *|#define JSC_|' "$ML_OUTFILE" > "$C_OUTFILE"
+cat "$ML_OUTFILE" \
+    | sed -e 's|^DEFINE *|#define JSC_|' \
+    | sed -e 's|\(#define JSC_[^ ]*\) *=|\1 |' > "$C_OUTFILE"

base/core/lib/unix_stubs.c

 #warning "_POSIX_SYNCHRONIZED_IO undefined or <= 0; aliasing unix_fdatasync to unix_fsync"
 CAMLprim value unix_fdatasync(value v_fd)
 {
-  return unix_fsync(v_fd)
+  return unix_fsync(v_fd);
 }
 #endif
 
   return pthread_self();
 }
 
+/* Clock functions */
+
+#ifdef JSC_POSIX_TIMERS
+#define clockid_t_val(v_cl) ((clockid_t) Nativeint_val(v_cl))
+
 CAMLprim value unix_pthread_getcpuclockid(value v_tid)
 {
   clockid_t c;
   return caml_copy_nativeint(CLOCK_THREAD_CPUTIME_ID);
 }
 
-/* Clock functions */
-
-#ifdef JSC_POSIX_TIMERS
-#define clockid_t_val(v_cl) ((clockid_t) Nativeint_val(v_cl))
-
 CAMLprim value unix_clock_gettime(value v_cl)
 {
   struct timespec ts;

base/core/oasis.sh

-#!/bin/bash
+#!/usr/bin/env bash
 set -e -u -o pipefail
 
-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
-
-enable_timers=false
-enable_timers_default="--disable-posix-timers"
-if [[ $(getconf _POSIX_TIMERS 2>/dev/null) -ge 200112 ]]; then
-    enable_timers=true
-    enable_timers_default="--enable-posix-timers"
-fi
-
-opts=( "$@" )
-for ((i=0; i<$#; i++)); do
-    case ${opts[$i]} in
-        --enable-linux)  enable_linux=true;  enable_linux_default= ;;
-        --disable-linux) enable_linux=false; enable_linux_default= ;;
-        --enable-posix-timers)  enable_timers=true;  enable_timers_default= ;;
-        --disable-posix-timers) enable_timers=false; enable_timers_default= ;;
-    esac
-done
+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
 
-here="$(dirname "${BASH_SOURCE[0]}")"
-my_join () {
-    local FIRST="true"
-    while read line; do
-        if [[ "$FIRST" != "true" ]]; then
-            echo -n ","
-        else
-            FIRST="false"
-        fi
-        echo -n "$line"
-    done
-    echo
-}
-
-list_mods () {
-    for i in "$here"/lib/*.ml; do
-        bname="$(basename $i)"
-        j=${bname%%.ml*};
-        case $j in
-            linux_ext|bigstring_marshal)
-                if [ "$enable_linux" == "false" ]; then continue; fi;;
-            inline_tests_runner) continue;;
-            *);;
+function list_mods {
+    for mod in $(find "$HERE/lib" -name "*.ml" -print | mod_names); do
+        case "$mod" in
+            *) echo "$mod";;
         esac
-        echo -n "${j:0:1}" | tr "[:lower:]" "[:upper:]"; echo ${j:1};
     done
 }
 
-list_stubs () {
-    for i in "$here"/lib/*.{c,h}; do
-        bname="$(basename $i)"
-        j=${bname%%.?};
-        case $j in
+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" == "false" ]; then continue; fi;;
-            *);;
+                if [[ "$enable_linux" == "true" ]]; then echo "$stub"; fi;;
+	    backtrace_stubs)
+		if [[ "$(uname -p)" == "x86_64" ]]; then echo "$stub"; fi;;
+            *) echo "$stub";;
         esac
-        echo "$bname"
     done
 }
 
 MODULES="$(list_mods | sort -u | my_join)"
-CSOURCES="config.h,$(list_stubs | 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.2
 Library core
   Path:               lib
   FindlibName:        core
-  Pack:               true
+  #Pack:               true
   Modules:${MODULES}
-  CCOpt:              $(getconf LFS64_CFLAGS)
+  CCOpt:              $(getconf LFS64_CFLAGS 2>/dev/null)
   CSources:           ${CSOURCES}
   CCLib:              ${CCLIB}
   BuildDepends:       variantslib,
                       unix,
                       threads
 
-Flag tests
-  Description:        Build and run tests
-  Default:            false
+$(declare_tests_flag)
 
 Executable test_runner
   Path:               lib_test
 
 EOF
 
-cat >$here/_tags <<EOF
-# OASIS_START
-# OASIS_STOP
+make_tags "$HERE/_tags" <<EOF
+# remove this part when oasis supports Pack: true
+$(tag_for_pack Core $HERE/lib/*.ml)
+
 <lib{,_test}/*.ml{,i}>: syntax_camlp4o
-<lib/{std,core_int63,bigstring,core_mutex,core_unix,bigstring_marshal,linux_ext}.ml{,i}>:pkg_camlp4.macro
+<lib/{std,core_int63,bigstring,core_mutex,core_unix,bigstring_marshal,linux_ext,backtrace}.ml{,i}>:pkg_camlp4.macro
 EOF
 
-cd $here
+cd $HERE
+rm -f setup.ml
 oasis setup
-./configure "$enable_linux_default" "$@"
+enable_pack_in_setup_ml core
+
+./configure "$enable_linux_default" "$enable_timers_default" "$@"

base/fieldslib/oasis.sh

-#!/bin/bash
+#!/usr/bin/env bash
 set -e -u -o pipefail
 
-here="$(dirname "${BASH_SOURCE[0]}")"
+source ../../build-common.sh
 
-cat >$here/_oasis <<EOF
+cat >$HERE/_oasis <<EOF
 #AUTOGENERATED FILE; EDIT oasis.sh INSTEAD
 OASISFormat:  0.2
 OCamlVersion: >= 3.12
 Library fieldslib
   Path:               lib
   FindlibName:        fieldslib
-  Pack:               true
+  #Pack:               true
   Modules:            Field
   XMETAType:          library
 
   XOCamlbuildLibraries: fieldslib
 EOF
 
-cat >$here/_tags <<EOF
-# OASIS_START
-# OASIS_STOP
+make_tags $HERE/_tags <<EOF
+# remove this part when oasis supports Pack: true
+$(tag_for_pack Fieldslib $HERE/lib/*.ml)
+
 <syntax/pa_fields_conv.ml>: syntax_camlp4o
-<lib/field.cmx>:for-pack(Fieldslib)
 EOF
 
-cd $here
+cd $HERE
+rm -f setup.ml
 oasis setup
+enable_pack_in_setup_ml fieldslib
+
 ./configure "$@"
 

base/fieldslib/syntax/run.sh

-#!/bin/bash
+#!/usr/bin/env bash
 set -e -u
 jomake --command=camlp4orf -I "$(hg root)/lib" pa_type_conv.cmo pa_fields_conv.cmo $@

base/pa_ounit/oasis.sh

-#!/bin/bash
+#!/usr/bin/env bash
 set -e -u -o pipefail
 
-here="$(dirname "${BASH_SOURCE[0]}")"
+source ../../build-common.sh
 
-cat >$here/_oasis <<EOF
+cat >$HERE/_oasis <<EOF
 #AUTOGENERATED FILE; EDIT oasis.sh INSTEAD
 OASISFormat:  0.2
 OCamlVersion: >= 3.12
   XMETADescription:   Syntax extension writing inline tests
 EOF
 
-cat >$here/_tags <<EOF
-# OASIS_START
-# OASIS_STOP
+make_tags $HERE/_tags <<EOF
 <syntax/pa_ounit.ml>: syntax_camlp4o,pkg_camlp4.extend
 EOF
 
-cd $here
+cd $HERE
 oasis setup
 ./configure "$@"
 

base/pa_ounit/preprocess.sh

-#!/bin/bash
+#!/usr/bin/env bash
 set -e -u
 LIB=pa_ounit
 [[ "$#" != 1 ]] && { echo "usage: $0  FILE_TO_PREPROCESS" >&2; exit 1; }

base/pipebang/oasis.sh

-#!/bin/bash
+#!/usr/bin/env bash
 set -e -u -o pipefail
 
-here="$(dirname "${BASH_SOURCE[0]}")"
+source ../../build-common.sh
 
-cat >$here/_oasis <<EOF
+cat >$HERE/_oasis <<EOF
 #AUTOGENERATED FILE; EDIT oasis.sh INSTEAD
 OASISFormat:  0.2
 OCamlVersion: >= 3.12
   XMETADescription:   Syntax extension writing inline tests
 EOF
 
-cat >$here/_tags <<EOF
-# OASIS_START
-# OASIS_STOP
+make_tags $HERE/_tags <<EOF
 <lib/pa_pipebang.ml>: syntax_camlp4o,pkg_camlp4.extend
 EOF
 
-cd $here
+cd $HERE
 oasis setup
 ./configure "$@"
 

base/sexplib/oasis.sh

-#!/bin/bash
+#!/usr/bin/env bash
 set -e -u -o pipefail
 
-here="$(dirname "${BASH_SOURCE[0]}")"
+source ../../build-common.sh
 
-cat >$here/_oasis <<EOF
+cat >$HERE/_oasis <<EOF
 #AUTOGENERATED FILE; EDIT oasis.sh INSTEAD
 OASISFormat:  0.2
 OCamlVersion: >= 3.12
 Library sexplib
   Path:               lib
   FindlibName:        sexplib
-  Pack:               true
+  #Pack:               true
   Modules:            Type,
                       Parser,
                       Lexer,
 #  FindlibName:        top
 
 # TODO: figure out how to build tests without installing sexplib
-Flag tests
-  Description:        Build and run tests
-  Default:            false
+$(declare_tests_flag)
 
 Executable sexp_test
   Path:               lib_test
   XOCamlbuildLibraries: sexplib
 EOF
 
-cat >$here/_tags <<EOF
-# OASIS_START
-# OASIS_STOP
-<lib/pre_sexp.ml>: pp(cpp -undef -traditional -Werror -I$here/syntax)
+make_tags $HERE/_tags <<EOF
+# remove this part when oasis supports Pack: true
+$(tag_for_pack Sexplib $HERE/lib/*.ml{,l,y})
+
+<lib/pre_sexp.ml>: pp(cpp -undef -traditional -Werror -I$HERE/syntax)
 <lib_test/*.ml{,i}>: syntax_camlp4o
 <syntax/pa_sexp_conv.ml>: syntax_camlp4o
 EOF
 
-cd $here
+cd $HERE
+rm -f setup.ml
 oasis setup
+enable_pack_in_setup_ml sexplib
+
 ./configure "$@"
 

base/type-conv/oasis.sh

-#!/bin/bash
+#!/usr/bin/env bash
 set -e -u -o pipefail
 
-here="$(dirname "${BASH_SOURCE[0]}")"
+source ../../build-common.sh
 
-cat >$here/_oasis <<EOF
+cat >$HERE/_oasis <<EOF
 #AUTOGENERATED FILE; EDIT oasis.sh INSTEAD
 OASISFormat:  0.1
 OCamlVersion: >= 3.11
   XOCamlbuildLibraries: type-conv
 EOF
 
-cat >$here/_tags <<EOF
-# OASIS_START
-# OASIS_STOP
+make_tags $HERE/_tags <<EOF
 <syntax/pa_type_conv.ml>: syntax_camlp4o
 EOF
 
-cd $here
+cd $HERE
 oasis setup
 ./configure "$@"
 

base/type-conv/syntax/META

 # OASIS_START
-# DO NOT EDIT (digest: b651fcddae83a0b465ce4d37e1e3eb78)
+# DO NOT EDIT (digest: 0db3e3d863cd3be314dcea4d54ef71a5)
 version = "2.3.0"
 description = "Syntax extension for type-conv"
 requires = "camlp4"
-archive(syntax,preprocessor) = "pa_type_conv.cma"
-archive(syntax,toploop) = "pa_type_conv.cma"
+archive(syntax, preprocessor) = "pa_type_conv.cma"
+archive(syntax, toploop) = "pa_type_conv.cma"
 exists_if = "pa_type_conv.cma"
 # OASIS_STOP
 

base/typehash/oasis.sh

-#!/bin/bash
+#!/usr/bin/env bash
 set -e -u -o pipefail
 
-here="$(dirname "${BASH_SOURCE[0]}")"
+source ../../build-common.sh
 
-cat >$here/_oasis <<EOF
+cat >$HERE/_oasis <<EOF
 #AUTOGENERATED FILE; EDIT oasis.sh INSTEAD
 OASISFormat:  0.2
 OCamlVersion: >= 3.12
 
 Library typehashlib
   Path:               lib
-  Modules:
+  Modules:            Typehash
   FindlibName:        typehashlib
 
 Library pa_typehash
   XMETADescription:   Syntax extension for "with typehash"
 EOF
 
-cat >$here/_tags <<EOF
-# OASIS_START
-# OASIS_STOP
+make_tags $HERE/_tags <<EOF
 <syntax/pa_typehash.ml>: syntax_camlp4o,pkg_camlp4.extend
 EOF
 
-mkdir -p $here/lib
-
-cd $here
+cd $HERE
 oasis setup
 ./configure "$@"
 

base/variantslib/lib/META

 # OASIS_START
-# DO NOT EDIT (digest: d688e46403d76f941c61cbf94f723123)
+# DO NOT EDIT (digest: a343500168996634e276f54b40ffe5f7)
 version = "107.01"
 description = "OCaml variants as first class values."
 archive(byte) = "variantslib.cma"
  version = "107.01"
  description = "Syntax extension for Variantslib"
  requires = "camlp4 type-conv variantslib"
- archive(syntax,preprocessor) = "pa_variants_conv.cma"
- archive(syntax,toploop) = "pa_variants_conv.cma"
+ archive(syntax, preprocessor) = "pa_variants_conv.cma"
+ archive(syntax, toploop) = "pa_variants_conv.cma"
  exists_if = "pa_variants_conv.cma"
 )
 # OASIS_STOP

base/variantslib/oasis.sh

-#!/bin/bash
+#!/usr/bin/env bash
 set -e -u -o -pipefail
 
-here="$(dirname "${BASH_SOURCE[0]}")"
+source ../../build-common.sh
 
-cat >$here/_oasis <<EOF
+cat >$HERE/_oasis <<EOF
 #AUTOGENERATED FILE; EDIT oasis.sh INSTEAD
 OASISFormat:  0.2
 OCamlVersion: >= 3.12
 Library variantslib
   Path:               lib
   FindlibName:        variantslib
-  Pack:               true
+  #Pack:               true
   Modules:            Variant
   XMETAType:          library
 
   XOCamlbuildLibraries: variantslib
 EOF
 
-cat >$here/_tags <<EOF
-# OASIS_START
-# OASIS_STOP
+make_tags $HERE/_tags <<EOF
+# remove this part when oasis supports Pack: true
+$(tag_for_pack Variantslib $HERE/lib/*.ml)
+
 <syntax/*.ml{,i}>: syntax_camlp4o
 EOF
 
-cd $here
+cd $HERE
+rm -f setup.ml
 oasis setup
+enable_pack_in_setup_ml variantslib
+
 ./configure "$@"
 

base/variantslib/preprocess.sh

-#!/bin/bash
+#!/usr/bin/env bash
 set -e -u
 [[ "$#" != 1 ]] && { echo "usage: $0  FILE_TO_PREPROCESS" >&2; exit 1; }
 [[ -e "$(hg root)/lib/pa_variants_conv/pa_variants_conv.cmo" ]] \

build-and-install

+#!/usr/bin/env bash
+set -u -o pipefail
+
+function usage {
+    echo "usage: ${BASH_SOURCE[0]} [-j <JOBS>] [tree]"
+    echo "         -h, --help       Display this help"
+    echo "         -j N             Run at most N jobs in parallel"
+    echo "         -u               Don't install, uninstall"
+}
+
+configflags="
+ enable-linux
+disable-linux
+ enable-posix-timers
+disable-posix-timers
+"
+
+opts=
+if getopt -V | grep -q enhanced; then
+  opts=$(getopt -n ${BASH_SOURCE[0]} -o "j:uh" \
+                -l "jobs:,help,$(echo -n $configflags | tr ' ' ,)" -- "$@")
+else
+  opts=$(getopt "j:uh" $*)
+fi
+
+if [[ $? != 0 ]]; then usage; exit 1; fi
+
+set -e
+eval set -- "$opts"
+
+linuxflag=
+timerflag=
+makeflags=""
+configopts=( )
+uninstall=false
+while true; do
+    case "$1" in
+        -h|--help) usage; exit 0;;
+        -j|--jobs) makeflags="$makeflags -j $2";      shift 2;;
+        -u) uninstall=true; shift;;
+        --enable-linux)  linuxflag="--enable-linux";  shift  ;;
+        --disable-linux) linuxflag="--disable-linux"; shift  ;;
+        --enable-posix-timers)  timerflag="--enable-posix-timers";  shift ;;
+        --disable-posix-timers) timerflag="--disable-posix-timers"; shift ;;
+        --) shift; break ;;
+         *) configopts+=( "$1" )
+    esac
+done
+
+tree=""
+case $# in
+    0) tree="."  ;;
+    1) tree="$1" ;;
+    *) 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
+"
+
+if $uninstall; then
+  libraries=$(echo "$libraries" | tac)
+fi
+
+cd "$tree"
+for dir in $libraries; do
+  echo "------ base/$dir ------"
+  pushd base/$dir
+  optflags=
+  
+  if $uninstall; then
+    make uninstall || true
+    popd; continue
+  fi
+  
+  case $dir in
+      core|core/extended) optflags="$linuxflag $timerflag" ;;
+      async/scheduler)    optflags="$linuxflag" ;;
+      async) # horrible hack (avoids rebuilding async_{core,scheduler,extra})
+          src=$(pwd)
+          dest=$(mktemp -d -t ocaml-core-async.XXXXXX)
+          mkdir -p "$dest/base/async"
+          cp -rp ../../build-common.sh "$dest/"
+          cp -rp lib oasis.sh "$dest/base/async/"
+          cd $dest/base/async
+          trap "rm -r '$dest'" EXIT
+          ;;
+  esac
+  ./oasis.sh $optflags "${configopts[@]:+${configopts[@]}}"
+  make build BUILDFLAGS="$makeflags"
+  make install || true
+
+  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"/
+      ;;
+  esac
+  popd
+
+done
+#!/bin/bash
+
+function my_join {
+    sep=","
+    if [[ $# -gt 0 ]]; then sep="$1"; fi
+    local cursep=
+    while read line; do
+        echo -n "$cursep"
+        cursep="$sep"
+        echo -n "$line"
+    done
+    echo
+}
+
+function capitalize {
+    local j="$1"
+    echo -n "${j:0:1}" | tr "[:lower:]" "[:upper:]"; echo ${j:1}
+}
+
+function mod_names {
+    while read line; do
+        bname=$(basename "$line")
+        j=${bname%%.ml*};
+        if [[ "$j" == "inline_tests_runner" ]]; then continue; fi
+        capitalize "$j"
+    done
+}
+
+function make_tags {
+    cat >"$1" <<EOF
+# OASIS_START
+# OASIS_STOP
+EOF
+    cat >>"$1"
+}
+
+function tag_for_pack {
+    local libname=$(capitalize "$1")
+    shift
+    for ml in "$@"; do
+        local dir=$(dirname "$ml" | sed -e 's_^\./__')
+        local bname=$(basename "$ml")
+        echo "\"${dir}/${bname%%.ml*}.cmx\": for-pack($libname)"
+        echo "\"${dir}/$(capitalize ${bname%%.ml*}).cmx\": for-pack($libname)"
+    done
+}
+
+function enable_pack_in_setup_ml {
+    # if this is not the patched version of oasis, we need to patch it.
+    if ! grep -q lib_pack setup.ml; then
+	patch -l -p1 <<EOF
+--- a/setup.ml	2012-01-26 09:04:49.000000000 +0000
++++ b/setup.ml	2012-01-26 09:25:06.000000000 +0000
+@@ -992,6 +992,7 @@
+   type library =
+       {
+         lib_modules:            string list;
++        lib_pack:               bool;
+         lib_internal_modules:   string list;
+         lib_findlib_parent:     findlib_name option;
+         lib_findlib_name:       findlib_name option;
+@@ -1285,6 +1286,7 @@
+         source_file_exists is_native ext_lib ext_dll =
+     (* The headers that should be compiled along *)
+     let headers =
++      if lib.lib_pack then [] else
+       List.fold_left
+         (fun hdrs modul ->
+            try
+@@ -1323,11 +1325,18 @@
+
+     (* Compute what libraries should be built *)
+     let acc_nopath =
++      (* Add the packed header file if required *)
++      let add_pack_header acc =
++        if lib.lib_pack then
++          [cs.cs_name^".cmi"] :: acc
++        else
++          acc
++      in
+       let byte acc =
+-        [cs.cs_name^".cma"] :: acc
++        add_pack_header ([cs.cs_name^".cma"] :: acc)
+       in
+       let native acc =
+-        [cs.cs_name^".cmxa"] :: [cs.cs_name^(ext_lib ())] :: acc
++        add_pack_header ([cs.cs_name^".cmxa"] :: [cs.cs_name^(ext_lib ())] :: acc)
+       in
+         match bs.bs_compiled_object with
+           | Native ->
+@@ -4261,6 +4270,7 @@
+                 List.rev_append lib_extra acc
+               in
+               let acc =
++                if lib.lib_pack then acc else
+                 (* Add uncompiled header from the source tree *)
+                 let path =
+                   BaseFilePath.of_unix bs.bs_path
+
+EOF
+	awk -f - setup.ml > setup.ml.pack <<EOF
+{ if (match(\$0, /lib_internal_modules =/)) { print "lib_pack = false;"; }
+  print \$0; }
+EOF
+	mv setup.ml.pack setup.ml
+    fi
+    awk -f - setup.ml > setup.ml.pack <<EOF
+BEGIN                      { next_pack=0; skipnext=0; }
+/cs_name/                  { next_pack=0; }
+/cs_name = "$1"/           { next_pack=1; }
+/lib_pack = (true|false);/ { if (next_pack) {
+                               print "lib_pack = true;"
+                               skipnext=1
+                             }
+                           }
+/.*/                       { if (!skipnext) { print \$0; }
+                             skipnext=0; }
+EOF
+    mv setup.ml.pack setup.ml
+    for dir in $(find . -name "$1".mllib -exec dirname \{\} \;); do
+        mv "$dir"/"$1".mllib "$dir"/"$1".mlpack
+    done
+}
+
+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
+
+    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
+}
+
+function getconf_or_zero {
+    local ret=$(getconf "$@" 2>/dev/null)
+    case "$ret" in
+	[0-9][0-9]*) echo "$ret" ;;
+	*) echo 0 ;;
+    esac
+}
+
+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")
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.