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 ADDED
@@ -0,0 +1,7 @@
1
+ # cpp.js
2
+
3
+ ## 1.0.0-beta.33
4
+
5
+ ### Patch Changes
6
+
7
+ - chore: add initial version of CHANGELOGS files
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) 2024, Buğra Sarı
106
+ Copyright (c) 2023-2025, Buğra Sarı
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cpp.js",
3
- "version": "1.0.0-beta.31",
3
+ "version": "1.0.0-beta.33",
4
4
  "license": "MIT",
5
5
  "homepage": "https://cpp.js.org",
6
6
  "repository": "https://github.com/bugra9/cpp.js.git",
@@ -1,8 +1,8 @@
1
- import { glob } from 'glob';
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
- ...glob.sync(`${state.config.paths.build}/bridge/*.i.cpp`, { absolute: true }),
6
+ ...findFiles(`${state.config.paths.build}/bridge/*.i.cpp`),
7
7
  ];
8
8
  }
@@ -1,15 +1,15 @@
1
- import { glob } from 'glob';
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
- ...glob.sync(`${state.config.paths.build}/Source-Release/Emscripten-x86_64/dependencies/**/*.a`, { absolute: true, cwd: state.config.paths.project }),
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(...glob.sync(`${d.paths.output}/prebuilt/Emscripten-x86_64/lib/lib${fileName}.a`, { absolute: true, cwd: d.paths.project }));
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
  });
@@ -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 CROSSCOMPILER = 'aarch64-linux-android33';
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 androidParams = [
19
+ const androidParamsArm64 = [
19
20
  '-e', `AR=${t}/llvm-ar`,
20
21
  '-e', `AS=${t}/llvm-as`,
21
- '-e', `CC=${t}/${CROSSCOMPILER}-clang`,
22
- '-e', `CXX=${t}/${CROSSCOMPILER}-clang++`,
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 = androidParams;
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', '-DCMAKE_ANDROID_ARCH_ABI=arm64-v8a',
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(...glob.sync('**/*.i', { absolute: true, cwd: modulePath }));
266
- modules.push(...glob.sync('*.i', { absolute: true, cwd: modulePath }));
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(glob.sync('**/*.h', { absolute: true, cwd: headerPath }));
292
+ headers.push(findFiles('**/*.h', { cwd: headerPath }));
293
293
  });
294
294
  headers = headers.filter((path) => !!path.toString()).flat();
295
295
 
@@ -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,
@@ -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
 
@@ -0,0 +1,5 @@
1
+ import { glob } from 'glob';
2
+
3
+ export default function findFiles(regex, options = {}) {
4
+ return glob.sync(regex, { absolute: true, posix: true, ...options }).map(p => p.replace('//?/', ''));
5
+ }
@@ -5,7 +5,7 @@ export default function getAbsolutePath(projectPath, path) {
5
5
  return null;
6
6
  }
7
7
  if (upath.isAbsolute(path)) {
8
- return path;
8
+ return upath.resolve(path);
9
9
  }
10
10
  if (projectPath) {
11
11
  return upath.resolve(upath.join(upath.resolve(projectPath), path));
@@ -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 = glob.sync('CMakeLists.txt', { absolute: true, cwd: basePath });
5
+ let temp = findFiles('CMakeLists.txt', { cwd: basePath });
6
6
  if (temp.length === 0) {
7
- temp = glob.sync('*/CMakeLists.txt', { absolute: true, cwd: basePath, ignore: ['node_modules/*', 'dist/*', 'build/*'] });
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];