aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Formula/v8cgi.rb
blob: 9404cad07172d67cb32d3c151baaef4de51cd138 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
require 'formula'

class V8cgi < Formula
  homepage 'http://code.google.com/p/v8cgi/'
  url 'http://v8cgi.googlecode.com/files/v8cgi-0.9.3-src.tar.gz'
  sha1 'a3dd4a648bce71aa3cb37ba2c1921f0605ff50f0'

  head 'http://v8cgi.googlecode.com/svn/trunk/'

  option "with-dom", "Enable DOM"
  option "with-gd", "Enable GD"
  option "with-sqlite", "Enable SQLite"

  depends_on 'scons' => :build
  depends_on 'v8'
  depends_on 'libmemcached'
  depends_on 'xerces-c' => :optional if build.include? 'with-dom'
  depends_on 'gd'       => :optional if build.include? 'with-gd'
  depends_on 'sqlite'   => :optional if build.include? 'with-sqlite'

  def install
    arch = Hardware.is_64_bit? ? 'x64' : 'ia32'

    v8_prefix = Formula.factory('v8').prefix

    args = ["config_file=#{etc}/v8cgi.conf", "v8_path=#{v8_prefix}"]
    args << ((build.include? 'with-dom') ? 'dom=1' : 'dom=0')
    args << ((build.include? 'with-gd') ? 'gd=1' : 'gd=0')
    args << ((build.include? 'with-sqlite') ? 'sqlite=1' : 'sqlite=0')

    cd 'v8cgi' do
      inreplace 'SConstruct', '../v8', v8_prefix

      system "scons",
             "-j #{ENV.make_jobs}",
             "arch=#{arch}",
             "library=shared",
             "socket=1",
             "process=1",
             "cgi=1",
             "mysql=0",
             "gl=0",
             "module=0",
             *args

      bin.install 'v8cgi'
      lib.install 'lib' => 'v8cgi'
      etc.install 'v8cgi.conf.darwin' => 'v8cgi.conf'
    end
  end
end