Skip to content
This repository was archived by the owner on Mar 29, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 52 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,64 @@ you from V8 API utilizing to implement more amazing stuff.

### Requirements

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

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

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

```
$ brew install https://raw.githubusercontent.com/pinepain/php-v8/master/scripts/homebrew/v8.rb
```

#### PHP 7

- For Ubuntu there are [ondrej/php](https://launchpad.net/~ondrej/+archive/ubuntu/php) PPA by [Ondřej Surý](https://deb.sury.org).

To install fresh `php7.0` do:

```
$ sudo add-apt-repository -y ppa:ondrej/php
$ sudo apt-get update -y
$ sudo apt-get install -y php7.0
```
- For OS X there are [homebrew/homebrew-php](https://github.com/Homebrew/homebrew-php) tap with php70, php71 and large
variety extensions for them.

To install fresh `php70` do:

```
$ brew tap homebrew/homebrew-php
$ brew install php70
```


### Installing from packages

- For Ubuntu there are [pinepain/php-v8](https://launchpad.net/~pinepain/+archive/ubuntu/php-v8) PPA.

```
$ brew install https://raw.githubusercontent.com/pinepain/php-v8/master/scripts/homebrew/v8.rb
```
To install fresh `php7.0` do:

```
$ sudo add-apt-repository -y ppa:pinepain/php-v8
$ sudo apt-get update -y
$ sudo apt-get install -y php-v8
```
- For OS X there are [php70-v8.rb][php70-v8.rb] and [php71-v8.rb][php71-v8.rb] homebrew formulas.

To install fresh `php70-v8` do:

```
$ brew install https://raw.githubusercontent.com/pinepain/php-v8/master/scripts/homebrew/php70-v8.rb
```

### Building from sources

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

[php-v8](https://github.com/pinepain/php-v8) PHP extension is licensed under the [MIT license](http://opensource.org/licenses/MIT).


[php70-v8.rb]: https://github.com/pinepain/php-v8/blob/master/scripts/homebrew/php70-v8.rb
[php71-v8.rb]: https://github.com/pinepain/php-v8/blob/master/scripts/homebrew/php71-v8.rb
10 changes: 8 additions & 2 deletions scripts/deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,15 @@ def __init__(self, deps_content, version, tpl_path, out_path):
self.tpl_path = tpl_path
self.out_path = out_path

def import_deps_fast(self):
def import_deps_fast(self, use_orig_repo=False):
vars = {}

url = "https://chromium.googlesource.com/v8/v8.git/+archive/%s.tar.gz" % self.version
if use_orig_repo:
url = "https://chromium.googlesource.com/v8/v8.git/+archive/%s.tar.gz" % self.version
head = "https://chromium.googlesource.com/v8/v8.git"
else:
url = "https://github.com/v8/v8/archive/%s.tar.gz" % self.version
head = "https://github.com/v8/v8.git"

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

vars['{{ URL }}'] = 'url "%s"' % url
vars['{{ SHA256 }}'] = 'sha256 "%s"' % sha256
vars['{{ HEAD }}'] = 'head "%s"' % head

resources_def = []
resources_def.append(" # resources definition, do not edit, autogenerated")
Expand Down
61 changes: 61 additions & 0 deletions scripts/homebrew/gen_formulas.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/usr/bin/env python

import sys
import os
import urllib
import hashlib
import argparse


parser = argparse.ArgumentParser()
parser.add_argument('--libv8-version', help='Specify required libv8 formula dependency')
parser.add_argument('version', help='php-v8 version to generate formulas for')
args = parser.parse_args()


class HomebrewPhpV8(object):
def __init__(self, tpl_path, out_path):
self.tpl_path = tpl_path
self.out_path = out_path

def generate(self, version, libv8_version, php_versions):
vars = {}

url = "https://github.com/pinepain/php-v8/archive/v%s.tar.gz" % version

f = urllib.urlopen(url)
s = f.read()
f.close()

sha256 = hashlib.sha256(s).hexdigest()

vars['{{ URL }}'] = 'url "%s"' % url
vars['{{ SHA256 }}'] = 'sha256 "%s"' % sha256

if libv8_version:
vars['{{ LIBV8_DEPENDENCY }}'] = 'depends_on "libv8-%s"' % libv8_version
else:
vars['{{ LIBV8_DEPENDENCY }}'] = '# NOTE: This formula depends on libv8, but actual "depends_on" dependency is not set yet'

for php in php_versions:
vars['{{ PHP_VERSION }}'] = php

tpl = ""
with open(self.tpl_path) as f:
tpl = f.read()

for k, v in vars.iteritems():
tpl = tpl.replace(k, v)

out_path = self.out_path
for k, v in vars.iteritems():
out_path = out_path.replace(k, v)

with open(out_path, 'w') as f:
f.write(tpl)


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

deps_resolver = HomebrewPhpV8(dir_path +'/php-v8.rb.in', dir_path + '/php{{ PHP_VERSION }}-v8.rb')
deps_resolver.generate(args.version, args.libv8_version, ['70', '71'])
16 changes: 8 additions & 8 deletions scripts/homebrew/load_deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@

import sys
import os
import argparse

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

import deps

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

version = sys.argv[1]

deps_loader = deps.V8DepsRemoteFileLoader(version)
deps_loader = deps.V8DepsRemoteFileLoader(args.version)
deps_content = deps_loader.load()

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

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

deps_resolver.import_deps_fast()
deps_resolver.import_deps_fast(args.use_orig_repo)
29 changes: 29 additions & 0 deletions scripts/homebrew/php-v8.rb.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
require "/usr/local/Library/Taps/homebrew/homebrew-php/Abstract/abstract-php-extension"

class Php{{ PHP_VERSION }}V8 < AbstractPhp71Extension
init
desc "PHP extension for V8 JavaScript engine"
homepage "https://github.com/pinepain/php-v8"
{{ URL }}
{{ SHA256 }}
head "https://github.com/pinepain/php-v8.git"

bottle do
end

{{ LIBV8_DEPENDENCY }}

# NOTE: this dependency is not valid as it takes core homebrew v8 formula, while own v8 already installed.
# It looks like vanilla v8 should be managed in a way like with PPA: libv8-x.y
#depends_on "v8"

def install
ENV.universal_binary if build.universal?

safe_phpize
system "./configure", "--prefix=#{prefix}", phpconfig
system "make"
prefix.install "modules/v8.so"
write_config_file if build.with? "config-file"
end
end
29 changes: 29 additions & 0 deletions scripts/homebrew/php70-v8.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
require "/usr/local/Library/Taps/homebrew/homebrew-php/Abstract/abstract-php-extension"

class Php70V8 < AbstractPhp71Extension
init
desc "PHP extension for V8 JavaScript engine"
homepage "https://github.com/pinepain/php-v8"
url "https://github.com/pinepain/php-v8/archive/v0.1.0.tar.gz"
sha256 "b203da5b7fc72ef0cd71af26b409e2a1977c7e9a1c48648b33882c325ab755a3"
head "https://github.com/pinepain/php-v8.git"

bottle do
end

# NOTE: This formula depends on libv8, but actual "depends_on" dependency is not set yet

# NOTE: this dependency is not valid as it takes core homebrew v8 formula, while own v8 already installed.
# It looks like vanilla v8 should be managed in a way like with PPA: libv8-x.y
#depends_on "v8"

def install
ENV.universal_binary if build.universal?

safe_phpize
system "./configure", "--prefix=#{prefix}", phpconfig
system "make"
prefix.install "modules/v8.so"
write_config_file if build.with? "config-file"
end
end
29 changes: 29 additions & 0 deletions scripts/homebrew/php71-v8.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
require "/usr/local/Library/Taps/homebrew/homebrew-php/Abstract/abstract-php-extension"

class Php71V8 < AbstractPhp71Extension
init
desc "PHP extension for V8 JavaScript engine"
homepage "https://github.com/pinepain/php-v8"
url "https://github.com/pinepain/php-v8/archive/v0.1.0.tar.gz"
sha256 "b203da5b7fc72ef0cd71af26b409e2a1977c7e9a1c48648b33882c325ab755a3"
head "https://github.com/pinepain/php-v8.git"

bottle do
end

# NOTE: This formula depends on libv8, but actual "depends_on" dependency is not set yet

# NOTE: this dependency is not valid as it takes core homebrew v8 formula, while own v8 already installed.
# It looks like vanilla v8 should be managed in a way like with PPA: libv8-x.y
#depends_on "v8"

def install
ENV.universal_binary if build.universal?

safe_phpize
system "./configure", "--prefix=#{prefix}", phpconfig
system "make"
prefix.install "modules/v8.so"
write_config_file if build.with? "config-file"
end
end
7 changes: 4 additions & 3 deletions scripts/homebrew/v8.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Track Chrome stable.
# https://omahaproxy.appspot.com/
# This formula is auto-generated by load_deps.py script. Do not edit it manually.
class V8 < Formula
desc "Google's JavaScript engine"
homepage "https://code.google.com/p/v8/"
url "https://chromium.googlesource.com/v8/v8.git/+archive/5.4.420.tar.gz"
sha256 "b62a9735443cc391c3404eaa0480de40cc0d72ae0645704b5f9c261e42ef8dfc"
head "https://chromium.googlesource.com/v8/v8.git"
url "https://github.com/v8/v8/archive/5.4.420.tar.gz"
sha256 "14f430e99f695ea632b60c946b222bfeac383ce7d205759530bc062cc58b565a"
head "https://github.com/v8/v8.git"

bottle do
cellar :any
Expand Down
2 changes: 1 addition & 1 deletion scripts/homebrew/v8.rb.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class V8 < Formula
homepage "https://code.google.com/p/v8/"
{{ URL }}
{{ SHA256 }}
head "https://chromium.googlesource.com/v8/v8.git"
{{ HEAD }}

bottle do
cellar :any
Expand Down
31 changes: 6 additions & 25 deletions scripts/ppa-packaging/libv8/debian/control
Original file line number Diff line number Diff line change
@@ -1,40 +1,21 @@
Source: libv8-5.4
Priority: optional
Maintainer: Debian Javascript Maintainers <pkg-javascript-devel@lists.alioth.debian.org>
Uploaders: Jérémy Lal <kapouer@melix.org>,
Jonas Smedegaard <dr@jones.dk>
Maintainer: Bogdan Padalko <pinepain@gmail.com>
Build-Depends: cdbs,
autotools-dev,
devscripts,
debhelper,
dh-buildinfo,
libicu-dev,
abi-compliance-checker
Standards-Version: 3.9.6
libicu-dev
Standards-Version: 3.9.8
Section: libs
Homepage: http://code.google.com/p/v8/
Vcs-Browser: http://anonscm.debian.org/git/collab-maint/libv8.git
Vcs-Git: git://anonscm.debian.org/collab-maint/libv8.git

Package: libv8-dev
Section: libdevel
Architecture: i386 kfreebsd-i386 hurd-i386 amd64 kfreebsd-amd64 armel armhf mipsel mips
Depends: libv8-5.4.420 (= ${binary:Version}), ${misc:Depends}
Conflicts: libv8-legacy-dev, libv8-3.14-dev
Replaces: libv8-legacy-dev, libv8-3.14-dev
Description: V8 JavaScript engine - development files for latest branch
V8 is a high performance JavaScript engine written in C++. It is used
in the web browser Chromium.
.
This package provide development headers for latest V8 branch.
Homepage: https://developers.google.com/v8/
Vcs-Browser: https://github.com/pinepain/php-v8
Vcs-Git: https://github.com/pinepain/php-v8.git

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