From 5d19c5eb764784da3215ef5fbdd4002b90e5009d Mon Sep 17 00:00:00 2001 From: johnche Date: Wed, 10 Aug 2022 20:24:03 +0800 Subject: [PATCH 1/3] build libnode for ios app embedding --- configure.py | 4 ++-- deps/cares/cares.gyp | 2 +- node.gyp | 2 +- node.gypi | 4 ++-- tools/gyp/pylib/gyp/common.py | 1 + tools/gyp/pylib/gyp/generator/ninja.py | 4 ++-- tools/v8_gypfiles/v8.gyp | 12 +++++++++--- 7 files changed, 18 insertions(+), 11 deletions(-) diff --git a/configure.py b/configure.py index 5b4f950e2be2cc..9cdf524edbddb8 100755 --- a/configure.py +++ b/configure.py @@ -45,7 +45,7 @@ parser = argparse.ArgumentParser() valid_os = ('win', 'mac', 'solaris', 'freebsd', 'openbsd', 'linux', - 'android', 'aix', 'cloudabi') + 'android', 'aix', 'cloudabi', 'ios') valid_arch = ('arm', 'arm64', 'ia32', 'mips', 'mipsel', 'mips64el', 'ppc', 'ppc64', 'x64', 'x86', 'x86_64', 's390x', 'riscv64', 'loong64') valid_arm_float_abi = ('soft', 'softfp', 'hard') @@ -2017,7 +2017,7 @@ def make_bin_override(): gyp_args += ['-Dbuild_type=' + config['BUILDTYPE']] if options.use_ninja: - gyp_args += ['-f', 'ninja'] + gyp_args += ['-f', 'ninja-' + flavor] elif flavor == 'win' and sys.platform != 'msys': gyp_args += ['-f', 'msvs', '-G', 'msvs_version=auto'] else: diff --git a/deps/cares/cares.gyp b/deps/cares/cares.gyp index 88933e00745d30..74f0e78e069f1e 100644 --- a/deps/cares/cares.gyp +++ b/deps/cares/cares.gyp @@ -157,7 +157,7 @@ 'include_dirs': [ 'config/linux' ], 'sources': [ 'config/linux/ares_config.h' ] }], - [ 'OS=="mac"', { + [ 'OS=="mac" or OS=="ios"', { 'include_dirs': [ 'config/darwin' ], 'sources': [ 'config/darwin/ares_config.h' ] }], diff --git a/node.gyp b/node.gyp index 9563073fd6c898..12c6bb9a5ca955 100644 --- a/node.gyp +++ b/node.gyp @@ -226,7 +226,7 @@ }, }, 'conditions': [ - ['OS != "aix" and OS != "mac"', { + ['OS != "aix" and OS != "mac" and OS != "ios"', { 'ldflags': [ '-Wl,--whole-archive', '<(obj_dir)/<(STATIC_LIB_PREFIX)<(node_core_target_name)<(STATIC_LIB_SUFFIX)', diff --git a/node.gypi b/node.gypi index d24928df8b29c9..e469716b0c123d 100644 --- a/node.gypi +++ b/node.gypi @@ -145,7 +145,7 @@ }, }, 'conditions': [ - ['OS!="aix" and node_shared=="false"', { + ['OS!="aix" and OS!="ios" and node_shared=="false"', { 'ldflags': [ '-Wl,--whole-archive', '<(obj_dir)/deps/zlib/<(STATIC_LIB_PREFIX)zlib<(STATIC_LIB_SUFFIX)', @@ -184,7 +184,7 @@ }, }, 'conditions': [ - ['OS!="aix" and node_shared=="false"', { + ['OS!="aix" and OS!="ios" and node_shared=="false"', { 'ldflags': [ '-Wl,--whole-archive', '<(obj_dir)/deps/uv/<(STATIC_LIB_PREFIX)uv<(STATIC_LIB_SUFFIX)', diff --git a/tools/gyp/pylib/gyp/common.py b/tools/gyp/pylib/gyp/common.py index 0847cdabc718d8..d77adee8afd55d 100644 --- a/tools/gyp/pylib/gyp/common.py +++ b/tools/gyp/pylib/gyp/common.py @@ -470,6 +470,7 @@ def CopyTool(flavor, out_path, generator_flags={}): "os400": "flock", "solaris": "flock", "mac": "mac", + "ios": "mac", "win": "win", }.get(flavor, None) if not prefix: diff --git a/tools/gyp/pylib/gyp/generator/ninja.py b/tools/gyp/pylib/gyp/generator/ninja.py index 3db3771ac97855..c771f4691087a4 100644 --- a/tools/gyp/pylib/gyp/generator/ninja.py +++ b/tools/gyp/pylib/gyp/generator/ninja.py @@ -1583,7 +1583,7 @@ def WriteTarget(self, spec, config_name, config, link_deps, compile_deps): elif spec["type"] == "static_library": self.target.binary = self.ComputeOutput(spec) if ( - self.flavor not in ("mac", "openbsd", "netbsd", "win") + self.flavor not in ("mac", "openbsd", "netbsd", "win", "ios") and not self.is_standalone_static_library ): self.ninja.build( @@ -2496,7 +2496,7 @@ def GenerateOutputForConfig(target_list, target_dicts, data, params, config_name ), ) - if flavor != "mac" and flavor != "win": + if flavor != "mac" and flavor != "win" and flavor != "ios": master_ninja.rule( "alink", description="AR $out", diff --git a/tools/v8_gypfiles/v8.gyp b/tools/v8_gypfiles/v8.gyp index 55f963693347c8..6efa1470d32ea9 100644 --- a/tools/v8_gypfiles/v8.gyp +++ b/tools/v8_gypfiles/v8.gyp @@ -847,7 +847,7 @@ 'conditions': [ ['v8_enable_webassembly==1', { 'conditions': [ - ['OS=="mac" or (_toolset=="host" and host_arch=="x64" and OS=="linux")', { + ['OS=="mac" or OS=="ios" or (_toolset=="host" and host_arch=="x64" and (host_os=="linux" or host_os=="mac"))', { 'sources': [ '<(V8_ROOT)/src/trap-handler/handler-inside-posix.cc', '<(V8_ROOT)/src/trap-handler/handler-outside-posix.cc', @@ -861,7 +861,7 @@ ], }], # TODO(targos): Replace False with OS=="win" if handler-outside-simulator.cc becomes compatible with MSVC. - ['_toolset=="host" and host_arch=="x64" and (OS=="linux" or OS=="mac" or False)', { + ['_toolset=="host" and host_arch=="x64" and (host_os=="linux" or host_os=="mac" or False)', { 'sources': [ '<(V8_ROOT)/src/trap-handler/handler-outside-simulator.cc', ], @@ -1145,13 +1145,19 @@ '<(V8_ROOT)/src/base/platform/platform-fuchsia.cc', ] }], - ['OS == "mac" or OS == "ios"', { + ['OS == "mac" or (_toolset=="host" and host_os=="mac")', { 'sources': [ '<(V8_ROOT)/src/base/debug/stack_trace_posix.cc', '<(V8_ROOT)/src/base/platform/platform-darwin.cc', '<(V8_ROOT)/src/base/platform/platform-macos.cc', ] }], + ['OS == "ios"', { + 'sources': [ + '<(V8_ROOT)/src/base/debug/stack_trace_posix.cc', + '<(V8_ROOT)/src/base/platform/platform-darwin.cc', + ] + }], ['is_win', { 'sources': [ '<(V8_ROOT)/src/base/debug/stack_trace_win.cc', From 66347c7de17de2efe7c4d93f7766a1842b062341 Mon Sep 17 00:00:00 2001 From: johnche Date: Thu, 25 Aug 2022 17:28:30 +0800 Subject: [PATCH 2/3] revert change to gyp --- tools/gyp/pylib/gyp/common.py | 1 - tools/gyp/pylib/gyp/generator/ninja.py | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/tools/gyp/pylib/gyp/common.py b/tools/gyp/pylib/gyp/common.py index d77adee8afd55d..0847cdabc718d8 100644 --- a/tools/gyp/pylib/gyp/common.py +++ b/tools/gyp/pylib/gyp/common.py @@ -470,7 +470,6 @@ def CopyTool(flavor, out_path, generator_flags={}): "os400": "flock", "solaris": "flock", "mac": "mac", - "ios": "mac", "win": "win", }.get(flavor, None) if not prefix: diff --git a/tools/gyp/pylib/gyp/generator/ninja.py b/tools/gyp/pylib/gyp/generator/ninja.py index c771f4691087a4..3db3771ac97855 100644 --- a/tools/gyp/pylib/gyp/generator/ninja.py +++ b/tools/gyp/pylib/gyp/generator/ninja.py @@ -1583,7 +1583,7 @@ def WriteTarget(self, spec, config_name, config, link_deps, compile_deps): elif spec["type"] == "static_library": self.target.binary = self.ComputeOutput(spec) if ( - self.flavor not in ("mac", "openbsd", "netbsd", "win", "ios") + self.flavor not in ("mac", "openbsd", "netbsd", "win") and not self.is_standalone_static_library ): self.ninja.build( @@ -2496,7 +2496,7 @@ def GenerateOutputForConfig(target_list, target_dicts, data, params, config_name ), ) - if flavor != "mac" and flavor != "win" and flavor != "ios": + if flavor != "mac" and flavor != "win": master_ninja.rule( "alink", description="AR $out", From d105434599fc756d62a205b60f7669f95a12f561 Mon Sep 17 00:00:00 2001 From: johnche Date: Mon, 29 Aug 2022 16:51:20 +0800 Subject: [PATCH 3/3] fix some style issues --- tools/v8_gypfiles/v8.gyp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/v8_gypfiles/v8.gyp b/tools/v8_gypfiles/v8.gyp index 6efa1470d32ea9..42e26cd9987cc5 100644 --- a/tools/v8_gypfiles/v8.gyp +++ b/tools/v8_gypfiles/v8.gyp @@ -847,7 +847,8 @@ 'conditions': [ ['v8_enable_webassembly==1', { 'conditions': [ - ['OS=="mac" or OS=="ios" or (_toolset=="host" and host_arch=="x64" and (host_os=="linux" or host_os=="mac"))', { + ['OS=="mac" or OS=="ios" or ' + '(_toolset=="host" and host_arch=="x64" and (host_os=="linux" or host_os=="mac"))', { 'sources': [ '<(V8_ROOT)/src/trap-handler/handler-inside-posix.cc', '<(V8_ROOT)/src/trap-handler/handler-outside-posix.cc', @@ -861,7 +862,8 @@ ], }], # TODO(targos): Replace False with OS=="win" if handler-outside-simulator.cc becomes compatible with MSVC. - ['_toolset=="host" and host_arch=="x64" and (host_os=="linux" or host_os=="mac" or False)', { + ['_toolset=="host" and host_arch=="x64" and ' + '(host_os=="linux" or host_os=="mac" or False)', { 'sources': [ '<(V8_ROOT)/src/trap-handler/handler-outside-simulator.cc', ],