cpp.js 1.0.0-beta.31 → 1.0.0-beta.33
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/CHANGELOG.md +7 -0
- package/README.md +3 -1
- package/package.json +1 -1
- package/src/actions/getAllBridges.js +2 -2
- package/src/actions/getDependLibs.js +3 -3
- package/src/actions/run.js +20 -6
- package/src/bin.js +4 -4
- package/src/state/index.js +2 -2
- package/src/state/loadConfig.js +2 -1
- package/src/utils/findFiles.js +5 -0
- package/src/utils/getAbsolutePath.js +1 -1
- package/src/utils/getCMakeListsFilePath.js +3 -3
package/CHANGELOG.md
ADDED
package/README.md
CHANGED
|
@@ -15,8 +15,10 @@
|
|
|
15
15
|
<a href="https://github.com/bugra9/cpp.js/discussions"><img alt="Discussions" src="https://img.shields.io/github/discussions/bugra9/cpp.js?style=for-the-badge" /></a>
|
|
16
16
|
<a href="https://github.com/bugra9/cpp.js/issues"><img alt="Issues" src="https://img.shields.io/github/issues/bugra9/cpp.js?style=for-the-badge" /></a>
|
|
17
17
|
<br />
|
|
18
|
+
<img alt="CodeQL" src="https://img.shields.io/github/actions/workflow/status/bugra9/cpp.js/github-code-scanning/codeql?branch=main&style=for-the-badge&label=CodeQL">
|
|
18
19
|
<img alt="Linux Build" src="https://img.shields.io/github/actions/workflow/status/bugra9/cpp.js/build-linux.yml?branch=main&style=for-the-badge&label=Linux%20Build">
|
|
19
20
|
<img alt="Macos Build" src="https://img.shields.io/github/actions/workflow/status/bugra9/cpp.js/build-macos.yml?branch=main&style=for-the-badge&label=Macos%20Build">
|
|
21
|
+
<img alt="Windows Build" src="https://img.shields.io/github/actions/workflow/status/bugra9/cpp.js/build-windows.yml?branch=main&style=for-the-badge&label=Windows%20Build">
|
|
20
22
|
</div>
|
|
21
23
|
|
|
22
24
|
<h3 align="center">
|
|
@@ -101,4 +103,4 @@ Integrate cpp.js seamlessly into your existing projects using the appropriate pa
|
|
|
101
103
|
## License
|
|
102
104
|
[MIT](https://github.com/bugra9/cpp.js/blob/main/LICENSE)
|
|
103
105
|
|
|
104
|
-
Copyright (c)
|
|
106
|
+
Copyright (c) 2023-2025, Buğra Sarı
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import findFiles from '../utils/findFiles.js';
|
|
2
2
|
import state from '../state/index.js';
|
|
3
3
|
|
|
4
4
|
export default function getAllBridges() {
|
|
5
5
|
return [
|
|
6
|
-
...
|
|
6
|
+
...findFiles(`${state.config.paths.build}/bridge/*.i.cpp`),
|
|
7
7
|
];
|
|
8
8
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import
|
|
1
|
+
import findFiles from '../utils/findFiles.js';
|
|
2
2
|
import state from '../state/index.js';
|
|
3
3
|
|
|
4
4
|
export default function getDependLibs() {
|
|
5
5
|
let dependLibs = [
|
|
6
|
-
...
|
|
6
|
+
...findFiles(`${state.config.paths.build}/Source-Release/Emscripten-x86_64/dependencies/**/*.a`, { cwd: state.config.paths.project }),
|
|
7
7
|
];
|
|
8
8
|
state.config.dependencyParameters.cmakeDepends.forEach((d) => {
|
|
9
9
|
if (d.export.libName) {
|
|
10
10
|
d.export.libName.forEach((fileName) => {
|
|
11
11
|
if (d.platform['Emscripten-x86_64'].ignoreLibName?.includes(fileName)) return;
|
|
12
|
-
dependLibs.push(...
|
|
12
|
+
dependLibs.push(...findFiles(`${d.paths.output}/prebuilt/Emscripten-x86_64/lib/lib${fileName}.a`, { cwd: d.paths.project }));
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
15
|
});
|
package/src/actions/run.js
CHANGED
|
@@ -5,7 +5,8 @@ import getOsUserAndGroupId from '../utils/getOsUserAndGroupId.js';
|
|
|
5
5
|
import { getContentHash } from '../utils/hash.js';
|
|
6
6
|
import state from '../state/index.js';
|
|
7
7
|
|
|
8
|
-
const
|
|
8
|
+
const CROSSCOMPILER_ARM64 = 'aarch64-linux-android33';
|
|
9
|
+
const CROSSCOMPILER_x86_64 = 'x86_64-linux-android33';
|
|
9
10
|
const ANDROID_NDK = '/opt/android-sdk/ndk/25.2.9519653';
|
|
10
11
|
const t = `${ANDROID_NDK}/toolchains/llvm/prebuilt/linux-x86_64/bin`;
|
|
11
12
|
const t2 = `${ANDROID_NDK}/toolchains/llvm/prebuilt/linux-x86_64`;
|
|
@@ -15,11 +16,23 @@ const iosBinPath = `${iOSDevPath}/Toolchains/XcodeDefault.xctoolchain/usr/bin`;
|
|
|
15
16
|
const iosSdkPath = `${iOSDevPath}/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk`;
|
|
16
17
|
const iosSimSdkPath = `${iOSDevPath}/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk`;
|
|
17
18
|
|
|
18
|
-
const
|
|
19
|
+
const androidParamsArm64 = [
|
|
19
20
|
'-e', `AR=${t}/llvm-ar`,
|
|
20
21
|
'-e', `AS=${t}/llvm-as`,
|
|
21
|
-
'-e', `CC=${t}/${
|
|
22
|
-
'-e', `CXX=${t}/${
|
|
22
|
+
'-e', `CC=${t}/${CROSSCOMPILER_ARM64}-clang`,
|
|
23
|
+
'-e', `CXX=${t}/${CROSSCOMPILER_ARM64}-clang++`,
|
|
24
|
+
'-e', `LD=${t}/ld`,
|
|
25
|
+
'-e', `RANLIB=${t}/llvm-ranlib`,
|
|
26
|
+
'-e', `STRIP=${t}/llvm-strip`,
|
|
27
|
+
'-e', `NM=${t}/nm`,
|
|
28
|
+
'-e', `CFLAGS=--sysroot=${t2}/sysroot`,
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
const androidParamsX86_64 = [
|
|
32
|
+
'-e', `AR=${t}/llvm-ar`,
|
|
33
|
+
'-e', `AS=${t}/llvm-as`,
|
|
34
|
+
'-e', `CC=${t}/${CROSSCOMPILER_x86_64}-clang`,
|
|
35
|
+
'-e', `CXX=${t}/${CROSSCOMPILER_x86_64}-clang++`,
|
|
23
36
|
'-e', `LD=${t}/ld`,
|
|
24
37
|
'-e', `RANLIB=${t}/llvm-ranlib`,
|
|
25
38
|
'-e', `STRIP=${t}/llvm-strip`,
|
|
@@ -91,11 +104,12 @@ export default function run(program, params = [], platformPrefix = null, platfor
|
|
|
91
104
|
break;
|
|
92
105
|
case 'Android':
|
|
93
106
|
[dProgram, ...dParams] = params;
|
|
94
|
-
platformParams =
|
|
107
|
+
platformParams = arch[0] === 'x86_64' ? androidParamsX86_64 : androidParamsArm64;
|
|
95
108
|
if (dProgram === 'cmake') {
|
|
96
109
|
dParams = [
|
|
97
110
|
...dParams,
|
|
98
|
-
'-DCMAKE_SYSTEM_NAME=Android', '-DCMAKE_SYSTEM_VERSION=33',
|
|
111
|
+
'-DCMAKE_SYSTEM_NAME=Android', '-DCMAKE_SYSTEM_VERSION=33',
|
|
112
|
+
`-DCMAKE_ANDROID_ARCH_ABI=${arch[0] === 'x86_64' ? 'x86_64' : 'arm64-v8a'}`,
|
|
99
113
|
`-DCMAKE_ANDROID_NDK=${ANDROID_NDK}`,
|
|
100
114
|
];
|
|
101
115
|
}
|
package/src/bin.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
import fs from 'node:fs';
|
|
4
4
|
import { execFileSync } from 'node:child_process';
|
|
5
5
|
import { Command, Option } from 'commander';
|
|
6
|
-
import { glob } from 'glob';
|
|
7
6
|
import replace from 'replace';
|
|
8
7
|
|
|
9
8
|
import { state } from './index.js';
|
|
@@ -18,6 +17,7 @@ import systemKeys from './utils/systemKeys.js';
|
|
|
18
17
|
|
|
19
18
|
import { getDockerImage } from './utils/pullDockerImage.js';
|
|
20
19
|
import { getContentHash } from './utils/hash.js';
|
|
20
|
+
import findFiles from './utils/findFiles.js';
|
|
21
21
|
|
|
22
22
|
const packageJSON = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url)));
|
|
23
23
|
|
|
@@ -262,8 +262,8 @@ function buildLib(platform) {
|
|
|
262
262
|
|
|
263
263
|
const modules = [];
|
|
264
264
|
state.config.paths.module.forEach((modulePath) => {
|
|
265
|
-
modules.push(...
|
|
266
|
-
modules.push(...
|
|
265
|
+
modules.push(...findFiles('**/*.i', { cwd: modulePath }));
|
|
266
|
+
modules.push(...findFiles('*.i', { cwd: modulePath }));
|
|
267
267
|
});
|
|
268
268
|
if (modules.length > 0) {
|
|
269
269
|
fs.mkdirSync(`${state.config.paths.output}/prebuilt/${p}/swig`, { recursive: true });
|
|
@@ -289,7 +289,7 @@ function buildLib(platform) {
|
|
|
289
289
|
async function createWasmJs() {
|
|
290
290
|
let headers = [];
|
|
291
291
|
state.config.paths.header.forEach((headerPath) => {
|
|
292
|
-
headers.push(
|
|
292
|
+
headers.push(findFiles('**/*.h', { cwd: headerPath }));
|
|
293
293
|
});
|
|
294
294
|
headers = headers.filter((path) => !!path.toString()).flat();
|
|
295
295
|
|
package/src/state/index.js
CHANGED
|
@@ -6,9 +6,9 @@ const cacheDir = `${process.cwd()}/.cppjs`;
|
|
|
6
6
|
|
|
7
7
|
const state = {
|
|
8
8
|
platforms: {
|
|
9
|
-
All: ['Emscripten-x86_64', 'Android-arm64-v8a', 'iOS-iphoneos', 'iOS-iphonesimulator'],
|
|
9
|
+
All: ['Emscripten-x86_64', 'Android-arm64-v8a', 'Android-x86_64', 'iOS-iphoneos', 'iOS-iphonesimulator'],
|
|
10
10
|
WebAssembly: ['Emscripten-x86_64'],
|
|
11
|
-
Android: ['Android-arm64-v8a'],
|
|
11
|
+
Android: ['Android-arm64-v8a', 'Android-x86_64'],
|
|
12
12
|
iOS: ['iOS-iphoneos', 'iOS-iphonesimulator'],
|
|
13
13
|
},
|
|
14
14
|
config: null,
|
package/src/state/loadConfig.js
CHANGED
|
@@ -64,7 +64,7 @@ function getFilledConfig(config, options = { isDepend: false }) {
|
|
|
64
64
|
newConfig.paths.bridge = (newConfig.paths.bridge || [...newConfig.paths.native, newConfig.paths.build])
|
|
65
65
|
.map((p) => getPath(p));
|
|
66
66
|
newConfig.paths.output = getPath(newConfig.paths.output) || newConfig.paths.build;
|
|
67
|
-
newConfig.paths.cmake = options.isDepend ? getCMakeListsFilePath(newConfig.paths.output) : (
|
|
67
|
+
newConfig.paths.cmake = options.isDepend ? getPath(getCMakeListsFilePath(newConfig.paths.output)) : (
|
|
68
68
|
getPath(newConfig.paths.cmake || getCMakeListsFilePath(newConfig.paths.project))
|
|
69
69
|
);
|
|
70
70
|
newConfig.paths.cmakeDir = getParentPath(newConfig.paths.cmake);
|
|
@@ -85,6 +85,7 @@ function getFilledConfig(config, options = { isDepend: false }) {
|
|
|
85
85
|
newConfig.platform['Emscripten-x86_64-browser'] = newConfig.platform['Emscripten-x86_64-browser'] || {};
|
|
86
86
|
newConfig.platform['Emscripten-x86_64-node'] = newConfig.platform['Emscripten-x86_64-node'] || {};
|
|
87
87
|
newConfig.platform['Android-arm64-v8a'] = newConfig.platform['Android-arm64-v8a'] || {};
|
|
88
|
+
newConfig.platform['Android-x86_64'] = newConfig.platform['Android-x86_64'] || {};
|
|
88
89
|
newConfig.platform['iOS-iphoneos'] = newConfig.platform['iOS-iphoneos'] || {};
|
|
89
90
|
newConfig.platform['iOS-iphonesimulator'] = newConfig.platform['iOS-iphonesimulator'] || {};
|
|
90
91
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { glob } from 'glob';
|
|
2
1
|
import getParentPath from './getParentPath.js';
|
|
2
|
+
import findFiles from './findFiles.js';
|
|
3
3
|
|
|
4
4
|
export default function getCMakeListsFilePath(basePath = process.cwd()) {
|
|
5
|
-
let temp =
|
|
5
|
+
let temp = findFiles('CMakeLists.txt', { cwd: basePath });
|
|
6
6
|
if (temp.length === 0) {
|
|
7
|
-
temp =
|
|
7
|
+
temp = findFiles('*/CMakeLists.txt', { cwd: basePath, ignore: ['node_modules/*', 'dist/*', 'build/*'] });
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
if (temp.length > 0) return temp[0];
|