Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

Commit 7c2dd61

Browse files
committed
feat(snapshot): The parameters passed to mksnapshot are now retrieved from the runtime
1 parent 6a9ce33 commit 7c2dd61

File tree

4 files changed

+29
-4
lines changed

4 files changed

+29
-4
lines changed

Diff for: androidProjectHelpers.js

+14
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,19 @@ const getAndroidV8Version = (projectDir) => {
3434
}
3535
}
3636

37+
const getMksnapshotParams = (projectDir) => {
38+
try {
39+
const androidSettingsJSON = getAndroidSettingsJson(projectDir);
40+
if (androidSettingsJSON !== null) {
41+
return androidSettingsJSON.mksnapshotParams;
42+
} else {
43+
return null;
44+
}
45+
} catch (e) {
46+
return null;
47+
}
48+
};
49+
3750
const getAndroidSettingsJson = projectDir => {
3851
const androidSettingsJsonPath = resolve(projectDir, PLATFORMS_ANDROID, "settings.json");
3952
if (existsSync(androidSettingsJsonPath)) {
@@ -49,4 +62,5 @@ module.exports = {
4962
ANDROID_CONFIGURATIONS_PATH,
5063
getAndroidRuntimeVersion,
5164
getAndroidV8Version,
65+
getMksnapshotParams
5266
};

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nativescript-dev-webpack",
3-
"version": "0.19.2",
3+
"version": "0.19.3",
44
"main": "index",
55
"description": "",
66
"homepage": "http://www.telerik.com",

Diff for: snapshot/android/project-snapshot-generator.js

+5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const {
1717
ANDROID_CONFIGURATIONS_PATH,
1818
getAndroidRuntimeVersion,
1919
getAndroidV8Version,
20+
getMksnapshotParams
2021
} = require("../../androidProjectHelpers");
2122

2223
const MIN_ANDROID_RUNTIME_VERSION = "3.0.0";
@@ -227,6 +228,9 @@ ProjectSnapshotGenerator.prototype.generate = function (generationOptions) {
227228

228229
const noV8VersionFoundMessage = `Cannot find suitable v8 version!`;
229230
let shouldRethrow = false;
231+
232+
const mksnapshotParams = getMksnapshotParams(this.options.projectRoot);
233+
230234
return this.getV8Version(generationOptions).then(v8Version => {
231235
shouldRethrow = true;
232236
if (!v8Version) {
@@ -241,6 +245,7 @@ ProjectSnapshotGenerator.prototype.generate = function (generationOptions) {
241245
useLibs: generationOptions.useLibs || false,
242246
inputFiles: generationOptions.inputFiles || [join(this.options.projectRoot, "__snapshot.js")],
243247
androidNdkPath,
248+
mksnapshotParams: mksnapshotParams
244249
};
245250

246251
return generator.generate(options).then(() => {

Diff for: snapshot/android/snapshot-generator.js

+9-3
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ SnapshotGenerator.prototype.convertToAndroidArchName = function(archName) {
8080
}
8181
}
8282

83-
SnapshotGenerator.prototype.runMksnapshotTool = function(snapshotToolsPath, inputFile, v8Version, targetArchs, buildCSource) {
83+
SnapshotGenerator.prototype.runMksnapshotTool = function(snapshotToolsPath, inputFile, v8Version, targetArchs, buildCSource, mksnapshotParams) {
8484
// Cleans the snapshot build folder
8585
shelljs.rm("-rf", join(this.buildPath, "snapshots"));
8686

@@ -98,7 +98,12 @@ SnapshotGenerator.prototype.runMksnapshotTool = function(snapshotToolsPath, inpu
9898
// Generate .blob file
9999
const currentArchBlobOutputPath = join(this.buildPath, "snapshots/blobs", androidArch);
100100
shelljs.mkdir("-p", currentArchBlobOutputPath);
101-
const command = `${currentArchMksnapshotToolPath} ${inputFile} --startup_blob ${join(currentArchBlobOutputPath, `${SNAPSHOT_BLOB_NAME}.blob`)} --profile_deserialization`;
101+
var params = "--profile_deserialization";
102+
if (mksnapshotParams) {
103+
// Starting from android runtime 5.3.0, the parameters passed to mksnapshot are read from the settings.json file
104+
params = mksnapshotParams;
105+
}
106+
const command = `${currentArchMksnapshotToolPath} ${inputFile} --startup_blob ${join(currentArchBlobOutputPath, `${SNAPSHOT_BLOB_NAME}.blob`)} ${params}`;
102107

103108
return new Promise((resolve, reject) => {
104109
const child = child_process.exec(command, {encoding: "utf8"}, (error, stdout, stderr) => {
@@ -167,7 +172,8 @@ SnapshotGenerator.prototype.generate = function(options) {
167172
preprocessedInputFile,
168173
options.v8Version,
169174
options.targetArchs,
170-
options.useLibs
175+
options.useLibs,
176+
options.mksnapshotParams
171177
).then(() => {
172178
this.buildIncludeGradle();
173179
if (options.useLibs) {

0 commit comments

Comments
 (0)