Skip to content
This repository was archived by the owner on Mar 29, 2024. It is now read-only.

Commit f03b23e

Browse files
committed
Add homebrew formula for php7{0,1}-v8 [skip ci]
1 parent 594c28e commit f03b23e

File tree

8 files changed

+169
-14
lines changed

8 files changed

+169
-14
lines changed

scripts/deps.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,15 @@ def __init__(self, deps_content, version, tpl_path, out_path):
132132
self.tpl_path = tpl_path
133133
self.out_path = out_path
134134

135-
def import_deps_fast(self):
135+
def import_deps_fast(self, use_orig_repo=False):
136136
vars = {}
137137

138-
url = "https://chromium.googlesource.com/v8/v8.git/+archive/%s.tar.gz" % self.version
138+
if use_orig_repo:
139+
url = "https://chromium.googlesource.com/v8/v8.git/+archive/%s.tar.gz" % self.version
140+
head = "https://chromium.googlesource.com/v8/v8.git"
141+
else:
142+
url = "https://github.com/v8/v8/archive/%s.tar.gz" % self.version
143+
head = "https://github.com/v8/v8.git"
139144

140145
f = urllib.urlopen(url)
141146
s = f.read()
@@ -145,6 +150,7 @@ def import_deps_fast(self):
145150

146151
vars['{{ URL }}'] = 'url "%s"' % url
147152
vars['{{ SHA256 }}'] = 'sha256 "%s"' % sha256
153+
vars['{{ HEAD }}'] = 'head "%s"' % head
148154

149155
resources_def = []
150156
resources_def.append(" # resources definition, do not edit, autogenerated")

scripts/homebrew/gen_formulas.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/env python
2+
3+
import sys
4+
import os
5+
import urllib
6+
import hashlib
7+
import argparse
8+
9+
10+
parser = argparse.ArgumentParser()
11+
parser.add_argument('--libv8-version', help='Specify required libv8 formula dependency')
12+
parser.add_argument('version', help='php-v8 version to generate formulas for')
13+
args = parser.parse_args()
14+
15+
16+
class HomebrewPhpV8(object):
17+
def __init__(self, tpl_path, out_path):
18+
self.tpl_path = tpl_path
19+
self.out_path = out_path
20+
21+
def generate(self, version, libv8_version, php_versions):
22+
vars = {}
23+
24+
url = "https://github.com/pinepain/php-v8/archive/v%s.tar.gz" % version
25+
26+
f = urllib.urlopen(url)
27+
s = f.read()
28+
f.close()
29+
30+
sha256 = hashlib.sha256(s).hexdigest()
31+
32+
vars['{{ URL }}'] = 'url "%s"' % url
33+
vars['{{ SHA256 }}'] = 'sha256 "%s"' % sha256
34+
35+
if libv8_version:
36+
vars['{{ LIBV8_DEPENDENCY }}'] = 'depends_on "libv8-%s"' % libv8_version
37+
else:
38+
vars['{{ LIBV8_DEPENDENCY }}'] = '# NOTE: This formula depends on libv8, but actual "depends_on" dependency is not set yet'
39+
40+
for php in php_versions:
41+
vars['{{ PHP_VERSION }}'] = php
42+
43+
tpl = ""
44+
with open(self.tpl_path) as f:
45+
tpl = f.read()
46+
47+
for k, v in vars.iteritems():
48+
tpl = tpl.replace(k, v)
49+
50+
out_path = self.out_path
51+
for k, v in vars.iteritems():
52+
out_path = out_path.replace(k, v)
53+
54+
with open(out_path, 'w') as f:
55+
f.write(tpl)
56+
57+
58+
dir_path = os.path.dirname(os.path.realpath(__file__))
59+
60+
deps_resolver = HomebrewPhpV8(dir_path +'/php-v8.rb.in', dir_path + '/php{{ PHP_VERSION }}-v8.rb')
61+
deps_resolver.generate(args.version, args.libv8_version, ['70', '71'])

scripts/homebrew/load_deps.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,24 @@
22

33
import sys
44
import os
5+
import argparse
56

67
parentdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
78
os.sys.path.insert(0, parentdir)
89

910
import deps
1011

11-
if len(sys.argv) != 2:
12-
# print("Usage: %s <path to DEPS file>" % sys.argv[0])
13-
print("Usage: %s <v8 version>" % sys.argv[0])
14-
exit(1)
12+
parser = argparse.ArgumentParser()
13+
parser.add_argument('--use-orig-repo', action='store_true', help='Use original repo rather then github mirror (use at your own risk)')
14+
parser.add_argument('version', help='V8 version to build')
15+
args = parser.parse_args()
1516

16-
version = sys.argv[1]
1717

18-
deps_loader = deps.V8DepsRemoteFileLoader(version)
18+
deps_loader = deps.V8DepsRemoteFileLoader(args.version)
1919
deps_content = deps_loader.load()
2020

2121
dir_path = os.path.dirname(os.path.realpath(__file__))
2222

23-
deps_resolver = deps.HomebrewDepsResolver(deps_content, version, dir_path +'/v8.rb.in', dir_path + '/v8.rb')
23+
deps_resolver = deps.HomebrewDepsResolver(deps_content, args.version, dir_path +'/v8.rb.in', dir_path + '/v8.rb')
2424

