Skip to content

Commit c67143d

Browse files
authored
Merge pull request #32 from NativeScript/v8-update
Update V8 to 13.8.9
2 parents b46e809 + 8a9bc01 commit c67143d

File tree

914 files changed

+139764
-101
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

914 files changed

+139764
-101
lines changed

README.md

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -68,34 +68,18 @@ Clone the repo:
6868
git clone https://github.com/NativeScript/napi-android.git
6969
```
7070

71-
Install the jsparser dependencies:
72-
73-
```Shell
74-
cd test-app/build-tools/jsparser
75-
npm install
76-
```
77-
7871
Set the following environment variables:
7972

8073
- `JAVA_HOME` such that `$JAVA_HOME/bin/java` points to your Java executable
8174
- `ANDROID_HOME` pointing to where you have installed the Android SDK
8275
- `ANDROID_NDK_HOME` pointing to the version of the Android NDK needed for this version of NativeScript
8376

84-
Run command
85-
86-
Windows:
77+
Run the following command to build the runtime:
8778

88-
```Shell
89-
gradlew -Pengine=V8
9079
```
91-
92-
Mac/Linux:
93-
94-
```Shell
95-
./gradlew -Pengine=V8
80+
npm run build
9681
```
97-
98-
You can pass in `QUICKJS`, `HERMES`, `JSC` or `V8` to compile the runtime with the respective JS engine.
82+
The command will let you interactively choose the JS engine you want to build with. i.e V8, QuickJS, Hermes or JSC, PrimJS, Static Hermes.
9983

10084
- The build process includes building of the runtime package (both optimized and with unstripped v8 symbol table), as well as all supplementary tools used for the android builds: metadata-generator, binding-generator, metadata-generator, static-binding-generator
10185
- The result of the build will be in the dist\_[engine] folder. For example if you are building with V8, the result will be in the dist_v8 folder.

build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def pVersion = "no package version was provided by build.gradle build"
3333
def arVersion = "no commit sha was provided by build.gradle build"
3434
def generateRegularRuntimePackage = !project.hasProperty("skipUnoptimized")
3535

36-
def jsEngine = engine ?: 'v8'
36+
def jsEngine = engine ?: 'V8-10'
3737

3838
def DIST_PATH = "$rootDir/dist_${jsEngine.toLowerCase()}"
3939
def TEST_APP_PATH = "$rootDir/test-app"
@@ -409,6 +409,7 @@ task createNpmPackage(type: Exec) {
409409
generateSbgJar.dependsOn(generateDtsgJar)
410410
generateSbgJar.dependsOn(jsParserNPMInstall)
411411
generateMdgJar.dependsOn(generateSbgJar)
412+
buildJsParser.dependsOn(jsParserNPMInstall)
412413
createDistDir.dependsOn(generateMdgJar)
413414

414415
getPackageVersion.dependsOn(createDistDir)

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
},
2727
"scripts": {
2828
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
29-
"version": "npm run changelog && git add CHANGELOG.md"
29+
"version": "npm run changelog && git add CHANGELOG.md",
30+
"build": "node ./scripts/build.js"
3031
},
3132
"devDependencies": {
3233
"conventional-changelog-cli": "^2.1.1",

scripts/build.js

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
#!/usr/bin/env node
2+
// Simple build helper for NativeScript Android runtime.
3+
// Supports interactive prompts or direct CLI flags.
4+
// See README in the repo for Gradle usage.
5+
6+
const { spawn } = require('child_process');
7+
const path = require('path');
8+
const readline = require('readline');
9+
10+
const VALID_ENGINES = ['V8-10',"V8-11","V8-13", 'QUICKJS', 'HERMES', 'JSC', 'SHERMES', 'PRIMJS'];
11+
const HOST_OBJECTS_SUPPORTED = new Set(['V8-10','V8-11',"V8-13", 'QUICKJS', 'PRIMJS']);
12+
13+
function parseArgs(argv) {
14+
const opts = {};
15+
argv.forEach(arg => {
16+
if (!arg.startsWith('--')) return;
17+
const eq = arg.indexOf('=');
18+
if (eq !== -1) {
19+
const k = arg.slice(2, eq);
20+
const v = arg.slice(eq + 1);
21+
opts[k] = v;
22+
} else {
23+
const k = arg.slice(2);
24+
// flag -> boolean true
25+
opts[k] = true;
26+
}
27+
});
28+
return opts;
29+
}
30+
31+
async function prompt(question, rl, defaultVal) {
32+
return new Promise(resolve => {
33+
const q = defaultVal ? `${question} (${defaultVal}) ` : `${question} `;
34+
rl.question(q, ans => {
35+
if (!ans && typeof defaultVal !== 'undefined') return resolve(defaultVal);
36+
resolve(ans);
37+
});
38+
});
39+
}
40+
41+
async function interactiveFill(opts) {
42+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
43+
try {
44+
// If skip-all-args is given, only ask for engine and host-objects (when supported).
45+
if (opts['skip-all-args']) {
46+
if (!opts.engine) {
47+
console.log('Select JS engine:');
48+
VALID_ENGINES.forEach((e, i) => console.log(` ${i + 1}) ${e}`));
49+
const ans = await prompt('Choose number or name', rl, 'V8-10');
50+
const pick = /^\d+$/.test(ans) ? VALID_ENGINES[Number(ans) - 1] : ans;
51+
opts.engine = VALID_ENGINES.includes(pick) ? pick : 'V8-10';
52+
}
53+
54+
// Only prompt for host objects if the chosen engine supports it
55+
if (HOST_OBJECTS_SUPPORTED.has(opts.engine)) {
56+
if (typeof opts['use-host-objects'] === 'undefined') {
57+
const ans = await prompt('Use host objects? [y/N]', rl, 'N');
58+
if (/^y(es)?$/i.test(ans)) opts['use-host-objects'] = true;
59+
}
60+
} else {
61+
// ensure the flag is not set for unsupported engines
62+
if (opts['use-host-objects']) {
63+
console.log(`Warning: host objects not supported for engine ${opts.engine}; ignoring --use-host-objects`);
64+
delete opts['use-host-objects'];
65+
}
66+
}
67+
68+
return opts;
69+
}
70+
71+
// original interactive flow (unchanged) when not skipping all args
72+
if (!opts.engine) {
73+
console.log('Select JS engine:');
74+
VALID_ENGINES.forEach((e, i) => console.log(` ${i + 1}) ${e}`));
75+
const ans = await prompt('Choose number or name', rl, 'V8');
76+
const pick = /^\d+$/.test(ans) ? VALID_ENGINES[Number(ans) - 1] : ans;
77+
opts.engine = VALID_ENGINES.includes(pick) ? pick : 'V8';
78+
}
79+
80+
const booleanPrompts = [
81+
{ key: 'use-host-objects', prop: 'useHostObjects', desc: 'Use host objects (useHostObjects)' },
82+
];
83+
84+
for (const p of booleanPrompts) {
85+
// skip host-objects prompt if the selected engine does not support it
86+
if (p.key === 'use-host-objects' && !HOST_OBJECTS_SUPPORTED.has(opts.engine)) {
87+
if (opts['use-host-objects']) {
88+
console.log(`Warning: host objects not supported for engine ${opts.engine}; ignoring --use-host-objects`);
89+
delete opts['use-host-objects'];
90+
}
91+
continue;
92+
}
93+
94+
if (typeof opts[p.key] === 'undefined') {
95+
const ans = await prompt(`${p.desc}? [y/N]`, rl, 'N');
96+
if (/^y(es)?$/i.test(ans)) opts[p.key] = true;
97+
}
98+
}
99+
100+
} finally {
101+
rl.close();
102+
}
103+
104+
return opts;
105+
}
106+
107+
function buildGradleArgs(opts) {
108+
const props = [];
109+
if (opts.engine) props.push(`-Pengine=${opts.engine}`);
110+
if (opts['use-host-objects']) props.push('-PuseHostObjects');
111+
if (opts['as-napi-module']) props.push('-PasNapiModule');
112+
113+
return props;
114+
}
115+
116+
async function main() {
117+
const initial = parseArgs(process.argv.slice(2));
118+
const opts = await interactiveFill(initial);
119+
120+
const gradleProps = buildGradleArgs(opts);
121+
const gradlew = process.platform === 'win32' ? 'gradlew' : './gradlew';
122+
const gradleCmd = [gradlew].concat(gradleProps, []);
123+
124+
console.log('\nGradle command:');
125+
console.log(gradleCmd.join(' '), '\n');
126+
127+
if (opts['dry-run']) {
128+
console.log('Dry run requested. Exiting without executing gradle.');
129+
return;
130+
}
131+
132+
const proc = spawn(gradleCmd[0], gradleCmd.slice(1), { stdio: 'inherit', cwd: process.cwd(), shell: false });
133+
134+
proc.on('exit', code => {
135+
if (code === 0) {
136+
console.log('\nBuild finished successfully.');
137+
} else {
138+
console.error(`\nBuild failed with exit code ${code}.`);
139+
}
140+
process.exit(code);
141+
});
142+
143+
proc.on("message", (message) => {
144+
console.log(message);
145+
})
146+
147+
proc.on('error', err => {
148+
console.error('Failed to start gradle:', err.message || err);
149+
process.exit(1);
150+
});
151+
}
152+
153+
main().catch(err => {
154+
console.error('Error:', err && err.message ? err.message : err);
155+
process.exit(1);
156+
});

test-app/app/src/main/assets/app/MyActivity.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,8 @@ var MyActivity = (function (_super) {
2929
MyActivity.prototype.onCreate = function (bundle) {
3030
_super.prototype.onCreate.call(this, bundle);
3131
require('./tests/testsWithContext').run(this);
32-
3332
//run jasmine
3433
execute();
35-
3634
var layout = new android.widget.LinearLayout(this);
3735
layout.setOrientation(1);
3836
this.setContentView(layout);

test-app/app/src/main/assets/app/mainpage.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ require("./tests/kotlin/properties/testPropertiesSupport.js");
7171
require('./tests/testNativeTimers');
7272
require("./tests/testPostFrameCallback");
7373
require("./tests/console/logTests.js");
74-
//require('./tests/testURLImpl.js');
75-
//require('./tests/testURLSearchParamsImpl.js');
74+
require('./tests/testURLImpl.js');
75+
require('./tests/testURLSearchParamsImpl.js');
7676

7777

test-app/app/src/main/assets/internal/ts_helpers.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
if (Parent.__isPrototypeImplementationObject) {
6464
throw new Error("Can not extend an already extended native object.");
6565
}
66-
66+
6767
function extend(thiz) {
6868
var child = thiz.__proto__.__child;
6969
if (!child.__extended) {
@@ -204,7 +204,7 @@
204204
}
205205

206206
global.setNativeArrayProp = (target, prop, value, receiver) => {
207-
if (typeof prop !== "symbol" && !isNaN(prop)) {
207+
if (typeof prop !== "symbol" && !isNaN(prop)) {
208208
receiver.setValueAtIndex(parseInt(prop), value);
209209
return true;
210210
}
@@ -218,7 +218,7 @@
218218
}
219219

220220
if (prop === Symbol.iterator) {
221-
let index = 0;
221+
var index = 0;
222222
const l = target.length;
223223
return function () {
224224
return {
@@ -240,7 +240,7 @@
240240
const values = receiver.getAllValues();
241241
const result = [];
242242
const l = target.length;
243-
for (let i = 0; i < l; i++) {
243+
for (var i = 0; i < l; i++) {
244244
result.push(callback(values[i], i, target));
245245
}
246246
return result;
@@ -258,7 +258,7 @@
258258
return function (callback) {
259259
const values = receiver.getAllValues();
260260
const l = values.length;
261-
for (let i = 0; i < l; i++) {
261+
for (var i = 0; i < l; i++) {
262262
callback(values[i], i, target);
263263
}
264264
};
@@ -351,7 +351,7 @@
351351
URL.revokeObjectURL = function (url) {
352352
BLOB_STORE.delete(url);
353353
};
354-
const InternalAccessor = class {};
354+
function InternalAccessor() {}
355355
InternalAccessor.getData = function (url) {
356356
return BLOB_STORE.get(url);
357357
};

test-app/gradle.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
#Thu, 30 Oct 2025 19:35:13 +0500
1+
#Thu, 30 Oct 2025 18:27:02 +0500
2+
23
# Project-wide Gradle settings.
34

45
# IDE (e.g. Android Studio) users:

0 commit comments

Comments
 (0)