|
686 | 686 | dest='shared_sqlite_libpath', |
687 | 687 | help='a directory to search for the shared sqlite DLL') |
688 | 688 |
|
| 689 | +shared_optgroup.add_argument('--shared-ffi', |
| 690 | + action='store_true', |
| 691 | + dest='shared_ffi', |
| 692 | + default=None, |
| 693 | + help='link to a shared libffi DLL instead of static linking') |
| 694 | + |
| 695 | +shared_optgroup.add_argument('--shared-ffi-includes', |
| 696 | + action='store', |
| 697 | + dest='shared_ffi_includes', |
| 698 | + help='directory containing libffi header files') |
| 699 | + |
| 700 | +shared_optgroup.add_argument('--shared-ffi-libname', |
| 701 | + action='store', |
| 702 | + dest='shared_ffi_libname', |
| 703 | + default='ffi', |
| 704 | + help='alternative libffi name to link to [default: %(default)s]') |
| 705 | + |
| 706 | +shared_optgroup.add_argument('--shared-ffi-libpath', |
| 707 | + action='store', |
| 708 | + dest='shared_ffi_libpath', |
| 709 | + help='a directory to search for the shared libffi DLL') |
| 710 | + |
689 | 711 | shared_optgroup.add_argument('--shared-temporal_capi', |
690 | 712 | action='store_true', |
691 | 713 | dest='shared_temporal_capi', |
|
1017 | 1039 | default=None, |
1018 | 1040 | help='build without SQLite (disables SQLite and Web Storage API)') |
1019 | 1041 |
|
1020 | | -parser.add_argument('--with-ffi', |
| 1042 | +parser.add_argument('--without-ffi', |
1021 | 1043 | action='store_true', |
1022 | | - dest='with_ffi', |
| 1044 | + dest='without_ffi', |
1023 | 1045 | default=None, |
1024 | | - help='build with FFI (Foreign Function Interface) support') |
| 1046 | + help='build without FFI (Foreign Function Interface) support') |
1025 | 1047 |
|
1026 | 1048 | parser.add_argument('--experimental-quic', |
1027 | 1049 | action='store_true', |
@@ -2188,9 +2210,40 @@ def without_sqlite_error(option): |
2188 | 2210 |
|
2189 | 2211 | configure_library('sqlite', o, pkgname='sqlite3') |
2190 | 2212 |
|
| 2213 | +def bundled_ffi_supported(os_name, target_arch): |
| 2214 | + supported = { |
| 2215 | + 'freebsd': {'arm', 'arm64', 'ia32', 'x64'}, |
| 2216 | + 'linux': {'arm', 'arm64', 'ia32', 'x64'}, |
| 2217 | + 'mac': {'arm64', 'x64'}, |
| 2218 | + 'win': {'arm', 'arm64', 'x64'}, |
| 2219 | + } |
| 2220 | + |
| 2221 | + if target_arch == 'x86': |
| 2222 | + target_arch = 'ia32' |
| 2223 | + |
| 2224 | + return target_arch in supported.get(os_name, set()) |
| 2225 | + |
2191 | 2226 | def configure_ffi(o): |
2192 | | - o['variables']['node_use_ffi'] = b(options.with_ffi) |
2193 | | - return |
| 2227 | + use_ffi = not options.without_ffi |
| 2228 | + |
| 2229 | + if use_ffi and not options.shared_ffi: |
| 2230 | + target_arch = o['variables']['target_arch'] |
| 2231 | + if not bundled_ffi_supported(flavor, target_arch): |
| 2232 | + warn(f'FFI is disabled for {flavor}/{target_arch}: the bundled libffi ' |
| 2233 | + 'integration is not available on this platform. Use --shared-ffi ' |
| 2234 | + 'to provide a system libffi or --without-ffi to silence this ' |
| 2235 | + 'warning.') |
| 2236 | + use_ffi = False |
| 2237 | + |
| 2238 | + o['variables']['node_use_ffi'] = b(use_ffi) |
| 2239 | + |
| 2240 | + if options.without_ffi: |
| 2241 | + if options.shared_ffi: |
| 2242 | + error('--without-ffi is incompatible with --shared-ffi') |
| 2243 | + return |
| 2244 | + |
| 2245 | + if not use_ffi: |
| 2246 | + return |
2194 | 2247 |
|
2195 | 2248 | configure_library('ffi', o, pkgname='libffi') |
2196 | 2249 |
|
|
0 commit comments