@psnext/slingcli 2.4.20260525-4 → 2.4.20260527-2
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/bin/sling.js +4 -1
- package/node_modules/@aws-sdk/core/package.json +2 -2
- package/node_modules/@aws-sdk/credential-provider-env/package.json +2 -2
- package/node_modules/@aws-sdk/credential-provider-http/dist-cjs/fromHttp/fromHttp.js +12 -6
- package/node_modules/@aws-sdk/credential-provider-http/dist-es/fromHttp/fromHttp.js +12 -6
- package/node_modules/@aws-sdk/credential-provider-http/package.json +3 -2
- package/node_modules/@aws-sdk/credential-provider-ini/package.json +9 -9
- package/node_modules/@aws-sdk/credential-provider-login/package.json +3 -3
- package/node_modules/@aws-sdk/credential-provider-node/package.json +7 -7
- package/node_modules/@aws-sdk/credential-provider-process/package.json +2 -2
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/package.json +3 -3
- package/node_modules/@aws-sdk/credential-provider-sso/package.json +4 -4
- package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +3 -3
- package/node_modules/@aws-sdk/middleware-websocket/package.json +2 -2
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/cognito-identity/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/signin/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso-oidc/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sts/index.js +1 -1
- package/node_modules/@aws-sdk/nested-clients/package.json +3 -3
- package/node_modules/@aws-sdk/signature-v4-multi-region/package.json +1 -2
- package/node_modules/@aws-sdk/xml-builder/package.json +2 -2
- package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/compaction.js +18 -24
- package/node_modules/@earendil-works/pi-agent-core/package.json +2 -2
- package/node_modules/@earendil-works/pi-ai/dist/cli.js +14 -0
- package/node_modules/@earendil-works/pi-ai/dist/models.generated.js +78 -63
- package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.js +8 -22
- package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.js +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/images/openrouter.js +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex-responses.js +60 -40
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai-completions.js +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai-responses.js +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/device-code.js +55 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/github-copilot.js +45 -69
- package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/index.js +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/overflow.js +5 -2
- package/node_modules/@earendil-works/pi-ai/package.json +4 -3
- package/node_modules/@earendil-works/pi-coding-agent/dist/cli/file-processor.js +2 -3
- package/node_modules/@earendil-works/pi-coding-agent/dist/config.js +18 -12
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session-runtime.js +2 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session-services.js +3 -2
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session.js +8 -2
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/auth-storage.js +2 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/compaction/compaction.js +18 -24
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/export-html/index.js +8 -6
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/export-html/template.js +6 -3
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/loader.js +12 -29
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/model-registry.js +5 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/output-guard.js +52 -22
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/package-manager.js +63 -36
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/prompt-templates.js +6 -20
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/resource-loader.js +38 -31
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/sdk.js +9 -4
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/session-manager.js +32 -24
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/settings-manager.js +6 -13
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/skills.js +8 -22
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/bash.js +54 -53
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/edit-diff.js +8 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/edit.js +44 -81
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/file-mutation-queue.js +27 -12
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/find.js +2 -3
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/grep.js +3 -3
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/ls.js +5 -5
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/output-accumulator.js +9 -3
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/path-utils.js +39 -21
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/read.js +9 -8
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/truncate.js +12 -2
- package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/write.js +20 -35
- package/node_modules/@earendil-works/pi-coding-agent/dist/main.js +5 -6
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/config-selector.js +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/footer.js +14 -5
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/login-dialog.js +29 -4
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/user-message.js +1 -1
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/interactive-mode.js +4 -4
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme.js +37 -28
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/rpc/rpc-client.js +64 -7
- package/node_modules/@earendil-works/pi-coding-agent/dist/modes/rpc/rpc-mode.js +15 -3
- package/node_modules/@earendil-works/pi-coding-agent/dist/utils/clipboard-native.js +14 -8
- package/node_modules/@earendil-works/pi-coding-agent/dist/utils/image-resize-core.js +124 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/utils/image-resize-worker.js +31 -0
- package/node_modules/@earendil-works/pi-coding-agent/dist/utils/image-resize.js +75 -115
- package/node_modules/@earendil-works/pi-coding-agent/dist/utils/paths.js +33 -7
- package/node_modules/@earendil-works/pi-coding-agent/npm-shrinkwrap.json +13 -26
- package/node_modules/@earendil-works/pi-coding-agent/package.json +6 -6
- package/node_modules/@earendil-works/pi-tui/dist/components/editor.js +40 -55
- package/node_modules/@earendil-works/pi-tui/dist/components/input.js +2 -2
- package/node_modules/@earendil-works/pi-tui/dist/components/markdown.js +12 -2
- package/node_modules/@earendil-works/pi-tui/dist/native-modifiers.js +53 -0
- package/node_modules/@earendil-works/pi-tui/dist/terminal-image.js +4 -1
- package/node_modules/@earendil-works/pi-tui/dist/terminal.js +38 -16
- package/node_modules/@earendil-works/pi-tui/dist/utils.js +19 -12
- package/node_modules/@earendil-works/pi-tui/native/darwin/prebuilds/darwin-arm64/darwin-modifiers.node +0 -0
- package/node_modules/@earendil-works/pi-tui/native/darwin/prebuilds/darwin-x64/darwin-modifiers.node +0 -0
- package/node_modules/@earendil-works/pi-tui/native/win32/prebuilds/win32-arm64/win32-console-mode.node +0 -0
- package/node_modules/@earendil-works/pi-tui/native/win32/prebuilds/win32-x64/win32-console-mode.node +0 -0
- package/node_modules/@earendil-works/pi-tui/package.json +3 -5
- package/node_modules/@smithy/node-http-handler/package.json +2 -2
- package/node_modules/undici/lib/api/api-request.js +1 -1
- package/node_modules/undici/lib/cache/sqlite-cache-store.js +3 -3
- package/node_modules/undici/lib/core/connect.js +16 -0
- package/node_modules/undici/lib/core/request.js +17 -2
- package/node_modules/undici/lib/core/socks5-client.js +10 -5
- package/node_modules/undici/lib/core/socks5-utils.js +17 -22
- package/node_modules/undici/lib/dispatcher/client-h1.js +64 -20
- package/node_modules/undici/lib/dispatcher/client.js +6 -2
- package/node_modules/undici/lib/dispatcher/h2c-client.js +1 -1
- package/node_modules/undici/lib/mock/mock-call-history.js +15 -15
- package/node_modules/undici/lib/util/cache.js +8 -7
- package/node_modules/undici/lib/web/fetch/formdata-parser.js +17 -6
- package/node_modules/undici/lib/web/fetch/index.js +5 -2
- package/node_modules/undici/lib/web/webidl/index.js +5 -5
- package/node_modules/undici/lib/web/websocket/stream/websocketstream.js +1 -7
- package/node_modules/undici/package.json +1 -1
- package/package.json +6 -6
- package/slingshot/index.js +269 -266
- package/node_modules/koffi/CHANGELOG.md +0 -1093
- package/node_modules/koffi/LICENSE.txt +0 -22
- package/node_modules/koffi/README.md +0 -43
- package/node_modules/koffi/build/koffi/darwin_arm64/koffi.node +0 -0
- package/node_modules/koffi/build/koffi/darwin_x64/koffi.node +0 -0
- package/node_modules/koffi/build/koffi/freebsd_arm64/koffi.node +0 -0
- package/node_modules/koffi/build/koffi/freebsd_ia32/koffi.node +0 -0
- package/node_modules/koffi/build/koffi/freebsd_x64/koffi.node +0 -0
- package/node_modules/koffi/build/koffi/linux_arm64/koffi.node +0 -0
- package/node_modules/koffi/build/koffi/linux_armhf/koffi.node +0 -0
- package/node_modules/koffi/build/koffi/linux_ia32/koffi.node +0 -0
- package/node_modules/koffi/build/koffi/linux_loong64/koffi.node +0 -0
- package/node_modules/koffi/build/koffi/linux_riscv64d/koffi.node +0 -0
- package/node_modules/koffi/build/koffi/linux_x64/koffi.node +0 -0
- package/node_modules/koffi/build/koffi/musl_arm64/koffi.node +0 -0
- package/node_modules/koffi/build/koffi/musl_x64/koffi.node +0 -0
- package/node_modules/koffi/build/koffi/openbsd_ia32/koffi.node +0 -0
- package/node_modules/koffi/build/koffi/openbsd_x64/koffi.node +0 -0
- package/node_modules/koffi/build/koffi/win32_arm64/koffi.exp +0 -0
- package/node_modules/koffi/build/koffi/win32_arm64/koffi.lib +0 -0
- package/node_modules/koffi/build/koffi/win32_arm64/koffi.node +0 -0
- package/node_modules/koffi/build/koffi/win32_ia32/koffi.exp +0 -0
- package/node_modules/koffi/build/koffi/win32_ia32/koffi.lib +0 -0
- package/node_modules/koffi/build/koffi/win32_ia32/koffi.node +0 -0
- package/node_modules/koffi/build/koffi/win32_x64/koffi.exp +0 -0
- package/node_modules/koffi/build/koffi/win32_x64/koffi.lib +0 -0
- package/node_modules/koffi/build/koffi/win32_x64/koffi.node +0 -0
- package/node_modules/koffi/doc/benchmarks.md +0 -126
- package/node_modules/koffi/doc/callbacks.md +0 -210
- package/node_modules/koffi/doc/contribute.md +0 -148
- package/node_modules/koffi/doc/functions.md +0 -250
- package/node_modules/koffi/doc/index.md +0 -61
- package/node_modules/koffi/doc/input.md +0 -471
- package/node_modules/koffi/doc/migration.md +0 -159
- package/node_modules/koffi/doc/misc.md +0 -180
- package/node_modules/koffi/doc/output.md +0 -305
- package/node_modules/koffi/doc/packaging.md +0 -88
- package/node_modules/koffi/doc/platforms.md +0 -36
- package/node_modules/koffi/doc/pointers.md +0 -328
- package/node_modules/koffi/doc/start.md +0 -118
- package/node_modules/koffi/doc/unions.md +0 -186
- package/node_modules/koffi/doc/variables.md +0 -102
- package/node_modules/koffi/index.d.ts +0 -288
- package/node_modules/koffi/index.js +0 -634
- package/node_modules/koffi/indirect.js +0 -533
- package/node_modules/koffi/lib/native/base/base.cc +0 -11015
- package/node_modules/koffi/lib/native/base/base.hh +0 -6003
- package/node_modules/koffi/lib/native/base/crc.inc +0 -2214
- package/node_modules/koffi/lib/native/base/crc_gen.py +0 -72
- package/node_modules/koffi/lib/native/base/mimetypes.inc +0 -1248
- package/node_modules/koffi/lib/native/base/mimetypes_gen.py +0 -58
- package/node_modules/koffi/lib/native/base/tower.cc +0 -821
- package/node_modules/koffi/lib/native/base/tower.hh +0 -81
- package/node_modules/koffi/lib/native/base/unicode.inc +0 -408
- package/node_modules/koffi/lib/native/base/unicode_gen.py +0 -152
- package/node_modules/koffi/package.json +0 -38
- package/node_modules/koffi/src/cnoke/LICENSE.txt +0 -22
- package/node_modules/koffi/src/cnoke/README.md +0 -99
- package/node_modules/koffi/src/cnoke/assets/FindCNoke.cmake +0 -127
- package/node_modules/koffi/src/cnoke/assets/toolchains.json +0 -126
- package/node_modules/koffi/src/cnoke/assets/win_delay_hook.c +0 -36
- package/node_modules/koffi/src/cnoke/cnoke.js +0 -170
- package/node_modules/koffi/src/cnoke/package.json +0 -24
- package/node_modules/koffi/src/cnoke/src/builder.js +0 -511
- package/node_modules/koffi/src/cnoke/src/index.js +0 -10
- package/node_modules/koffi/src/cnoke/src/tools.js +0 -407
- package/node_modules/koffi/src/koffi/CMakeLists.txt +0 -182
- package/node_modules/koffi/src/koffi/src/abi_arm32.cc +0 -1018
- package/node_modules/koffi/src/koffi/src/abi_arm32_asm.S +0 -169
- package/node_modules/koffi/src/koffi/src/abi_arm64.cc +0 -1295
- package/node_modules/koffi/src/koffi/src/abi_arm64_asm.S +0 -195
- package/node_modules/koffi/src/koffi/src/abi_arm64_asm.asm +0 -174
- package/node_modules/koffi/src/koffi/src/abi_loong64.cc +0 -5
- package/node_modules/koffi/src/koffi/src/abi_loong64_asm.S +0 -204
- package/node_modules/koffi/src/koffi/src/abi_riscv64.cc +0 -915
- package/node_modules/koffi/src/koffi/src/abi_riscv64_asm.S +0 -203
- package/node_modules/koffi/src/koffi/src/abi_x64_sysv.cc +0 -939
- package/node_modules/koffi/src/koffi/src/abi_x64_sysv_asm.S +0 -231
- package/node_modules/koffi/src/koffi/src/abi_x64_win.cc +0 -715
- package/node_modules/koffi/src/koffi/src/abi_x64_win_asm.S +0 -166
- package/node_modules/koffi/src/koffi/src/abi_x64_win_asm.asm +0 -192
- package/node_modules/koffi/src/koffi/src/abi_x86.cc +0 -860
- package/node_modules/koffi/src/koffi/src/abi_x86_asm.S +0 -193
- package/node_modules/koffi/src/koffi/src/abi_x86_asm.asm +0 -177
- package/node_modules/koffi/src/koffi/src/call.cc +0 -1326
- package/node_modules/koffi/src/koffi/src/call.hh +0 -179
- package/node_modules/koffi/src/koffi/src/errno.inc +0 -462
- package/node_modules/koffi/src/koffi/src/ffi.cc +0 -2702
- package/node_modules/koffi/src/koffi/src/ffi.hh +0 -354
- package/node_modules/koffi/src/koffi/src/init.js +0 -105
- package/node_modules/koffi/src/koffi/src/parser.cc +0 -220
- package/node_modules/koffi/src/koffi/src/parser.hh +0 -54
- package/node_modules/koffi/src/koffi/src/util.cc +0 -1807
- package/node_modules/koffi/src/koffi/src/util.hh +0 -221
- package/node_modules/koffi/src/koffi/src/uv.cc +0 -193
- package/node_modules/koffi/src/koffi/src/uv.def +0 -10
- package/node_modules/koffi/src/koffi/src/uv.hh +0 -40
- package/node_modules/koffi/src/koffi/src/win32.cc +0 -198
- package/node_modules/koffi/src/koffi/src/win32.hh +0 -119
- package/node_modules/koffi/src/koffi/tools/write_trampolines.js +0 -77
- package/node_modules/koffi/vendor/node-addon-api/LICENSE.md +0 -9
- package/node_modules/koffi/vendor/node-addon-api/README.md +0 -95
- package/node_modules/koffi/vendor/node-addon-api/napi-inl.deprecated.h +0 -186
- package/node_modules/koffi/vendor/node-addon-api/napi-inl.h +0 -7033
- package/node_modules/koffi/vendor/node-addon-api/napi.h +0 -3309
- package/node_modules/koffi/vendor/node-api-headers/LICENSE +0 -21
- package/node_modules/koffi/vendor/node-api-headers/README.md +0 -95
- package/node_modules/koffi/vendor/node-api-headers/def/js_native_api.def +0 -125
- package/node_modules/koffi/vendor/node-api-headers/def/node_api.def +0 -157
- package/node_modules/koffi/vendor/node-api-headers/include/js_native_api.h +0 -591
- package/node_modules/koffi/vendor/node-api-headers/include/js_native_api_types.h +0 -210
- package/node_modules/koffi/vendor/node-api-headers/include/node_api.h +0 -265
- package/node_modules/koffi/vendor/node-api-headers/include/node_api_types.h +0 -58
- package/node_modules/koffi/vendor/node-api-headers/include/uv/aix.h +0 -32
- package/node_modules/koffi/vendor/node-api-headers/include/uv/bsd.h +0 -34
- package/node_modules/koffi/vendor/node-api-headers/include/uv/darwin.h +0 -61
- package/node_modules/koffi/vendor/node-api-headers/include/uv/errno.h +0 -483
- package/node_modules/koffi/vendor/node-api-headers/include/uv/linux.h +0 -34
- package/node_modules/koffi/vendor/node-api-headers/include/uv/os390.h +0 -33
- package/node_modules/koffi/vendor/node-api-headers/include/uv/posix.h +0 -31
- package/node_modules/koffi/vendor/node-api-headers/include/uv/sunos.h +0 -44
- package/node_modules/koffi/vendor/node-api-headers/include/uv/threadpool.h +0 -37
- package/node_modules/koffi/vendor/node-api-headers/include/uv/tree.h +0 -521
- package/node_modules/koffi/vendor/node-api-headers/include/uv/unix.h +0 -512
- package/node_modules/koffi/vendor/node-api-headers/include/uv/version.h +0 -43
- package/node_modules/koffi/vendor/node-api-headers/include/uv/win.h +0 -698
- package/node_modules/koffi/vendor/node-api-headers/include/uv.h +0 -1990
|
@@ -1,407 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
// SPDX-FileCopyrightText: 2025 Niels Martignène <niels.martignene@protonmail.com>
|
|
3
|
-
|
|
4
|
-
'use strict';
|
|
5
|
-
|
|
6
|
-
const crypto = require('crypto');
|
|
7
|
-
const fs = require('fs');
|
|
8
|
-
const http = require('https');
|
|
9
|
-
const path = require('path');
|
|
10
|
-
const zlib = require('zlib');
|
|
11
|
-
|
|
12
|
-
async function download_http(url, dest) {
|
|
13
|
-
console.log('>> Downloading ' + url);
|
|
14
|
-
|
|
15
|
-
let [tmp_name, file] = open_temporary_stream(dest);
|
|
16
|
-
|
|
17
|
-
try {
|
|
18
|
-
await new Promise((resolve, reject) => {
|
|
19
|
-
let request = http.get(url, response => {
|
|
20
|
-
if (response.statusCode != 200) {
|
|
21
|
-
let err = new Error(`Download failed: ${response.statusMessage} [${response.statusCode}]`);
|
|
22
|
-
err.code = response.statusCode;
|
|
23
|
-
|
|
24
|
-
reject(err);
|
|
25
|
-
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
response.pipe(file);
|
|
30
|
-
|
|
31
|
-
file.on('finish', () => file.close(() => {
|
|
32
|
-
try {
|
|
33
|
-
fs.renameSync(file.path, dest);
|
|
34
|
-
} catch (err) {
|
|
35
|
-
if (!fs.existsSync(dest))
|
|
36
|
-
reject(err);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
resolve();
|
|
40
|
-
}));
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
request.on('error', reject);
|
|
44
|
-
file.on('error', reject);
|
|
45
|
-
});
|
|
46
|
-
} catch (err) {
|
|
47
|
-
file.close();
|
|
48
|
-
|
|
49
|
-
try {
|
|
50
|
-
fs.unlinkSync(tmp_name);
|
|
51
|
-
} catch (err) {
|
|
52
|
-
if (err.code != 'ENOENT')
|
|
53
|
-
throw err;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
throw err;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function open_temporary_stream(prefix) {
|
|
61
|
-
let buf = Buffer.allocUnsafe(4);
|
|
62
|
-
|
|
63
|
-
for (;;) {
|
|
64
|
-
try {
|
|
65
|
-
crypto.randomFillSync(buf);
|
|
66
|
-
|
|
67
|
-
let suffix = buf.toString('hex').padStart(8, '0');
|
|
68
|
-
let filename = `${prefix}.${suffix}`;
|
|
69
|
-
|
|
70
|
-
let file = fs.createWriteStream(filename, { flags: 'wx', mode: 0o644 });
|
|
71
|
-
return [filename, file];
|
|
72
|
-
} catch (err) {
|
|
73
|
-
if (err.code != 'EEXIST')
|
|
74
|
-
throw err;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function extract_targz(filename, dest_dir, strip = 0) {
|
|
80
|
-
let reader = fs.createReadStream(filename).pipe(zlib.createGunzip());
|
|
81
|
-
|
|
82
|
-
return new Promise((resolve, reject) => {
|
|
83
|
-
let header = null;
|
|
84
|
-
let extended = {};
|
|
85
|
-
|
|
86
|
-
reader.on('readable', () => {
|
|
87
|
-
try {
|
|
88
|
-
for (;;) {
|
|
89
|
-
if (header == null) {
|
|
90
|
-
let buf = reader.read(512);
|
|
91
|
-
if (buf == null)
|
|
92
|
-
break;
|
|
93
|
-
|
|
94
|
-
// Two zeroed 512-byte blocks end the stream
|
|
95
|
-
if (!buf[0])
|
|
96
|
-
continue;
|
|
97
|
-
|
|
98
|
-
header = {
|
|
99
|
-
filename: buf.toString('utf-8', 0, 100).replace(/\0/g, ''),
|
|
100
|
-
mode: parseInt(buf.toString('ascii', 100, 109), 8),
|
|
101
|
-
size: parseInt(buf.toString('ascii', 124, 137), 8),
|
|
102
|
-
type: String.fromCharCode(buf[156])
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
// UStar filename prefix
|
|
106
|
-
/*if (buf.toString('ascii', 257, 263) == 'ustar\0') {
|
|
107
|
-
let prefix = buf.toString('utf-8', 345, 500).replace(/\0/g, '');
|
|
108
|
-
console.log(prefix);
|
|
109
|
-
header.filename = prefix ? (prefix + '/' + header.filename) : header.filename;
|
|
110
|
-
}*/
|
|
111
|
-
|
|
112
|
-
Object.assign(header, extended);
|
|
113
|
-
extended = {};
|
|
114
|
-
|
|
115
|
-
// Safety checks
|
|
116
|
-
header.filename = header.filename.replace(/\\/g, '/');
|
|
117
|
-
if (!header.filename.length)
|
|
118
|
-
throw new Error(`Insecure empty filename inside TAR archive`);
|
|
119
|
-
if (path_is_absolute(header.filename[0]))
|
|
120
|
-
throw new Error(`Insecure filename starting with / inside TAR archive`);
|
|
121
|
-
if (path_has_dotdot(header.filename))
|
|
122
|
-
throw new Error(`Insecure filename containing '..' inside TAR archive`);
|
|
123
|
-
|
|
124
|
-
for (let i = 0; i < strip; i++)
|
|
125
|
-
header.filename = header.filename.substr(header.filename.indexOf('/') + 1);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
let aligned = Math.floor((header.size + 511) / 512) * 512;
|
|
129
|
-
let data = header.size ? reader.read(aligned) : null;
|
|
130
|
-
if (data == null) {
|
|
131
|
-
if (header.size)
|
|
132
|
-
break;
|
|
133
|
-
data = Buffer.alloc(0);
|
|
134
|
-
}
|
|
135
|
-
data = data.subarray(0, header.size);
|
|
136
|
-
|
|
137
|
-
if (header.type == '0' || header.type == '7') {
|
|
138
|
-
let filename = dest_dir + '/' + header.filename;
|
|
139
|
-
let dirname = path.dirname(filename);
|
|
140
|
-
|
|
141
|
-
fs.mkdirSync(dirname, { recursive: true, mode: 0o755 });
|
|
142
|
-
fs.writeFileSync(filename, data, { mode: header.mode });
|
|
143
|
-
} else if (header.type == '5') {
|
|
144
|
-
let filename = dest_dir + '/' + header.filename;
|
|
145
|
-
fs.mkdirSync(filename, { recursive: true, mode: header.mode });
|
|
146
|
-
} else if (header.type == 'L') { // GNU tar
|
|
147
|
-
extended.filename = data.toString('utf-8').replace(/\0/g, '');
|
|
148
|
-
} else if (header.type == 'x') { // PAX entry
|
|
149
|
-
let str = data.toString('utf-8');
|
|
150
|
-
|
|
151
|
-
try {
|
|
152
|
-
while (str.length) {
|
|
153
|
-
let matches = str.match(/^([0-9]+) ([a-zA-Z0-9\._]+)=(.*)\n/);
|
|
154
|
-
|
|
155
|
-
let skip = parseInt(matches[1], 10);
|
|
156
|
-
let key = matches[2];
|
|
157
|
-
let value = matches[3];
|
|
158
|
-
|
|
159
|
-
switch (key) {
|
|
160
|
-
case 'path': { extended.filename = value; } break;
|
|
161
|
-
case 'size': { extended.size = parseInt(value, 10); } break;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
str = str.substr(skip).trimStart();
|
|
165
|
-
}
|
|
166
|
-
} catch (err) {
|
|
167
|
-
throw new Error('Malformed PAX entry');
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
header = null;
|
|
172
|
-
}
|
|
173
|
-
} catch (err) {
|
|
174
|
-
reject(err);
|
|
175
|
-
}
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
reader.on('error', reject);
|
|
179
|
-
reader.on('end', resolve);
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
function path_is_absolute(path) {
|
|
184
|
-
if (process.platform == 'win32' && path.match(/^[a-zA-Z]:/))
|
|
185
|
-
path = path.substr(2);
|
|
186
|
-
return is_path_separator(path[0]);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
function path_has_dotdot(path) {
|
|
190
|
-
let start = 0;
|
|
191
|
-
|
|
192
|
-
for (;;) {
|
|
193
|
-
let offset = path.indexOf('..', start);
|
|
194
|
-
if (offset < 0)
|
|
195
|
-
break;
|
|
196
|
-
start = offset + 2;
|
|
197
|
-
|
|
198
|
-
if (offset && !is_path_separator(path[offset - 1]))
|
|
199
|
-
continue;
|
|
200
|
-
if (offset + 2 < path.length && !is_path_separator(path[offset + 2]))
|
|
201
|
-
continue;
|
|
202
|
-
|
|
203
|
-
return true;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
return false;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
function is_path_separator(c) {
|
|
210
|
-
if (c == '/')
|
|
211
|
-
return true;
|
|
212
|
-
if (process.platform == 'win32' && c == '\\')
|
|
213
|
-
return true;
|
|
214
|
-
|
|
215
|
-
return false;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
function sync_files(src_dir, dest_dir) {
|
|
219
|
-
let keep = new Set;
|
|
220
|
-
|
|
221
|
-
// Copy source files
|
|
222
|
-
{
|
|
223
|
-
let entries = fs.readdirSync(src_dir, { withFileTypes: true });
|
|
224
|
-
|
|
225
|
-
for (let entry of entries) {
|
|
226
|
-
if (!entry.isFile())
|
|
227
|
-
continue;
|
|
228
|
-
|
|
229
|
-
keep.add(entry.name);
|
|
230
|
-
fs.copyFileSync(src_dir + `/${entry.name}`, dest_dir + `/${entry.name}`);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
// Delete old destination files
|
|
235
|
-
{
|
|
236
|
-
let entries = fs.readdirSync(dest_dir, { withFileTypes: true });
|
|
237
|
-
|
|
238
|
-
for (let entry of entries) {
|
|
239
|
-
if (!entry.isFile())
|
|
240
|
-
continue;
|
|
241
|
-
if (keep.has(entry.name))
|
|
242
|
-
continue;
|
|
243
|
-
|
|
244
|
-
fs.unlinkSync(dest_dir + `/${entry.name}`);
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
function determine_arch() {
|
|
250
|
-
let arch = process.arch;
|
|
251
|
-
|
|
252
|
-
if (arch == 'riscv32' || arch == 'riscv64') {
|
|
253
|
-
let buf = read_file_header(process.execPath, 512);
|
|
254
|
-
let header = decode_elf_header(buf);
|
|
255
|
-
let float_abi = (header.e_flags & 0x6);
|
|
256
|
-
|
|
257
|
-
switch (float_abi) {
|
|
258
|
-
case 0: {} break;
|
|
259
|
-
case 2: { arch += 'f'; } break;
|
|
260
|
-
case 4: { arch += 'd'; } break;
|
|
261
|
-
case 6: { arch += 'q'; } break;
|
|
262
|
-
}
|
|
263
|
-
} else if (arch == 'arm') {
|
|
264
|
-
let buf = read_file_header(process.execPath, 512);
|
|
265
|
-
let header = decode_elf_header(buf);
|
|
266
|
-
|
|
267
|
-
if (header.e_flags & 0x400) {
|
|
268
|
-
arch += 'hf';
|
|
269
|
-
} else if (header.e_flags & 0x200) {
|
|
270
|
-
arch += 'sf';
|
|
271
|
-
} else {
|
|
272
|
-
throw new Error('Unknown ARM floating-point ABI');
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
return arch;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
function read_file_header(filename, read) {
|
|
280
|
-
let fd = null;
|
|
281
|
-
|
|
282
|
-
try {
|
|
283
|
-
let fd = fs.openSync(filename);
|
|
284
|
-
|
|
285
|
-
let buf = Buffer.allocUnsafe(read);
|
|
286
|
-
let len = fs.readSync(fd, buf);
|
|
287
|
-
|
|
288
|
-
return buf.subarray(0, len);
|
|
289
|
-
} finally {
|
|
290
|
-
if (fd != null)
|
|
291
|
-
fs.closeSync(fd);
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
function decode_elf_header(buf) {
|
|
296
|
-
let header = {};
|
|
297
|
-
|
|
298
|
-
if (buf.length < 16)
|
|
299
|
-
throw new Error('Truncated header');
|
|
300
|
-
if (buf[0] != 0x7F || buf[1] != 69 || buf[2] != 76 || buf[3] != 70)
|
|
301
|
-
throw new Error('Invalid magic number');
|
|
302
|
-
if (buf[6] != 1)
|
|
303
|
-
throw new Error('Invalid ELF version');
|
|
304
|
-
if (buf[5] != 1)
|
|
305
|
-
throw new Error('Big-endian architectures are not supported');
|
|
306
|
-
|
|
307
|
-
let machine = buf.readUInt16LE(18);
|
|
308
|
-
|
|
309
|
-
switch (machine) {
|
|
310
|
-
case 3: { header.e_machine = 'ia32'; } break;
|
|
311
|
-
case 40: { header.e_machine = 'arm'; } break;
|
|
312
|
-
case 62: { header.e_machine = 'amd64'; } break;
|
|
313
|
-
case 183: { header.e_machine = 'arm64'; } break;
|
|
314
|
-
case 243: {
|
|
315
|
-
switch (buf[4]) {
|
|
316
|
-
case 1: { header.e_machine = 'riscv32'; } break;
|
|
317
|
-
case 2: { header.e_machine = 'riscv64'; } break;
|
|
318
|
-
}
|
|
319
|
-
} break;
|
|
320
|
-
case 248: {
|
|
321
|
-
switch (buf[4]) {
|
|
322
|
-
case 1: { header.e_machine = 'loong32'; } break;
|
|
323
|
-
case 2: { header.e_machine = 'loong64'; } break;
|
|
324
|
-
}
|
|
325
|
-
} break;
|
|
326
|
-
default: throw new Error('Unknown ELF machine type');
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
switch (buf[4]) {
|
|
330
|
-
case 1: { // 32 bit
|
|
331
|
-
buf = buf.subarray(0, 68);
|
|
332
|
-
if (buf.length < 68)
|
|
333
|
-
throw new Error('Truncated ELF header');
|
|
334
|
-
|
|
335
|
-
header.ei_class = 32;
|
|
336
|
-
header.e_flags = buf.readUInt32LE(36);
|
|
337
|
-
} break;
|
|
338
|
-
case 2: { // 64 bit
|
|
339
|
-
buf = buf.subarray(0, 120);
|
|
340
|
-
if (buf.length < 120)
|
|
341
|
-
throw new Error('Truncated ELF header');
|
|
342
|
-
|
|
343
|
-
header.ei_class = 64;
|
|
344
|
-
header.e_flags = buf.readUInt32LE(48);
|
|
345
|
-
} break;
|
|
346
|
-
default: throw new Error('Invalid ELF class');
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
return header;
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
function unlink_recursive(path) {
|
|
353
|
-
try {
|
|
354
|
-
fs.rmSync(path, { recursive: true, maxRetries: process.platform == 'win32' ? 3 : 0 });
|
|
355
|
-
} catch (err) {
|
|
356
|
-
if (err.code !== 'ENOENT')
|
|
357
|
-
throw err;
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
function get_napi_version(napi, major) {
|
|
362
|
-
if (napi > 8)
|
|
363
|
-
return null;
|
|
364
|
-
|
|
365
|
-
// https://nodejs.org/api/n-api.html#node-api-version-matrix
|
|
366
|
-
const support = {
|
|
367
|
-
6: ['6.14.2', '6.14.2', '6.14.2'],
|
|
368
|
-
8: ['8.6.0', '8.10.0', '8.11.2'],
|
|
369
|
-
9: ['9.0.0', '9.3.0', '9.11.0'],
|
|
370
|
-
10: ['10.0.0', '10.0.0', '10.0.0', '10.16.0', '10.17.0', '10.20.0', '10.23.0'],
|
|
371
|
-
11: ['11.0.0', '11.0.0', '11.0.0', '11.8.0'],
|
|
372
|
-
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'],
|
|
373
|
-
13: ['13.0.0', '13.0.0', '13.0.0', '13.0.0', '13.0.0'],
|
|
374
|
-
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'],
|
|
375
|
-
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']
|
|
376
|
-
};
|
|
377
|
-
const max = Math.max(...Object.keys(support).map(k => parseInt(k, 10)));
|
|
378
|
-
|
|
379
|
-
if (major > max)
|
|
380
|
-
return major + '.0.0';
|
|
381
|
-
if (support[major] == null)
|
|
382
|
-
return null;
|
|
383
|
-
|
|
384
|
-
let required = support[major][napi - 1] || null;
|
|
385
|
-
return required;
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
// Ignores prerelease suffixes
|
|
389
|
-
function cmp_version(ver1, ver2) {
|
|
390
|
-
ver1 = String(ver1).replace(/-.*$/, '').split('.').reduce((acc, v, idx) => acc + parseInt(v, 10) * Math.pow(10, 2 * (5 - idx)), 0);
|
|
391
|
-
ver2 = String(ver2).replace(/-.*$/, '').split('.').reduce((acc, v, idx) => acc + parseInt(v, 10) * Math.pow(10, 2 * (5 - idx)), 0);
|
|
392
|
-
|
|
393
|
-
let cmp = Math.min(Math.max(ver1 - ver2, -1), 1);
|
|
394
|
-
return cmp;
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
module.exports = {
|
|
398
|
-
download_http,
|
|
399
|
-
extract_targz,
|
|
400
|
-
path_is_absolute,
|
|
401
|
-
path_has_dotdot,
|
|
402
|
-
sync_files,
|
|
403
|
-
determine_arch,
|
|
404
|
-
unlink_recursive,
|
|
405
|
-
get_napi_version,
|
|
406
|
-
cmp_version
|
|
407
|
-
};
|
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
# SPDX-License-Identifier: MIT
|
|
2
|
-
# SPDX-FileCopyrightText: 2025 Niels Martignène <niels.martignene@protonmail.com>
|
|
3
|
-
|
|
4
|
-
cmake_minimum_required(VERSION 3.10)
|
|
5
|
-
cmake_policy(SET CMP0091 NEW)
|
|
6
|
-
|
|
7
|
-
if(NOT NODE_JS_INCLUDE_DIRS)
|
|
8
|
-
message(FATAL_ERROR "Please use CNoke to build Koffi, follow instructions here: https://koffi.dev/contribute#build-from-source")
|
|
9
|
-
endif()
|
|
10
|
-
|
|
11
|
-
project(koffi C CXX ASM)
|
|
12
|
-
find_package(CNoke)
|
|
13
|
-
|
|
14
|
-
include(CheckCXXCompilerFlag)
|
|
15
|
-
|
|
16
|
-
set(CMAKE_CXX_STANDARD 20)
|
|
17
|
-
if(MSVC)
|
|
18
|
-
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)
|
|
19
|
-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus /Zc:preprocessor /Zc:twoPhase- /W4 /wd4200 /wd4201 /wd4127 /wd4458 /wd4706 /wd4702 /wd4324")
|
|
20
|
-
|
|
21
|
-
# ASM_MASM does not (yet) work on Windows ARM64
|
|
22
|
-
if(NOT CMAKE_GENERATOR_PLATFORM MATCHES "ARM64")
|
|
23
|
-
enable_language(ASM_MASM)
|
|
24
|
-
endif()
|
|
25
|
-
else()
|
|
26
|
-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-missing-field-initializers -Wno-unused-parameter -Wno-class-memaccess -Wswitch -Werror=switch")
|
|
27
|
-
|
|
28
|
-
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
|
29
|
-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-warning-option")
|
|
30
|
-
endif()
|
|
31
|
-
endif()
|
|
32
|
-
|
|
33
|
-
if(UNIX AND NOT APPLE)
|
|
34
|
-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_FILE_OFFSET_BITS=64")
|
|
35
|
-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_FILE_OFFSET_BITS=64")
|
|
36
|
-
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -z noexecstack")
|
|
37
|
-
endif()
|
|
38
|
-
|
|
39
|
-
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
40
|
-
|
|
41
|
-
# ---- Koffi ----
|
|
42
|
-
|
|
43
|
-
# Recompute the version string after each commit
|
|
44
|
-
if(EXISTS "${CMAKE_SOURCE_DIR}/../../.git/logs/HEAD")
|
|
45
|
-
configure_file("${CMAKE_SOURCE_DIR}/../../.git/logs/HEAD" git_logs_HEAD COPYONLY)
|
|
46
|
-
endif()
|
|
47
|
-
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/package.json)
|
|
48
|
-
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/package.json PKG)
|
|
49
|
-
else()
|
|
50
|
-
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/../../package.json PKG)
|
|
51
|
-
endif()
|
|
52
|
-
string(REGEX MATCH "\"version\": \"([^\"]+)\"" XX "${PKG}")
|
|
53
|
-
set(KOFFI_VERSION ${CMAKE_MATCH_1})
|
|
54
|
-
|
|
55
|
-
set_source_files_properties(src/ffi.cc PROPERTIES COMPILE_DEFINITIONS VERSION=${KOFFI_VERSION})
|
|
56
|
-
|
|
57
|
-
add_custom_command(OUTPUT trampolines/gnu.inc
|
|
58
|
-
trampolines/armasm.inc
|
|
59
|
-
trampolines/masm32.inc
|
|
60
|
-
trampolines/masm64.inc
|
|
61
|
-
COMMENT "Generate trampoline macros"
|
|
62
|
-
COMMAND "${NODE_JS_EXECPATH}"
|
|
63
|
-
ARGS "${CMAKE_CURRENT_SOURCE_DIR}/tools/write_trampolines.js" "${CMAKE_CURRENT_BINARY_DIR}/trampolines" 8192
|
|
64
|
-
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/tools/write_trampolines.js")
|
|
65
|
-
|
|
66
|
-
set(KOFFI_SRC
|
|
67
|
-
src/call.cc
|
|
68
|
-
src/ffi.cc
|
|
69
|
-
src/parser.cc
|
|
70
|
-
src/util.cc
|
|
71
|
-
src/uv.cc
|
|
72
|
-
src/win32.cc
|
|
73
|
-
../../lib/native/base/base.cc
|
|
74
|
-
)
|
|
75
|
-
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
|
76
|
-
# CMAKE_SYSTEM_PROCESSOR is wrong on Windows ARM64
|
|
77
|
-
|
|
78
|
-
if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch|arm" OR CMAKE_GENERATOR_PLATFORM STREQUAL "ARM64" OR CMAKE_OSX_ARCHITECTURES MATCHES "arm")
|
|
79
|
-
if(WIN32)
|
|
80
|
-
get_filename_component(cl_dir "${CMAKE_CXX_COMPILER}" DIRECTORY)
|
|
81
|
-
file(TO_CMAKE_PATH "${cl_dir}/armasm64.exe" asm_compiler)
|
|
82
|
-
|
|
83
|
-
# Work around missing ARM64-native ARMASM64 compiler (at least in VS 17.3 Preview 2)
|
|
84
|
-
if(NOT EXISTS "${asm_compiler}")
|
|
85
|
-
file(TO_CMAKE_PATH "${cl_dir}/../../Hostx64/arm64/armasm64.exe" asm_compiler)
|
|
86
|
-
endif()
|
|
87
|
-
|
|
88
|
-
message(STATUS "Using ARMASM64 compiler: ${asm_compiler}")
|
|
89
|
-
|
|
90
|
-
file(TO_CMAKE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/src/abi_arm64_asm.asm" asm_source)
|
|
91
|
-
file(TO_CMAKE_PATH "${CMAKE_CURRENT_BINARY_DIR}/abi_arm64_asm.obj" asm_object)
|
|
92
|
-
|
|
93
|
-
add_custom_command(
|
|
94
|
-
OUTPUT "${asm_object}"
|
|
95
|
-
COMMAND "${asm_compiler}"
|
|
96
|
-
ARGS /nologo /i "${CMAKE_CURRENT_BINARY_DIR}/trampolines" /o "${asm_object}" "${asm_source}"
|
|
97
|
-
DEPENDS "${asm_source}" trampolines/armasm.inc
|
|
98
|
-
COMMENT "Assembling ${asm_source}"
|
|
99
|
-
)
|
|
100
|
-
set_source_files_properties("${asm_object}" PROPERTIES EXTERNAL_OBJECT TRUE)
|
|
101
|
-
|
|
102
|
-
list(APPEND KOFFI_SRC src/abi_arm64.cc "${asm_object}")
|
|
103
|
-
else()
|
|
104
|
-
list(APPEND KOFFI_SRC src/abi_arm64.cc src/abi_arm64_asm.S)
|
|
105
|
-
endif()
|
|
106
|
-
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "riscv")
|
|
107
|
-
list(APPEND KOFFI_SRC src/abi_riscv64.cc src/abi_riscv64_asm.S)
|
|
108
|
-
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "loongarch64")
|
|
109
|
-
list(APPEND KOFFI_SRC src/abi_riscv64.cc src/abi_loong64_asm.S)
|
|
110
|
-
else()
|
|
111
|
-
if(WIN32)
|
|
112
|
-
if(MSVC)
|
|
113
|
-
list(APPEND KOFFI_SRC src/abi_x64_win.cc src/abi_x64_win_asm.asm)
|
|
114
|
-
else()
|
|
115
|
-
list(APPEND KOFFI_SRC src/abi_x64_win.cc src/abi_x64_win_asm.S)
|
|
116
|
-
endif()
|
|
117
|
-
else()
|
|
118
|
-
list(APPEND KOFFI_SRC src/abi_x64_sysv.cc src/abi_x64_sysv_asm.S)
|
|
119
|
-
endif()
|
|
120
|
-
endif()
|
|
121
|
-
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
|
122
|
-
if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch|arm")
|
|
123
|
-
list(APPEND KOFFI_SRC src/abi_arm32.cc src/abi_arm32_asm.S)
|
|
124
|
-
else()
|
|
125
|
-
if(WIN32)
|
|
126
|
-
list(APPEND KOFFI_SRC src/abi_x86.cc src/abi_x86_asm.asm)
|
|
127
|
-
else()
|
|
128
|
-
list(APPEND KOFFI_SRC src/abi_x86.cc src/abi_x86_asm.S)
|
|
129
|
-
endif()
|
|
130
|
-
endif()
|
|
131
|
-
endif()
|
|
132
|
-
|
|
133
|
-
add_node_addon(NAME koffi SOURCES ${KOFFI_SRC} trampolines/gnu.inc)
|
|
134
|
-
target_include_directories(koffi PRIVATE . ../.. ../../vendor/node-addon-api "${CMAKE_CURRENT_BINARY_DIR}/trampolines")
|
|
135
|
-
|
|
136
|
-
if(WIN32)
|
|
137
|
-
set(UV_LINK_LIB "${CMAKE_CURRENT_BINARY_DIR}/uv.lib")
|
|
138
|
-
if(MSVC)
|
|
139
|
-
add_custom_command(OUTPUT uv.lib
|
|
140
|
-
COMMAND ${CMAKE_AR} ${CMAKE_STATIC_LINKER_FLAGS}
|
|
141
|
-
/def:src/uv.def /out:${UV_LINK_LIB}
|
|
142
|
-
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
143
|
-
MAIN_DEPENDENCY src/uv.def)
|
|
144
|
-
else()
|
|
145
|
-
add_custom_command(OUTPUT uv.lib
|
|
146
|
-
COMMAND ${CMAKE_DLLTOOL} -d src/uv.def -l ${UV_LINK_LIB}
|
|
147
|
-
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
148
|
-
MAIN_DEPENDENCY src/uv.def)
|
|
149
|
-
endif()
|
|
150
|
-
target_sources(koffi PRIVATE uv.lib)
|
|
151
|
-
target_link_libraries(koffi PRIVATE ${UV_LINK_LIB})
|
|
152
|
-
endif()
|
|
153
|
-
|
|
154
|
-
target_compile_definitions(koffi PRIVATE FELIX_TARGET=koffi NAPI_DISABLE_CPP_EXCEPTIONS NAPI_VERSION=8 CORE_NO_STATX)
|
|
155
|
-
if(WIN32)
|
|
156
|
-
target_compile_definitions(koffi PRIVATE _CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_DEPRECATE)
|
|
157
|
-
target_link_libraries(koffi PRIVATE ws2_32)
|
|
158
|
-
endif()
|
|
159
|
-
|
|
160
|
-
if(UNIX AND NOT APPLE)
|
|
161
|
-
target_compile_options(koffi PRIVATE -fno-semantic-interposition -fvisibility=hidden -fdata-sections -ffunction-sections)
|
|
162
|
-
target_link_options(koffi PRIVATE -Wl,--gc-sections)
|
|
163
|
-
endif()
|
|
164
|
-
|
|
165
|
-
if(NOT MSVC OR CMAKE_C_COMPILER_ID MATCHES "[Cc]lang")
|
|
166
|
-
# Restore C/C++ compiler sanity
|
|
167
|
-
|
|
168
|
-
if(NOT MSVC)
|
|
169
|
-
target_compile_options(koffi PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions -fno-strict-aliasing -fwrapv
|
|
170
|
-
-fno-delete-null-pointer-checks>)
|
|
171
|
-
else()
|
|
172
|
-
target_compile_options(koffi PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-fno-strict-aliasing /clang:-fwrapv
|
|
173
|
-
-fno-delete-null-pointer-checks>)
|
|
174
|
-
endif()
|
|
175
|
-
|
|
176
|
-
check_cxx_compiler_flag(-fno-finite-loops use_no_finite_loops)
|
|
177
|
-
if(use_no_finite_loops)
|
|
178
|
-
target_compile_options(koffi PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-fno-finite-loops>)
|
|
179
|
-
endif()
|
|
180
|
-
endif()
|
|
181
|
-
|
|
182
|
-
enable_unity_build(koffi EXCLUDE src/uv.cc)
|