From fb21726c78ae928127aa0476722e77994d1e92d9 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Wed, 17 Apr 2019 18:10:48 +0200 Subject: node/v8: build dynamic libs --- deps/build_node | 11 ++++++++--- deps/build_v8 | 25 +++++++++++++++++------- deps/node/configure.py | 15 +++++++++------ deps/node/deps/v8/include/v8-platform.h | 2 +- deps/node/deps/v8/include/v8.h | 33 -------------------------------- deps/node/deps/v8/include/v8config.h | 34 +++++++++++++++++++++++++++++++++ deps/node/node.gypi | 9 ++++++++- 7 files changed, 78 insertions(+), 51 deletions(-) diff --git a/deps/build_node b/deps/build_node index 40363be6..f98f5692 100755 --- a/deps/build_node +++ b/deps/build_node @@ -1,6 +1,9 @@ #!/usr/bin/env bash -set -euf -o pipefail +set -eu -o pipefail + +scriptdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" +cd $scriptdir NDK=$1 @@ -29,8 +32,6 @@ export LINK=$TOOLCHAIN_DIR/bin/armv7a-linux-androideabi$API_LEVEL-clang++ export RANLIB=$TOOLCHAIN_DIR/bin/arm-linux-androideabi-ranlib export STRIP=$TOOLCHAIN_DIR/bin/arm-linux-androideabi-strip -export LDFLAGS="-static-libstdc++" - cd node export GYP_DEFINES="OS=android clang=1" @@ -48,6 +49,10 @@ function myconf() { if [ -z ${2+x} ]; then myconf && make + cd $scriptdir + x=compiled/armeabi-v7a/ + mkdir -p $x + cp node/out/Release/lib.target/libnode.so $x/ else eval $2 fi diff --git a/deps/build_v8 b/deps/build_v8 index b627fde1..30343e36 100755 --- a/deps/build_v8 +++ b/deps/build_v8 @@ -1,8 +1,9 @@ #!/usr/bin/env bash -set -euf -o pipefail +set -eu -o pipefail -cd $(dirname "$BASH_SOURCE") +scriptdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" +cd $scriptdir NDK=$1 @@ -18,16 +19,26 @@ fi ln -fs $NDK ./node/deps/v8/third_party/android_ndk +# We do not export anything about the tool chain, as v8 +# will pick their own toolchain for android from the ndk + cd ./node/deps/v8 python2 ./tools/node/fetch_deps.py $PWD -./tools/dev/v8gen.py arm.release -- \ +mode=debug + +./tools/dev/v8gen.py arm.$mode -- \ 'target_os="android"' \ 'target_cpu="arm"' \ - 'is_component_build=false' \ - 'v8_monolithic=true' \ + 'is_component_build=true' \ 'v8_android_log_stdout=true' \ - 'v8_use_external_startup_data=false' + 'v8_use_external_startup_data=false' \ + 'is_clang=true' + +./_depot_tools/ninja -C out.gn/arm.$mode v8 d8 -./_depot_tools/ninja -C out.gn/arm.release v8_monolith +cd $scriptdir +x=compiled/armeabi-v7a/ +mkdir -p $x +cp node/deps/v8/out.gn/arm.$mode/*.so $x/ diff --git a/deps/node/configure.py b/deps/node/configure.py index 8ae56fde..6a30501c 100755 --- a/deps/node/configure.py +++ b/deps/node/configure.py @@ -1110,14 +1110,17 @@ def configure_node(o): o['variables']['node_shared'] = b(options.shared) node_module_version = getmoduleversion.get_version() - if sys.platform == 'darwin': - shlib_suffix = '%s.dylib' - elif sys.platform.startswith('aix'): - shlib_suffix = '%s.a' + if options.dest_os == 'android': + shlib_suffix = "so" else: - shlib_suffix = 'so.%s' + if sys.platform == 'darwin': + shlib_suffix = '%s.dylib' + elif sys.platform.startswith('aix'): + shlib_suffix = '%s.a' + else: + shlib_suffix = 'so.%s' + shlib_suffix %= node_module_version - shlib_suffix %= node_module_version o['variables']['node_module_version'] = int(node_module_version) o['variables']['shlib_suffix'] = shlib_suffix diff --git a/deps/node/deps/v8/include/v8-platform.h b/deps/node/deps/v8/include/v8-platform.h index cfeb13b6..cf64ed9f 100644 --- a/deps/node/deps/v8/include/v8-platform.h +++ b/deps/node/deps/v8/include/v8-platform.h @@ -387,7 +387,7 @@ class Platform { * since epoch. Useful for implementing |CurrentClockTimeMillis| if * nothing special needed. */ - static double SystemClockTimeMillis(); + V8_EXPORT static double SystemClockTimeMillis(); }; } // namespace v8 diff --git a/deps/node/deps/v8/include/v8.h b/deps/node/deps/v8/include/v8.h index 325d3b09..ddedb141 100644 --- a/deps/node/deps/v8/include/v8.h +++ b/deps/node/deps/v8/include/v8.h @@ -25,39 +25,6 @@ #include "v8-version.h" // NOLINT(build/include) #include "v8config.h" // NOLINT(build/include) -// We reserve the V8_* prefix for macros defined in V8 public API and -// assume there are no name conflicts with the embedder's code. - -#ifdef V8_OS_WIN - -// Setup for Windows DLL export/import. When building the V8 DLL the -// BUILDING_V8_SHARED needs to be defined. When building a program which uses -// the V8 DLL USING_V8_SHARED needs to be defined. When either building the V8 -// static library or building a program which uses the V8 static library neither -// BUILDING_V8_SHARED nor USING_V8_SHARED should be defined. -#ifdef BUILDING_V8_SHARED -# define V8_EXPORT __declspec(dllexport) -#elif USING_V8_SHARED -# define V8_EXPORT __declspec(dllimport) -#else -# define V8_EXPORT -#endif // BUILDING_V8_SHARED - -#else // V8_OS_WIN - -// Setup for Linux shared library export. -#if V8_HAS_ATTRIBUTE_VISIBILITY -# ifdef BUILDING_V8_SHARED -# define V8_EXPORT __attribute__ ((visibility("default"))) -# else -# define V8_EXPORT -# endif -#else -# define V8_EXPORT -#endif - -#endif // V8_OS_WIN - /** * The v8 JavaScript engine. */ diff --git a/deps/node/deps/v8/include/v8config.h b/deps/node/deps/v8/include/v8config.h index 75fd5aa7..9f4a9ef6 100644 --- a/deps/node/deps/v8/include/v8config.h +++ b/deps/node/deps/v8/include/v8config.h @@ -420,6 +420,40 @@ namespace v8 { template class AlignOfHelper { char c; T t; }; } #define V8_WARN_UNUSED_RESULT /* NOT SUPPORTED */ #endif + +// We reserve the V8_* prefix for macros defined in V8 public API and +// assume there are no name conflicts with the embedder's code. + +#ifdef V8_OS_WIN + +// Setup for Windows DLL export/import. When building the V8 DLL the +// BUILDING_V8_SHARED needs to be defined. When building a program which uses +// the V8 DLL USING_V8_SHARED needs to be defined. When either building the V8 +// static library or building a program which uses the V8 static library neither +// BUILDING_V8_SHARED nor USING_V8_SHARED should be defined. +#ifdef BUILDING_V8_SHARED +# define V8_EXPORT __declspec(dllexport) +#elif USING_V8_SHARED +# define V8_EXPORT __declspec(dllimport) +#else +# define V8_EXPORT +#endif // BUILDING_V8_SHARED + +#else // V8_OS_WIN + +// Setup for Linux shared library export. +#if V8_HAS_ATTRIBUTE_VISIBILITY +# ifdef BUILDING_V8_SHARED +# define V8_EXPORT __attribute__ ((visibility("default"))) +# else +# define V8_EXPORT +# endif +#else +# define V8_EXPORT +#endif + +#endif // V8_OS_WIN + // clang-format on #endif // V8CONFIG_H_ diff --git a/deps/node/node.gypi b/deps/node/node.gypi index 5721a375..ee9ccbde 100644 --- a/deps/node/node.gypi +++ b/deps/node/node.gypi @@ -85,7 +85,14 @@ ], }], [ 'node_use_bundled_v8=="false"', { - 'libraries' : [ '