Add config properties to specify snapshot blob file names. (flutter/engine#2943)

* Add config properties to specify snapshot blob file names.

This adds the ability of the shell to override the default
dart aot snapshot blob file names, and it wires up Android's
FlutterMain to recognize the properties in the app's manifest.

This will be used for flutter applications that build their
binary snapshots into files other than the default ones
that the engine uses.
This commit is contained in:
Todd Volkert
2016-08-18 16:27:16 -07:00
committed by GitHub
parent cc54935495
commit dd98748b48
3 changed files with 30 additions and 11 deletions

View File

@@ -21,6 +21,10 @@ struct Settings {
bool enable_dart_checked_mode = false;
bool trace_startup = false;
std::string aot_snapshot_path;
std::string aot_isolate_snapshot_file_name;
std::string aot_vm_isolate_snapshot_file_name;
std::string aot_instructions_blob_file_name;
std::string aot_rodata_blob_file_name;
std::string temp_directory_path;
std::vector<std::string> dart_flags;

View File

@@ -339,10 +339,10 @@ DartJniIsolateData* GetDartJniDataForCurrentIsolate() {
#if DART_ALLOW_DYNAMIC_RESOLUTION
const char* kDartVmIsolateSnapshotBufferName = "kDartVmIsolateSnapshotBuffer";
const char* kDartIsolateSnapshotBufferName = "kDartIsolateSnapshotBuffer";
const char* kInstructionsSnapshotName = "kInstructionsSnapshot";
const char* kDataSnapshotName = "kDataSnapshot";
constexpr char kDartVmIsolateSnapshotBufferName[] = "kDartVmIsolateSnapshotBuffer";
constexpr char kDartIsolateSnapshotBufferName[] = "kDartIsolateSnapshotBuffer";
constexpr char kInstructionsSnapshotName[] = "kInstructionsSnapshot";
constexpr char kDataSnapshotName[] = "kDataSnapshot";
#if OS(IOS)
@@ -390,14 +390,19 @@ struct SymbolAsset {
const char* symbol_name;
const char* file_name;
bool is_executable;
size_t settings_offset;
void* mapping;
};
static SymbolAsset g_symbol_assets[] = {
{kDartVmIsolateSnapshotBufferName, "snapshot_aot_vmisolate", false},
{kDartIsolateSnapshotBufferName, "snapshot_aot_isolate", false},
{kInstructionsSnapshotName, "snapshot_aot_instr", true},
{kDataSnapshotName, "snapshot_aot_rodata", false},
{kDartVmIsolateSnapshotBufferName, "snapshot_aot_vmisolate", false,
offsetof(Settings, aot_vm_isolate_snapshot_file_name)},
{kDartIsolateSnapshotBufferName, "snapshot_aot_isolate", false,
offsetof(Settings, aot_isolate_snapshot_file_name)},
{kInstructionsSnapshotName, "snapshot_aot_instr", true,
offsetof(Settings, aot_instructions_blob_file_name)},
{kDataSnapshotName, "snapshot_aot_rodata", false,
offsetof(Settings, aot_rodata_blob_file_name)},
};
// Resolve a precompiled snapshot symbol by mapping the corresponding asset
@@ -411,10 +416,17 @@ void* _DartSymbolLookup(const char* symbol_name) {
return symbol_asset.mapping;
}
const std::string& aot_snapshot_path = Settings::Get().aot_snapshot_path;
const Settings& settings = Settings::Get();
const std::string& aot_snapshot_path = settings.aot_snapshot_path;
FTL_CHECK(!aot_snapshot_path.empty());
std::string asset_path = aot_snapshot_path + "/" + symbol_asset.file_name;
const char* file_name = symbol_asset.file_name;
const std::string* settings_override = reinterpret_cast<const std::string*>(
reinterpret_cast<const uint8_t*>(&settings) + symbol_asset.settings_offset);
if (!settings_override->empty())
file_name = settings_override->c_str();
std::string asset_path = aot_snapshot_path + "/" + file_name;
struct stat info;
if (stat(asset_path.c_str(), &info) < 0)
return nullptr;

View File

@@ -18,7 +18,10 @@ namespace blink {
#if DART_ALLOW_DYNAMIC_RESOLUTION
extern const char* kDartIsolateSnapshotBufferName;
extern const char kDartVmIsolateSnapshotBufferName[];
extern const char kDartIsolateSnapshotBufferName[];
extern const char kInstructionsSnapshotName[];
extern const char kDataSnapshotName[];
void* _DartSymbolLookup(const char* symbol_name);