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

Commit 406dfe8

Browse files
authored
Merge pull request #15 from pinepain/upgrade-to-v8-5.7
Upgrade to v8 5.7
2 parents 8680f52 + cbf52e4 commit 406dfe8

File tree

124 files changed

+186
-1397
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+186
-1397
lines changed

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ language: php
55

66
php:
77
- 7.0
8-
# - 7.1
8+
- 7.1
99
- nightly
1010

1111
matrix:
@@ -17,8 +17,8 @@ env:
1717
- NO_INTERACTION=1
1818
- TEST_TIMEOUT=120
1919
matrix:
20-
- V8=5.4
21-
- V8=5.4 TEST_PHP_ARGS=-m
20+
- V8=5.7
21+
- V8=5.7 TEST_PHP_ARGS=-m
2222

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

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ project(php_v8)
33

44
# NOTE: This CMake file is just for syntax highlighting in CLion
55

6+
include_directories(/usr/local/opt/v8@5.7/include)
7+
include_directories(/usr/local/opt/v8@5.7/include/libplatform)
8+
69
include_directories(/usr/local/include/php)
710
include_directories(/usr/local/include/php/TSRM)
811
include_directories(/usr/local/include/php/Zend)

README.md

Lines changed: 23 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,18 @@ in your IDE and other code-analysis tools.
7070

7171
## Installation
7272

73+
### Requirements
74+
75+
#### V8
76+
You will need a recent v8 Google JavaScript engine version installed. At this time the extension is tested on 5.7.202.
77+
78+
#### PHP
79+
This extension is PHP7-only. It works and tested with both PHP 7.0 and PHP 7.1.
80+
81+
#### OS
82+
This extension works and tested on x64 Linux and macOS. As of written it is Ubuntu 16.04 LTS Xenial Xerus, amd64
83+
and macOS 10.12.1. Windows is not supported at this time.
84+
7385
### Quick guide
7486

