Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

executable file 99 lines (90 sloc) 2.852 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
#!/usr/bin/env bash
#
# Assemble a bunch of standard library kernels for the
# various OS configurations:
#
# xen: direct microkernel
# unix_direct: UNIX tun/tap with ML net stack
# unix_socket: UNIX with kernel sockets and no access to lower layers
# node: node.js backend
#
# These all end up with a set of packed OCaml modules in one directory
# that can be pointed to with -I for compilation against that "kernel".
#
# The myocamlbuild.ml in scripts/ understands the necessary runes to link
# against each of these backends (mainly the library dependencies)

set -e
ROOT=`pwd`
BUILDDIR=${ROOT}/_build

function assemble_xen {
  if [ -d ${ROOT}/lib/_build/xen ]; then
echo Assembling: Xen
    OBJ=${BUILDDIR}/xen
    mkdir -p ${OBJ}/lib ${OBJ}/syntax
    for i in dietlibc/libdiet.a libm/libm.a ocaml/libocaml.a ocaml/libocamlbc.a kernel/libxen.a kernel/libxencaml.a kernel/longjmp.o kernel/x86_64.o; do
cp ${ROOT}/lib/_build/xen/os/runtime_xen/$i ${OBJ}/lib/
    done
cp ${ROOT}/lib/os/runtime_xen/kernel/mirage-x86_64.lds ${OBJ}/lib/
    cp ${ROOT}/lib/_build/xen/std/*.{cmi,cmo,cma,cmx,a,o,cmxa} ${OBJ}/lib/
  else
echo Skipping: Xen
  fi
}

function assemble_unix {
  mode=$1
  echo Assembling: UNIX $1
  OBJ=${BUILDDIR}/unix-$1
  if [ ! -d ${ROOT}/lib/_build/unix-$1 ]; then
echo Must build unix-$1 first
    exit 1
  fi
mkdir -p ${OBJ}/lib
  for i in libunixrun.a main.o; do
cp ${ROOT}/lib/_build/unix-$1/os/runtime_unix/$i ${OBJ}/lib/
  done
cp ${ROOT}/lib/_build/unix-$1/std/*.{cmi,cma,cmx,cmxa,a,o,cmo} ${OBJ}/lib/
}

function assemble_node {
  mode=$1
  echo Assembling: node
  OBJ=${BUILDDIR}/node
  if [ -d ${ROOT}/lib/_build/node ]; then
mkdir -p ${OBJ}/lib
    for i in libos.a dllos.so; do
cp ${ROOT}/lib/_build/node/os/runtime_node/$i ${OBJ}/lib/
    done
cp ${ROOT}/lib/_build/node/std/*.{cmi,cmo,cma} ${OBJ}/lib/
    cp ${ROOT}/lib/os/runtime_node/*.js ${OBJ}/lib/
  else
echo Skipping: Node
  fi
}

function assemble_syntax {
  echo Assembling: camlp4 extensions
  OBJ=${BUILDDIR}/syntax
  mkdir -p ${OBJ}
  cp ${ROOT}/syntax/_build/*.{cmi,cmxs} ${OBJ}/
}

function assemble_scripts {
  echo Assembling: scripts
  OBJ=${BUILDDIR}/scripts
  mkdir -p ${OBJ}
  cp ${ROOT}/scripts/myocamlbuild.ml ${OBJ}/
}

function assemble_bin {
  echo Assembling: binaries
  OBJ=${BUILDDIR}/bin
  mkdir -p ${OBJ}
  sed -e "s,@MIRAGELIB@,${PREFIX},g" < ${ROOT}/scripts/mir-build > ${OBJ}/mir-build
  cp ${ROOT}/scripts/mir-run ${OBJ}/mir-run
  chmod 755 ${OBJ}/mir-build ${OBJ}/mir-run
  cp ${ROOT}/tools/crunch/_build/crunch.native ${OBJ}/mir-crunch
  cp ${ROOT}/tools/fs/mir-fs-create ${OBJ}/mir-fs-create
  cp ${ROOT}/scripts/mir-fat-create ${OBJ}/mir-fat-create
}

assemble_syntax
assemble_xen
assemble_unix "direct"
assemble_unix "socket"
assemble_scripts
assemble_bin
Something went wrong with that request. Please try again.