/
compile
executable file
·75 lines (54 loc) · 1.93 KB
/
compile
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
#!/usr/bin/env bash
# bin/compile <build-dir> <cache-dir>
# fail fast
set -e
#set -x
unset GIT_DIR
mkdir -p "$1" "$2"
BUILD_DIR=$(cd "$1/" && pwd)
CACHE_DIR=$(cd "$2/" && pwd)
# this variable is used by pub to determine the package install location
PUB_CACHE="/app/pub-cache"
export PUB_CACHE
mkdir -p $PUB_CACHE
function message {
echo "$1"
sync
}
MACHINE=`uname -a`
message "-----> Welcome, this machine is: $MACHINE"
if [ -z "$DART_SDK_URL" ]; then
message "ERROR: you must specify DART_SDK_URL to a Dart SDK for Linux. See README for this buildpack."
exit 1
fi
cd $BUILD_DIR
message "-----> Installing Dart VM via URL $DART_SDK_URL"
cd $CACHE_DIR
curl -L $DART_SDK_URL -o - | tar xzf -
message "-----> Copy Dart binaries to app root"
cp -r $CACHE_DIR/dart-sdk $BUILD_DIR
# we need to copy the sdk into the /app folder in order for the sdk libraries
# to be referenced correctly
# reason being that the /tmp folder will be deleted after build, and /app
# resembles the location of the ready built app
cp -r $CACHE_DIR/dart-sdk /app
DART_BIN=`ls -l /app/dart-sdk/bin/dart`
message "-----> Dart cmd found at $DART_BIN"
CAN_DART_RUN=`/app/dart-sdk/bin/dart --version`
message "-----> Dart reports version: $CAN_DART_RUN"
cd $BUILD_DIR
for filename in `find . -name pubspec.yaml | grep -v dart-sdk | grep -v pub-cache`; do
pub_dir=`dirname $filename`
message "*** Found pubspec.yaml in $BUILD_DIR/$pub_dir"
cd $BUILD_DIR/$pub_dir
message "*** Running pub get"
#start pub from the /app folder to have correct symlink paths
/app/dart-sdk/bin/pub get
message "*** Running pub build"
/app/dart-sdk/bin/pub build
done
# I think heroku deletes all the contents of /app and replaces it with
# whatever is in $BUILD_DIR, so copy over the pub-cache. Why not put it in
# $BUILD_DIR in the first place? because we need symlinks setup correctly.
cp -R $PUB_CACHE $BUILD_DIR/pub-cache
message `ls -l $BUILD_DIR/pub-cache`