sulu-ocaml-core / base / core / extended / oasis.sh

#!/usr/bin/env bash
set -e -u -o pipefail

source ../../../build-common.sh

cat >$HERE/_oasis <<EOF
#AUTOGENERATED FILE; EDIT oasis.sh INSTEAD

OASISFormat:  0.3
OCamlVersion: >= 3.12
Name:         core_extended
Version:      $core_version
Synopsis:     Jane Street Capital's standard library overlay
Authors:      Jane street capital
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
XStdFilesAUTHORS: false
XStdFilesINSTALLFilename: INSTALL
XStdFilesREADME: false

Flag linux
  Description: Enable linux specific extensions
  Default\$:   false   # actually, the default is detected

Flag "posix-timers"
  Description: Enable POSIX timers
  Default\$:   false   # actually, the default is detected

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:            $(list_mods  "$HERE/lib")
  CSources:           $(list_stubs "$HERE/lib"),config.h
  CCOpt+:             -Ilib
  BuildDepends:       sexplib.syntax,
                      sexplib,
                      fieldslib.syntax,
                      fieldslib,
                      bin_prot,
                      bin_prot.syntax,
                      pa_ounit,
                      pa_pipebang,
                      core,
                      bigarray,
                      pcre,
                      res,
                      unix,
                      threads

Executable core_extended_hello
  Path:               lib_test
  MainIs:             core_extended_hello.ml
  Build\$:            flag(tests)
  Custom:             true
  CompiledObject:     best
  Install:            false
  BuildDepends:       core_extended

Executable core_hello
  Path:               lib_test
  MainIs:             core_hello.ml
  Build\$:            flag(tests)
  Custom:             true
  CompiledObject:     best
  Install:            false
  BuildDepends:       core,threads

Executable test_runner
  Path:               lib_test
  MainIs:             test_runner.ml
  Build\$:            flag(tests)
  Custom:             true
  CompiledObject:     best
  Install:            false
  BuildDepends:       core_extended,oUnit (>= 1.1.0),threads

Test test_runner
  Run\$:              flag(tests)
  Command:            \$test_runner --core-hello \$core_hello --core-extended-hello \$core_extended_hello
  WorkingDirectory:   lib_test
  TestTools:          core_hello,core_extended_hello

Document "core-extended"
  Title:                Jane street's core extended library
  Type:                 ocamlbuild (0.3)
  BuildTools+:          ocamldoc
  XOCamlbuildPath:      lib
  XOCamlbuildLibraries: core_extended

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

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
$useful_ocaml_functions

let dispatch = function
  | After_rules as e ->

    dep  ["ocaml"; "ocamldep"; "mlh"] (select_files "lib/" ".mlh");

    flag ["mlh"; "ocaml"; "ocamldep"] (S[A"-ppopt"; A"-Ilib/"]);
    flag ["mlh"; "ocaml"; "compile"]  (S[A"-ppopt"; A"-Ilib/"]);

    begin match getconf "LFS64_CFLAGS" with
    | None -> ()
    | Some flags -> flag ["compile"; "c"] (S[A"-ccopt"; A flags])
    end;

    dispatch_default e
  | e -> dispatch_default e

let () = Ocamlbuild_plugin.dispatch dispatch
EOF

make_setup_ml "$HERE/setup.ml" <<EOF
$useful_ocaml_functions

let linux_possible = test "uname | grep -q -i linux"
let timers_possible =
  match getconf "_POSIX_TIMERS" with
  | None   -> false
  | Some x -> (try int_of_string x >= 200112 with _ -> 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
oasis setup
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.