-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbuild_prod.sh
executable file
·123 lines (101 loc) · 3.23 KB
/
build_prod.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/usr/bin/env bash
set -x
CACHE_DIR="node_modules"
function check_error {
EXIT_CODE="$@"
if [ $EXIT_CODE -ne 0 ]; then
echo "Exit check failed: $EXIT_CODE"
exit $EXIT_CODE
fi
}
function do_webpack {
# sysconfcpus workaround: https://github.com/elm-lang/elm-compiler/issues/1473
if [ -e $HOME/bin/sysconfcpus ]; then
$HOME/bin/sysconfcpus -n 1 webpack "$@" 2>&1
check_error $?
echo "sysconfcpus -n 1 build succeeeded"
else
echo "sysconfcpus failed, falling back to regular build"
webpack "$@" 2>&1
check_error $?
fi
}
if [ $INSTALL_WEBPACK ]; then
echo "##> Installing webpack..."
npm install -g webpack
echo "##> Installed webpack."
fi
# detect netlify (or other ci)
if [ $REPOSITORY_URL ]; then
echo "DETECTED CI OR NETLIFY"
echo ""
# # prep for netlify cache stuff
# echo "Restoring .cache at $CACHE_DIR/.cache: \n`ls $CACHE_DIR/.cache`\n"
# cp -a $CACHE_DIR/.cache .cache || true
#
# # get cached elm stuff
# mkdir -p .cache
# cp -a .cache/elm-stuff elm-stuff || true
#
# # print cache directory
# echo "Cache Directory before build:\n"
# ls -al .cache
# echo ""
if [ ! -e $HOME/bin/sysconfcpus ]; then
echo "Trying to get a version of sysconfcpus..."
git clone https://github.com/obmarg/libsysconfcpus.git
cd libsysconfcpus
./configure --prefix=$HOME
echo "prefix used: $HOME"
make install
cd ..
echo "ls $HOME\n"
ls $HOME
echo "ls $HOME/bin\n"
ls $HOME/bin
echo "done ls $HOME\n"
echo "\"Installed\" sysconfcpus"
fi
# # prepping build by precompiling purs and elm
# echo "Compiling purescirpt"
# # using yarn run bc we got a weird error from netlify about not finding `purs` once
# $HOME/bin/sysconfcpus -n 1 yarn run pulp build -j 1 # build all deps we've downloaded
# check_error $?
# echo "Compiling elm"
# yarn run elm-make web/src/SecureVote/SPAs/SwarmMVP/Main.elm --output temp-32489734985.html 2>&1 # compile elm
# check_error $?
echo "Manually installing elm - yarn seems to miss it..."
npm install elm
echo "Elm installed"
# ls node_modules/elm/
# ls node_modules/elm/Elm-Platform/
# ls node_modules/elm/Elm-Platform/0.18.0/
# ls node_modules/elm/Elm-Platform/0.18.0/.cabal-sandbox/
ls node_modules/elm/Elm-Platform/0.18.0/.cabal-sandbox/bin/
# bit drastic - try to avoid netlify's CI thinking we can't compile due to elm-web3
# rm node_modules/elm/Elm-Platform/0.18.0/.cabal-sandbox/bin/elm-package
# $HOME/bin/sysconfcpus -n 1 yarn run elm-install install
$HOME/bin/sysconfcpus -n 1 yarn run elm-package
check_error $?
# do build
echo "Building now..."
time do_webpack "$@"
check_error $?
echo "Build Complete"
# # save in cache
# echo "Caching elm stuff"
# rm -rf .cache/elm-stuff || true
# cp -a elm-stuff .cache/elm-stuff
#
# # print cache directory
# echo "Cache Directory after build: (ls -al .cache)\n"
# ls -al .cache
# echo ""
#
# # save netlify cache
# cp -a .cache $CACHE_DIR/.cache
# echo "Saved .cache to $CACHE_DIR/.cache: \n`ls $CACHE_DIR/.cache`\n"
else
do_webpack
check_error $?
fi