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

Commit 5a31eab

Browse files
authored
Merge pull request #2 from pinepain/packaging
Add packaging and update to v8 5.4.420
2 parents 3f6ba0a + a850b5b commit 5a31eab

31 files changed

+860
-128
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ env:
1717
- NO_INTERACTION=1
1818
- TEST_TIMEOUT=120
1919
matrix:
20-
- V8=5.2
21-
- V8=5.2 TEST_PHP_ARGS=-m
20+
- V8=5.4
21+
- V8=5.4 TEST_PHP_ARGS=-m
2222

2323
before_install:
2424
- sudo add-apt-repository ppa:pinepain/libv8-${V8} -y

README.md

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

6464
### Requirements
6565

66-
You will need some fresh v8 Google JavaScript enging version installed. At this time extension tested on 5.2.371.
66+
You will need some fresh v8 Google JavaScript enging version installed. At this time extension tested on 5.4.420.
6767

68-
- For Ubuntu there are [pinepain/libv8-5.2](https://launchpad.net/~pinepain/+archive/ubuntu/libv8-5.2) PPA.
68+
- For Ubuntu there are [pinepain/libv8-5.4](https://launchpad.net/~pinepain/+archive/ubuntu/libv8-5.4) PPA.
6969
To install fresh libv8 do:
7070

7171
```
72-
$ sudo add-apt-repository ppa:pinepain/libv8-5.2 -y
72+
$ sudo add-apt-repository ppa:pinepain/libv8-5.4 -y
7373
$ sudo apt-get update -q
74-
$ sudo apt-get install -y libv8-5.2-dev
74+
$ sudo apt-get install -y libv8-5.4-dev
7575
```
7676
- For OS X there are [v8.rb](https://github.com/pinepain/php-v8/blob/master/scripts/homebrew/v8.rb) homebrew formula.
7777
To install fresh libv8 do:

scripts/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.pyc

scripts/build_v8.sh

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 70 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
#!/usr/bin/env python
22

33
import sys
4+
import os
45
import urllib
56
import base64
6-
7+
import hashlib
78

89
class VarImpl(object):
910
"""
@@ -54,24 +55,10 @@ def Lookup(self, var_name):
5455
raise gclient_utils.Error("Var is not defined: %s" % var_name)
5556

5657

57-
def FileRead(filename, mode='rU'):
58-
with open(filename, mode=mode) as f:
59-
return f.read()
60-
61-
62-
if len(sys.argv) < 2 or len(sys.argv) > 3:
63-
# print("Usage: %s <path to DEPS file>" % sys.argv[0])
64-
print("Usage: %s <v8 version>" % sys.argv[0])
65-
print("Options:")
66-
print(" --homebrew Generate hombrew output")
67-
exit(1)
68-
69-
7058
# https://chromium.googlesource.com/v8/v8.git/+archive/5.0.71.11.tar.gz
7159
# https://chromium.googlesource.com/v8/v8.git/+/5.0.71.11/DEPS?format=TEXT
7260

73-
74-
class V8DepsFileLoader(object):
61+
class V8DepsRemoteFileLoader(object):
7562
def __init__(self, version):
7663
self.version = version
7764

@@ -83,22 +70,16 @@ def load(self):
8370

8471
return base64.b64decode(s)
8572

73+
class V8DepsLocalFileLoader(object):
74+
def __init__(self, path):
75+
self.path = path
8676

87-
class V8DepsResolver(object):
88-
def __init__(self, version):
89-
self.version = version
90-
91-
def get_deps(self):
92-
url = 'https://chromium.googlesource.com/v8/v8.git/+archive/%s.tar.gz' % self.version
93-
94-
return {url: 'v8'}
95-
96-
def output_deps(self):
97-
for k, v in self.get_deps().items():
98-
print ("%s %s" % (k, v))
77+
def load(self):
78+
with open(self.path) as f:
79+
return f.read()
9980

10081

101-
class DepsResolver(object):
82+
class AbstractDepsResolver(object):
10283
def __init__(self, deps_content):
10384
self.deps_content = deps_content
10485

@@ -124,9 +105,17 @@ def convert_parsed_deps(self, deps):
124105
deps_converted = {}
125106

126107
for k, v in deps.items():
127-
v = v.replace('@', '/+archive/') + '.tar.gz'
108+
url, revision = v.split('@', 2)
109+
110+
resource = url.rsplit('/', 1)[1].split('.', 1)[0]
111+
target = k.replace('v8/', '')
128112

129-
deps_converted[v] = k
113+
deps_converted[resource] = {
114+
'url': url,
115+
'revision': revision,
116+
'resource': resource,
117+
'target': target
118+
}
130119

131120
return deps_converted
132121

@@ -135,70 +124,73 @@ def get_deps(self):
135124

136125
return self.convert_parsed_deps(parsed)
137126

138-
def output_deps(self):
139-
for k, v in self.get_deps().items():
140-
print ("%s %s" % (k, v))
141127

128+
class HomebrewDepsResolver(AbstractDepsResolver):
129+
def __init__(self, deps_content, version, tpl_path, out_path):
130+
self.deps_content = deps_content
131+
self.version = version
132+
self.tpl_path = tpl_path
133+
self.out_path = out_path
142134

143-
class HomebrewDepsResolver(DepsResolver):
144-
def convert_parsed_deps(self, deps):
145-
deps_converted = {}
135+
def import_deps_fast(self):
136+
vars = {}
146137

147-
for k, v in deps.items():
148-
url, revision = v.split('@', 2)
138+
url = "https://chromium.googlesource.com/v8/v8.git/+archive/%s.tar.gz" % self.version
149139

150-
resource = url.rsplit('/', 1)[1].split('.', 1)[0]
151-
target = k.replace('v8/', '')
140+
f = urllib.urlopen(url)
141+
s = f.read()
142+
f.close()
152143

153-
deps_converted[resource] = {
154-
'url': url,
155-
'revision': revision,
156-
'resource': resource,
157-
'target': target
158-
}
144+
sha256 = hashlib.sha256(s).hexdigest()
159145

160-
return deps_converted
146+
vars['{{ URL }}'] = 'url "%s"' % url
147+
vars['{{ SHA256 }}'] = 'sha256 "%s"' % sha256
161148

162-
def output_deps(self):
163-
print (" # resources definition, do not edit, autogenerated")
164-
print ("")
149+
resources_def = []
150+
resources_def.append(" # resources definition, do not edit, autogenerated")
151+
resources_def.append("")
165152

166153
for k, v in self.get_deps().items():
167-
print (" resource \"%s\" do " % (v['resource']))
168-
print (" url \"%s\"," % (v['url']))
169-
print (" :revision => \"%s\"" % (v['revision']))
170-
print (" end")
171-
print ("")
154+
resources_def.append(" resource \"%s\" do" % (v['resource']))
155+
resources_def.append(" url \"%s\"," % (v['url']))
156+
resources_def.append(" :revision => \"%s\"" % (v['revision']))
157+
resources_def.append(" end")
158+
resources_def.append("")
159+
160+
vars['{{ RESOURCES_DEFINITION }}'] = "\n".join(resources_def).strip()
172161

173-
print ("")
174-
print ("")
175-
print (" # resources installation, do not edit, autogenerated")
162+
resources_inst = []
163+
resources_inst.append(" # resources installation, do not edit, autogenerated")
176164

177165
for k, v in self.get_deps().items():
178-
print (" (buildpath/\"{target}\").install resource(\"{resource}\")".format(**v))
166+
resources_inst.append(" (buildpath/\"{target}\").install resource(\"{resource}\")".format(**v))
167+
168+
vars['{{ RESOURCES_INSTALLATION }}'] = "\n".join(resources_inst).strip()
179169

180-
print ("")
170+
tpl = ""
171+
with open(self.tpl_path) as f:
172+
tpl = f.read()
181173

182-
if len(sys.argv) == 2:
183-
version = sys.argv[1]
184-
is_homebrew = False
185-
else:
186-
version = sys.argv[2]
187-
is_homebrew = True
174+
for k, v in vars.iteritems():
175+
tpl = tpl.replace(k, v)
188176

189-
deps_loader = V8DepsFileLoader(version)
177+
with open(self.out_path, 'w') as f:
178+
f.write(tpl)
190179

191-
deps_content = deps_loader.load()
192180

193-
# print(deps_content)
194-
# deps_content = FileRead(sys.argv[1])
181+
class PPAPackagingDepsResolver(AbstractDepsResolver):
182+
def import_deps_fast(self):
183+
for k, v in self.get_deps().items():
184+
tgz = v['url'] + '/+archive/' + v['revision']+ '.tar.gz'
185+
186+
cmd = "mkdir -p " + v['target']
195187

196-
v8_deps_resolver = V8DepsResolver(version)
197-
if is_homebrew:
198-
deps_resolver = HomebrewDepsResolver(deps_content)
199-
else:
200-
deps_resolver = DepsResolver(deps_content)
188+
if os.path.isdir(v['target']):
189+
cmd = "rm -rf " + v['target'] + " && " + cmd
201190

202-
v8_deps_resolver.output_deps()
191+
print(cmd)
192+
os.system(cmd)
203193

204-
deps_resolver.output_deps()
194+
cmd = "curl -s " + tgz + " | tar zxf - -C " + v['target']
195+
print (cmd)
196+
os.system(cmd)

scripts/homebrew/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Homebrew formula for v8 JavaScript engling and semi-automated script to update it
2+
==============================
3+
4+
Prerequisites
5+
-------------
6+
7+
You need up to date homebrew and supported OS X
8+
9+
Refreshing formula
10+
------------------
11+
12+
The process is very much automated and the following command can be used to update formula to desired v8 version.
13+
14+
./load_deps.py <v8 version>
15+
16+
Installing v8
17+
-------------
18+
19+
You can install it a same way as other Hombrew formulae:
20+
21+
brew install v8.rb

scripts/homebrew/load_deps.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env python
2+
3+
import sys
4+
import os
5+
6+
parentdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
7+
os.sys.path.insert(0, parentdir)
8+
9+
import deps
10+
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)
15+
16+
version = sys.argv[1]
17+
18+
deps_loader = deps.V8DepsRemoteFileLoader(version)
19+
deps_content = deps_loader.load()
20+
21+
dir_path = os.path.dirname(os.path.realpath(__file__))
22+
23+
deps_resolver = deps.HomebrewDepsResolver(deps_content, version, dir_path +'/v8.rb.in', dir_path + '/v8.rb')
24+
25+
deps_resolver.import_deps_fast()

0 commit comments

Comments
 (0)