Skip to content

Commit

Permalink
Revert "Don't link the core snapshot in the Android engine. (flutter#…
Browse files Browse the repository at this point in the history
…5348)" (flutter#5352)

This reverts commit e0d4c46.
  • Loading branch information
rmacnak-google authored May 23, 2018
1 parent 47f4a2a commit 2e9ff1f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 23 deletions.
9 changes: 9 additions & 0 deletions runtime/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ source_set("runtime") {

public_configs = [ "$flutter_root:config" ]

# In AOT mode, precompiled snapshots contain the instruction buffer.
# Generation of the same requires all application specific script code to be
# specified up front. In such cases, there can be no generic snapshot.
# In Fuchsia, we load from a file instead of linking.
if (!flutter_aot && !is_fuchsia) {
deps += [ "$flutter_root/lib/snapshot" ]
}

if (flutter_runtime_mode != "release" && !is_fuchsia) {
# Only link in Observatory in non-release modes on non-Fuchsia. Fuchsia
# instead puts Observatory into the runner's package.
Expand All @@ -127,6 +135,7 @@ executable("runtime_unittests") {
":runtime",
":runtime_fixtures",
"$flutter_root/fml",
"$flutter_root/lib/snapshot",
"$flutter_root/testing",
"//garnet/public/lib/fxl",
"//third_party/dart/runtime:libdart_jit",
Expand Down
35 changes: 13 additions & 22 deletions shell/platform/android/io/flutter/view/FlutterMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private static String fromFlutterAssets(String filePath) {

private static boolean sInitialized = false;
private static ResourceExtractor sResourceExtractor;
private static boolean sIsPrecompiledAsBlobs;
private static boolean sIsPrecompiled;
private static boolean sIsPrecompiledAsSharedLibrary;
private static Settings sSettings;

Expand Down Expand Up @@ -201,24 +201,19 @@ public static void ensureInitializationComplete(Context applicationContext, Stri
if (args != null) {
Collections.addAll(shellArgs, args);
}
if (sIsPrecompiledAsSharedLibrary) {
shellArgs.add("--" + AOT_SHARED_LIBRARY_PATH + "=" +
new File(PathUtils.getDataDirectory(applicationContext), sAotSharedLibraryPath));
} else {
if (sIsPrecompiledAsBlobs) {
shellArgs.add("--" + AOT_SNAPSHOT_PATH_KEY + "=" +
PathUtils.getDataDirectory(applicationContext));
} else {
shellArgs.add("--cache-dir-path=" +
PathUtils.getCacheDirectory(applicationContext));

shellArgs.add("--" + AOT_SNAPSHOT_PATH_KEY + "=" +
PathUtils.getDataDirectory(applicationContext) + "/" + sFlutterAssetsDir);
}
if (sIsPrecompiled) {
shellArgs.add("--" + AOT_SNAPSHOT_PATH_KEY + "=" +
PathUtils.getDataDirectory(applicationContext));
shellArgs.add("--" + AOT_VM_SNAPSHOT_DATA_KEY + "=" + sAotVmSnapshotData);
shellArgs.add("--" + AOT_VM_SNAPSHOT_INSTR_KEY + "=" + sAotVmSnapshotInstr);
shellArgs.add("--" + AOT_ISOLATE_SNAPSHOT_DATA_KEY + "=" + sAotIsolateSnapshotData);
shellArgs.add("--" + AOT_ISOLATE_SNAPSHOT_INSTR_KEY + "=" + sAotIsolateSnapshotInstr);
} else if (sIsPrecompiledAsSharedLibrary) {
shellArgs.add("--" + AOT_SHARED_LIBRARY_PATH + "=" +
new File(PathUtils.getDataDirectory(applicationContext), sAotSharedLibraryPath));
} else {
shellArgs.add("--cache-dir-path=" +
PathUtils.getCacheDirectory(applicationContext));
}

if (sSettings.getLogTag() != null) {
Expand Down Expand Up @@ -269,10 +264,6 @@ private static void initResources(Context applicationContext) {
.addResources(SKY_RESOURCES)
.addResource(fromFlutterAssets(sFlx))
.addResource(fromFlutterAssets(sSnapshotBlob))
.addResource(fromFlutterAssets(sAotVmSnapshotData))
.addResource(fromFlutterAssets(sAotVmSnapshotInstr))
.addResource(fromFlutterAssets(sAotIsolateSnapshotData))
.addResource(fromFlutterAssets(sAotIsolateSnapshotInstr))
.addResource(fromFlutterAssets(DEFAULT_KERNEL_BLOB))
.addResource(fromFlutterAssets(DEFAULT_PLATFORM_DILL));
if (sIsPrecompiledAsSharedLibrary) {
Expand Down Expand Up @@ -307,21 +298,21 @@ private static Set<String> listRootAssets(Context applicationContext) {

private static void initAot(Context applicationContext) {
Set<String> assets = listRootAssets(applicationContext);
sIsPrecompiledAsBlobs = assets.containsAll(Arrays.asList(
sIsPrecompiled = assets.containsAll(Arrays.asList(
sAotVmSnapshotData,
sAotVmSnapshotInstr,
sAotIsolateSnapshotData,
sAotIsolateSnapshotInstr
));
sIsPrecompiledAsSharedLibrary = assets.contains(sAotSharedLibraryPath);
if (sIsPrecompiledAsBlobs && sIsPrecompiledAsSharedLibrary) {
if (sIsPrecompiled && sIsPrecompiledAsSharedLibrary) {
throw new RuntimeException(
"Found precompiled app as shared library and as Dart VM snapshots.");
}
}

public static boolean isRunningPrecompiledCode() {
return sIsPrecompiledAsBlobs || sIsPrecompiledAsSharedLibrary;
return sIsPrecompiled || sIsPrecompiledAsSharedLibrary;
}

public static String findAppBundlePath(Context applicationContext) {
Expand Down
1 change: 0 additions & 1 deletion shell/testing/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ executable("testing") {
"$flutter_root/assets",
"$flutter_root/common",
"$flutter_root/fml",
"$flutter_root/lib/snapshot",
"$flutter_root/shell/common",
"//garnet/public/lib/fxl",
"//third_party/dart/runtime:libdart_jit",
Expand Down

0 comments on commit 2e9ff1f

Please sign in to comment.