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

Add missed features, cleanup #20

Merged
merged 18 commits into from
Feb 18, 2017
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
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ env:
- NO_INTERACTION=1
- TEST_TIMEOUT=120
matrix:
- V8=5.7
- V8=5.7 TEST_PHP_ARGS=-m
- V8=5.8
- V8=5.8 TEST_PHP_ARGS=-m

before_install:
- sudo add-apt-repository ppa:pinepain/libv8-${V8} -y
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ project(php_v8)

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

include_directories(/usr/local/opt/v8@5.7/include)
include_directories(/usr/local/opt/v8@5.7/include/libplatform)
include_directories(/usr/local/opt/v8@5.8/include)
include_directories(/usr/local/opt/v8@5.8/include/libplatform)

include_directories(/usr/local/include/php)
include_directories(/usr/local/include/php/TSRM)
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ in your IDE and other code-analysis tools.
### Requirements

#### V8
You will need a recent v8 Google JavaScript engine version installed. At this time the extension is tested on 5.7.514.
You will need a recent v8 Google JavaScript engine version installed. At this time the extension is tested on 5.8.168.

#### PHP
This extension is PHP7-only. It works and tested with both PHP 7.0 and PHP 7.1.
Expand All @@ -96,7 +96,7 @@ $ php --ri v8

