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

feat: snapshot in Docker on macOS with Android runtime 6.3.0 or higher #1077

Merged
merged 1 commit into from
Nov 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion snapshot/android/project-snapshot-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ ProjectSnapshotGenerator.prototype.generate = function (generationOptions) {
androidNdkPath: generationOptions.androidNdkPath,
mksnapshotParams: mksnapshotParams,
snapshotInDocker: generationOptions.snapshotInDocker,
recommendedAndroidNdkRevision
recommendedAndroidNdkRevision,
runtimeVersion
};

return generator.generate(options).then(() => {
Expand Down
11 changes: 8 additions & 3 deletions snapshot/android/snapshot-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const { dirname, relative, join, EOL } = require("path");
const child_process = require("child_process");
const { convertToUnixPath, warn } = require("../../lib/utils");
const PropertiesReader = require('properties-reader');
const semver = require("semver");
const shelljs = require("shelljs");

const { createDirectory, downloadFile, getHostOS, getHostOSArch, CONSTANTS, has32BitArch, isMacOSCatalinaOrHigher, isSubPath } = require("./utils");
Expand Down Expand Up @@ -36,12 +37,16 @@ module.exports = SnapshotGenerator;

SnapshotGenerator.SNAPSHOT_PACKAGE_NANE = "nativescript-android-snapshot";

SnapshotGenerator.prototype.shouldSnapshotInDocker = function (hostOS, targetArchs) {
SnapshotGenerator.prototype.shouldSnapshotInDocker = function (hostOS, targetArchs, currentRuntimeVersion) {
let shouldSnapshotInDocker = false;
const minRuntimeWithoutMacOSSnapshotTools = "6.3.0";
const generateInDockerMessage = "The snapshots will be generated in a docker container.";
if (hostOS == CONSTANTS.WIN_OS_NAME) {
if (hostOS === CONSTANTS.WIN_OS_NAME) {
console.log(`The V8 snapshot tools are not supported on Windows. ${generateInDockerMessage}`);
shouldSnapshotInDocker = true;
} else if (hostOS === CONSTANTS.MAC_OS_NAME && semver.gte(currentRuntimeVersion, minRuntimeWithoutMacOSSnapshotTools)) {
console.log(`Starting from Android Runtime 6.3.0, the Snapshot tools are no longer supported on macOS. ${generateInDockerMessage}`);
shouldSnapshotInDocker = true;
} else if (isMacOSCatalinaOrHigher() && has32BitArch(targetArchs)) {
console.log(`Starting from macOS Catalina, the 32-bit processes are no longer supported. ${generateInDockerMessage}`);
shouldSnapshotInDocker = true;
Expand Down Expand Up @@ -295,7 +300,7 @@ SnapshotGenerator.prototype.generate = function (options) {

this.preprocessInputFiles(options.inputFiles, preprocessedInputFile);
const hostOS = getHostOS();
const snapshotInDocker = options.snapshotInDocker || this.shouldSnapshotInDocker(hostOS, options.targetArchs);
const snapshotInDocker = options.snapshotInDocker || this.shouldSnapshotInDocker(hostOS, options.targetArchs, options.runtimeVersion);

// generates the actual .blob and .c files
return this.generateSnapshots(
Expand Down