Skip to content

Commit

Permalink
[unity]node.js 添加no-browser-globals. fix #521
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieyang authored Nov 16, 2021
1 parent 241f52b commit a9972d3
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 48 deletions.
6 changes: 5 additions & 1 deletion nodejs-build/linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@ cd node
git fetch origin v$VERSION
git checkout v$VERSION

echo "=====[Patching Node.js]====="

git apply --cached $GITHUB_WORKSPACE/nodejs-build/nodemod.patch
git apply --cached $GITHUB_WORKSPACE/nodejs-build/lib_uv_add_on_watcher_queue_updated.patch
git checkout -- .

./configure --shared
echo "=====[Building Node.js]====="

./configure --shared --no-browser-globals
make -j8

mkdir -p ../puerts-node/nodejs/include
Expand Down
6 changes: 5 additions & 1 deletion nodejs-build/macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@ cd node
git fetch origin v$VERSION
git checkout v$VERSION

echo "=====[Patching Node.js]====="

git apply --cached $GITHUB_WORKSPACE/nodejs-build/nodemod.patch
git apply --cached $GITHUB_WORKSPACE/nodejs-build/lib_uv_add_on_watcher_queue_updated.patch
git checkout -- .

./configure --shared
echo "=====[Building Node.js]====="

./configure --shared --no-browser-globals
make -j8

mkdir -p ../puerts-node/nodejs/include
Expand Down
53 changes: 15 additions & 38 deletions nodejs-build/nodemod.patch
Original file line number Diff line number Diff line change
@@ -1,48 +1,25 @@
diff --git a/node.gyp b/node.gyp
index 8ba0dfebe8..53b67360d9 100644
index f18a0d58a8..5c4cc23ac0 100644
--- a/node.gyp
+++ b/node.gyp
@@ -827,6 +827,7 @@
@@ -818,6 +818,7 @@
'Dbghelp',
'Psapi',
'Ws2_32',
+ 'Winmm',
],
}],
[ 'node_use_etw=="true"', {
diff --git a/src/node.cc b/src/node.cc
index b3823235de..71f36aa4ae 100644
--- a/src/node.cc
+++ b/src/node.cc
@@ -134,6 +134,10 @@ using v8::Undefined;
using v8::V8;
using v8::Value;

+std::unique_ptr<v8::Platform> NewDefaultPlatform() {
+ return v8::platform::NewDefaultPlatform();
+}
+
namespace per_process {

// node_revert.h
diff --git a/src/node.h b/src/node.h
index 38e0ef50f9..5fa8c255a1 100644
--- a/src/node.h
+++ b/src/node.h
@@ -71,6 +71,7 @@

#include "v8-platform.h" // NOLINT(build/include_order)
#include "node_version.h" // NODE_MODULE_VERSION
+#include "libplatform/libplatform.h"

#include <memory>
#include <functional>
@@ -123,6 +124,8 @@ struct napi_module;
// terminally confused when it's done in node_internals.h
namespace node {

+std::unique_ptr<v8::Platform> NewDefaultPlatform();
+
namespace tracing {

class TracingController;
diff --git a/vcbuild.bat b/vcbuild.bat
index 4316658bb4..a455f60339 100644
--- a/vcbuild.bat
+++ b/vcbuild.bat
@@ -51,7 +51,7 @@ set noetw_msi_arg=
set i18n_arg=
set download_arg=
set build_release=
-set configure_flags=
+set configure_flags=--no-browser-globals
set build_addons=
set dll=
set enable_static=
3 changes: 3 additions & 0 deletions nodejs-build/windows_trybuild.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ cd node
git fetch origin v%VERSION%
git checkout v%VERSION%

echo =====[ Patching Node.js ]=====

node %GITHUB_WORKSPACE%\v8-build\CRLF2LF.js %GITHUB_WORKSPACE%\nodejs-build\nodemod.patch
call git apply --cached --reject %GITHUB_WORKSPACE%\nodejs-build\nodemod.patch
node %GITHUB_WORKSPACE%\v8-build\CRLF2LF.js %GITHUB_WORKSPACE%\nodejs-build\lib_uv_add_on_watcher_queue_updated.patch
Expand All @@ -15,4 +17,5 @@ call git checkout -- .

copy /y %GITHUB_WORKSPACE%\nodejs-build\zlib.def deps\zlib\win32\zlib.def

echo =====[ Building Node.js ]=====
.\vcbuild.bat dll openssl-no-asm
10 changes: 2 additions & 8 deletions unity/Assets/Puerts/Src/JsEnv.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,8 @@ public JsEnv(ILoader loader, int debugPort, IntPtr externalRuntime, IntPtr exter
ExecuteFile("puerts/cjsload.js");
ExecuteFile("puerts/modular.js");
ExecuteFile("puerts/csharp.js");
#if !PUERTS_GENERAL
if (!isNode)
{
#endif
ExecuteFile("puerts/timer.js");
#if !PUERTS_GENERAL
}
#endif
ExecuteFile("puerts/timer.js");

ExecuteFile("puerts/events.js");
ExecuteFile("puerts/promises.js");
#if !PUERTS_GENERAL
Expand Down

0 comments on commit a9972d3

Please sign in to comment.