25-
deps_resolver.import_deps_fast()
25+
deps_resolver.import_deps_fast(args.use_orig_repo)

scripts/homebrew/php-v8.rb.in

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
require "/usr/local/Library/Taps/homebrew/homebrew-php/Abstract/abstract-php-extension"
2+
3+
class Php{{ PHP_VERSION }}V8 < AbstractPhp71Extension
4+
init
5+
desc "PHP extension for V8 JavaScript engine"
6+
homepage "https://github.com/pinepain/php-v8"
7+
{{ URL }}
8+
{{ SHA256 }}
9+
head "https://github.com/pinepain/php-v8.git"
10+
11+
bottle do
12+
end
13+
14+
{{ LIBV8_DEPENDENCY }}
15+
16+
# NOTE: this dependency is not valid as it takes core homebrew v8 formula, while own v8 already installed.
17+
# It looks like vanilla v8 should be managed in a way like with PPA: libv8-x.y
18+
#depends_on "v8"
19+
20+
def install
21+
ENV.universal_binary if build.universal?
22+
23+
safe_phpize
24+
system "./configure", "--prefix=#{prefix}", phpconfig
25+
system "make"
26+
prefix.install "modules/v8.so"
27+
write_config_file if build.with? "config-file"
28+
end
29+
end

scripts/homebrew/php70-v8.rb

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
require "/usr/local/Library/Taps/homebrew/homebrew-php/Abstract/abstract-php-extension"
2+
3+
class Php70V8 < AbstractPhp71Extension
4+
init
5+
desc "PHP extension for V8 JavaScript engine"
6+
homepage "https://github.com/pinepain/php-v8"
7+
url "https://github.com/pinepain/php-v8/archive/v0.1.0.tar.gz"
8+
sha256 "b203da5b7fc72ef0cd71af26b409e2a1977c7e9a1c48648b33882c325ab755a3"
9+
head "https://github.com/pinepain/php-v8.git"
10+
11+
bottle do
12+
end
13+
14+
# NOTE: This formula depends on libv8, but actual "depends_on" dependency is not set yet
15+
16+
# NOTE: this dependency is not valid as it takes core homebrew v8 formula, while own v8 already installed.
17+
# It looks like vanilla v8 should be managed in a way like with PPA: libv8-x.y
18+
#depends_on "v8"
19+
20+
def install
21+
ENV.universal_binary if build.universal?
22+
23+
safe_phpize
24+
system "./configure", "--prefix=#{prefix}", phpconfig
25+
system "make"
26+
prefix.install "modules/v8.so"
27+
write_config_file if build.with? "config-file"
28+
end
29+
end

scripts/homebrew/php71-v8.rb

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
require "/usr/local/Library/Taps/homebrew/homebrew-php/Abstract/abstract-php-extension"
2+
3+
class Php71V8 < AbstractPhp71Extension
4+
init
5+
desc "PHP extension for V8 JavaScript engine"
6+
homepage "https://github.com/pinepain/php-v8"
7+
url "https://github.com/pinepain/php-v8/archive/v0.1.0.tar.gz"
8+
sha256 "b203da5b7fc72ef0cd71af26b409e2a1977c7e9a1c48648b33882c325ab755a3"
9+
head "https://github.com/pinepain/php-v8.git"
10+
11+
bottle do
12+
end
13+
14+
# NOTE: This formula depends on libv8, but actual "depends_on" dependency is not set yet
15+
16+
# NOTE: this dependency is not valid as it takes core homebrew v8 formula, while own v8 already installed.
17+
# It looks like vanilla v8 should be managed in a way like with PPA: libv8-x.y
18+
#depends_on "v8"
19+
20+
def install
21+
ENV.universal_binary if build.universal?
22+
23+
safe_phpize
24+
system "./configure", "--prefix=#{prefix}", phpconfig
25+
system "make"
26+
prefix.install "modules/v8.so"
27+
write_config_file if build.with? "config-file"
28+
end
29+
end

scripts/homebrew/v8.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# Track Chrome stable.
22
# https://omahaproxy.appspot.com/
3+
# This formula is auto-generated by load_deps.py script. Do not edit it manually.
34
class V8 < Formula
45
desc "Google's JavaScript engine"
56
homepage "https://code.google.com/p/v8/"
6-
url "https://chromium.googlesource.com/v8/v8.git/+archive/5.4.420.tar.gz"
7-
sha256 "b62a9735443cc391c3404eaa0480de40cc0d72ae0645704b5f9c261e42ef8dfc"
8-
head "https://chromium.googlesource.com/v8/v8.git"
7+
url "https://github.com/v8/v8/archive/5.4.420.tar.gz"
8+
sha256 "14f430e99f695ea632b60c946b222bfeac383ce7d205759530bc062cc58b565a"
9+
head "https://github.com/v8/v8.git"
910

1011
bottle do
1112
cellar :any

scripts/homebrew/v8.rb.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class V8 < Formula
66
homepage "https://code.google.com/p/v8/"
77
{{ URL }}
88
{{ SHA256 }}
9-
head "https://chromium.googlesource.com/v8/v8.git"
9+
{{ HEAD }}
1010

1111
bottle do
1212
cellar :any

0 commit comments

Comments
 (0)