cpp.js 0.4.0 → 0.4.1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cpp.js",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,6 +1,6 @@
1
1
  import glob from 'glob';
2
2
  import { execFileSync } from 'child_process';
3
- import pullDockerImage from '../utils/pullDockerImage.js';
3
+ import pullDockerImage, { getDockerImage } from '../utils/pullDockerImage.js';
4
4
  import getBaseInfo from '../utils/getBaseInfo.js';
5
5
  import getPathInfo from '../utils/getPathInfo.js';
6
6
  import getOsUserAndGroupId from '../utils/getOsUserAndGroupId.js';
@@ -23,7 +23,7 @@ export default function createBridge(compiler) {
23
23
 
24
24
  const options = { cwd: output.absolute, stdio : 'pipe' };
25
25
  const args = [
26
- "run", "--user", getOsUserAndGroupId(), "-v", `${base.withoutSlash}:/live`, "bugra9/cpp.js",
26
+ "run", "--user", getOsUserAndGroupId(), "-v", `${base.withoutSlash}:/live`, getDockerImage(),
27
27
  "swig", "-c++", '-emscripten', '-o', `/live/${output.relative}/${filePath.split('/').at(-1)}.cpp`, ...includePath, `/live/${input.relative}`
28
28
  ];
29
29
  execFileSync("docker", args, options);
@@ -1,6 +1,6 @@
1
1
  import { execFileSync } from 'child_process';
2
2
  import glob from 'glob';
3
- import pullDockerImage from '../utils/pullDockerImage.js';
3
+ import pullDockerImage, { getDockerImage } from '../utils/pullDockerImage.js';
4
4
  import getBaseInfo from '../utils/getBaseInfo.js';
5
5
  import getPathInfo from '../utils/getPathInfo.js';
6
6
  import getOsUserAndGroupId from '../utils/getOsUserAndGroupId.js';
@@ -54,7 +54,7 @@ class CppjsCompiler {
54
54
  cMakeParentPath.pop();
55
55
  cMakeParentPath = cMakeParentPath.join('/');
56
56
  const args = [
57
- "run", "--user", getOsUserAndGroupId(), "-v", `${base.withoutSlash}:/live`, "-v", `${cMakeParentPath}:/cmake`, "--workdir", `/live/${output.relative}`, "bugra9/cpp.js",
57
+ "run", "--user", getOsUserAndGroupId(), "-v", `${base.withoutSlash}:/live`, "-v", `${cMakeParentPath}:/cmake`, "--workdir", `/live/${output.relative}`, getDockerImage(),
58
58
  "emcmake", "cmake", "/cmake", '-DCMAKE_BUILD_TYPE=Release',
59
59
  `-DBASE_DIR=/live/${projectPath.relative}`,
60
60
  `-DNATIVE_GLOB=${this.config.ext.source.map(ext => `${native}/*.${ext}`).join(';')}`,
@@ -75,7 +75,7 @@ class CppjsCompiler {
75
75
  cMakeParentPath.pop();
76
76
  cMakeParentPath = cMakeParentPath.join('/');
77
77
  const args = [
78
- "run", "--user", getOsUserAndGroupId(), "-v", `${base.withoutSlash}:/live`, "-v", `${cMakeParentPath}:/cmake`, "--workdir", `/live/${output.relative}`, "bugra9/cpp.js",
78
+ "run", "--user", getOsUserAndGroupId(), "-v", `${base.withoutSlash}:/live`, "-v", `${cMakeParentPath}:/cmake`, "--workdir", `/live/${output.relative}`, getDockerImage(),
79
79
  "emmake", "make", "install"
80
80
  ];
81
81
  const options = { cwd: this.config.paths.temp, stdio : 'pipe' };
@@ -88,7 +88,7 @@ class CppjsCompiler {
88
88
  const output = getPathInfo(this.config.paths.temp, this.config.paths.base);
89
89
  const base = getBaseInfo(this.config.paths.base);
90
90
  const args = [
91
- "run", "--user", getOsUserAndGroupId(), "-v", `${base.withoutSlash}:/live`, "-v", `${this.config.paths.cli}:/cli`, "bugra9/cpp.js",
91
+ "run", "--user", getOsUserAndGroupId(), "-v", `${base.withoutSlash}:/live`, "-v", `${this.config.paths.cli}:/cli`, getDockerImage(),
92
92
  "emcc", "-lembind", "-Wl,--whole-archive", ...this.libs, ...(this.options.cc || []), "-s", "WASM=1", "-s", "MODULARIZE=1", '-o', `/live/${output.relative}/${this.config.general.name}.js`, '--extern-post-js', '/cli/assets/extern-post.js'
93
93
  ];
94
94
  const options = { cwd: this.config.paths.temp, stdio : 'pipe' };
@@ -1,7 +1,7 @@
1
1
  import { execFileSync } from 'child_process';
2
2
 
3
3
  export default function pullDockerImage() {
4
- const isImageExist = execFileSync("docker", ["images", "-q", "bugra9/cpp.js:0.2.0"], {encoding: 'utf-8'}).trim() !== '';
4
+ const isImageExist = execFileSync("docker", ["images", "-q", getDockerImage()], {encoding: 'utf-8'}).trim() !== '';
5
5
 
6
6
  if (!isImageExist) {
7
7
  console.log('');
@@ -9,9 +9,13 @@ export default function pullDockerImage() {
9
9
  console.log('============= Downloading the docker image... =============');
10
10
  console.log('===========================================================');
11
11
  console.log('');
12
- execFileSync("docker", ["pull", "bugra9/cpp.js"], {stdio: 'inherit'});
12
+ execFileSync("docker", ["pull", getDockerImage], {stdio: 'inherit'});
13
13
  console.log('');
14
14
  console.log('===========================================================');
15
15
  console.log('');
16
16
  }
17
17
  }
18
+
19
+ export function getDockerImage() {
20
+ return "bugra9/cpp.js:0.2.0";
21
+ }