-
Notifications
You must be signed in to change notification settings - Fork 118
/
build_distro.sh
executable file
·79 lines (59 loc) · 2.3 KB
/
build_distro.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
#!/bin/bash
set -xe
echo Building DDlog distribution.
echo IMPORTANT: this script must be run in a clean copy of the DDlog source tree.
if [ -z ${DIST_NAME} ]
then
DIST_NAME=ddlog
fi
# Directory for distribution files.
DIST_DIR=ddlog
rm -rf "$DIST_DIR"
# Step 1: Build DDlog binaries.
mkdir -p "$DIST_DIR/bin"
stack install --no-terminal --local-bin-path "$DIST_DIR/bin"
# Step 2: Add DDlog standard libraries to the distribution.
cp -r lib "$DIST_DIR/"
# Step 3: Include Rust dependencies for offline build.
# We don't have space for this on the Windows runner.
if [ "$RUNNER_OS" != "Windows" ] ; then
cd rust/template
# In addition to dependencies specified in `Cargo.toml`, add dependencies from
# all `.toml` filesin the lib directory.
cat Cargo.toml ../../lib/*.toml > Cargo.full.toml
# Backup original `Cargo.toml`.
mv Cargo.toml Cargo.toml.bak
cp Cargo.full.toml Cargo.toml
# Set relative path to vendor directory in `.cargo/config`
cargo vendor -s Cargo.toml > config.tmp
# Restore `Cargo.toml`.
mv Cargo.toml.bak Cargo.toml
# The last line of config.tmp contains absolute path to the `vendor` directory,
# which we don't want, so chop it off.
if [ `uname -s` = Darwin ]; then ghead -n -1 config.tmp > config; else head -n -1 config.tmp > config; fi
# Use relative path instead.
echo "directory = \"vendor\"" >> config
# Move instead of copying, as we are running out of space
# in the Github actions container.
mv vendor "../../$DIST_DIR/"
mkdir "../../$DIST_DIR/.cargo"
cp config "../../$DIST_DIR/.cargo/"
cd ../../
cp Cargo.lock "$DIST_DIR/"
fi
# Step 4: Add DDlog Java libraries.
# First copy Java sources only, then build and copy the .jar.
cp -r java "$DIST_DIR/"
cd java
# Run `make clean` first in case the directory contains class files created by a
# different version of Java.
CLASSPATH=. make clean all
cd ..
cp java/ddlogapi.jar "$DIST_DIR/java/"
cp java/ddlogapi_DDlogAPI.h "$DIST_DIR/java/"
cp java/ddlogapi_DDlogAPI_DDlogCommandVector.h "$DIST_DIR/java/"
cp -r doc "$DIST_DIR/"
# Step 5: Archive everything.
tar -czf "$DIST_NAME.tar.gz" "$DIST_DIR"
echo Distribution archive generated in $DIST_NAME.tar.gz
echo 'To install DDlog, extract the archive to your chosen installation directory and add ddlog/bin to $PATH.'