我需要在我的工作机器上安装 Spidermonkey JS 引擎。我正在开发的项目有一个 jslint 脚本,需要 Spidermonkey 或类似的 js 二进制文件。我尝试从源代码编译Spidermonkey,但陷入了依赖地狱。我尝试从 ubuntu 存储库安装 rhino 软件包,结果发现速度很慢而且很损坏。今天早上,我按照此处的说明成功编译了 Google 的 V8 引擎并构建了 v8jslint:
http://blog.stevenreid.co.uk/2011/06/27/jslint-command-line-tool-powered-by-v8/
v8jslint 可以工作,但只会 lint 一个一次归档。例如,
$ v8jslint foo/*.js
如果我在 foo 下有 a.js、b.js 和 c.js,v8jslint 只会检查 a.js。简单修复:我可以为此编写一个 bash 脚本。一个更大的问题是 v8jslint 与我们构建服务器上的 Spidermonkey jslint 不兼容。有没有人在最新版本的 Ubuntu 上成功构建 Spidermonkey,或者知道一个好的解决方法?
I need to install the Spidermonkey JS engine on my work machine. The project I'm working on has a jslint script that requires Spidermonkey or a similar js binary. I've tried compiling Spidermonkey from source and gotten stuck in dependency hell. I tried installing the rhino package from the ubuntu repositories, and that turned out to be slow and broken. This morning, I successfully compiled Google's V8 engine and built v8jslint following the instructions here:
http://blog.stevenreid.co.uk/2011/06/27/jslint-command-line-tool-powered-by-v8/
v8jslint works, but will only lint one file at a time. For instance,
$ v8jslint foo/*.js
if I have a.js, b.js and c.js under foo, v8jslint will only lint a.js. Easy fix: I could write a bash script for this. A bigger problem is that v8jslint is not compatible with the Spidermonkey jslint on our build server. Has anyone had any success building Spidermonkey on a recent version of Ubuntu, or know a good workaround?
发布评论
评论(5)
你可以从源代码构建,但蜘蛛猴仍然可以在 ubuntu 上使用,它只是被重命名为“ libmozjs”。安装“libmozjs-24-bin”,然后将其称为“js24”或将 /usr/bin/js24 符号链接到“js”,如下所示:
You can build from source, but spider monkey is still available on ubuntu, it's just been renamed to "libmozjs". Install "libmozjs-24-bin" and then either refer to it as "js24" or symlink /usr/bin/js24 to "js", like so:
修好了。您需要“autoconf2.13”包。使用 apt-get 安装它。转至 Mozilla 上的 SpiderMonkey 源代码页面。找到 hg 存储库(链接如下)并下载 Mozilla 树的快照。不要克隆它,只需从顶部栏中获取 .tar.gz 或 .tar.bz2 格式的存档即可。
http://hg.mozilla.org/index.cgi/mozilla-central /file/tip
将存档和 cd 解压到根目录中。
这应该会生成一个名为 js 的二进制文件。由于某种原因,当我运行 make install 时,它没有将 js 复制到 /bin/ 中。我只是符号链接 /bin/js 指向 ~/.../mozilla/js/src/js。 Lint 脚本现在可以工作,我不再需要启动构建来修复 lint 错误 :P
来源:
https: //developer.mozilla.org/en/SpiderMonkey_Build_Documentation
注意:上面的链接调用命令
autoconf-2.13
。我认为这是一个错字;您想使用我在代码中编写的autoconf2.13
。Fixed it. You need the 'autoconf2.13' package. Install it with apt-get. Go to the SpiderMonkey source code page on Mozilla. Find the hg repository (linked below) and download a snapshot of the Mozilla tree. Don't clone it, just get the archive as .tar.gz or .tar.bz2 from the top bar.
http://hg.mozilla.org/index.cgi/mozilla-central/file/tip
Unzip the archive and cd into the root directory.
This should make a binary called js. For some reason, when I ran make install, it did not copy js into /bin/. I just symlinked /bin/js to point to ~/.../mozilla/js/src/js. Lint scripts work now and I don't have to start a build to fix lint errors anymore :P
Source:
https://developer.mozilla.org/en/SpiderMonkey_Build_Documentation
Note: the above link calls for the command
autoconf-2.13
. I think this is a typo; you want to useautoconf2.13
as I wrote in the code.更新:
看起来spidermonkey-bin不再可以通过启动板ppa使用,
而且当我尝试克隆它时,v8jslint存储库已关闭。
update:
looks like spidermonkey-bin is no longer available through the launchpad ppa
plus the v8jslint repo was down when I tried to clone it.
另外,(via #2:spidermonkey-bin 在 Ubuntu Lucid 中不可用 - 问题 -hallettj /jslint.vim - GitHub),可以使用 PPA for Launchpad工程:“Canonical Launchpad 工程”团队:
Also, (via #2: spidermonkey-bin not availble in Ubuntu Lucid - Issues - hallettj/jslint.vim - GitHub), can use PPA for Launchpad Engineering : “Canonical Launchpad Engineering” team:
安装包
libmozjs-24-bin
。它包含 Spidermonkey JavaScript shell 二进制文件/usr/bin/js24
,您可以将其安装作为命令js
的替代方案。Install the package
libmozjs-24-bin
. It contains the Spidermonkey JavaScript shell binary/usr/bin/js24
which you can the be installed as an alternative for the commandjs
.