在 Ubuntu 上获取 Spidermonkey js 的最佳方式?

发布于 2024-11-19 18:56:17 字数 688 浏览 6 评论 0 原文

我需要在我的工作机器上安装 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

空城仅有旧梦在 2024-11-26 18:56:17

你可以从源代码构建,但蜘蛛猴仍然可以在 ubuntu 上使用,它只是被重命名为“ libmozjs”。安装“libmozjs-24-bin”,然后将其称为“js24”或将 /usr/bin/js24 符号链接到“js”,如下所示:

sudo apt-get install libmozjs-24-bin; sudo ln -sf /usr/bin/js24 /usr/bin/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:

sudo apt-get install libmozjs-24-bin; sudo ln -sf /usr/bin/js24 /usr/bin/js
川水往事 2024-11-26 18:56:17

修好了。您需要“autoconf2.13”包。使用 apt-get 安装它。转至 Mozilla 上的 SpiderMonkey 源代码页面。找到 hg 存储库(链接如下)并下载 Mozilla 树的快照。不要克隆它,只需从顶部栏中获取 .tar.gz 或 .tar.bz2 格式的存档即可。

http://hg.mozilla.org/index.cgi/mozilla-central /file/tip

将存档和 cd 解压到根目录中。

$ cd js/src
$ autoconf2.13
$ ./configure
$ make

这应该会生成一个名为 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.

$ cd js/src
$ autoconf2.13
$ ./configure
$ make

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 use autoconf2.13 as I wrote in the code.

生生不灭 2024-11-26 18:56:17

更新:

看起来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.

×眷恋的温暖 2024-11-26 18:56:17

另外,(via #2:spidermonkey-bin 在 Ubuntu Lucid 中不可用 - 问题 -hallettj /jslint.vim - GitHub),可以使用 PPA for Launchpad工程:“Canonical Launchpad 工程”团队

sudo add-apt-repository ppa:launchpad/ppa
sudo apt-get update
sudo apt-get install spidermonkey-bin
apt-cache show spidermonkey-bin
sudo apt-get install spidermonkey-bin # also installs extra: libmozjs2d

# .. and then: 
$ js --help
JavaScript-C 1.8.0 pre-release 1 2007-10-03
usage: js [-zKPswWxCij] [-t timeoutSeconds] [-c stackchunksize] [-o option] [-v version] [-f scriptfile] [-e script] [-S maxstacksize] [scriptfile] [scriptarg...]
$ js
js> var f = function(){ print("the answer is " + 42); }; 
js> f();
the answer is 42
js> ^C
$

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:

sudo add-apt-repository ppa:launchpad/ppa
sudo apt-get update
sudo apt-get install spidermonkey-bin
apt-cache show spidermonkey-bin
sudo apt-get install spidermonkey-bin # also installs extra: libmozjs2d

# .. and then: 
$ js --help
JavaScript-C 1.8.0 pre-release 1 2007-10-03
usage: js [-zKPswWxCij] [-t timeoutSeconds] [-c stackchunksize] [-o option] [-v version] [-f scriptfile] [-e script] [-S maxstacksize] [scriptfile] [scriptarg...]
$ js
js> var f = function(){ print("the answer is " + 42); }; 
js> f();
the answer is 42
js> ^C
$
你的笑 2024-11-26 18:56:17

安装包libmozjs-24-bin。它包含 Spidermonkey JavaScript shell 二进制文件 /usr/bin/js24,您可以将其安装作为命令 js 的替代方案。

sudo apt-get install libmozjs-24-bin
sudo update-alternatives --install /usr/bin/js js /usr/bin/js24 10

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 command js.

sudo apt-get install libmozjs-24-bin
sudo update-alternatives --install /usr/bin/js js /usr/bin/js24 10
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文