forked from mirage/mirage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathassemble.sh
executable file
·85 lines (78 loc) · 2.31 KB
/
assemble.sh
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
#!/bin/bash -e
#
# 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)
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 kernel/libxen.a kernel/libxencaml.a 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,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,cmx,cmxa,a,o,cmo} ${OBJ}/lib/
}
function assemble_node {
mode=$1
echo Assembling: node $1
OBJ=${BUILDDIR}/node-$1
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/*.{cma,cmi,cmo} ${OBJ}/
}
function assemble_scripts {
echo Assembling: scripts
OBJ=${BUILDDIR}/scripts
mkdir -p ${OBJ}
cp ${ROOT}/scripts/myocamlbuild.ml ${OBJ}/
}
assemble_syntax
assemble_xen
assemble_unix "direct"
assemble_unix "socket"
assemble_node "socket"
assemble_scripts