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

Commit 84edd91

Browse files
authored
Merge pull request #5 from pinepain/packaging
Add more packaging for php-v8
2 parents c2050e1 + 869eea6 commit 84edd91

File tree

22 files changed

+393
-72
lines changed

22 files changed

+393
-72
lines changed

README.md

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,22 +63,64 @@ you from V8 API utilizing to implement more amazing stuff.
6363

6464
### Requirements
6565

66+
#### V8
6667
You will need some fresh v8 Google JavaScript enging version installed. At this time extension tested on 5.4.420.
6768

6869
- For Ubuntu there are [pinepain/libv8-5.4](https://launchpad.net/~pinepain/+archive/ubuntu/libv8-5.4) PPA.
6970
To install fresh libv8 do:
7071

7172
```
72-
$ sudo add-apt-repository ppa:pinepain/libv8-5.4 -y
73-
$ sudo apt-get update -q
73+
$ sudo add-apt-repository -y ppa:pinepain/libv8-5.4
74+
$ sudo apt-get update -y
7475
$ sudo apt-get install -y libv8-5.4-dev
7576
```
7677
- For OS X there are [v8.rb](https://github.com/pinepain/php-v8/blob/master/scripts/homebrew/v8.rb) homebrew formula.
77-
To install fresh libv8 do:
78+
To install fresh libv8 do:
79+
80+
```
81+
$ brew install https://raw.githubusercontent.com/pinepain/php-v8/master/scripts/homebrew/v8.rb
82+
```
83+
84+
#### PHP 7
85+
86+
- For Ubuntu there are [ondrej/php](https://launchpad.net/~ondrej/+archive/ubuntu/php) PPA by [Ondřej Surý](https://deb.sury.org).
87+
88+
To install fresh `php7.0` do:
89+
90+
```
91+
$ sudo add-apt-repository -y ppa:ondrej/php
92+
$ sudo apt-get update -y
93+
$ sudo apt-get install -y php7.0
94+
```
95+
- For OS X there are [homebrew/homebrew-php](https://github.com/Homebrew/homebrew-php) tap with php70, php71 and large
96+
variety extensions for them.
97+
98+
To install fresh `php70` do:
99+
100+
```
101+
$ brew tap homebrew/homebrew-php
102+
$ brew install php70
103+
```
104+
105+
106+
### Installing from packages
107+
108+
- For Ubuntu there are [pinepain/php-v8](https://launchpad.net/~pinepain/+archive/ubuntu/php-v8) PPA.
78109

79-
```
80-
$ brew install https://raw.githubusercontent.com/pinepain/php-v8/master/scripts/homebrew/v8.rb
81-
```
110+
To install fresh `php7.0` do:
111+
112+
```
113+
$ sudo add-apt-repository -y ppa:pinepain/php-v8
114+
$ sudo apt-get update -y
115+
$ sudo apt-get install -y php-v8
116+
```
117+
- For OS X there are [php70-v8.rb][php70-v8.rb] and [php71-v8.rb][php71-v8.rb] homebrew formulas.
118+
119+
To install fresh `php70-v8` do:
120+
121+
```
122+
$ brew install https://raw.githubusercontent.com/pinepain/php-v8/master/scripts/homebrew/php70-v8.rb
123+
```
82124

83125
### Building from sources
84126

@@ -108,3 +150,7 @@ $ sudo make install
108150
Copyright (c) 2015-2016 Bogdan Padalko <pinepain@gmail.com>
109151

110152
[php-v8](https://github.com/pinepain/php-v8) PHP extension is licensed under the [MIT license](http://opensource.org/licenses/MIT).
153+
154+
155+
[php70-v8.rb]: https://github.com/pinepain/php-v8/blob/master/scripts/homebrew/php70-v8.rb
156+
[php71-v8.rb]: https://github.com/pinepain/php-v8/blob/master/scripts/homebrew/php71-v8.rb

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

scripts/ppa-packaging/libv8/debian/control

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,21 @@
11
Source: libv8-5.4
22
Priority: optional
3-
Maintainer: Debian Javascript Maintainers <pkg-javascript-devel@lists.alioth.debian.org>
4-
Uploaders: Jérémy Lal <kapouer@melix.org>,
5-
Jonas Smedegaard <dr@jones.dk>
3+
Maintainer: Bogdan Padalko <pinepain@gmail.com>
64
Build-Depends: cdbs,
7-
autotools-dev,
85
devscripts,
96
debhelper,
107
dh-buildinfo,
11-
libicu-dev,
12-
abi-compliance-checker
13-
Standards-Version: 3.9.6
8+
libicu-dev
9+
Standards-Version: 3.9.8
1410
Section: libs
15-
Homepage: http://code.google.com/p/v8/
16-
Vcs-Browser: http://anonscm.debian.org/git/collab-maint/libv8.git
17-
Vcs-Git: git://anonscm.debian.org/collab-maint/libv8.git
18-
19-
Package: libv8-dev
20-
Section: libdevel
21-
Architecture: i386 kfreebsd-i386 hurd-i386 amd64 kfreebsd-amd64 armel armhf mipsel mips
22-
Depends: libv8-5.4.420 (= ${binary:Version}), ${misc:Depends}
23-
Conflicts: libv8-legacy-dev, libv8-3.14-dev
24-
Replaces: libv8-legacy-dev, libv8-3.14-dev
25-
Description: V8 JavaScript engine - development files for latest branch
26-
V8 is a high performance JavaScript engine written in C++. It is used
27-
in the web browser Chromium.
28-
.
29-
This package provide development headers for latest V8 branch.
11+
Homepage: https://developers.google.com/v8/
12+
Vcs-Browser: https://github.com/pinepain/php-v8
13+
Vcs-Git: https://github.com/pinepain/php-v8.git
3014

3115
Package: libv8-5.4-dev
3216
Section: libdevel
3317
Architecture: i386 kfreebsd-i386 hurd-i386 amd64 kfreebsd-amd64 armel armhf mipsel mips
3418
Depends: libv8-5.4.420 (= ${binary:Version}), ${misc:Depends}
35-
Provides: libv8-legacy-dev, libv8-dev
36-
Conflicts: libv8-dev
37-
Replaces: libv8-dev
3819
Description: V8 JavaScript engine - development files for 5.4 branch
3920
V8 is a high performance JavaScript engine written in C++. It is used
4021
in the web browser Chromium.

0 commit comments

Comments
 (0)