mirror of
https://github.com/phpv8/v8js.git
synced 2024-11-08 10:18:41 +00:00
Don't try to guess if blob.bin files are needed
Search for them, if they exist, provide them to V8. Otherwise try to go without them. Conflicts: config.m4 Backport from php7 branch.
This commit is contained in:
parent
ea8ac66762
commit
5c07ed2974
96
config.m4
96
config.m4
@ -115,8 +115,6 @@ if test "$PHP_V8JS" != "no"; then
|
||||
dnl Check for V8 version
|
||||
dnl (basic support for library linking assumed to be achieved above)
|
||||
dnl
|
||||
|
||||
|
||||
LIBS="$LIBS $V8JS_SHARED_LIBADD"
|
||||
AC_CACHE_CHECK(for V8 version, ac_cv_v8_version, [
|
||||
AC_TRY_RUN([#include <v8.h>
|
||||
@ -152,90 +150,36 @@ int main ()
|
||||
AC_MSG_ERROR([could not determine libv8 version])
|
||||
fi
|
||||
|
||||
PHP_ADD_INCLUDE($V8_DIR)
|
||||
|
||||
# modify flags for (possibly) succeeding V8 startup check
|
||||
CPPFLAGS="$CPPFLAGS -I$V8_DIR"
|
||||
dnl
|
||||
dnl Scan for blob.bin files (that might be needed)
|
||||
dnl
|
||||
AC_DEFUN([V8_SEARCH_BLOB], [
|
||||
AC_MSG_CHECKING([for $1])
|
||||
blob_found=0
|
||||
|
||||
dnl building for v8 4.4.10 or later, which requires us to
|
||||
dnl provide startup data, if V8 wasn't compiled with snapshot=off.
|
||||
AC_MSG_CHECKING([whether V8 requires startup data])
|
||||
AC_TRY_RUN([
|
||||
#include <v8.h>
|
||||
#include <libplatform/libplatform.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
|
||||
public:
|
||||
virtual void* Allocate(size_t length) {
|
||||
void* data = AllocateUninitialized(length);
|
||||
return data == NULL ? data : memset(data, 0, length);
|
||||
}
|
||||
virtual void* AllocateUninitialized(size_t length) { return malloc(length); }
|
||||
virtual void Free(void* data, size_t) { free(data); }
|
||||
};
|
||||
|
||||
int main ()
|
||||
{
|
||||
v8::Platform *v8_platform = v8::platform::CreateDefaultPlatform();
|
||||
v8::V8::InitializePlatform(v8_platform);
|
||||
v8::V8::Initialize();
|
||||
|
||||
static ArrayBufferAllocator array_buffer_allocator;
|
||||
v8::Isolate::CreateParams create_params;
|
||||
create_params.array_buffer_allocator = &array_buffer_allocator;
|
||||
|
||||
v8::Isolate::New(create_params);
|
||||
return 0;
|
||||
}
|
||||
], [
|
||||
AC_MSG_RESULT([no])
|
||||
], [
|
||||
AC_MSG_RESULT([yes])
|
||||
AC_DEFINE([PHP_V8_USE_EXTERNAL_STARTUP_DATA], [1], [Whether V8 requires (and can be provided with custom versions of) external startup data])
|
||||
|
||||
SEARCH_PATH="$V8_DIR/lib $V8_DIR/share/v8"
|
||||
|
||||
AC_MSG_CHECKING([for natives_blob.bin])
|
||||
SEARCH_FOR="natives_blob.bin"
|
||||
|
||||
for i in $SEARCH_PATH ; do
|
||||
if test -r $i/$SEARCH_FOR; then
|
||||
AC_MSG_RESULT([found ($i/$SEARCH_FOR)])
|
||||
AC_DEFINE_UNQUOTED([PHP_V8_NATIVES_BLOB_PATH], "$i/$SEARCH_FOR", [Full path to natives_blob.bin file])
|
||||
native_blob_found=1
|
||||
fi
|
||||
done
|
||||
|
||||
if test -z "$native_blob_found"; then
|
||||
AC_MSG_RESULT([not found])
|
||||
AC_MSG_ERROR([Please provide V8 native blob as needed])
|
||||
for i in "$V8_DIR/$PHP_LIBDIR" "$V8_DIR/share/v8"; do
|
||||
if test -r "$i/$1"; then
|
||||
AC_MSG_RESULT([found ($i/$1)])
|
||||
AC_DEFINE_UNQUOTED([$2], "$i/$1", [Full path to $1 file])
|
||||
blob_found=1
|
||||
fi
|
||||
done
|
||||
|
||||
AC_MSG_CHECKING([for snapshot_blob.bin])
|
||||
SEARCH_FOR="snapshot_blob.bin"
|
||||
|
||||
for i in $SEARCH_PATH ; do
|
||||
if test -r $i/$SEARCH_FOR; then
|
||||
AC_MSG_RESULT([found ($i/$SEARCH_FOR)])
|
||||
AC_DEFINE_UNQUOTED([PHP_V8_SNAPSHOT_BLOB_PATH], "$i/$SEARCH_FOR", [Full path to snapshot_blob.bin file])
|
||||
snapshot_blob_found=1
|
||||
fi
|
||||
done
|
||||
|
||||
if test -z "$snapshot_blob_found"; then
|
||||
AC_MSG_RESULT([not found])
|
||||
AC_MSG_ERROR([Please provide V8 snapshot blob as needed])
|
||||
fi
|
||||
if test "$blob_found" -ne 1; then
|
||||
AC_MSG_RESULT([not found])
|
||||
fi
|
||||
])
|
||||
V8_SEARCH_BLOB([natives_blob.bin], [PHP_V8_NATIVES_BLOB_PATH])
|
||||
V8_SEARCH_BLOB([snapshot_blob.bin], [PHP_V8_SNAPSHOT_BLOB_PATH])
|
||||
|
||||
|
||||
AC_LANG_RESTORE
|
||||
LIBS=$old_LIBS
|
||||
LDFLAGS="$old_LDFLAGS $LDFLAGS_libplatform"
|
||||
LDFLAGS="$old_LDFLAGS"
|
||||
CPPFLAGS=$old_CPPFLAGS
|
||||
|
||||
|
||||
PHP_ADD_INCLUDE($V8_DIR)
|
||||
PHP_NEW_EXTENSION(v8js, [ \
|
||||
v8js_array_access.cc \
|
||||
v8js.cc \
|
||||
|
@ -54,7 +54,7 @@ void v8js_v8_init(TSRMLS_D) /* {{{ */
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PHP_V8_USE_EXTERNAL_STARTUP_DATA
|
||||
#if defined(PHP_V8_NATIVES_BLOB_PATH) && defined(PHP_V8_SNAPSHOT_BLOB_PATH)
|
||||
/* V8 doesn't work without startup data, load it. */
|
||||
v8::V8::InitializeExternalStartupData(
|
||||
PHP_V8_NATIVES_BLOB_PATH,
|
||||
|
Loading…
Reference in New Issue
Block a user