0
0
mirror of https://github.com/phpv8/v8js.git synced 2024-12-22 14:01:53 +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.
This commit is contained in:
Stefan Siegl 2016-12-05 16:28:59 +00:00
parent 09f98e7cb1
commit 77e7338018
2 changed files with 21 additions and 77 deletions

View File

@ -115,8 +115,6 @@ if test "$PHP_V8JS" != "no"; then
dnl Check for V8 version dnl Check for V8 version
dnl (basic support for library linking assumed to be achieved above) dnl (basic support for library linking assumed to be achieved above)
dnl dnl
LIBS="$LIBS $V8JS_SHARED_LIBADD" LIBS="$LIBS $V8JS_SHARED_LIBADD"
AC_CACHE_CHECK(for V8 version, ac_cv_v8_version, [ AC_CACHE_CHECK(for V8 version, ac_cv_v8_version, [
AC_TRY_RUN([#include <v8.h> AC_TRY_RUN([#include <v8.h>
@ -152,90 +150,36 @@ int main ()
AC_MSG_ERROR([could not determine libv8 version]) AC_MSG_ERROR([could not determine libv8 version])
fi fi
PHP_ADD_INCLUDE($V8_DIR)
# modify flags for (possibly) succeeding V8 startup check dnl
CPPFLAGS="$CPPFLAGS -I$V8_DIR" 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 for i in "$V8_DIR/$PHP_LIBDIR" "$V8_DIR/share/v8"; do
dnl provide startup data, if V8 wasn't compiled with snapshot=off. if test -r "$i/$1"; then
AC_MSG_CHECKING([whether V8 requires startup data]) AC_MSG_RESULT([found ($i/$1)])
AC_TRY_RUN([ AC_DEFINE_UNQUOTED([$2], "$i/$1", [Full path to $1 file])
#include <v8.h> blob_found=1
#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/$PHP_LIBDIR $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])
fi fi
done
AC_MSG_CHECKING([for snapshot_blob.bin]) if test "$blob_found" -ne 1; then
SEARCH_FOR="snapshot_blob.bin" AC_MSG_RESULT([not found])
fi
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
]) ])
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 AC_LANG_RESTORE
LIBS=$old_LIBS LIBS=$old_LIBS
LDFLAGS="$old_LDFLAGS $LDFLAGS_libplatform" LDFLAGS="$old_LDFLAGS"
CPPFLAGS=$old_CPPFLAGS CPPFLAGS=$old_CPPFLAGS
PHP_ADD_INCLUDE($V8_DIR)
PHP_NEW_EXTENSION(v8js, [ \ PHP_NEW_EXTENSION(v8js, [ \
v8js_array_access.cc \ v8js_array_access.cc \
v8js.cc \ v8js.cc \

View File

@ -52,7 +52,7 @@ void v8js_v8_init(TSRMLS_D) /* {{{ */
} }
#endif #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 doesn't work without startup data, load it. */
v8::V8::InitializeExternalStartupData( v8::V8::InitializeExternalStartupData(
PHP_V8_NATIVES_BLOB_PATH, PHP_V8_NATIVES_BLOB_PATH,