Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

Buhov/local snapshot improvements #194

Merged
ivanbuhov merged 6 commits into master from buhov/local-snapshot-improvements
Jun 20, 2017

Conversation

Copy link
Contributor

@ivanbuhov ivanbuhov commented Jun 19, 2017
edited
Loading

  1. mksnapshot tools are now downloaded on demand before running them
  2. Introduce __snapshot and __snapshotEnabled global variables:
    __snapshotEnabled -> has a value of true if snapshot is loaded in the app
    __snapshot -> has a value of true when the executed code is in snapshot context and false when the code is executed on device/emulator
  3. Clean platforms/android/build folder on snapshot generation in order to trigger full rebuild of the .apk files
  4. Install include.gradle file even when blobs are used in order to exclude the snapshotted file from the apk.
  5. Respect ANDROID_NDK_HOME env variable in case androidNdkPath is not specified

this.generateTnsJavaClassesFile({ output: tnsJavaClassesDestination, options: generationOptions.tnsJavaClassesOptions });
}

var snapshotToolsPath = generationOptions.snapshotToolsPath ?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: let's make it an arrow func instead of using ternary operator 2 times

ivanbuhov reacted with thumbs up emoji
const generator = new SnapshotGenerator({ buildPath: this.getBuildPath() });
const generatorBuildPath = generator.generate({
return generator.generate({
snapshotToolsPath: snapshotToolsPath,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: just snapshotToolsPath is more readable

ivanbuhov reacted with thumbs up emoji
options: options.tnsJavaClassesOptions
});

// Run the snapshot tool when the packing is done
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: update the comment, too, or remove it

ivanbuhov reacted with thumbs up emoji
}
module.exports = SnapshotGenerator;

SnapshotGenerator.MKSNAPSHOT_TOOLS_PATH = path.join(__dirname, "snapshot-generator-tools/mksnapshot");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style suggestion:

const { join, dirname } = require("path");
...
const getAbsolutePath = path => join(__dirname, path);

Copy link
Contributor Author

@ivanbuhov ivanbuhov Jun 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you think we need getAbsolutePath function? It is as verbose as using join(__dirname, path) but I find join(__dirname, path) to be more clear.

}

SnapshotGenerator.prototype.getMksnapshotToolsDirOrThrow = function(v8Version) {
var snapshotToolsDownloads = {};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const

ivanbuhov reacted with thumbs up emoji
});
}

var downloadUrl = "https://raw.githubusercontent.com/NativeScript/mksnapshot-tools/production/" + mksnapshotToolRelativePath;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const and maybe we should extract the url to some global var

ivanbuhov reacted with thumbs up emoji
throw new Error("Can't find mksnapshot tool for " + arch + " at path " + currentArchMksnapshotToolPath);
}

var androidArch = this.convertToAndroidArchName(arch);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const

ivanbuhov reacted with thumbs up emoji
var currentArchBlobOutputPath = path.join(this.buildPath, "snapshots/blobs", androidArch);
shelljs.mkdir("-p", currentArchBlobOutputPath);
var stdErrorStream = fs.openSync(mksnapshotStdErrPath, 'w');
child_process.execSync(currentArchMksnapshotToolPath + " " + inputFile + " --startup_blob " + path.join(currentArchBlobOutputPath, "TNSSnapshot.blob") + " --profile_deserialization", {encoding: "utf8", stdio: [process.stdin, process.stdout, stdErrorStream]});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extract the command

ivanbuhov reacted with thumbs up emoji
var currentArchBlobOutputPath = path.join(this.buildPath, "snapshots/blobs", androidArch);
shelljs.mkdir("-p", currentArchBlobOutputPath);
var stdErrorStream = fs.openSync(mksnapshotStdErrPath, 'w');
child_process.execSync(currentArchMksnapshotToolPath + " " + inputFile + " --startup_blob " + path.join(currentArchBlobOutputPath, "TNSSnapshot.blob") + " --profile_deserialization", {encoding: "utf8", stdio: [process.stdin, process.stdout, stdErrorStream]});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

erm, let's use exec and not pipe the error stream to a file

ivanbuhov reacted with thumbs up emoji
var currentArchSrcOutputPath = path.join(this.buildPath, "snapshots/src", androidArch);
shelljs.mkdir("-p", currentArchSrcOutputPath);
shellJsExecuteInDir(currentArchBlobOutputPath, function(){
shelljs.exec("xxd -i TNSSnapshot.blob > " + path.join(currentArchSrcOutputPath, "TNSSnapshot.c"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's extract TNSSnapshot (the filename) to a const somewhere

ivanbuhov reacted with thumbs up emoji
@ivanbuhov ivanbuhov force-pushed the buhov/local-snapshot-improvements branch from 24778ab to d18fd66 Compare June 20, 2017 13:08
Copy link
Contributor

sis0k0 commented Jun 20, 2017

groceries

@ivanbuhov ivanbuhov merged commit dc897ea into master Jun 20, 2017
@ivanbuhov ivanbuhov deleted the buhov/local-snapshot-improvements branch June 20, 2017 16:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Reviewers
1 more reviewer

@sis0k0 sis0k0 sis0k0 approved these changes

Reviewers whose approvals may not affect merge requirements
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants

AltStyle によって変換されたページ (->オリジナル) /