koffi 2.1.3 → 2.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +44 -68
- package/{LICENSE.txt → src/cnoke/LICENSE.txt} +0 -0
- package/src/cnoke/README.md +97 -0
- package/src/cnoke/assets/FindCNoke.cmake +71 -0
- package/src/cnoke/assets/win_delay_hook.c +34 -0
- package/src/cnoke/cnoke.js +968 -0
- package/src/cnoke/package.json +25 -0
- package/{vendor → src/core}/libcc/libcc.cc +38 -11
- package/{vendor → src/core}/libcc/libcc.hh +4 -2
- package/{CMakeLists.txt → src/koffi/CMakeLists.txt} +3 -3
- package/{ChangeLog.md → src/koffi/ChangeLog.md} +11 -0
- package/src/koffi/LICENSE.txt +661 -0
- package/{README.md → src/koffi/README.md} +0 -0
- package/{benchmark → src/koffi/benchmark}/CMakeLists.txt +9 -6
- package/{benchmark → src/koffi/benchmark}/atoi_koffi.js +0 -0
- package/{benchmark → src/koffi/benchmark}/atoi_napi.cc +1 -1
- package/{benchmark → src/koffi/benchmark}/atoi_napi.js +0 -0
- package/{benchmark → src/koffi/benchmark}/atoi_node_ffi.js +0 -0
- package/src/koffi/benchmark/benchmark.js +118 -0
- package/src/koffi/benchmark/rand_koffi.js +52 -0
- package/src/koffi/benchmark/rand_napi.cc +69 -0
- package/src/koffi/benchmark/rand_napi.js +47 -0
- package/src/koffi/benchmark/rand_node_ffi.js +55 -0
- package/{benchmark → src/koffi/benchmark}/raylib_cc.cc +2 -2
- package/{benchmark → src/koffi/benchmark}/raylib_cc.js +0 -0
- package/{benchmark → src/koffi/benchmark}/raylib_koffi.js +0 -0
- package/{benchmark → src/koffi/benchmark}/raylib_node_ffi.js +0 -0
- package/{benchmark → src/koffi/benchmark}/raylib_node_raylib.js +0 -0
- package/src/koffi/build/2.1.4/koffi_darwin_arm64.tar.gz +0 -0
- package/src/koffi/build/2.1.4/koffi_darwin_x64.tar.gz +0 -0
- package/src/koffi/build/2.1.4/koffi_freebsd_arm64.tar.gz +0 -0
- package/src/koffi/build/2.1.4/koffi_freebsd_ia32.tar.gz +0 -0
- package/src/koffi/build/2.1.4/koffi_freebsd_x64.tar.gz +0 -0
- package/src/koffi/build/2.1.4/koffi_linux_arm32hf.tar.gz +0 -0
- package/src/koffi/build/2.1.4/koffi_linux_arm64.tar.gz +0 -0
- package/src/koffi/build/2.1.4/koffi_linux_ia32.tar.gz +0 -0
- package/src/koffi/build/2.1.4/koffi_linux_riscv64hf64.tar.gz +0 -0
- package/src/koffi/build/2.1.4/koffi_linux_x64.tar.gz +0 -0
- package/src/koffi/build/2.1.4/koffi_openbsd_ia32.tar.gz +0 -0
- package/src/koffi/build/2.1.4/koffi_openbsd_x64.tar.gz +0 -0
- package/src/koffi/build/2.1.4/koffi_win32_arm64.tar.gz +0 -0
- package/src/koffi/build/2.1.4/koffi_win32_ia32.tar.gz +0 -0
- package/src/koffi/build/2.1.4/koffi_win32_x64.tar.gz +0 -0
- package/{doc → src/koffi/doc}/Makefile +0 -0
- package/{doc → src/koffi/doc}/benchmarks.md +0 -0
- package/{doc → src/koffi/doc}/benchmarks.xlsx +0 -0
- package/{doc → src/koffi/doc}/changes.md +0 -0
- package/{doc → src/koffi/doc}/conf.py +0 -0
- package/{doc → src/koffi/doc}/contribute.md +5 -5
- package/{doc → src/koffi/doc}/functions.md +0 -0
- package/{doc → src/koffi/doc}/index.rst +1 -1
- package/{doc → src/koffi/doc}/make.bat +0 -0
- package/{doc → src/koffi/doc}/memory.md +1 -0
- package/{doc → src/koffi/doc}/platforms.md +0 -0
- package/{doc → src/koffi/doc}/poetry.lock +0 -0
- package/{doc → src/koffi/doc}/pyproject.toml +0 -0
- package/{doc → src/koffi/doc}/start.md +0 -0
- package/{doc → src/koffi/doc}/static/bench_linux.png +0 -0
- package/{doc → src/koffi/doc}/static/bench_windows.png +0 -0
- package/{doc → src/koffi/doc}/static/custom.css +0 -0
- package/{doc → src/koffi/doc}/static/perf_linux_20220623.png +0 -0
- package/{doc → src/koffi/doc}/static/perf_linux_20220623_2.png +0 -0
- package/{doc → src/koffi/doc}/static/perf_linux_20220627.png +0 -0
- package/{doc → src/koffi/doc}/static/perf_linux_20220628.png +0 -0
- package/{doc → src/koffi/doc}/static/perf_linux_20220812.png +0 -0
- package/{doc → src/koffi/doc}/static/perf_windows_20220623.png +0 -0
- package/{doc → src/koffi/doc}/static/perf_windows_20220623_2.png +0 -0
- package/{doc → src/koffi/doc}/static/perf_windows_20220627.png +0 -0
- package/{doc → src/koffi/doc}/static/perf_windows_20220628.png +0 -0
- package/{doc → src/koffi/doc}/static/perf_windows_20220812.png +0 -0
- package/{doc → src/koffi/doc}/templates/badges.html +1 -1
- package/{doc → src/koffi/doc}/types.md +0 -0
- package/src/koffi/qemu/qemu/.gitkeep +0 -0
- package/{qemu → src/koffi/qemu}/qemu.js +217 -131
- package/{qemu → src/koffi/qemu}/registry/machines.json +24 -0
- package/{qemu → src/koffi/qemu}/registry/sha256sum.txt +0 -0
- package/src/{abi_arm32.cc → koffi/src/abi_arm32.cc} +1 -1
- package/src/{abi_arm32_fwd.S → koffi/src/abi_arm32_fwd.S} +0 -0
- package/src/{abi_arm64.cc → koffi/src/abi_arm64.cc} +1 -1
- package/src/{abi_arm64_fwd.S → koffi/src/abi_arm64_fwd.S} +0 -0
- package/src/{abi_arm64_fwd.asm → koffi/src/abi_arm64_fwd.asm} +0 -0
- package/src/{abi_riscv64.cc → koffi/src/abi_riscv64.cc} +1 -1
- package/src/{abi_riscv64_fwd.S → koffi/src/abi_riscv64_fwd.S} +0 -0
- package/src/{abi_x64_sysv.cc → koffi/src/abi_x64_sysv.cc} +1 -1
- package/src/{abi_x64_sysv_fwd.S → koffi/src/abi_x64_sysv_fwd.S} +0 -0
- package/src/{abi_x64_win.cc → koffi/src/abi_x64_win.cc} +1 -1
- package/src/{abi_x64_win_fwd.asm → koffi/src/abi_x64_win_fwd.asm} +0 -0
- package/src/{abi_x86.cc → koffi/src/abi_x86.cc} +1 -1
- package/src/{abi_x86_fwd.S → koffi/src/abi_x86_fwd.S} +0 -0
- package/src/{abi_x86_fwd.asm → koffi/src/abi_x86_fwd.asm} +0 -0
- package/src/{call.cc → koffi/src/call.cc} +1 -1
- package/src/{call.hh → koffi/src/call.hh} +2 -2
- package/src/{ffi.cc → koffi/src/ffi.cc} +34 -18
- package/src/{ffi.hh → koffi/src/ffi.hh} +5 -3
- package/src/{index.js → koffi/src/index.js} +0 -0
- package/src/{parser.cc → koffi/src/parser.cc} +1 -1
- package/src/{parser.hh → koffi/src/parser.hh} +1 -1
- package/src/{util.cc → koffi/src/util.cc} +1 -1
- package/src/{util.hh → koffi/src/util.hh} +1 -1
- package/{test → src/koffi/test}/CMakeLists.txt +14 -15
- package/{test → src/koffi/test}/async.js +0 -0
- package/{test → src/koffi/test}/callbacks.js +0 -0
- package/{test → src/koffi/test}/misc.c +13 -0
- package/{test → src/koffi/test}/misc.def +0 -0
- package/{test → src/koffi/test}/raylib.js +0 -0
- package/{test → src/koffi/test}/sqlite.js +1 -1
- package/{test → src/koffi/test}/sync.js +17 -0
- package/vendor/brotli/BUILD +144 -0
- package/vendor/brotli/CMakeLists.txt +421 -0
- package/vendor/brotli/CONTRIBUTING.md +27 -0
- package/vendor/brotli/LICENSE +19 -0
- package/vendor/brotli/MANIFEST.in +17 -0
- package/vendor/brotli/Makefile +55 -0
- package/vendor/brotli/Makefile.am +38 -0
- package/vendor/brotli/README +15 -0
- package/vendor/brotli/README.md +104 -0
- package/vendor/brotli/WORKSPACE +21 -0
- package/vendor/brotli/bootstrap +35 -0
- package/vendor/brotli/c/common/constants.c +15 -0
- package/vendor/brotli/c/common/constants.h +200 -0
- package/vendor/brotli/c/common/context.c +156 -0
- package/vendor/brotli/c/common/context.h +113 -0
- package/vendor/brotli/c/common/dictionary.c +5914 -0
- package/vendor/brotli/c/common/dictionary.h +64 -0
- package/vendor/brotli/c/common/platform.c +22 -0
- package/vendor/brotli/c/common/platform.h +594 -0
- package/vendor/brotli/c/common/transform.c +291 -0
- package/vendor/brotli/c/common/transform.h +85 -0
- package/vendor/brotli/c/common/version.h +26 -0
- package/vendor/brotli/c/dec/bit_reader.c +76 -0
- package/vendor/brotli/c/dec/bit_reader.h +351 -0
- package/vendor/brotli/c/dec/decode.c +2608 -0
- package/vendor/brotli/c/dec/huffman.c +339 -0
- package/vendor/brotli/c/dec/huffman.h +121 -0
- package/vendor/brotli/c/dec/prefix.h +732 -0
- package/vendor/brotli/c/dec/state.c +159 -0
- package/vendor/brotli/c/dec/state.h +365 -0
- package/vendor/brotli/c/enc/backward_references.c +145 -0
- package/vendor/brotli/c/enc/backward_references.h +39 -0
- package/vendor/brotli/c/enc/backward_references_hq.c +843 -0
- package/vendor/brotli/c/enc/backward_references_hq.h +95 -0
- package/vendor/brotli/c/enc/backward_references_inc.h +163 -0
- package/vendor/brotli/c/enc/bit_cost.c +35 -0
- package/vendor/brotli/c/enc/bit_cost.h +63 -0
- package/vendor/brotli/c/enc/bit_cost_inc.h +127 -0
- package/vendor/brotli/c/enc/block_encoder_inc.h +34 -0
- package/vendor/brotli/c/enc/block_splitter.c +194 -0
- package/vendor/brotli/c/enc/block_splitter.h +51 -0
- package/vendor/brotli/c/enc/block_splitter_inc.h +440 -0
- package/vendor/brotli/c/enc/brotli_bit_stream.c +1314 -0
- package/vendor/brotli/c/enc/brotli_bit_stream.h +84 -0
- package/vendor/brotli/c/enc/cluster.c +56 -0
- package/vendor/brotli/c/enc/cluster.h +48 -0
- package/vendor/brotli/c/enc/cluster_inc.h +320 -0
- package/vendor/brotli/c/enc/command.c +28 -0
- package/vendor/brotli/c/enc/command.h +190 -0
- package/vendor/brotli/c/enc/compress_fragment.c +790 -0
- package/vendor/brotli/c/enc/compress_fragment.h +61 -0
- package/vendor/brotli/c/enc/compress_fragment_two_pass.c +645 -0
- package/vendor/brotli/c/enc/compress_fragment_two_pass.h +54 -0
- package/vendor/brotli/c/enc/dictionary_hash.c +1846 -0
- package/vendor/brotli/c/enc/dictionary_hash.h +25 -0
- package/vendor/brotli/c/enc/encode.c +1927 -0
- package/vendor/brotli/c/enc/encoder_dict.c +33 -0
- package/vendor/brotli/c/enc/encoder_dict.h +43 -0
- package/vendor/brotli/c/enc/entropy_encode.c +503 -0
- package/vendor/brotli/c/enc/entropy_encode.h +122 -0
- package/vendor/brotli/c/enc/entropy_encode_static.h +539 -0
- package/vendor/brotli/c/enc/fast_log.c +105 -0
- package/vendor/brotli/c/enc/fast_log.h +66 -0
- package/vendor/brotli/c/enc/find_match_length.h +79 -0
- package/vendor/brotli/c/enc/hash.h +488 -0
- package/vendor/brotli/c/enc/hash_composite_inc.h +125 -0
- package/vendor/brotli/c/enc/hash_forgetful_chain_inc.h +293 -0
- package/vendor/brotli/c/enc/hash_longest_match64_inc.h +267 -0
- package/vendor/brotli/c/enc/hash_longest_match_inc.h +262 -0
- package/vendor/brotli/c/enc/hash_longest_match_quickly_inc.h +266 -0
- package/vendor/brotli/c/enc/hash_rolling_inc.h +212 -0
- package/vendor/brotli/c/enc/hash_to_binary_tree_inc.h +329 -0
- package/vendor/brotli/c/enc/histogram.c +100 -0
- package/vendor/brotli/c/enc/histogram.h +63 -0
- package/vendor/brotli/c/enc/histogram_inc.h +51 -0
- package/vendor/brotli/c/enc/literal_cost.c +175 -0
- package/vendor/brotli/c/enc/literal_cost.h +30 -0
- package/vendor/brotli/c/enc/memory.c +170 -0
- package/vendor/brotli/c/enc/memory.h +114 -0
- package/vendor/brotli/c/enc/metablock.c +663 -0
- package/vendor/brotli/c/enc/metablock.h +105 -0
- package/vendor/brotli/c/enc/metablock_inc.h +183 -0
- package/vendor/brotli/c/enc/params.h +46 -0
- package/vendor/brotli/c/enc/prefix.h +53 -0
- package/vendor/brotli/c/enc/quality.h +165 -0
- package/vendor/brotli/c/enc/ringbuffer.h +167 -0
- package/vendor/brotli/c/enc/static_dict.c +486 -0
- package/vendor/brotli/c/enc/static_dict.h +40 -0
- package/vendor/brotli/c/enc/static_dict_lut.h +5864 -0
- package/vendor/brotli/c/enc/utf8_util.c +85 -0
- package/vendor/brotli/c/enc/utf8_util.h +32 -0
- package/vendor/brotli/c/enc/write_bits.h +87 -0
- package/vendor/brotli/c/include/brotli/decode.h +344 -0
- package/vendor/brotli/c/include/brotli/encode.h +448 -0
- package/vendor/brotli/c/include/brotli/port.h +288 -0
- package/vendor/brotli/c/include/brotli/types.h +83 -0
- package/vendor/brotli/c/tools/brotli.c +1116 -0
- package/vendor/brotli/c/tools/brotli.md +107 -0
- package/vendor/brotli/compiler_config_setting.bzl +28 -0
- package/vendor/brotli/configure +8 -0
- package/vendor/brotli/configure-cmake +318 -0
- package/vendor/brotli/configure.ac +14 -0
- package/vendor/brotli/docs/brotli.1 +132 -0
- package/vendor/brotli/docs/constants.h.3 +47 -0
- package/vendor/brotli/docs/decode.h.3 +415 -0
- package/vendor/brotli/docs/encode.h.3 +586 -0
- package/vendor/brotli/docs/types.h.3 +117 -0
- package/vendor/brotli/premake5.lua +78 -0
- package/vendor/brotli/python/Makefile +57 -0
- package/vendor/brotli/python/README.md +54 -0
- package/vendor/brotli/python/_brotli.cc +753 -0
- package/vendor/brotli/python/bro.py +160 -0
- package/vendor/brotli/python/brotli.py +56 -0
- package/vendor/brotli/python/tests/__init__.py +0 -0
- package/vendor/brotli/python/tests/_test_utils.py +112 -0
- package/vendor/brotli/python/tests/bro_test.py +102 -0
- package/vendor/brotli/python/tests/compress_test.py +41 -0
- package/vendor/brotli/python/tests/compressor_test.py +94 -0
- package/vendor/brotli/python/tests/decompress_test.py +42 -0
- package/vendor/brotli/python/tests/decompressor_test.py +59 -0
- package/vendor/brotli/scripts/libbrotlicommon.pc.in +11 -0
- package/vendor/brotli/scripts/libbrotlidec.pc.in +12 -0
- package/vendor/brotli/scripts/libbrotlienc.pc.in +12 -0
- package/vendor/brotli/scripts/sources.lst +104 -0
- package/vendor/brotli/setup.cfg +5 -0
- package/vendor/brotli/setup.py +293 -0
- package/vendor/brotli/tests/Makefile +17 -0
- package/vendor/brotli/tests/compatibility_test.sh +25 -0
- package/vendor/brotli/tests/roundtrip_test.sh +36 -0
- package/vendor/brotli/tests/run-compatibility-test.cmake +31 -0
- package/vendor/brotli/tests/run-roundtrip-test.cmake +36 -0
- package/vendor/brotli/tests/testdata/empty +0 -0
- package/vendor/brotli/tests/testdata/empty.compressed +1 -0
- package/vendor/brotli/tests/testdata/ukkonooa +1 -0
- package/vendor/brotli/tests/testdata/ukkonooa.compressed +0 -0
- package/vendor/miniz/ChangeLog.md +235 -0
- package/vendor/miniz/LICENSE +22 -0
- package/vendor/miniz/examples/example1.c +105 -0
- package/vendor/miniz/examples/example2.c +164 -0
- package/vendor/miniz/examples/example3.c +269 -0
- package/vendor/miniz/examples/example4.c +102 -0
- package/vendor/miniz/examples/example5.c +327 -0
- package/vendor/miniz/examples/example6.c +166 -0
- package/vendor/miniz/miniz.c +7835 -0
- package/vendor/miniz/miniz.h +1422 -0
- package/vendor/miniz/readme.md +46 -0
- package/vendor/{sqlite3 → sqlite3mc}/sqlite3ext.h +18 -2
- package/vendor/{sqlite3/sqlite3.c → sqlite3mc/sqlite3mc.c} +60872 -4890
- package/vendor/sqlite3mc/sqlite3mc.def +312 -0
- package/vendor/{sqlite3/sqlite3.h → sqlite3mc/sqlite3mc.h} +480 -36
- package/build/qemu/2.1.3/koffi_darwin_arm64.tar.gz +0 -0
- package/build/qemu/2.1.3/koffi_darwin_x64.tar.gz +0 -0
- package/build/qemu/2.1.3/koffi_freebsd_arm64.tar.gz +0 -0
- package/build/qemu/2.1.3/koffi_freebsd_ia32.tar.gz +0 -0
- package/build/qemu/2.1.3/koffi_freebsd_x64.tar.gz +0 -0
- package/build/qemu/2.1.3/koffi_linux_arm32hf.tar.gz +0 -0
- package/build/qemu/2.1.3/koffi_linux_arm64.tar.gz +0 -0
- package/build/qemu/2.1.3/koffi_linux_ia32.tar.gz +0 -0
- package/build/qemu/2.1.3/koffi_linux_riscv64hf64.tar.gz +0 -0
- package/build/qemu/2.1.3/koffi_linux_x64.tar.gz +0 -0
- package/build/qemu/2.1.3/koffi_openbsd_ia32.tar.gz +0 -0
- package/build/qemu/2.1.3/koffi_openbsd_x64.tar.gz +0 -0
- package/build/qemu/2.1.3/koffi_win32_arm64.tar.gz +0 -0
- package/build/qemu/2.1.3/koffi_win32_ia32.tar.gz +0 -0
- package/build/qemu/2.1.3/koffi_win32_x64.tar.gz +0 -0
- package/vendor/_patches/glfw_001_fix_openbsd_xlib_soname.patch +0 -145
- package/vendor/raylib/projects/VS2019-Android/raylib_android/raylib_android.NativeActivity/raylib_android.NativeActivity.vcxproj +0 -226
- package/vendor/raylib/projects/VS2019-Android/raylib_android/raylib_android.NativeActivity/raylib_android.NativeActivity.vcxproj.filters +0 -10
- package/vendor/raylib/projects/VS2019-Android/raylib_android/raylib_android.NativeActivity/raylib_android.NativeActivity.vcxproj.user +0 -4
- package/vendor/raylib/projects/VS2019-Android/raylib_android.sln +0 -75
- package/vendor/raylib/projects/VS2022/examples/audio_module_playing.vcxproj +0 -390
- package/vendor/raylib/projects/VS2022/examples/audio_multichannel_sound.vcxproj +0 -390
- package/vendor/raylib/projects/VS2022/examples/audio_music_stream.vcxproj +0 -390
- package/vendor/raylib/projects/VS2022/examples/audio_raw_stream.vcxproj +0 -390
- package/vendor/raylib/projects/VS2022/examples/audio_sound_loading.vcxproj +0 -390
- package/vendor/raylib/projects/VS2022/examples/audio_stream_effects.vcxproj +0 -390
- package/vendor/raylib/projects/VS2022/examples/core_2d_camera.vcxproj +0 -390
- package/vendor/raylib/projects/VS2022/examples/core_2d_camera_mouse_zoom.vcxproj +0 -390
- package/vendor/raylib/projects/VS2022/examples/core_2d_camera_platformer.vcxproj +0 -390
- package/vendor/raylib/projects/VS2022/examples/core_3d_camera_first_person.vcxproj +0 -390
- package/vendor/raylib/projects/VS2022/examples/core_3d_camera_free.vcxproj +0 -390
- package/vendor/raylib/projects/VS2022/examples/core_3d_camera_mode.vcxproj +0 -390
- package/vendor/raylib/projects/VS2022/examples/core_3d_picking.vcxproj +0 -390
- package/vendor/raylib/projects/VS2022/examples/core_basic_screen_manager.vcxproj +0 -390
- package/vendor/raylib/projects/VS2022/examples/core_basic_window.vcxproj +0 -390
- package/vendor/raylib/projects/VS2022/examples/core_custom_frame_control.vcxproj +0 -390
- package/vendor/raylib/projects/VS2022/examples/core_custom_logging.vcxproj +0 -390
- package/vendor/raylib/projects/VS2022/examples/core_drop_files.vcxproj +0 -390
- package/vendor/raylib/projects/VS2022/examples/core_input_gamepad.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/core_input_gestures.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/core_input_keys.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/core_input_mouse.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/core_input_mouse_wheel.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/core_input_multitouch.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/core_loading_thread.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/core_random_values.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/core_scissor_test.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/core_split_screen.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/core_storage_values.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/core_vr_simulator.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/core_window_flags.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/core_window_letterbox.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/core_window_should_close.vcxproj +0 -390
- package/vendor/raylib/projects/VS2022/examples/core_world_screen.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/easings_testbed.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/embedded_files_loading.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/models_animation.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/models_billboard.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/models_box_collisions.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/models_cubicmap.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/models_first_person_maze.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/models_geometric_shapes.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/models_heightmap.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/models_loading.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/models_loading_gltf.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/models_loading_vox.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/models_mesh_generation.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/models_mesh_picking.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/models_orthographic_projection.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/models_rlgl_solar_system.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/models_skybox.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/models_waving_cubes.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/models_yaw_pitch_roll.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/rlgl_compute_shaders.vcxproj +0 -391
- package/vendor/raylib/projects/VS2022/examples/rlgl_standalone.vcxproj +0 -391
- package/vendor/raylib/projects/VS2022/examples/shaders_basic_lighting.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/shaders_custom_uniform.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/shaders_eratosthenes.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/shaders_fog.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/shaders_hot_reloading.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/shaders_julia_set.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/shaders_mesh_instancing.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/shaders_model_shader.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/shaders_multi_sample2d.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/shaders_palette_switch.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/shaders_postprocessing.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/shaders_raymarching.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/shaders_shapes_textures.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/shaders_simple_mask.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/shaders_spotlight.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/shaders_texture_drawing.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/shaders_texture_waves.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/shapes_basic_shapes.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/shapes_bouncing_ball.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/shapes_collision_area.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/shapes_colors_palette.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/shapes_draw_circle_sector.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/shapes_draw_rectangle_rounded.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/shapes_draw_ring.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/shapes_easings_ball_anim.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/shapes_easings_box_anim.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/shapes_easings_rectangle_array.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/shapes_following_eyes.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/shapes_lines_bezier.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/shapes_logo_raylib.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/shapes_logo_raylib_anim.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/shapes_rectangle_scaling.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/text_codepoints_loading.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/text_draw_3d.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/text_font_filters.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/text_font_loading.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/text_font_sdf.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/text_font_spritefont.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/text_format_text.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/text_input_box.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/text_raylib_fonts.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/text_rectangle_bounds.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/text_unicode.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/text_writing_anim.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/textures_background_scrolling.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/textures_blend_modes.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/textures_bunnymark.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/textures_draw_tiled.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/textures_fog_of_war.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/textures_gif_player.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/textures_image_drawing.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/textures_image_generation.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/textures_image_loading.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/textures_image_processing.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/textures_image_text.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/textures_logo_raylib.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/textures_mouse_painting.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/textures_npatch_drawing.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/textures_particles_blending.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/textures_polygon.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/textures_raw_data.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/textures_sprite_anim.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/textures_sprite_button.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/textures_sprite_explosion.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/textures_srcrec_dstrec.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/examples/textures_to_image.vcxproj +0 -387
- package/vendor/raylib/projects/VS2022/raylib/raylib.vcxproj +0 -340
- package/vendor/raylib/projects/VS2022/raylib.sln +0 -2347
- package/vendor/sqlite3/shell.c +0 -23496
|
@@ -0,0 +1,968 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// This program is free software: you can redistribute it and/or modify
|
|
4
|
+
// it under the terms of the GNU Affero General Public License as published by
|
|
5
|
+
// the Free Software Foundation, either version 3 of the License, or
|
|
6
|
+
// (at your option) any later version.
|
|
7
|
+
//
|
|
8
|
+
// This program is distributed in the hope that it will be useful,
|
|
9
|
+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11
|
+
// GNU Affero General Public License for more details.
|
|
12
|
+
//
|
|
13
|
+
// You should have received a copy of the GNU Affero General Public License
|
|
14
|
+
// along with this program. If not, see https://www.gnu.org/licenses/.
|
|
15
|
+
|
|
16
|
+
'use strict';
|
|
17
|
+
|
|
18
|
+
const crypto = require('crypto');
|
|
19
|
+
const fs = require('fs');
|
|
20
|
+
const http = require('https');
|
|
21
|
+
const os = require('os');
|
|
22
|
+
const path = require('path');
|
|
23
|
+
const process = require('process');
|
|
24
|
+
const zlib = require('zlib');
|
|
25
|
+
const { spawnSync } = require('child_process');
|
|
26
|
+
const { Buffer } = require('buffer');
|
|
27
|
+
|
|
28
|
+
// Globals
|
|
29
|
+
|
|
30
|
+
const default_mode = 'RelWithDebInfo';
|
|
31
|
+
|
|
32
|
+
let app_dir = null;
|
|
33
|
+
let project_dir = null;
|
|
34
|
+
let package_dir = null;
|
|
35
|
+
let cache_dir = null;
|
|
36
|
+
let build_dir = null;
|
|
37
|
+
let work_dir = null;
|
|
38
|
+
|
|
39
|
+
let runtime_version = null;
|
|
40
|
+
let arch = null;
|
|
41
|
+
let toolset = null;
|
|
42
|
+
let prefer_clang = false;
|
|
43
|
+
let mode = default_mode;
|
|
44
|
+
let targets = [];
|
|
45
|
+
let verbose = false;
|
|
46
|
+
let prebuild = false;
|
|
47
|
+
let prebuild_url = null;
|
|
48
|
+
let prebuild_req = null;
|
|
49
|
+
|
|
50
|
+
let cmake_bin = null;
|
|
51
|
+
|
|
52
|
+
// Main
|
|
53
|
+
|
|
54
|
+
main();
|
|
55
|
+
|
|
56
|
+
async function main() {
|
|
57
|
+
let command = build;
|
|
58
|
+
|
|
59
|
+
// Parse options
|
|
60
|
+
{
|
|
61
|
+
let i = 2;
|
|
62
|
+
|
|
63
|
+
if (process.argv.length >= 3 && process.argv[2][0] != '-') {
|
|
64
|
+
switch (process.argv[2]) {
|
|
65
|
+
case 'build': { command = build; i++; } break;
|
|
66
|
+
case 'configure': { command = configure; i++; } break;
|
|
67
|
+
case 'clean': { command = clean; i++; } break;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
for (; i < process.argv.length; i++) {
|
|
72
|
+
let arg = process.argv[i];
|
|
73
|
+
let value = null;
|
|
74
|
+
|
|
75
|
+
if (arg[0] == '-') {
|
|
76
|
+
if (arg.length > 2 && arg[1] != '-') {
|
|
77
|
+
value = arg.substr(2);
|
|
78
|
+
arg = arg.substr(0, 2);
|
|
79
|
+
} else if (arg[1] == '-') {
|
|
80
|
+
let offset = arg.indexOf('=');
|
|
81
|
+
|
|
82
|
+
if (offset > 2 && arg.length > offset + 1) {
|
|
83
|
+
value = arg.substr(offset + 1);
|
|
84
|
+
arg = arg.substr(0, offset);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (value == null && process.argv[i + 1] != null && process.argv[i + 1][0] != '-') {
|
|
88
|
+
value = process.argv[i + 1];
|
|
89
|
+
i++; // Skip this value next iteration
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (arg == '--help') {
|
|
94
|
+
print_usage();
|
|
95
|
+
return;
|
|
96
|
+
} else if (arg == '-d' || arg == '--directory') {
|
|
97
|
+
if (value == null)
|
|
98
|
+
throw new Error(`Missing value for ${arg}`);
|
|
99
|
+
|
|
100
|
+
project_dir = fs.realpathSync(value);
|
|
101
|
+
} else if ((command == build || command == configure) && (arg == '-v' || arg == '--runtime-version')) {
|
|
102
|
+
if (value == null)
|
|
103
|
+
throw new Error(`Missing value for ${arg}`);
|
|
104
|
+
if (!value.match(/^[0-9]+\.[0-9]+\.[0-9]+$/))
|
|
105
|
+
throw new Error(`Malformed runtime version '${value}'`);
|
|
106
|
+
|
|
107
|
+
runtime_version = value;
|
|
108
|
+
} else if ((command == build || command == configure) && (arg == '-a' || arg == '--arch')) {
|
|
109
|
+
if (value == null)
|
|
110
|
+
throw new Error(`Missing value for ${arg}`);
|
|
111
|
+
|
|
112
|
+
arch = value;
|
|
113
|
+
} else if ((command == build || command == configure) && (arg == '-t' || arg == '--toolset')) {
|
|
114
|
+
if (value == null)
|
|
115
|
+
throw new Error(`Missing value for ${arg}`);
|
|
116
|
+
|
|
117
|
+
toolset = value;
|
|
118
|
+
} else if ((command == build || command == configure) && (arg == '-C' || arg == '--prefer-clang')) {
|
|
119
|
+
prefer_clang = true;
|
|
120
|
+
} else if ((command == build || command == configure) && (arg == '-B' || arg == '--config')) {
|
|
121
|
+
if (value == null)
|
|
122
|
+
throw new Error(`Missing value for ${arg}`);
|
|
123
|
+
|
|
124
|
+
switch (value.toLowerCase()) {
|
|
125
|
+
case 'relwithdebinfo': { mode = 'RelWithDebInfo'; } break;
|
|
126
|
+
case 'debug': { mode = 'Debug'; } break;
|
|
127
|
+
case 'release': { mode = 'Release'; } break;
|
|
128
|
+
|
|
129
|
+
default: {
|
|
130
|
+
throw new Error(`Unknown value '${value}' for ${arg}`);
|
|
131
|
+
} break;
|
|
132
|
+
}
|
|
133
|
+
} else if ((command == build || command == configure) && (arg == '-D' || arg == '--debug')) {
|
|
134
|
+
mode = 'Debug';
|
|
135
|
+
} else if (command == build && arg == '--verbose') {
|
|
136
|
+
verbose = true;
|
|
137
|
+
} else if (command == build && arg == '--prebuild') {
|
|
138
|
+
prebuild = true;
|
|
139
|
+
prebuild_url = value;
|
|
140
|
+
} else if (command == build && arg == '--require') {
|
|
141
|
+
if (value == null)
|
|
142
|
+
throw new Error(`Missing value for ${arg}`);
|
|
143
|
+
|
|
144
|
+
prebuild_req = value;
|
|
145
|
+
} else if (command == build && (arg == '-T' || arg == '--target')) {
|
|
146
|
+
if (value == null)
|
|
147
|
+
throw new Error(`Missing value for ${arg}`);
|
|
148
|
+
|
|
149
|
+
targets = [value];
|
|
150
|
+
} else {
|
|
151
|
+
if (arg[0] == '-') {
|
|
152
|
+
throw new Error(`Unexpected argument '${arg}'`);
|
|
153
|
+
} else {
|
|
154
|
+
throw new Error(`Unexpected value '${arg}'`);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (runtime_version == null)
|
|
161
|
+
runtime_version = process.version;
|
|
162
|
+
if (runtime_version.startsWith('v'))
|
|
163
|
+
runtime_version = runtime_version.substr(1);
|
|
164
|
+
if (arch == null)
|
|
165
|
+
arch = determine_arch();
|
|
166
|
+
|
|
167
|
+
app_dir = __dirname.replace(/\\/g, '/');
|
|
168
|
+
if (project_dir == null)
|
|
169
|
+
project_dir = process.cwd();
|
|
170
|
+
project_dir = project_dir.replace(/\\/g, '/');
|
|
171
|
+
package_dir = find_parent_directory(project_dir, 'package.json');
|
|
172
|
+
cache_dir = get_cache_directory();
|
|
173
|
+
build_dir = project_dir + '/build';
|
|
174
|
+
work_dir = build_dir + `/v${runtime_version}_${arch}`;
|
|
175
|
+
|
|
176
|
+
try {
|
|
177
|
+
await command();
|
|
178
|
+
} catch (err) {
|
|
179
|
+
console.error(err);
|
|
180
|
+
process.exit(1);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function print_usage() {
|
|
185
|
+
let help = `Usage: cnoke [command] [options...]
|
|
186
|
+
|
|
187
|
+
Commands:
|
|
188
|
+
configure Configure CMake build
|
|
189
|
+
build Build project (configure if needed)
|
|
190
|
+
clean Clean build files
|
|
191
|
+
|
|
192
|
+
Options:
|
|
193
|
+
-d, --directory <DIR> Change project directory
|
|
194
|
+
(default: current working directory)
|
|
195
|
+
|
|
196
|
+
-B, --config <CONFIG> Change build type: RelWithDebInfo, Debug, Release
|
|
197
|
+
(default: ${default_mode})
|
|
198
|
+
-D, --debug Shortcut for --config Debug
|
|
199
|
+
|
|
200
|
+
--prebuild [URL] Enable use of prebuilt binaries
|
|
201
|
+
--require <PATH> Require specified module, drop prebuild if it fails
|
|
202
|
+
|
|
203
|
+
-a, --arch <ARCH> Change architecture and ABI
|
|
204
|
+
(default: ${determine_arch()})
|
|
205
|
+
-v, --runtime-version <VERSION> Change node version
|
|
206
|
+
(default: ${process.version})
|
|
207
|
+
-t, --toolset <TOOLSET> Change default CMake toolset
|
|
208
|
+
-C, --prefer-clang Use Clang instead of default CMake compiler
|
|
209
|
+
|
|
210
|
+
-T, --target <TARGET> Only build the specified target
|
|
211
|
+
|
|
212
|
+
--verbose Show build commands while building
|
|
213
|
+
|
|
214
|
+
The ARCH value is similar to process.arch, with the following differences:
|
|
215
|
+
|
|
216
|
+
- arm is changed to arm32hf or arm32sf depending on the floating-point ABI used (hard-float, soft-float)
|
|
217
|
+
- riscv32 is changed to riscv32sf, riscv32hf32, riscv32hf64 or riscv32hf128 depending on the floating-point ABI
|
|
218
|
+
- riscv64 is changed to riscv64sf, riscv64hf32, riscv64hf64 or riscv64hf128 depending on the floating-point ABI`;
|
|
219
|
+
|
|
220
|
+
console.log(help);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// Commands
|
|
224
|
+
|
|
225
|
+
async function configure(retry = true) {
|
|
226
|
+
let args = [project_dir];
|
|
227
|
+
|
|
228
|
+
check_cmake();
|
|
229
|
+
check_compatibility();
|
|
230
|
+
|
|
231
|
+
console.log(`>> Node: ${runtime_version}`);
|
|
232
|
+
console.log(`>> Target: ${process.platform}_${arch}`);
|
|
233
|
+
|
|
234
|
+
// Prepare build directory
|
|
235
|
+
fs.mkdirSync(cache_dir, { recursive: true, mode: 0o755 });
|
|
236
|
+
fs.mkdirSync(build_dir, { recursive: true, mode: 0o755 });
|
|
237
|
+
fs.mkdirSync(work_dir, { recursive: true, mode: 0o755 });
|
|
238
|
+
|
|
239
|
+
retry &= fs.existsSync(work_dir + '/CMakeCache.txt');
|
|
240
|
+
|
|
241
|
+
// Download Node headers
|
|
242
|
+
{
|
|
243
|
+
let basename = `node-v${runtime_version}-headers.tar.gz`;
|
|
244
|
+
let urls = [
|
|
245
|
+
`https://nodejs.org/dist/v${runtime_version}/${basename}`,
|
|
246
|
+
`https://unofficial-builds.nodejs.org/download/release/v${runtime_version}/${basename}`
|
|
247
|
+
];
|
|
248
|
+
let destname = `${cache_dir}/${basename}`;
|
|
249
|
+
|
|
250
|
+
if (!fs.existsSync(destname))
|
|
251
|
+
await download(urls, destname);
|
|
252
|
+
await extract_targz(destname, work_dir + '/headers', 1);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// Download Node import library (Windows)
|
|
256
|
+
if (process.platform === 'win32') {
|
|
257
|
+
let dirname;
|
|
258
|
+
switch (arch) {
|
|
259
|
+
case 'ia32': { dirname = 'win-x86'; } break;
|
|
260
|
+
case 'x64': { dirname = 'win-x64'; } break;
|
|
261
|
+
case 'arm64': { dirname = 'win-arm64'; } break;
|
|
262
|
+
|
|
263
|
+
default: {
|
|
264
|
+
throw new Error(`Unsupported architecture '${arch}' for Node on Windows`);
|
|
265
|
+
} break;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
let destname = `${cache_dir}/node_v${runtime_version}_${arch}.lib`;
|
|
269
|
+
|
|
270
|
+
if (!fs.existsSync(destname)) {
|
|
271
|
+
let urls = [
|
|
272
|
+
`https://nodejs.org/dist/v${runtime_version}/${dirname}/node.lib`,
|
|
273
|
+
`https://unofficial-builds.nodejs.org/download/release/v${runtime_version}/${dirname}/node.lib`
|
|
274
|
+
];
|
|
275
|
+
await download(urls, destname);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
fs.copyFileSync(destname, work_dir + '/node.lib');
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
args.push(`-DCMAKE_MODULE_PATH=${app_dir}/assets`);
|
|
282
|
+
|
|
283
|
+
args.push(`-DNODE_JS_INCLUDE_DIRS=${work_dir}/headers/include/node`);
|
|
284
|
+
|
|
285
|
+
// Set platform flags
|
|
286
|
+
switch (process.platform) {
|
|
287
|
+
case 'win32': {
|
|
288
|
+
fs.copyFileSync(`${app_dir}/assets/win_delay_hook.c`, work_dir + '/win_delay_hook.c');
|
|
289
|
+
|
|
290
|
+
args.push(`-DNODE_JS_SOURCES=${work_dir}/win_delay_hook.c`);
|
|
291
|
+
args.push(`-DNODE_JS_LIBRARIES=${work_dir}/node.lib`);
|
|
292
|
+
|
|
293
|
+
switch (arch) {
|
|
294
|
+
case 'ia32': {
|
|
295
|
+
args.push('-DNODE_JS_LINK_FLAGS=/DELAYLOAD:node.exe;/SAFESEH:NO');
|
|
296
|
+
args.push('-A', 'Win32');
|
|
297
|
+
} break;
|
|
298
|
+
case 'arm64': {
|
|
299
|
+
args.push('-DNODE_JS_LINK_FLAGS=/DELAYLOAD:node.exe;/SAFESEH:NO');
|
|
300
|
+
args.push('-A', 'ARM64');
|
|
301
|
+
} break;
|
|
302
|
+
case 'x64': {
|
|
303
|
+
args.push('-DNODE_JS_LINK_FLAGS=/DELAYLOAD:node.exe');
|
|
304
|
+
args.push('-A', 'x64');
|
|
305
|
+
} break;
|
|
306
|
+
}
|
|
307
|
+
} break;
|
|
308
|
+
|
|
309
|
+
case 'darwin': {
|
|
310
|
+
args.push('-DNODE_JS_LINK_FLAGS=-undefined;dynamic_lookup');
|
|
311
|
+
|
|
312
|
+
switch (arch) {
|
|
313
|
+
case 'arm64': { args.push('-DCMAKE_OSX_ARCHITECTURES=arm64'); } break;
|
|
314
|
+
case 'x64': { args.push('-DCMAKE_OSX_ARCHITECTURES=x86_64'); } break;
|
|
315
|
+
}
|
|
316
|
+
} break;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
if (process.platform != 'win32') {
|
|
320
|
+
// Prefer Ninja if available
|
|
321
|
+
if (spawnSync('ninja', ['--version']).status === 0)
|
|
322
|
+
args.push('-G', 'Ninja');
|
|
323
|
+
|
|
324
|
+
// Use CCache if available
|
|
325
|
+
if (spawnSync('ccache', ['--version']).status === 0) {
|
|
326
|
+
args.push('-DCMAKE_C_COMPILER_LAUNCHER=ccache');
|
|
327
|
+
args.push('-DCMAKE_CXX_COMPILER_LAUNCHER=ccache');
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
if (prefer_clang) {
|
|
332
|
+
if (process.platform == 'win32') {
|
|
333
|
+
args.push('-T', 'ClangCL');
|
|
334
|
+
} else {
|
|
335
|
+
args.push('-DCMAKE_C_COMPILER=clang');
|
|
336
|
+
args.push('-DCMAKE_CXX_COMPILER=clang++');
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
if (toolset != null)
|
|
340
|
+
args.push('-T', toolset);
|
|
341
|
+
|
|
342
|
+
args.push(`-DCMAKE_BUILD_TYPE=${mode}`);
|
|
343
|
+
for (let type of ['ARCHIVE', 'RUNTIME', 'LIBRARY']) {
|
|
344
|
+
for (let suffix of ['', '_DEBUG', '_RELEASE', '_RELWITHDEBINFO'])
|
|
345
|
+
args.push(`-DCMAKE_${type}_OUTPUT_DIRECTORY${suffix}=${build_dir}`);
|
|
346
|
+
}
|
|
347
|
+
args.push('--no-warn-unused-cli');
|
|
348
|
+
|
|
349
|
+
console.log('>> Running configuration');
|
|
350
|
+
|
|
351
|
+
let proc = spawnSync(cmake_bin, args, { cwd: work_dir, stdio: 'inherit' });
|
|
352
|
+
if (proc.status !== 0) {
|
|
353
|
+
unlink_recursive(work_dir);
|
|
354
|
+
if (retry)
|
|
355
|
+
return configure(false);
|
|
356
|
+
|
|
357
|
+
throw new Error('Failed to run configure step');
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
async function build() {
|
|
362
|
+
check_compatibility();
|
|
363
|
+
|
|
364
|
+
if (prebuild) {
|
|
365
|
+
let pkg = read_package_json();
|
|
366
|
+
|
|
367
|
+
if (prebuild_url == null) {
|
|
368
|
+
if (pkg.cnoke.prebuild == null)
|
|
369
|
+
throw new Error('Missing prebuild URL');
|
|
370
|
+
|
|
371
|
+
prebuild_url = pkg.cnoke.prebuild;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
fs.mkdirSync(build_dir, { recursive: true, mode: 0o755 });
|
|
375
|
+
|
|
376
|
+
let url = prebuild_url.replace(/{{([a-zA-Z_][a-zA-Z_0-9]*)}}/g, (match, p1) => {
|
|
377
|
+
switch (p1) {
|
|
378
|
+
case 'version': {
|
|
379
|
+
let pkg = read_package_json();
|
|
380
|
+
return pkg.version || '';
|
|
381
|
+
} break;
|
|
382
|
+
case 'platform': return process.platform;
|
|
383
|
+
case 'arch': return arch;
|
|
384
|
+
|
|
385
|
+
default: return match;
|
|
386
|
+
}
|
|
387
|
+
});
|
|
388
|
+
let basename = path.basename(url);
|
|
389
|
+
|
|
390
|
+
try {
|
|
391
|
+
let archive_filename = null;
|
|
392
|
+
|
|
393
|
+
if (url.startsWith('file:/')) {
|
|
394
|
+
if (url.startsWith('file://localhost/')) {
|
|
395
|
+
url = url.substr(16);
|
|
396
|
+
} else {
|
|
397
|
+
let offset = 6;
|
|
398
|
+
while (offset < 9 && url[offset] == '/')
|
|
399
|
+
offset++;
|
|
400
|
+
url = url.substr(offset - 1);
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
if (process.platform == 'win32' && url.match(/^\/[a-zA-Z]+:[\\\/]/))
|
|
404
|
+
url = url.substr(1);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
if (url.match(/^[a-z]+:\/\//)) {
|
|
408
|
+
archive_filename = build_dir + '/' + basename;
|
|
409
|
+
await download(url, archive_filename);
|
|
410
|
+
} else {
|
|
411
|
+
if (path_is_absolute(url)) {
|
|
412
|
+
archive_filename = url;
|
|
413
|
+
} else if (package_dir != null) {
|
|
414
|
+
archive_filename = package_dir + '/' + url;
|
|
415
|
+
} else {
|
|
416
|
+
archive_filename = project_dir + '/' + url;
|
|
417
|
+
}
|
|
418
|
+
if (!fs.existsSync(archive_filename))
|
|
419
|
+
throw new Error('Cannot find local prebuilt archive');
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
console.log('>> Extracting prebuilt binaries...');
|
|
423
|
+
await extract_targz(archive_filename, build_dir, 1);
|
|
424
|
+
|
|
425
|
+
// Make sure the binary works
|
|
426
|
+
if (prebuild_req == null)
|
|
427
|
+
prebuild_req = pkg.cnoke.require;
|
|
428
|
+
if (prebuild_req != null) {
|
|
429
|
+
let proc = spawnSync(process.execPath, ['-e', 'require(process.argv[1])', prebuild_req]);
|
|
430
|
+
if (proc.status === 0)
|
|
431
|
+
return;
|
|
432
|
+
} else {
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
// Clean it up if it does not, before source build. Only delete files, it is safer and it is enough!
|
|
437
|
+
let entries = fs.readdirSync(build_dir, { withFileTypes: true });
|
|
438
|
+
for (let entry of entries) {
|
|
439
|
+
if (!entry.isDirectory()) {
|
|
440
|
+
let filename = path.join(build_dir, entry.name);
|
|
441
|
+
fs.unlinkSync(filename);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
console.error('Failed to load prebuilt binary, rebuilding from source');
|
|
446
|
+
} catch (err) {
|
|
447
|
+
console.error('Failed to find prebuilt binary for your platform, building manually');
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
check_cmake();
|
|
452
|
+
|
|
453
|
+
if (!fs.existsSync(work_dir + '/CMakeCache.txt'))
|
|
454
|
+
await configure();
|
|
455
|
+
|
|
456
|
+
// In case Make gets used
|
|
457
|
+
if (process.env.MAKEFLAGS == null)
|
|
458
|
+
process.env.MAKEFLAGS = '-j' + os.cpus().length;
|
|
459
|
+
|
|
460
|
+
let args = [
|
|
461
|
+
'--build', work_dir,
|
|
462
|
+
'--config', mode
|
|
463
|
+
];
|
|
464
|
+
|
|
465
|
+
if (verbose)
|
|
466
|
+
args.push('--verbose');
|
|
467
|
+
for (let target of targets)
|
|
468
|
+
args.push('--target', target);
|
|
469
|
+
|
|
470
|
+
console.log('>> Running build');
|
|
471
|
+
|
|
472
|
+
let proc = spawnSync(cmake_bin, args, { stdio: 'inherit' });
|
|
473
|
+
if (proc.status !== 0)
|
|
474
|
+
throw new Error('Failed to run build step');
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
async function clean() {
|
|
478
|
+
unlink_recursive(build_dir);
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
// Utility
|
|
482
|
+
|
|
483
|
+
function get_cache_directory() {
|
|
484
|
+
if (process.platform == 'win32') {
|
|
485
|
+
let cache_dir = process.env['APPDATA'];
|
|
486
|
+
if (cache_dir == null)
|
|
487
|
+
throw new Error('Missing APPDATA environment variable');
|
|
488
|
+
|
|
489
|
+
cache_dir = path.join(cache_dir, 'cnoke');
|
|
490
|
+
return cache_dir;
|
|
491
|
+
} else {
|
|
492
|
+
let cache_dir = process.env['XDG_CACHE_HOME'];
|
|
493
|
+
|
|
494
|
+
if (cache_dir == null) {
|
|
495
|
+
let home = process.env['HOME'];
|
|
496
|
+
if (home == null)
|
|
497
|
+
throw new Error('Missing HOME environment variable');
|
|
498
|
+
|
|
499
|
+
cache_dir = path.join(home, '.cache');
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
cache_dir = path.join(cache_dir, 'cnoke');
|
|
503
|
+
return cache_dir;
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
function check_cmake() {
|
|
508
|
+
if (cmake_bin != null)
|
|
509
|
+
return;
|
|
510
|
+
|
|
511
|
+
// Check for CMakeLists.txt
|
|
512
|
+
if (!fs.existsSync(project_dir + '/CMakeLists.txt'))
|
|
513
|
+
throw new Error('This directory does not appear to have a CMakeLists.txt file');
|
|
514
|
+
|
|
515
|
+
// Check for CMake
|
|
516
|
+
{
|
|
517
|
+
let proc = spawnSync('cmake', ['--version']);
|
|
518
|
+
|
|
519
|
+
if (proc.status === 0) {
|
|
520
|
+
cmake_bin = 'cmake';
|
|
521
|
+
} else {
|
|
522
|
+
if (process.platform == 'win32') {
|
|
523
|
+
// I really don't want to depend on anything in CNoke, and Node.js does not provide
|
|
524
|
+
// anything to read from the registry. This is okay, REG.exe exists since Windows XP.
|
|
525
|
+
let proc = spawnSync('reg', ['query', 'HKEY_LOCAL_MACHINE\\SOFTWARE\\Kitware\\CMake', '/v', 'InstallDir']);
|
|
526
|
+
|
|
527
|
+
if (proc.status === 0) {
|
|
528
|
+
let matches = proc.stdout.toString('utf-8').match(/InstallDir[ \t]+REG_[A-Z_]+[ \t]+(.*)+/);
|
|
529
|
+
|
|
530
|
+
if (matches != null) {
|
|
531
|
+
let bin = path.join(matches[1].trim(), 'bin\\cmake.exe');
|
|
532
|
+
|
|
533
|
+
if (fs.existsSync(bin))
|
|
534
|
+
cmake_bin = bin;
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
if (cmake_bin == null)
|
|
540
|
+
throw new Error('CMake does not seem to be available');
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
console.log(`>> Using CMake binary: ${cmake_bin}`);
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
function check_compatibility() {
|
|
548
|
+
let pkg = read_package_json();
|
|
549
|
+
|
|
550
|
+
if (pkg.cnoke.node != null && cmp_version(runtime_version, pkg.cnoke.node) < 0)
|
|
551
|
+
throw new Error(`Project ${pkg.name} requires Node.js >= ${pkg.cnoke.node}`);
|
|
552
|
+
|
|
553
|
+
if (pkg.cnoke.napi != null) {
|
|
554
|
+
let major = parseInt(runtime_version, 10);
|
|
555
|
+
let required = get_napi_version(pkg.cnoke.napi, major);
|
|
556
|
+
|
|
557
|
+
if (required == null)
|
|
558
|
+
throw new Error(`Project ${pkg.name} does not support the Node ${major}.x branch (old or missing N-API)`);
|
|
559
|
+
if (cmp_version(runtime_version, required) < 0)
|
|
560
|
+
throw new Error(`Project ${pkg.name} requires Node >= ${required} in the Node ${major}.x branch (with N-API >= ${pkg.engines.napi})`);
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
function read_package_json() {
|
|
565
|
+
let pkg = {};
|
|
566
|
+
|
|
567
|
+
if (package_dir != null) {
|
|
568
|
+
try {
|
|
569
|
+
let json = fs.readFileSync(package_dir + '/package.json', { encoding: 'utf-8' });
|
|
570
|
+
pkg = JSON.parse(json);
|
|
571
|
+
} catch (err) {
|
|
572
|
+
if (err.code != 'ENOENT')
|
|
573
|
+
throw err;
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
if (pkg.cnoke == null)
|
|
578
|
+
pkg.cnoke = {};
|
|
579
|
+
|
|
580
|
+
return pkg;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
function unlink_recursive(path) {
|
|
584
|
+
try {
|
|
585
|
+
if (fs.rmSync != null) {
|
|
586
|
+
fs.rmSync(path, { recursive: true, maxRetries: process.platform == 'win32' ? 3 : 0 });
|
|
587
|
+
} else {
|
|
588
|
+
fs.rmdirSync(path, { recursive: true, maxRetries: process.platform == 'win32' ? 3 : 0 });
|
|
589
|
+
}
|
|
590
|
+
} catch (err) {
|
|
591
|
+
if (err.code !== 'ENOENT')
|
|
592
|
+
throw err;
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
async function download(url, dest) {
|
|
597
|
+
if (Array.isArray(url)) {
|
|
598
|
+
let urls = url;
|
|
599
|
+
|
|
600
|
+
for (let url of urls) {
|
|
601
|
+
try {
|
|
602
|
+
await download(url, dest);
|
|
603
|
+
return;
|
|
604
|
+
} catch (err) {
|
|
605
|
+
if (err.code != 404)
|
|
606
|
+
throw err;
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
throw new Error('All URLs returned error 404');
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
console.log('>> Downloading ' + url);
|
|
614
|
+
|
|
615
|
+
let [tmp_name, file] = open_temporary_stream(dest);
|
|
616
|
+
|
|
617
|
+
try {
|
|
618
|
+
await new Promise((resolve, reject) => {
|
|
619
|
+
let request = http.get(url, response => {
|
|
620
|
+
if (response.statusCode != 200) {
|
|
621
|
+
let err = new Error(`Download failed: ${response.statusMessage} [${response.statusCode}]`);
|
|
622
|
+
err.code = response.statusCode;
|
|
623
|
+
|
|
624
|
+
reject(err);
|
|
625
|
+
|
|
626
|
+
return;
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
response.pipe(file);
|
|
630
|
+
|
|
631
|
+
file.on('finish', () => file.close(() => {
|
|
632
|
+
try {
|
|
633
|
+
fs.renameSync(file.path, dest);
|
|
634
|
+
} catch (err) {
|
|
635
|
+
if (err.code != 'EBUSY')
|
|
636
|
+
reject(err);
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
resolve();
|
|
640
|
+
}));
|
|
641
|
+
});
|
|
642
|
+
|
|
643
|
+
request.on('error', reject);
|
|
644
|
+
file.on('error', reject);
|
|
645
|
+
});
|
|
646
|
+
} catch (err) {
|
|
647
|
+
file.close();
|
|
648
|
+
|
|
649
|
+
try {
|
|
650
|
+
fs.unlinkSync(tmp_name);
|
|
651
|
+
} catch (err) {
|
|
652
|
+
if (err.code != 'ENOENT')
|
|
653
|
+
throw err;
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
throw err;
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
function open_temporary_stream(prefix) {
|
|
661
|
+
let buf = Buffer.allocUnsafe(4);
|
|
662
|
+
|
|
663
|
+
for (;;) {
|
|
664
|
+
try {
|
|
665
|
+
crypto.randomFillSync(buf);
|
|
666
|
+
|
|
667
|
+
let suffix = buf.toString('hex').padStart(8, '0');
|
|
668
|
+
let filename = `${prefix}.${suffix}`;
|
|
669
|
+
|
|
670
|
+
let file = fs.createWriteStream(filename, { flags: 'wx', mode: 0o644 });
|
|
671
|
+
return [filename, file];
|
|
672
|
+
} catch (err) {
|
|
673
|
+
if (err.code != 'EEXIST')
|
|
674
|
+
throw err;
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
function read_file_header(filename, read) {
|
|
680
|
+
let fd = null;
|
|
681
|
+
|
|
682
|
+
try {
|
|
683
|
+
let fd = fs.openSync(filename);
|
|
684
|
+
|
|
685
|
+
let buf = Buffer.allocUnsafe(read);
|
|
686
|
+
let len = fs.readSync(fd, buf);
|
|
687
|
+
|
|
688
|
+
return buf.subarray(0, len);
|
|
689
|
+
} finally {
|
|
690
|
+
if (fd != null)
|
|
691
|
+
fs.closeSync(fd);
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
function extract_targz(filename, dest_dir, strip = 0) {
|
|
696
|
+
let reader = fs.createReadStream(filename).pipe(zlib.createGunzip());
|
|
697
|
+
|
|
698
|
+
return new Promise((resolve, reject) => {
|
|
699
|
+
let header = null;
|
|
700
|
+
let extended = {};
|
|
701
|
+
|
|
702
|
+
reader.on('readable', () => {
|
|
703
|
+
try {
|
|
704
|
+
for (;;) {
|
|
705
|
+
if (header == null) {
|
|
706
|
+
let buf = reader.read(512);
|
|
707
|
+
if (buf == null)
|
|
708
|
+
break;
|
|
709
|
+
|
|
710
|
+
// Two zeroed 512-byte blocks end the stream
|
|
711
|
+
if (!buf[0])
|
|
712
|
+
continue;
|
|
713
|
+
|
|
714
|
+
header = {
|
|
715
|
+
filename: buf.toString('utf-8', 0, 100).replace(/\0/g, ''),
|
|
716
|
+
mode: parseInt(buf.toString('ascii', 100, 109), 8),
|
|
717
|
+
size: parseInt(buf.toString('ascii', 124, 137), 8),
|
|
718
|
+
type: String.fromCharCode(buf[156])
|
|
719
|
+
};
|
|
720
|
+
|
|
721
|
+
// UStar filename prefix
|
|
722
|
+
/*if (buf.toString('ascii', 257, 263) == 'ustar\0') {
|
|
723
|
+
let prefix = buf.toString('utf-8', 345, 500).replace(/\0/g, '');
|
|
724
|
+
console.log(prefix);
|
|
725
|
+
header.filename = prefix ? (prefix + '/' + header.filename) : header.filename;
|
|
726
|
+
}*/
|
|
727
|
+
|
|
728
|
+
Object.assign(header, extended);
|
|
729
|
+
extended = {};
|
|
730
|
+
|
|
731
|
+
// Safety checks
|
|
732
|
+
header.filename = header.filename.replace(/\\/g, '/');
|
|
733
|
+
if (!header.filename.length)
|
|
734
|
+
throw new Error(`Insecure empty filename inside TAR archive`);
|
|
735
|
+
if (header.filename[0] == '/')
|
|
736
|
+
throw new Error(`Insecure filename starting with / inside TAR archive`);
|
|
737
|
+
if (path_has_dotdot(header.filename))
|
|
738
|
+
throw new Error(`Insecure filename containing '..' inside TAR archive`);
|
|
739
|
+
|
|
740
|
+
for (let i = 0; i < strip; i++)
|
|
741
|
+
header.filename = header.filename.substr(header.filename.indexOf('/') + 1);
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
let aligned = Math.floor((header.size + 511) / 512) * 512;
|
|
745
|
+
let data = header.size ? reader.read(aligned) : null;
|
|
746
|
+
if (data == null) {
|
|
747
|
+
if (header.size)
|
|
748
|
+
break;
|
|
749
|
+
data = Buffer.alloc(0);
|
|
750
|
+
}
|
|
751
|
+
data = data.subarray(0, header.size);
|
|
752
|
+
|
|
753
|
+
if (header.type == '0' || header.type == '7') {
|
|
754
|
+
let filename = dest_dir + '/' + header.filename;
|
|
755
|
+
let dirname = path.dirname(filename);
|
|
756
|
+
|
|
757
|
+
fs.mkdirSync(dirname, { recursive: true, mode: 0o755 });
|
|
758
|
+
fs.writeFileSync(filename, data, { mode: header.mode });
|
|
759
|
+
} else if (header.type == '5') {
|
|
760
|
+
let filename = dest_dir + '/' + header.filename;
|
|
761
|
+
fs.mkdirSync(filename, { recursive: true, mode: header.mode });
|
|
762
|
+
} else if (header.type == 'L') { // GNU tar
|
|
763
|
+
extended.filename = data.toString('utf-8').replace(/\0/g, '');
|
|
764
|
+
} else if (header.type == 'x') { // PAX entry
|
|
765
|
+
let str = data.toString('utf-8');
|
|
766
|
+
|
|
767
|
+
try {
|
|
768
|
+
while (str.length) {
|
|
769
|
+
let matches = str.match(/^([0-9]+) ([a-zA-Z0-9\._]+)=(.*)\n/);
|
|
770
|
+
|
|
771
|
+
let skip = parseInt(matches[1], 10);
|
|
772
|
+
let key = matches[2];
|
|
773
|
+
let value = matches[3];
|
|
774
|
+
|
|
775
|
+
switch (key) {
|
|
776
|
+
case 'path': { extended.filename = value; } break;
|
|
777
|
+
case 'size': { extended.size = parseInt(value, 10); } break;
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
str = str.substr(skip).trimStart();
|
|
781
|
+
}
|
|
782
|
+
} catch (err) {
|
|
783
|
+
throw new Error('Malformed PAX entry');
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
header = null;
|
|
788
|
+
}
|
|
789
|
+
} catch (err) {
|
|
790
|
+
reject(err);
|
|
791
|
+
}
|
|
792
|
+
});
|
|
793
|
+
|
|
794
|
+
reader.on('error', reject);
|
|
795
|
+
reader.on('end', resolve);
|
|
796
|
+
});
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
function path_is_absolute(path) {
|
|
800
|
+
if (process.platform == 'win32' && path.match(/^[a-zA-Z]:/))
|
|
801
|
+
path = path.substr(2);
|
|
802
|
+
return is_path_separator(path[0]);
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
function path_has_dotdot(path) {
|
|
806
|
+
let start = 0;
|
|
807
|
+
|
|
808
|
+
for (;;) {
|
|
809
|
+
let offset = path.indexOf('..', start);
|
|
810
|
+
if (offset < 0)
|
|
811
|
+
break;
|
|
812
|
+
start = offset + 2;
|
|
813
|
+
|
|
814
|
+
if (offset && !is_path_separator(path[offset - 1]))
|
|
815
|
+
continue;
|
|
816
|
+
if (offset + 2 < path.length && !is_path_separator(path[offset + 2]))
|
|
817
|
+
continue;
|
|
818
|
+
|
|
819
|
+
return true;
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
return false;
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
function is_path_separator(c) {
|
|
826
|
+
if (c == '/')
|
|
827
|
+
return true;
|
|
828
|
+
if (process.platform == 'win32' && c == '\\')
|
|
829
|
+
return true;
|
|
830
|
+
|
|
831
|
+
return false;
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
function find_parent_directory(dirname, basename)
|
|
835
|
+
{
|
|
836
|
+
if (process.platform == 'win32')
|
|
837
|
+
dirname = dirname.replace(/\\/g, '/');
|
|
838
|
+
|
|
839
|
+
do {
|
|
840
|
+
if (fs.existsSync(dirname + '/' + basename))
|
|
841
|
+
return dirname;
|
|
842
|
+
|
|
843
|
+
dirname = path.dirname(dirname);
|
|
844
|
+
} while (!dirname.endsWith('/'));
|
|
845
|
+
|
|
846
|
+
return null;
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
function determine_arch() {
|
|
850
|
+
let arch = process.arch;
|
|
851
|
+
|
|
852
|
+
if (arch == 'riscv32' || arch == 'riscv64') {
|
|
853
|
+
let buf = read_file_header(process.execPath, 512);
|
|
854
|
+
let header = decode_elf_header(buf);
|
|
855
|
+
let float_abi = (header.e_flags & 0x6) >> 1;
|
|
856
|
+
|
|
857
|
+
switch (float_abi) {
|
|
858
|
+
case 0: { arch += 'sf'; } break;
|
|
859
|
+
case 1: { arch += 'hf32'; } break;
|
|
860
|
+
case 2: { arch += 'hf64'; } break;
|
|
861
|
+
case 3: { arch += 'hf128'; } break;
|
|
862
|
+
}
|
|
863
|
+
} else if (arch == 'arm') {
|
|
864
|
+
arch = 'arm32';
|
|
865
|
+
|
|
866
|
+
let buf = read_file_header(process.execPath, 512);
|
|
867
|
+
let header = decode_elf_header(buf);
|
|
868
|
+
|
|
869
|
+
if (header.e_flags & 0x400) {
|
|
870
|
+
arch += 'hf';
|
|
871
|
+
} else if (header.e_flags & 0x200) {
|
|
872
|
+
arch += 'sf';
|
|
873
|
+
} else {
|
|
874
|
+
throw new Error('Unknown ARM floating-point ABI');
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
return arch;
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
function decode_elf_header(buf) {
|
|
882
|
+
let header = {};
|
|
883
|
+
|
|
884
|
+
if (buf.length < 16)
|
|
885
|
+
throw new Error('Truncated header');
|
|
886
|
+
if (buf[0] != 0x7F || buf[1] != 69 || buf[2] != 76 || buf[3] != 70)
|
|
887
|
+
throw new Error('Invalid magic number');
|
|
888
|
+
if (buf[6] != 1)
|
|
889
|
+
throw new Error('Invalid ELF version');
|
|
890
|
+
if (buf[5] != 1)
|
|
891
|
+
throw new Error('Big-endian architectures are not supported');
|
|
892
|
+
|
|
893
|
+
let machine = buf.readUInt16LE(18);
|
|
894
|
+
|
|
895
|
+
switch (machine) {
|
|
896
|
+
case 3: { header.e_machine = 'ia32'; } break;
|
|
897
|
+
case 40: { header.e_machine = 'arm'; } break;
|
|
898
|
+
case 62: { header.e_machine = 'amd64'; } break;
|
|
899
|
+
case 183: { header.e_machine = 'arm64'; } break;
|
|
900
|
+
case 243: {
|
|
901
|
+
switch (buf[4]) {
|
|
902
|
+
case 1: { header.e_machine = 'riscv32'; } break;
|
|
903
|
+
case 2: { header.e_machine = 'riscv64'; } break;
|
|
904
|
+
}
|
|
905
|
+
} break;
|
|
906
|
+
default: throw new Error('Unknown ELF machine type');
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
switch (buf[4]) {
|
|
910
|
+
case 1: { // 32 bit
|
|
911
|
+
buf = buf.subarray(0, 68);
|
|
912
|
+
if (buf.length < 68)
|
|
913
|
+
throw new Error('Truncated ELF header');
|
|
914
|
+
|
|
915
|
+
header.ei_class = 32;
|
|
916
|
+
header.e_flags = buf.readUInt32LE(36);
|
|
917
|
+
} break;
|
|
918
|
+
case 2: { // 64 bit
|
|
919
|
+
buf = buf.subarray(0, 120);
|
|
920
|
+
if (buf.length < 120)
|
|
921
|
+
throw new Error('Truncated ELF header');
|
|
922
|
+
|
|
923
|
+
header.ei_class = 64;
|
|
924
|
+
header.e_flags = buf.readUInt32LE(48);
|
|
925
|
+
} break;
|
|
926
|
+
default: throw new Error('Invalid ELF class');
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
return header;
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
// Versioning
|
|
933
|
+
|
|
934
|
+
function get_napi_version(napi, major) {
|
|
935
|
+
if (napi > 8)
|
|
936
|
+
return null;
|
|
937
|
+
|
|
938
|
+
// https://nodejs.org/api/n-api.html#node-api-version-matrix
|
|
939
|
+
const support = {
|
|
940
|
+
6: ['6.14.2', '6.14.2', '6.14.2'],
|
|
941
|
+
8: ['8.6.0', '8.10.0', '8.11.2'],
|
|
942
|
+
9: ['9.0.0', '9.3.0', '9.11.0'],
|
|
943
|
+
10: ['10.0.0', '10.0.0', '10.0.0', '10.16.0', '10.17.0', '10.20.0', '10.23.0'],
|
|
944
|
+
11: ['11.0.0', '11.0.0', '11.0.0', '11.8.0'],
|
|
945
|
+
12: ['12.0.0', '12.0.0', '12.0.0', '12.0.0', '12.11.0', '12.17.0', '12.19.0', '12.22.0'],
|
|
946
|
+
13: ['13.0.0', '13.0.0', '13.0.0', '13.0.0', '13.0.0'],
|
|
947
|
+
14: ['14.0.0', '14.0.0', '14.0.0', '14.0.0', '14.0.0', '14.0.0', '14.12.0', '14.17.0'],
|
|
948
|
+
15: ['15.0.0', '15.0.0', '15.0.0', '15.0.0', '15.0.0', '15.0.0', '15.0.0', '15.12.0']
|
|
949
|
+
};
|
|
950
|
+
const max = Math.max(...Object.keys(support).map(k => parseInt(k, 10)));
|
|
951
|
+
|
|
952
|
+
if (major > max)
|
|
953
|
+
return major + '.0.0';
|
|
954
|
+
if (support[major] == null)
|
|
955
|
+
return null;
|
|
956
|
+
|
|
957
|
+
let required = support[major][napi - 1] || null;
|
|
958
|
+
return required;
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
// Ignores prerelease suffixes
|
|
962
|
+
function cmp_version(ver1, ver2) {
|
|
963
|
+
ver1 = String(ver1).replace(/-.*$/, '').split('.').reduce((acc, v, idx) => acc + parseInt(v, 10) * Math.pow(10, 2 * (5 - idx)), 0);
|
|
964
|
+
ver2 = String(ver2).replace(/-.*$/, '').split('.').reduce((acc, v, idx) => acc + parseInt(v, 10) * Math.pow(10, 2 * (5 - idx)), 0);
|
|
965
|
+
|
|
966
|
+
let cmp = Math.min(Math.max(ver1 - ver2, -1), 1);
|
|
967
|
+
return cmp;
|
|
968
|
+
}
|