Source code

Revision control

Other Tools

1
#!/bin/bash
2
3
# Find out ASAP if some command breaks here, because we're copying a lot of
4
# files we don't actually maintain ourselves, and requirements could easily be
5
# broken.
6
set -e
7
8
: ${MKDIR:=mkdir}
9
: ${TAR:=tar}
10
: ${AUTOCONF:=$(which autoconf-2.13 autoconf2.13 | head -1)}
11
: ${SRCDIR:=$(cd $(dirname $0); pwd 2>/dev/null)}
12
: ${MOZJS_NAME:=mozjs}
13
# The place to gather files to be added to the tarball.
14
: ${STAGING:=/tmp/mozjs-src-pkg}
15
# The place to put the resulting tarball.
16
: ${DIST:=/tmp}
17
18
if [[ -f "$SRCDIR/../../config/milestone.txt" ]]; then
19
MILESTONE="$(tail -1 $SRCDIR/../../config/milestone.txt)"
20
IFS=. read -a VERSION < <(echo "$MILESTONE")
21
MOZJS_MAJOR_VERSION=${MOZJS_MAJOR_VERSION:-${VERSION[0]}}
22
MOZJS_MINOR_VERSION=${MOZJS_MINOR_VERSION:-${VERSION[1]}}
23
MOZJS_PATCH_VERSION=${MOZJS_PATCH_VERSION:-${VERSION[2]}}
24
fi
25
26
cmd=${1:-build}
27
version="${MOZJS_NAME}-${MOZJS_MAJOR_VERSION}.${MOZJS_MINOR_VERSION}.${MOZJS_PATCH_VERSION:-${MOZJS_ALPHA:-0}}"
28
tgtpath=${STAGING}/${version}
29
pkg="${version}.tar.bz2"
30
pkgpath="${DIST}/${pkg}"
31
taropts="-jcf"
32
33
# need these environment vars:
34
echo "Environment:"
35
echo " MAKE = $MAKE"
36
echo " MKDIR = $MKDIR"
37
echo " TAR = $TAR"
38
echo " AUTOCONF = $AUTOCONF"
39
echo " STAGING = $STAGING"
40
echo " DIST = $DIST"
41
echo " SRCDIR = $SRCDIR"
42
echo " MOZJS_NAME = $MOZJS_NAME"
43
echo " MOZJS_MAJOR_VERSION = $MOZJS_MAJOR_VERSION"
44
echo " MOZJS_MINOR_VERSION = $MOZJS_MINOR_VERSION"
45
echo " MOZJS_PATCH_VERSION = $MOZJS_PATCH_VERSION"
46
echo " MOZJS_ALPHA = $MOZJS_ALPHA"
47
echo ""
48
49
TOPSRCDIR=${SRCDIR}/../..
50
51
case $cmd in
52
"clean")
53
echo "Cleaning ${pkgpath} and ${tgtpath} ..."
54
rm -rf ${pkgpath} ${tgtpath}
55
;;
56
"build")
57
# Make sure that everything copied here is kept in sync with
58
# `testing/taskcluster/tasks/branches/base_jobs.yml`!
59
60
if [ -e ${tgtpath}/js/src/Makefile ]; then
61
echo "error: found js/src/Makefile. Please clean before packaging." >&2
62
exit 1
63
fi
64
65
echo "Staging source tarball in ${tgtpath}..."
66
if [ -d ${tgtpath} ]; then
67
echo "WARNING - dist tree ${tgtpath} already exists!"
68
fi
69
70
${MKDIR} -p ${tgtpath}
71
72
# Top-level config and build files
73
cp -pPR \
74
${TOPSRCDIR}/LICENSE \
75
${TOPSRCDIR}/Makefile.in \
76
${TOPSRCDIR}/configure.py \
77
${TOPSRCDIR}/moz.build \
78
${TOPSRCDIR}/moz.configure \
79
${TOPSRCDIR}/test.mozbuild \
80
${tgtpath}/
81
82
# Additional libraries (optionally) used by SpiderMonkey
83
cp -pPR \
84
${TOPSRCDIR}/mfbt \
85
${TOPSRCDIR}/nsprpub \
86
${tgtpath}/
87
88
${MKDIR} -p ${tgtpath}/intl
89
cp -pPR \
90
${TOPSRCDIR}/intl/icu \
91
${tgtpath}/intl/
92
93
${MKDIR} -p ${tgtpath}/memory
94
cp -pPR \
95
${TOPSRCDIR}/memory/moz.build \
96
${TOPSRCDIR}/memory/build \
97
${TOPSRCDIR}/memory/mozalloc \
98
${tgtpath}/memory/
99
100
${MKDIR} -p ${tgtpath}/modules
101
cp -pPR \
102
${TOPSRCDIR}/modules/fdlibm \
103
${TOPSRCDIR}/modules/zlib \
104
${tgtpath}/modules/
105
106
${MKDIR} -p ${tgtpath}/mozglue
107
cp -pPR \
108
${TOPSRCDIR}/mozglue/baseprofiler \
109
${TOPSRCDIR}/mozglue/build \
110
${TOPSRCDIR}/mozglue/misc \
111
${TOPSRCDIR}/mozglue/moz.build \
112
${TOPSRCDIR}/mozglue/static \
113
${tgtpath}/mozglue/
114
115
${MKDIR} -p ${tgtpath}/tools/fuzzing
116
cp -pPR \
117
${TOPSRCDIR}/tools/fuzzing/moz.build \
118
${TOPSRCDIR}/tools/fuzzing/interface \
119
${TOPSRCDIR}/tools/fuzzing/registry \
120
${TOPSRCDIR}/tools/fuzzing/libfuzzer \
121
${tgtpath}/tools/fuzzing/
122
123
124
# Build system and dependencies
125
cp -pPR \
126
${TOPSRCDIR}/build \
127
${TOPSRCDIR}/config \
128
${TOPSRCDIR}/python \
129
${tgtpath}/
130
131
${MKDIR} -p ${tgtpath}/.cargo
132
cp -pPR \
133
${TOPSRCDIR}/.cargo/config.in \
134
${tgtpath}/.cargo/
135
136
${MKDIR} -p ${tgtpath}/third_party
137
cp -pPR \
138
${TOPSRCDIR}/third_party/python \
139
${TOPSRCDIR}/third_party/rust \
140
${tgtpath}/third_party/
141
142
${MKDIR} -p ${tgtpath}/dom/bindings
143
cp -pPR \
144
${TOPSRCDIR}/dom/bindings/mozwebidlcodegen \
145
${tgtpath}/dom/bindings/
146
147
${MKDIR} -p ${tgtpath}/layout/tools/reftest
148
cp -pPR \
149
${TOPSRCDIR}/layout/tools/reftest/reftest \
150
${tgtpath}/layout/tools/reftest/
151
152
${MKDIR} -p ${tgtpath}/testing
153
cp -pPR \
154
${TOPSRCDIR}/testing/mozbase \
155
${tgtpath}/testing/
156
157
${MKDIR} -p ${tgtpath}/testing/web-platform/tests
158
cp -pPR \
159
${TOPSRCDIR}/testing/web-platform/tests/streams \
160
${tgtpath}/testing/web-platform/tests/
161
162
${MKDIR} -p ${tgtpath}/taskcluster/taskgraph
163
cp -pPR \
164
${TOPSRCDIR}/taskcluster/moz.build \
165
${tgtpath}/taskcluster/
166
cp -pPR \
167
${TOPSRCDIR}/taskcluster/taskgraph/test \
168
${tgtpath}/taskcluster/taskgraph/
169
170
${MKDIR} -p ${tgtpath}/toolkit/crashreporter/tools
171
cp -pPR \
172
${TOPSRCDIR}/toolkit/crashreporter/tools/symbolstore.py \
173
${tgtpath}/toolkit/crashreporter/tools/
174
175
${MKDIR} -p ${tgtpath}/toolkit/mozapps/installer
176
cp -pPR \
177
${TOPSRCDIR}/toolkit/mozapps/installer/package-name.mk \
178
${TOPSRCDIR}/toolkit/mozapps/installer/upload-files.mk \
179
${tgtpath}/toolkit/mozapps/installer/
180
181
182
# SpiderMonkey itself
183
184
${MKDIR} -p ${tgtpath}/js/src
185
cp -pPR \
186
${TOPSRCDIR}/js/app.mozbuild \
187
${TOPSRCDIR}/js/*.configure \
188
${tgtpath}/js/
189
cp -pPR \
190
${TOPSRCDIR}/js/examples \
191
${TOPSRCDIR}/js/public \
192
${TOPSRCDIR}/js/rust \
193
${tgtpath}/js/
194
195
find ${TOPSRCDIR}/js/src -mindepth 1 -maxdepth 1 -not -path ${STAGING} -a -not -name ${pkg} \
196
-exec cp -pPR {} ${tgtpath}/js/src/ \;
197
198
199
# Generate configure files to avoid build dependency on autoconf-2.13
200
cp -pPR ${TOPSRCDIR}/js/src/configure.in ${tgtpath}/js/src/configure
201
chmod a+x ${tgtpath}/js/src/configure
202
${AUTOCONF} --localdir=${TOPSRCDIR}/js/src \
203
${TOPSRCDIR}/js/src/old-configure.in >${tgtpath}/js/src/old-configure
204
205
# Copy or create INSTALL
206
if [ -e ${STAGING}/INSTALL ]; then
207
cp ${STAGING}/INSTALL ${tgtpath}/
208
else
209
cat <<INSTALL_EOF >${tgtpath}/INSTALL
210
Full build documentation for SpiderMonkey is hosted on MDN:
212
213
Note that the libraries produced by the build system include symbols,
214
causing the binaries to be extremely large. It is highly suggested that \`strip\`
215
be run over the binaries before deploying them.
216
217
Building with default options may be performed as follows:
218
cd js/src
219
mkdir obj
220
cd obj
221
../configure
222
make # or mozmake on Windows
223
INSTALL_EOF
224
fi
225
226
# Copy or create README
227
if [ -e ${STAGING}/README ]; then
228
cp ${STAGING}/README ${tgtpath}/
229
else
230
cat <<README_EOF >${tgtpath}/README
231
This directory contains SpiderMonkey ${MOZJS_MAJOR_VERSION}.
232
233
This release is based on a revision of Mozilla ${MOZJS_MAJOR_VERSION}:
235
The changes in the patches/ directory were applied.
236
237
MDN hosts the latest SpiderMonkey ${MOZJS_MAJOR_VERSION} release notes:
239
README_EOF
240
fi
241
242
# Copy patches dir, if it currently exists in STAGING
243
if [ -d ${STAGING}/patches ]; then
244
cp -pPR ${STAGING}/patches ${tgtpath}/
245
elif [ -d ${TOPSRCDIR}/patches ]; then
246
cp -pPR ${TOPSRCDIR}/patches ${tgtpath}/
247
fi
248
249
# Remove *.pyc and *.pyo files if any
250
find ${tgtpath} -type f -name "*.pyc" -o -name "*.pyo" | xargs rm -f
251
252
# Remove non-JS Cargo.toml files (for example, the invalid Cargo.toml files
253
# used for some testing).
254
find ${tgtpath} -type f -name Cargo.toml | grep -v js | xargs rm -f
255
256
# Roll the tarball
257
echo "Packaging source tarball at ${pkgpath}..."
258
${TAR} $taropts ${pkgpath} -C ${STAGING} ${version}
259
;;
260
*)
261
echo "Unrecognized command: $cmd"
262
;;
263
esac