2009-10-15 08:07:12 +00:00
|
|
|
require 'formula'
|
2009-10-10 23:16:57 +00:00
|
|
|
|
2012-09-04 05:21:40 +00:00
|
|
|
class PythonVersion < Requirement
|
2013-01-20 02:45:59 +00:00
|
|
|
env :userpaths
|
|
|
|
|
|
|
|
satisfy { `python -c 'import sys;print(sys.version[:3])'`.strip.to_f >= 2.6 }
|
|
|
|
|
2013-02-02 02:39:14 +00:00
|
|
|
def message;
|
|
|
|
"Node's build system, gyp, requires Python 2.6 or newer."
|
2012-09-04 05:21:40 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-06-27 03:38:24 +00:00
|
|
|
class NpmNotInstalled < Requirement
|
2013-01-20 02:45:59 +00:00
|
|
|
fatal true
|
|
|
|
|
2012-06-27 03:38:24 +00:00
|
|
|
def modules_folder
|
|
|
|
"#{HOMEBREW_PREFIX}/lib/node_modules"
|
|
|
|
end
|
|
|
|
|
|
|
|
def message; <<-EOS.undent
|
2013-02-02 02:39:14 +00:00
|
|
|
The homebrew node recipe now (beginning with 0.8.0) comes with npm.
|
|
|
|
It appears you already have npm installed at #{modules_folder}/npm.
|
|
|
|
To use the npm that comes with this recipe,
|
|
|
|
first uninstall npm with `npm uninstall npm -g`.
|
|
|
|
Then run this command again.
|
|
|
|
|
|
|
|
If you would like to keep your installation of npm instead of
|
|
|
|
using the one provided with homebrew,
|
|
|
|
install the formula with the --without-npm option added.
|
2012-06-27 03:38:24 +00:00
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
2013-01-20 02:45:59 +00:00
|
|
|
satisfy :build_env => false do
|
2012-06-27 03:38:24 +00:00
|
|
|
begin
|
2013-02-19 14:43:27 +00:00
|
|
|
path = Pathname.new("#{modules_folder}/npm/bin/npm")
|
2013-01-31 20:43:31 +00:00
|
|
|
path.realpath.to_s.include?(HOMEBREW_CELLAR)
|
2013-02-18 23:35:35 +00:00
|
|
|
rescue Errno::ENOENT
|
2012-06-27 03:38:24 +00:00
|
|
|
true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-03-10 05:11:03 +00:00
|
|
|
class Node < Formula
|
2012-01-26 05:00:23 +00:00
|
|
|
homepage 'http://nodejs.org/'
|
2013-02-26 11:25:42 +00:00
|
|
|
url 'http://nodejs.org/dist/v0.8.21/node-v0.8.21.tar.gz'
|
|
|
|
sha1 '65ab7307f1aee12be4c88e396e2510967a52b1c6'
|
2013-01-12 02:36:04 +00:00
|
|
|
|
2012-12-29 04:50:32 +00:00
|
|
|
devel do
|
2013-03-02 04:41:09 +00:00
|
|
|
url 'http://nodejs.org/dist/v0.9.11/node-v0.9.11.tar.gz'
|
|
|
|
sha1 '66370601eb824305b12c7f3e5b2a5e8ca94f1209'
|
2012-12-29 04:50:32 +00:00
|
|
|
end
|
2012-02-18 01:10:45 +00:00
|
|
|
|
2012-01-26 05:00:23 +00:00
|
|
|
head 'https://github.com/joyent/node.git'
|
|
|
|
|
2012-08-13 00:03:04 +00:00
|
|
|
option 'enable-debug', 'Build with debugger hooks'
|
2012-06-27 03:38:24 +00:00
|
|
|
option 'without-npm', 'npm will not be installed'
|
2013-02-23 08:23:11 +00:00
|
|
|
option 'with-shared-libs', 'Use Homebrew V8 and system OpenSSL, zlib'
|
|
|
|
|
|
|
|
depends_on NpmNotInstalled unless build.without? 'npm'
|
|
|
|
depends_on PythonVersion
|
|
|
|
depends_on 'v8' if build.with? 'shared-libs'
|
2012-08-13 00:03:04 +00:00
|
|
|
|
2012-03-18 20:33:24 +00:00
|
|
|
fails_with :llvm do
|
|
|
|
build 2326
|
|
|
|
end
|
2011-03-21 21:24:22 +00:00
|
|
|
|
2009-10-10 23:16:57 +00:00
|
|
|
def install
|
2012-09-14 00:24:45 +00:00
|
|
|
# Lie to `xcode-select` for now to work around a GYP bug that affects
|
|
|
|
# CLT-only systems:
|
|
|
|
#
|
|
|
|
# http://code.google.com/p/gyp/issues/detail?id=292
|
|
|
|
# joyent/node#3681
|
2012-09-14 01:54:17 +00:00
|
|
|
ENV['DEVELOPER_DIR'] = MacOS.dev_tools_path unless MacOS::Xcode.installed?
|
2012-09-14 00:24:45 +00:00
|
|
|
|
2012-06-27 03:38:24 +00:00
|
|
|
args = %W{--prefix=#{prefix}}
|
2013-02-23 08:23:11 +00:00
|
|
|
|
|
|
|
if build.with? 'shared-libs'
|
|
|
|
args << '--shared-openssl' unless MacOS.version == :leopard
|
|
|
|
args << '--shared-v8'
|
|
|
|
args << '--shared-zlib'
|
|
|
|
end
|
|
|
|
|
2012-08-13 00:03:04 +00:00
|
|
|
args << "--debug" if build.include? 'enable-debug'
|
2012-06-27 03:38:24 +00:00
|
|
|
args << "--without-npm" if build.include? 'without-npm'
|
2010-08-09 05:08:08 +00:00
|
|
|
|
|
|
|
system "./configure", *args
|
2009-10-10 23:16:57 +00:00
|
|
|
system "make install"
|
2012-06-27 03:38:24 +00:00
|
|
|
|
2012-08-28 04:55:39 +00:00
|
|
|
unless build.include? 'without-npm'
|
2012-06-27 03:38:24 +00:00
|
|
|
(lib/"node_modules/npm/npmrc").write(npmrc)
|
|
|
|
end
|
2009-10-10 23:16:57 +00:00
|
|
|
end
|
2010-12-28 11:11:21 +00:00
|
|
|
|
2012-06-27 03:38:24 +00:00
|
|
|
def npm_prefix
|
|
|
|
"#{HOMEBREW_PREFIX}/share/npm"
|
|
|
|
end
|
|
|
|
|
|
|
|
def npm_bin
|
|
|
|
"#{npm_prefix}/bin"
|
|
|
|
end
|
|
|
|
|
|
|
|
def modules_folder
|
|
|
|
"#{HOMEBREW_PREFIX}/lib/node_modules"
|
|
|
|
end
|
2011-12-02 03:19:47 +00:00
|
|
|
|
2012-06-27 03:38:24 +00:00
|
|
|
def npmrc
|
|
|
|
<<-EOS.undent
|
|
|
|
prefix = #{npm_prefix}
|
2011-12-02 03:19:47 +00:00
|
|
|
EOS
|
2010-12-28 11:11:21 +00:00
|
|
|
end
|
2012-06-27 03:38:24 +00:00
|
|
|
|
|
|
|
def caveats
|
2012-08-28 04:55:39 +00:00
|
|
|
if build.include? 'without-npm'
|
2012-06-27 03:38:24 +00:00
|
|
|
<<-EOS.undent
|
|
|
|
Homebrew has NOT installed npm. We recommend the following method of
|
|
|
|
installation:
|
2012-08-30 09:48:07 +00:00
|
|
|
curl https://npmjs.org/install.sh | sh
|
2012-06-27 03:38:24 +00:00
|
|
|
|
|
|
|
After installing, add the following path to your NODE_PATH environment
|
|
|
|
variable to have npm libraries picked up:
|
|
|
|
#{modules_folder}
|
|
|
|
EOS
|
|
|
|
elsif not ENV['PATH'].split(':').include? npm_bin
|
|
|
|
<<-EOS.undent
|
|
|
|
Homebrew installed npm.
|
|
|
|
We recommend prepending the following path to your PATH environment
|
|
|
|
variable to have npm-installed binaries picked up:
|
|
|
|
#{npm_bin}
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
end
|
2009-10-10 23:16:57 +00:00
|
|
|
end
|