7587
#### Ubuntu
@@ -82,77 +94,25 @@ $ sudo apt-get install -y php7.0 php-v8
8294
$ php --ri v8
8395
```
8496

97+
While [pinepain/php](https://launchpad.net/~pinepain/+archive/ubuntu/php) PPA targets to contain all necessary
98+
extensions with dependencies, you may find useful
99+
[pinepain/libv8-5.7](https://launchpad.net/~pinepain/+archive/ubuntu/libv8-5.7) and
100+
[pinepain/php-v8](https://launchpad.net/~pinepain/+archive/ubuntu/php-v8) standalone PPAs.
101+
102+
85103
#### OS X (homebrew)
86104

87105
```
88106
$ brew tap homebrew/dupes
89107
$ brew tap homebrew/php
90-
$ brew install php70
91-
$ brew install https://raw.githubusercontent.com/pinepain/packaging/master/homebrew/v8.rb
92-
$ brew install https://raw.githubusercontent.com/pinepain/packaging/master/homebrew/php70-v8.rb
108+
$ brew tap pinepain/devtools
109+
$ brew install php70
110+
$ brew install v8@5.7
111+
$ brew install php70-v8
93112
$ php --ri v8
94113
```
95114

96-
### Requirements
97-
98-
#### V8
99-
You will need a recent v8 Google JavaScript engine version installed. At this time the extension is tested on 5.4.420.
100-
101-
- For Ubuntu there is the [pinepain/libv8-5.4](https://launchpad.net/~pinepain/+archive/ubuntu/libv8-5.4) PPA.
102-
To install libv8:
103-
104-
```
105-
$ sudo add-apt-repository -y ppa:pinepain/libv8-5.4
106-
$ sudo apt-get update -y
107-
$ sudo apt-get install -y libv8-5.4-dev
108-
```
109-
- For OS X there is the [v8.rb][v8.rb] homebrew formula.
110-
To install libv8:
111-
112-
```
113-
$ brew install https://raw.githubusercontent.com/pinepain/packaging/master/homebrew/v8.rb
114-
```
115-
116-
#### PHP 7
117-
118-
- For Ubuntu there is the [ondrej/php](https://launchpad.net/~ondrej/+archive/ubuntu/php) PPA by [Ondřej Surý](https://deb.sury.org).
119-
120-
To install `php7.0`:
121-
122-
```
123-
$ sudo add-apt-repository -y ppa:ondrej/php
124-
$ sudo apt-get update -y
125-
$ sudo apt-get install -y php7.0
126-
```
127-
- For OS X there is the [homebrew/homebrew-php](https://github.com/Homebrew/homebrew-php) tap with php70, php71 and a large
128-
variety extensions for them.
129-
130-
To install `php70`:
131-
132-
```
133-
$ brew tap homebrew/homebrew-php
134-
$ brew install php70
135-
```
136-
137-
138-
### Installing php-v8 from packages
139-
140-
- For Ubuntu there is the [pinepain/php-v8](https://launchpad.net/~pinepain/+archive/ubuntu/php-v8) PPA.
141-
142-
To install `php-v8`:
143-
144-
```
145-
$ sudo add-apt-repository -y ppa:pinepain/php-v8
146-
$ sudo apt-get update -y
147-
$ sudo apt-get install -y php-v8
148-
```
149-
- For OS X there are the [php70-v8.rb][php70-v8.rb] and [php71-v8.rb][php71-v8.rb] homebrew formulas.
150-
151-
To install `php70-v8` do:
152-
153-
```
154-
$ brew install https://raw.githubusercontent.com/pinepain/packaging/master/homebrew/php70-v8.rb
155-
```
115+
For macOS php-v8 formulae and dependencies provided by [pinepain/devtools](https://github.com/pinepain/homebrew-devtools) tap.
156116

157117
### Building php-v8 from sources
158118

@@ -186,7 +146,3 @@ Copyright (c) 2015-2016 Bogdan Padalko <pinepain@gmail.com>
186146

187147
[v8-hello-world]: https://chromium.googlesource.com/v8/v8/+/master/samples/hello-world.cc
188148
[v8-intro]: https://developers.google.com/v8/intro
189-
[v8.rb]: https://github.com/pinepain/packaging/blob/master/homebrew/v8.rb
190-
[php70-v8.rb]: https://github.com/pinepain/packaging/blob/master/homebrew/php70-v8.rb
191-
[php71-v8.rb]: https://github.com/pinepain/packaging/blob/master/homebrew/php71-v8.rb
192-
[php-v8-stubs]: https://github.com/pinepain/php-v8-stubs

config.m4

Lines changed: 33 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,19 @@ PHP_ARG_WITH(v8, for V8 Javascript Engine,
22
[ --with-v8 Include V8 JavaScript Engine])
33

44
if test "$PHP_V8" != "no"; then
5+
V8_LIB_DIR=""
6+
V8_INCLUDE_DIR=""
7+
58
SEARCH_PATH="/usr/local /usr"
69
SEARCH_FOR="include/v8.h"
710

11+
DESIRED_V8_VERSION=5.7
12+
13+
# Path where v8 from packages we recommend are installed, it's /opt/libv8-MAJOR.MINOR on Ubuntu
14+
# and /usr/local/opt/v8@MAJOR.MINOR on macOS
15+
PRIORITY_SEARCH_PATH="/opt/libv8-${DESIRED_V8_VERSION} /usr/local/opt/v8@${DESIRED_V8_VERSION}"
16+
SEARCH_PATH="${PRIORITY_SEARCH_PATH} /usr/local /usr"
17+
818
if test -r $PHP_V8/$SEARCH_FOR; then
919
case $host_os in
1020
darwin* )
@@ -14,28 +24,31 @@ if test "$PHP_V8" != "no"; then
1424
LDFLAGS="$LDFLAGS -Wl,--rpath=$PHP_V8/$PHP_LIBDIR"
1525
;;
1626
esac
17-
V8_DIR=$PHP_V8
27+
V8_LIB_DIR=$PHP_V8/$PHP_LIBDIR
28+
V8_INCLUDE_DIR=$PHP_V8/include
1829
else
1930
AC_MSG_CHECKING([for V8 files in default path])
2031
for i in $SEARCH_PATH ; do
2132
if test -r $i/$SEARCH_FOR; then
22-
V8_DIR=$i
2333
AC_MSG_RESULT(found in $i)
34+
V8_LIB_DIR=$i/$PHP_LIBDIR
35+
V8_INCLUDE_DIR=$i/include
2436
fi
2537
done
2638
fi
2739

28-
if test -z "$V8_DIR"; then
40+
if test -z "$V8_LIB_DIR"; then
2941
AC_MSG_RESULT([not found])
30-
AC_MSG_ERROR([Please reinstall the v8 distribution])
42+
AC_MSG_ERROR([Please reinstall the v8 distribution or provide valid path to it])
3143
fi
3244

33-
PHP_ADD_INCLUDE($V8_DIR/include)
34-
PHP_ADD_LIBRARY_WITH_PATH(v8, $V8_DIR/$PHP_LIBDIR, V8_SHARED_LIBADD)
45+
AC_DEFINE_UNQUOTED([PHP_V8_LIB_DIR], ["$V8_LIB_DIR/"], [Root directory with libraries (and icu data file)])
46+
47+
PHP_ADD_INCLUDE($V8_INCLUDE_DIR)
48+
PHP_ADD_LIBRARY_WITH_PATH(v8, $V8_LIB_DIR, V8_SHARED_LIBADD)
3549
PHP_SUBST(V8_SHARED_LIBADD)
3650
PHP_REQUIRE_CXX()
3751

38-
3952
AC_CACHE_CHECK(for C standard version, ac_cv_v8_cstd, [
4053
ac_cv_v8_cstd="c++11"
4154
old_CPPFLAGS=$CPPFLAGS
@@ -54,54 +67,22 @@ if test "$PHP_V8" != "no"; then
5467
case $host_os in
5568
darwin* )
5669
# MacOS does not support --rpath
57-
LDFLAGS="-L$V8_DIR/$PHP_LIBDIR"
70+
LDFLAGS="-L$V8_LIB_DIR"
5871
;;
5972
* )
60-
LDFLAGS="-Wl,--rpath=$V8_DIR/$PHP_LIBDIR -L$V8_DIR/$PHP_LIBDIR"
73+
LDFLAGS="-Wl,--rpath=$V8_LIB_DIR -L$V8_LIB_DIR"
6174
;;
6275
esac
6376

6477
PHP_ADD_INCLUDE($V8_DIR)
6578

66-
case $host_os in
67-
darwin* )
68-
static_link_extra="libv8_libplatform.a libv8_libbase.a"
69-
#static_link_extra="libv8_base.a libv8_libbase.a libv8_libplatform.a libv8_snapshot.a"
70-
;;
71-
* )
72-
static_link_extra="libv8_libplatform.a"
73-
#static_link_extra="libv8_base.a libv8_libbase.a libv8_libplatform.a libv8_snapshot.a"
74-
;;
75-
esac
76-
77-
for static_link_extra_file in $static_link_extra; do
78-
AC_MSG_CHECKING([for $static_link_extra_file])
79-
static_link_dir=""
80-
81-
for i in $PHP_V8 $SEARCH_PATH ; do
82-
if test -r $i/lib64/$static_link_extra_file; then
83-
static_link_dir=$i/lib64
84-
AC_MSG_RESULT(found in $i)
85-
fi
86-
if test -r $i/lib/$static_link_extra_file; then
87-
static_link_dir=$i/lib
88-
AC_MSG_RESULT(found in $i)
89-
fi
90-
done
91-
92-
if test -z "$static_link_dir"; then
93-
AC_MSG_RESULT([not found])
94-
AC_MSG_ERROR([Please provide $static_link_extra_file next to the libv8.so])
95-
fi
96-
97-
LDFLAGS="$LDFLAGS $static_link_dir/$static_link_extra_file"
98-
done
99-
100-
LIBS=-lv8
101-
CPPFLAGS="-I$V8_DIR/include -std=$ac_cv_v8_cstd"
79+
LDFLAGS="$LDFLAGS -lv8_libbase -lv8_libplatform"
80+
LIBS="-lv8 -lv8_libbase -lv8_libplatform"
81+
CPPFLAGS="-I$V8_INCLUDE_DIR -std=$ac_cv_v8_cstd"
10282
AC_LANG_SAVE
10383
AC_LANG_CPLUSPLUS
10484

85+
10586
# NOTE: it is possible to get version string from headers with simple regexp match
10687
AC_CACHE_CHECK(for V8 version, ac_cv_v8_version, [
10788
AC_TRY_RUN([
@@ -124,7 +105,7 @@ if test "$PHP_V8" != "no"; then
124105
], [ac_cv_v8_version=`cat ./conftestval|awk '{print $1}'`], [ac_cv_v8_version=NONE], [ac_cv_v8_version=NONE])
125106
])
126107

127-
V8_MIN_API_VERSION_STR=5.4.420
108+
V8_MIN_API_VERSION_STR=5.7.202
128109

129110
if test "$ac_cv_v8_version" != "NONE"; then
130111
ac_IFS=$IFS
@@ -147,15 +128,18 @@ if test "$PHP_V8" != "no"; then
147128

148129
# On OS X clang reports warnings in zeng_strings.h, like
149130
# php/Zend/zend_string.h:326:2: warning: 'register' storage class specifier is deprecated [-Wdeprecated-register]
150-
# We want to make building log cleaner, so let's suppress this warning
131+
# also
132+
# php/Zend/zend_operators.h:128:18: warning: 'finite' is deprecated: first deprecated in macOS 10.9 [-Wdeprecated-declarations]
133+
# but as we want to track also deprecated methods from v8 we won't ignore -Wdeprecated-declarations warnings
134+
# We want to make building log cleaner, so let's suppress only -Wdeprecated-register warning
151135
ac_cv_suppress_register_warnings_flag="-Wno-deprecated-register"
136+
#ac_cv_suppress_register_warnings_flag="-Wno-deprecated-register -Wno-deprecated-declarations"
152137

153138
AC_DEFINE([V8_DEPRECATION_WARNINGS], [1], [Enable compiler warnings when using V8_DEPRECATED apis.])
154139
AC_DEFINE([V8_IMMINENT_DEPRECATION_WARNINGS], [1], [Enable compiler warnings to make it easier to see what v8 apis will be deprecated (V8_DEPRECATED) soon.])
155140

156141
AC_LANG_RESTORE
157-
LIBS=$old_LIBS
158-
#LDFLAGS=$old_LDFLAGS # we have to links some static libraries
142+
#LDFLAGS=$old_LDFLAGS # we have to links some libraries
159143
CPPFLAGS=$old_CPPFLAGS
160144

161145
if test -z "$TRAVIS" ; then

php_v8.h

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ extern "C" {
3131
extern zend_module_entry php_v8_module_entry;
3232
#define phpext_v8_ptr &php_v8_module_entry
3333

34+
#ifndef PHP_V8_LIB_DIR
35+
#define PHP_V8_LIB_DIR NULL
36+
#endif
3437

3538
#ifndef PHP_V8_VERSION
3639
#define PHP_V8_VERSION "0.2.0-dev"
@@ -70,12 +73,3 @@ ZEND_TSRMLS_CACHE_EXTERN();
7073
ZEND_EXTERN_MODULE_GLOBALS(v8);
7174

7275
#endif //PHP_V8_H
73-
74-
/*
75-
* Local variables:
76-
* tab-width: 4
77-
* c-basic-offset: 4
78-
* End:
79-
* vim600: noet sw=4 ts=4 fdm=marker
80-
* vim<600: noet sw=4 ts=4
81-
*/

scripts/test_v8/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
hello_world
2+
hello_world.dSYM

scripts/test_v8/hello_world_build_deb.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
#!/bin/bash
22

3+
ROOT=/opt/libv8-5.7
4+
LIB_DIR=$ROOT/lib/
5+
6+
SRC_DIR=$ROOT
7+
INCLUDE_DIR=$ROOT/include
8+
39
g++ hello_world.cpp -o hello_world \
410
-g \
511
-O2 \
612
-std=c++11 \
7-
-I/usr/ \
8-
-I/usr/include \
9-
-L/usr/lib/ \
13+
-I$SRC_DIR \
14+
-I$INCLUDE_DIR \
15+
-L$LIB_DIR \
1016
-lv8_libbase \
1117
-lv8_libplatform \
1218
-lv8 \
Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
#!/bin/bash
22

3+
ROOT=/usr/local/opt/v8@5.7
4+
LIB_DIR=$ROOT/lib/
5+
6+
SRC_DIR=$ROOT
7+
INCLUDE_DIR=$ROOT/include
8+
39
g++ hello_world.cpp -o hello_world \
410
-g \
511
-O2 \
612
-std=c++11 \
7-
-I/usr/local \
8-
-I/usr/local/include \
9-
-L/usr/local/lib/ \
13+
-I$SRC_DIR \
14+
-I$INCLUDE_DIR \
15+
-L$LIB_DIR \
1016
-lv8_libbase \
1117
-lv8_libplatform \
1218
-lv8 \
1319
-lpthread
20+
21+
install_name_tool -add_rpath $LIB_DIR hello_world

src/php_v8_a.cc

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ void php_v8_init()
2929
return;
3030
}
3131

32+
v8::V8::InitializeICUDefaultLocation(PHP_V8_LIB_DIR);
33+
3234
// NOTE: if we use snapshot and extenal startup data then we have to initialize it (see https://codereview.chromium.org/315033002/)
3335
// v8::V8::InitializeExternalStartupData(NULL);
3436
v8::Platform *platform = v8::platform::CreateDefaultPlatform();
@@ -54,15 +56,3 @@ void php_v8_init()
5456
// v8::V8::Dispose();
5557
// v8::V8::ShutdownPlatform();
5658
}
57-
58-
59-
60-
61-
/*
62-
* Local variables:
63-
* tab-width: 4
64-
* c-basic-offset: 4
65-
* End:
66-
* vim600: noet sw=4 ts=4 fdm=marker
67-
* vim<600: noet sw=4 ts=4
68-
*/

0 commit comments

Comments
 (0)