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

Commit a96667d

Browse files
committed
Adapt buil system to v8 5.7
1 parent 8680f52 commit a96667d

File tree

8 files changed

+65
-58
lines changed

8 files changed

+65
-58
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)

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 & 0 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"

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 & 0 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();

0 commit comments

Comments
 (0)