-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy pathpackage_drake.sh
48 lines (39 loc) · 1.44 KB
/
package_drake.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
#!/bin/bash
### Builds libdrake.so, and packages it with the required headers.
### @param1 the name of the output file, which should end in .tar.gz.
### After installing the package, OS X users may want to adjust the .so file's
### id to match its installed location, using install_name_tool -id.
# If any command in the script exits non-zero, stop.
set -e
mydir=`pwd`
outfile="$(cd "$(dirname "$1")" && pwd)/$(basename "$1")"
touch $outfile
cd $mydir
# Build Drake.
workspace=`bazel info workspace`
cd $workspace
bazel build //drake:libdrake.so //drake:libdrake_headers
# Copy off all the package artifacts into a temporary directory.
tmpdir=`mktemp -d`
mkdir -p $tmpdir/lib
mkdir -p $tmpdir/include/external/scratch
cp bazel-bin/drake/libdrake.so $tmpdir/lib
cp bazel-bin/drake/libdrake_headers.tar.gz $tmpdir/include/external/scratch
chmod -R 755 $tmpdir
# Un-tar the headers. The -P flag and scratch directory are necessary because
# Bazel bakes a .. into the paths of external headers.
cd $tmpdir/include/external/scratch
tar -xPzf libdrake_headers.tar.gz
# Headers from Drake proper are now inside include/external/scratch, while
# headers from externals are in external/scratch. Move the Drake headers up
# to include/drake.
mv drake $tmpdir/include
# Clean up the header tarball, and the scratch directory.
rm libdrake_headers.tar.gz
cd ..
rmdir scratch
# Make the package tarball.
cd $tmpdir
tar -czf "$outfile" ./*
# cd to where we started.
cd $mydir