@@ -0,0 +1,65 @@
1+{ stdenv, fetchurl, pkgconfig, perl, python, zip, libffi, readline }:
2+
3+stdenv.mkDerivation rec {
4+ version = "31.5.0";
5+ name = "spidermonkey-${version}";
6+
7+ # the release notes point to some guys home directory, see
8+ # https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/Releases/31
9+ # probably it would be more ideal to pull a particular tag/revision
10+ # from the mercurial repo
11+ src = fetchurl {
12+ url = "https://people.mozilla.org/~sstangl/mozjs-31.5.0.tar.bz2";
13+ sha256 = "1q8icql5hh1g3gzg5fp4rl9rfagyhm9gilfn3dgi7qn4i1mrfqsd";
14+ };
15+
16+ buildInputs = [ pkgconfig perl python zip libffi readline ];
17+
18+ postUnpack = "sourceRoot=\${sourceRoot}/js/src";
19+
20+ preConfigure = ''
21+ export LIBXUL_DIST=$out
22+ '';
23+
24+ configureFlags = [
25+ "--enable-threadsafe"
26+ "--with-system-ffi"
27+ "--enable-readline"
28+
29+ # there is at least one unfixed issue building the tests, so I didn't bother
30+ "--disable-tests"
31+
32+ # enabling these because they're wanted by 0ad. They may or may
33+ # not be good defaults for other uses.
34+ "--enable-gcgenerational"
35+ "--enable-shared-js"
36+
37+ # Due to a build-system bug, this means the exact opposite of what it says.
38+ # It is required by gcgenerational.
39+ "--disable-exact-rooting"
40+ ];
41+
42+ # This addresses some build system bug. It's quite likely to be safe
43+ # to re-enable parallel builds if the source revision changes.
44+ enableParallelBuilding = false;
45+
46+ # see comment by --disable-tests
47+ doCheck = false;
48+
49+ postFixup = ''
50+ # The headers are symlinks to a directory that doesn't get put
51+ # into $out, so they end up broken. Fix that by just resolving the
52+ # symlinks.
53+ for i in $(find $out -type l); do
54+ cp --remove-destination "$(readlink "$i")" "$i";
55+ done
56+ '';
57+
58+ meta = with stdenv.lib; {
59+ description = "Mozilla's JavaScript engine written in C/C++";
60+ homepage = https://developer.mozilla.org/en/SpiderMonkey;
61+ # TODO: MPL/GPL/LGPL tri-license.
62+
63+ maintainers = [ maintainers.goibhniu ];
64+ };
65+}