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
: ${RSYNC:=rsync}
11
: ${AUTOCONF:=$(which autoconf-2.13 autoconf2.13 autoconf213 | head -1)}
12
: ${SRCDIR:=$(cd $(dirname $0); pwd 2>/dev/null)}
13
: ${MOZJS_NAME:=mozjs}
14
# The place to gather files to be added to the tarball.
15
: ${STAGING:=/tmp/mozjs-src-pkg}
16
# The place to put the resulting tarball.
17
: ${DIST:=/tmp}
18
19
if [[ -f "$SRCDIR/../../config/milestone.txt" ]]; then
20
MILESTONE="$(tail -1 $SRCDIR/../../config/milestone.txt)"
21
IFS=. read -a VERSION < <(echo "$MILESTONE")
22
MOZJS_MAJOR_VERSION=${MOZJS_MAJOR_VERSION:-${VERSION[0]}}
23
MOZJS_MINOR_VERSION=${MOZJS_MINOR_VERSION:-${VERSION[1]}}
24
MOZJS_PATCH_VERSION=${MOZJS_PATCH_VERSION:-${VERSION[2]}}
25
fi
26
27
cmd=${1:-build}
28
version="${MOZJS_NAME}-${MOZJS_MAJOR_VERSION}.${MOZJS_MINOR_VERSION}.${MOZJS_PATCH_VERSION:-${MOZJS_ALPHA:-0}}"
29
tgtpath=${STAGING}/${version}
30
pkg="${version}.tar.bz2"
31
pkgpath="${DIST}/${pkg}"
32
taropts="-jcf"
33
34
# need these environment vars:
35
echo "Environment:"
36
echo " MAKE = $MAKE"
37
echo " MKDIR = $MKDIR"
38
echo " TAR = $TAR"
39
echo " RSYNC = $RSYNC"
40
echo " AUTOCONF = $AUTOCONF"
41
echo " STAGING = $STAGING"
42
echo " DIST = $DIST"
43
echo " SRCDIR = $SRCDIR"
44
echo " MOZJS_NAME = $MOZJS_NAME"
45
echo " MOZJS_MAJOR_VERSION = $MOZJS_MAJOR_VERSION"
46
echo " MOZJS_MINOR_VERSION = $MOZJS_MINOR_VERSION"
47
echo " MOZJS_PATCH_VERSION = $MOZJS_PATCH_VERSION"
48
echo " MOZJS_ALPHA = $MOZJS_ALPHA"
49
echo ""
50
51
TOPSRCDIR=${SRCDIR}/../..
52
53
case $cmd in
54
"clean")
55
echo "Cleaning ${pkgpath} and ${tgtpath} ..."
56
rm -rf ${pkgpath} ${tgtpath}
57
;;
58
"build")
59
# Make sure that everything copied here is kept in sync with
60
# `taskcluster/ci/spidermonkey/kind.yml`!
61
62
if [ -e ${tgtpath}/js/src/Makefile ]; then
63
echo "error: found js/src/Makefile. Please clean before packaging." >&2
64
exit 1
65
fi
66
67
echo "Staging source tarball in ${tgtpath}..."
68
if [ -d ${tgtpath} ]; then
69
echo "WARNING - dist tree ${tgtpath} already exists!"
70
fi
71
72
${MKDIR} -p ${tgtpath}
73
74
rsync \
75
--delete-excluded \
76
--prune-empty-dirs \
77
--quiet \
78
--recursive \
79
"${TOPSRCDIR}"/ ${tgtpath}/ \
80
--filter=". -" <<FILTER_EOF
81
# Top-level config and build files
82
83
+ /configure.py
84
+ /LICENSE
85
+ /Makefile.in
86
+ /moz.build
87
+ /moz.configure
88
+ /test.mozbuild
89
90
# Additional libraries (optionally) used by SpiderMonkey
91
92
+ /mfbt/**
93
+ /nsprpub/**
94
95
- /intl/icu/source/data
96
- /intl/icu/source/test
97
- /intl/icu/source/tools
98
+ /intl/icu/**
99
100
+ /memory/build/**
101
+ /memory/moz.build
102
+ /memory/mozalloc/**
103
104
+ /modules/fdlibm/**
105
+ /modules/zlib/**
106
107
+ /mozglue/baseprofiler/**
108
+ /mozglue/build/**
109
+ /mozglue/misc/**
110
+ /mozglue/moz.build
111
+ /mozglue/static/**
112
113
+ /tools/fuzzing/moz.build
114
+ /tools/fuzzing/interface/**
115
+ /tools/fuzzing/registry/**
116
+ /tools/fuzzing/libfuzzer/**
117
118
# Build system and dependencies
119
120
+ /build/**
121
+ /config/**
122
+ /python/**
123
124
+ /.cargo/config.in
125
126
- /third_party/python/gyp
127
+ /third_party/python/**
128
+ /third_party/rust/**
129
130
+ /layout/tools/reftest/reftest/**
131
132
+ /testing/mozbase/**
133
+ /testing/web-platform/tests/streams/**
134
135
+ /toolkit/crashreporter/tools/symbolstore.py
136
+ /toolkit/mozapps/installer/package-name.mk
137
138
# SpiderMonkey itself
139
140
+ /js/src/**
141
+ /js/app.mozbuild
142
+ /js/*.configure
143
+ /js/examples/**
144
+ /js/public/**
145
+ /js/rust/**
146
147
+ */
148
- /**
149
FILTER_EOF
150
151
# Generate configure files to avoid build dependency on autoconf-2.13
152
cp -pPR ${TOPSRCDIR}/js/src/configure.in ${tgtpath}/js/src/configure
153
chmod a+x ${tgtpath}/js/src/configure
154
${AUTOCONF} --localdir=${TOPSRCDIR}/js/src \
155
${TOPSRCDIR}/js/src/old-configure.in >${tgtpath}/js/src/old-configure
156
157
# Copy or create INSTALL
158
if [ -e ${STAGING}/INSTALL ]; then
159
cp ${STAGING}/INSTALL ${tgtpath}/
160
else
161
cat <<INSTALL_EOF >${tgtpath}/INSTALL
162
Full build documentation for SpiderMonkey is hosted on MDN:
164
165
Note that the libraries produced by the build system include symbols,
166
causing the binaries to be extremely large. It is highly suggested that \`strip\`
167
be run over the binaries before deploying them.
168
169
Building with default options may be performed as follows:
170
cd js/src
171
mkdir obj
172
cd obj
173
../configure
174
make # or mozmake on Windows
175
INSTALL_EOF
176
fi
177
178
# Copy or create README
179
if [ -e ${STAGING}/README ]; then
180
cp ${STAGING}/README ${tgtpath}/
181
else
182
cat <<README_EOF >${tgtpath}/README
183
This directory contains SpiderMonkey ${MOZJS_MAJOR_VERSION}.
184
185
This release is based on a revision of Mozilla ${MOZJS_MAJOR_VERSION}:
187
The changes in the patches/ directory were applied.
188
189
MDN hosts the latest SpiderMonkey ${MOZJS_MAJOR_VERSION} release notes:
191
README_EOF
192
fi
193
194
# Copy patches dir, if it currently exists in STAGING
195
if [ -d ${STAGING}/patches ]; then
196
cp -pPR ${STAGING}/patches ${tgtpath}/
197
elif [ -d ${TOPSRCDIR}/patches ]; then
198
cp -pPR ${TOPSRCDIR}/patches ${tgtpath}/
199
fi
200
201
# Remove *.pyc and *.pyo files if any
202
find ${tgtpath} -type f -name "*.pyc" -o -name "*.pyo" | xargs rm -f
203
204
# Roll the tarball
205
echo "Packaging source tarball at ${pkgpath}..."
206
${TAR} $taropts ${pkgpath} -C ${STAGING} ${version}
207
;;
208
*)
209
echo "Unrecognized command: $cmd"
210
;;
211
esac