While [pinepain/php](https://launchpad.net/~pinepain/+archive/ubuntu/php) PPA targets to contain all necessary
extensions with dependencies, you may find
[pinepain/libv8-5.7](https://launchpad.net/~pinepain/+archive/ubuntu/libv8-5.7),
[pinepain/libv8-5.8](https://launchpad.net/~pinepain/+archive/ubuntu/libv8-5.8),
[pinepain/libv8-experimental](https://launchpad.net/~pinepain/+archive/ubuntu/libv8-experimental) and
[pinepain/php-v8](https://launchpad.net/~pinepain/+archive/ubuntu/php-v8) standalone PPAs useful.

Expand All @@ -108,7 +108,7 @@ $ brew tap homebrew/dupes
$ brew tap homebrew/php
$ brew tap pinepain/devtools
$ brew install php70
$ brew install v8@5.7
$ brew install v8@5.8
$ brew install php70-v8
$ php --ri v8
```
Expand All @@ -134,6 +134,7 @@ $ sudo make install
- to be able to customize some tests make sure you have `variables_order = "EGPCS"` in your php.ini
- `export DEV_TESTS=1` allows to run tests that are made for development reasons (e.g. test some weird behavior or for debugging)
- To prevent the test suite from asking you to send results to the PHP QA team do `export NO_INTERACTION=1`
- To run tests with memory leaaks check, install `valgrind` and do `export TEST_PHP_ARGS="-m"`

- To track memory usage you may want to use `smem`, `pmem` or even `lsof` to see what shared object are loaded
and `free` to display free and used memory in the system.
Expand Down
117 changes: 52 additions & 65 deletions config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ if test "$PHP_V8" != "no"; then
SEARCH_PATH="/usr/local /usr"
SEARCH_FOR="include/v8.h"

V8_MIN_API_VERSION_STR=5.7.514
V8_MIN_API_VERSION_STR=5.8.168

DESIRED_V8_VERSION=`echo "${V8_MIN_API_VERSION_STR}" | $AWK 'BEGIN { FS = "."; } { printf "%s.%s", [$]1, [$]2;}'`

Expand All @@ -18,53 +18,39 @@ if test "$PHP_V8" != "no"; then
SEARCH_PATH="${PRIORITY_SEARCH_PATH} /usr/local /usr"

if test -r $PHP_V8/$SEARCH_FOR; then
case $host_os in
darwin* )
# MacOS does not support --rpath
;;
* )
LDFLAGS="$LDFLAGS -Wl,--rpath=$PHP_V8/$PHP_LIBDIR"
;;
esac
V8_LIB_DIR=$PHP_V8/$PHP_LIBDIR
V8_INCLUDE_DIR=$PHP_V8/include
V8_ROOT_DIR=$PHP_V8
else
AC_MSG_CHECKING([for V8 files in default path])
for i in $SEARCH_PATH ; do
if test -r $i/$SEARCH_FOR; then
AC_MSG_RESULT(found in $i)
V8_LIB_DIR=$i/$PHP_LIBDIR
V8_INCLUDE_DIR=$i/include
V8_ROOT_DIR=$i
break
fi
done
fi

if test -z "$V8_LIB_DIR"; then
if test -z "$V8_ROOT_DIR"; then
AC_MSG_RESULT([not found])
AC_MSG_ERROR([Please reinstall the v8 distribution or provide valid path to it])
fi

AC_DEFINE_UNQUOTED([PHP_V8_LIB_DIR], ["$V8_LIB_DIR/"], [Root directory with libraries (and icu data file)])
V8_LIB_DIR=$V8_ROOT_DIR/$PHP_LIBDIR
V8_INCLUDE_DIR=$V8_ROOT_DIR/include

PHP_ADD_INCLUDE($V8_INCLUDE_DIR)
PHP_ADD_LIBRARY_WITH_PATH(v8, $V8_LIB_DIR, V8_SHARED_LIBADD)
PHP_SUBST(V8_SHARED_LIBADD)
PHP_REQUIRE_CXX()
AC_MSG_CHECKING([for ICU data file icudtl.dat])

AC_CACHE_CHECK(for C standard version, ac_cv_v8_cstd, [
ac_cv_v8_cstd="c++11"
old_CPPFLAGS=$CPPFLAGS
AC_LANG_PUSH([C++])
CPPFLAGS="-std="$ac_cv_v8_cstd
AC_TRY_RUN([int main() { return 0; }],[],[ac_cv_v8_cstd="c++0x"],[])
AC_LANG_POP([C++])
CPPFLAGS=$old_CPPFLAGS
]);
if test -r "$V8_LIB_DIR/icudtl.dat"; then
PHP_V8_ICU_DATA_DIR="$V8_LIB_DIR/" # trailing slash is required
AC_MSG_RESULT(found in $PHP_V8_ICU_DATA_DIR)
fi

if test -z "PHP_V8_ICU_DATA_DIR"; then
AC_MSG_RESULT([not found])
AC_MSG_ERROR([ICU data file icudtl.dat not found])
fi

old_LIBS=$LIBS
old_LDFLAGS=$LDFLAGS
old_CPPFLAGS=$CPPFLAGS
AC_DEFINE_UNQUOTED([PHP_V8_ICU_DATA_DIR], ["$PHP_V8_ICU_DATA_DIR"], [ICU data path (trailing slash is required)])

case $host_os in
darwin* )
Expand All @@ -76,35 +62,24 @@ if test "$PHP_V8" != "no"; then
;;
esac

PHP_ADD_INCLUDE($V8_DIR)
AC_CACHE_CHECK(for V8 version, ac_cv_v8_version, [
if test -z "$V8_INCLUDE_DIR/v8-version.h"; then
AC_MSG_RESULT([not found])
AC_MSG_ERROR([Please reinstall the v8 distribution or provide valid path to it])
fi

LDFLAGS="$LDFLAGS -lv8_libbase -lv8_libplatform"
LIBS="-lv8 -lv8_libbase -lv8_libplatform"
CPPFLAGS="-I$V8_INCLUDE_DIR -std=$ac_cv_v8_cstd"
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
major=`cat $V8_INCLUDE_DIR/v8-version.h | grep V8_MAJOR_VERSION | awk '{print $3}'`
minor=`cat $V8_INCLUDE_DIR/v8-version.h | grep V8_MINOR_VERSION | awk '{print $3}'`
build=`cat $V8_INCLUDE_DIR/v8-version.h | grep V8_BUILD_NUMBER | awk '{print $3}'`
patch=`cat $V8_INCLUDE_DIR/v8-version.h | grep V8_PATCH_LEVEL | awk '{print $3}'`
candidate=`cat $V8_INCLUDE_DIR/v8-version.h | grep V8_IS_CANDIDATE_VERSION | awk '{print $3}'`

version="$major.$minor.$build"

# NOTE: it is possible to get version string from headers with simple regexp match
AC_CACHE_CHECK(for V8 version, ac_cv_v8_version, [
AC_TRY_RUN([
#include <v8.h>
#include <iostream>
#include <fstream>
using namespace std;

int main ()
{
ofstream testfile ("conftestval");
if (testfile.is_open()) {
testfile << v8::V8::GetVersion();
testfile << "\n";
testfile.close();
return 0;
}
return 1;
}
], [ac_cv_v8_version=`cat ./conftestval|awk '{print $1}'`], [ac_cv_v8_version=NONE], [ac_cv_v8_version=NONE])
if test $patch -gt 0; then version="$version.$patch"; fi
if test $candidate -gt 0; then version="$version (candidate)"; fi

ac_cv_v8_version=$version
])

V8_MIN_API_VERSION_NUM=`echo "${V8_MIN_API_VERSION_STR}" | $AWK 'BEGIN { FS = "."; } { printf "%d", [$]1 * 1000000 + [$]2 * 1000 + [$]3;}'`
Expand All @@ -121,23 +96,30 @@ if test "$PHP_V8" != "no"; then
AC_MSG_ERROR([could not determine libv8 version])
fi

PHP_ADD_INCLUDE($V8_DIR)
PHP_ADD_INCLUDE($V8_INCLUDE_DIR)

PHP_ADD_LIBRARY_WITH_PATH(v8, $V8_LIB_DIR, V8_SHARED_LIBADD)
PHP_ADD_LIBRARY_WITH_PATH(v8_libbase, $V8_LIB_DIR, V8_SHARED_LIBADD)
PHP_ADD_LIBRARY_WITH_PATH(v8_libplatform, $V8_LIB_DIR, V8_SHARED_LIBADD)

PHP_SUBST(V8_SHARED_LIBADD)
PHP_REQUIRE_CXX()

CPPFLAGS="$CPPFLAGS -std=c++11"

# On OS X clang reports warnings in zeng_strings.h, like
# php/Zend/zend_string.h:326:2: warning: 'register' storage class specifier is deprecated [-Wdeprecated-register]
# also
# php/Zend/zend_operators.h:128:18: warning: 'finite' is deprecated: first deprecated in macOS 10.9 [-Wdeprecated-declarations]
# but as we want to track also deprecated methods from v8 we won't ignore -Wdeprecated-declarations warnings
# We want to make building log cleaner, so let's suppress only -Wdeprecated-register warning
PHP_V8_COMPILER_OPTIONS="-Wno-deprecated-register"
#PHP_V8_COMPILER_OPTIONS="-Wno-deprecated-register -Wno-deprecated-declarations"
CPPFLAGS="$CPPFLAGS -Wno-deprecated-register -Wno-unicode"
#CPPFLAGS="$CPPFLAGS -Wno-deprecated-declarations"

AC_DEFINE([V8_DEPRECATION_WARNINGS], [1], [Enable compiler warnings when using V8_DEPRECATED apis.])
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.])

AC_LANG_RESTORE
LIBS=$old_LIBS
#LDFLAGS=$old_LDFLAGS # we have to links some libraries
CPPFLAGS=$old_CPPFLAGS

if test -z "$TRAVIS" ; then
type git &>/dev/null

Expand Down Expand Up @@ -185,6 +167,11 @@ if test "$PHP_V8" != "no"; then
src/php_v8_object_template.cc \
src/php_v8_function_template.cc \
src/php_v8_script.cc \
src/php_v8_unbound_script.cc \
src/php_v8_cached_data.cc \
src/php_v8_compile_options.cc \
src/php_v8_script_compiler.cc \
src/php_v8_source.cc \
src/php_v8_data.cc \
src/php_v8_value.cc \
src/php_v8_primitive.cc \
Expand Down Expand Up @@ -220,7 +207,7 @@ if test "$PHP_V8" != "no"; then
src/php_v8_named_property_handler_configuration.cc \
src/php_v8_indexed_property_handler_configuration.cc \
src/php_v8_access_type.cc \
], $ext_shared, , "$PHP_V8_COMPILER_OPTIONS -std="$ac_cv_v8_cstd -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
], $ext_shared, , -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)

PHP_ADD_BUILD_DIR($ext_builddir/src)

Expand Down
4 changes: 2 additions & 2 deletions php_v8.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ extern "C" {
extern zend_module_entry php_v8_module_entry;
#define phpext_v8_ptr &php_v8_module_entry

#ifndef PHP_V8_LIB_DIR
#define PHP_V8_LIB_DIR NULL
#ifndef PHP_V8_ICU_DATA_DIR
#define PHP_V8_ICU_DATA_DIR NULL
#endif

#ifndef PHP_V8_VERSION
Expand Down
2 changes: 1 addition & 1 deletion src/php_v8_a.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void php_v8_init()
return;
}

v8::V8::InitializeICUDefaultLocation(PHP_V8_LIB_DIR);
v8::V8::InitializeICUDefaultLocation(PHP_V8_ICU_DATA_DIR);

// NOTE: if we use snapshot and extenal startup data then we have to initialize it (see https://codereview.chromium.org/315033002/)
// v8::V8::InitializeExternalStartupData(NULL);
Expand Down
Loading