Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(584)

Unified Diff: runtime/bin/gen_snapshot.cc

Issue 1903583002: GN Build fixes for Flutter + gen_snapshot fix (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/bin/gen_snapshot.cc
diff --git a/runtime/bin/gen_snapshot.cc b/runtime/bin/gen_snapshot.cc
index 258b9a72850901574b3a6519cbec3c488849dc25..e4e4ce56b0b0117c00db7b6613ab0c756ada411d 100644
--- a/runtime/bin/gen_snapshot.cc
+++ b/runtime/bin/gen_snapshot.cc
@@ -41,7 +41,6 @@ namespace bin {
static const char* vm_isolate_snapshot_filename = NULL;
static const char* isolate_snapshot_filename = NULL;
static const char* instructions_snapshot_filename = NULL;
-static const char* embedder_entry_points_manifest = NULL;
static const char* package_root = NULL;
@@ -54,6 +53,10 @@ static char* app_script_name = NULL;
// Global state that captures the URL mappings specified on the command line.
static CommandLineOptions* url_mapping = NULL;
+// Global state that captures the entry point manifest files specified on the
+// command line.
+static CommandLineOptions* entry_points_files = NULL;
+
static bool IsValidFlag(const char* name,
const char* prefix,
intptr_t prefix_length) {
@@ -105,7 +108,7 @@ static bool ProcessInstructionsSnapshotOption(const char* option) {
static bool ProcessEmbedderEntryPointsManifestOption(const char* option) {
const char* name = ProcessOption(option, "--embedder_entry_points_manifest=");
if (name != NULL) {
- embedder_entry_points_manifest = name;
+ entry_points_files->AddArgument(name);
return true;
}
return false;
@@ -181,14 +184,14 @@ static int ParseArguments(int argc,
}
if ((instructions_snapshot_filename != NULL) &&
- (embedder_entry_points_manifest == NULL)) {
+ (entry_points_files->count() == 0)) {
Log::PrintErr(
"Specifying an instructions snapshot filename indicates precompilation"
". But no embedder entry points manifest was specified.\n\n");
return -1;
}
- if ((embedder_entry_points_manifest != NULL) &&
+ if ((entry_points_files->count() > 0) &&
(instructions_snapshot_filename == NULL)) {
Log::PrintErr(
"Specifying the embedder entry points manifest indicates "
@@ -201,8 +204,8 @@ static int ParseArguments(int argc,
static bool IsSnapshottingForPrecompilation(void) {
- return embedder_entry_points_manifest != NULL &&
- instructions_snapshot_filename != NULL;
+ return (entry_points_files->count() > 0) &&
+ (instructions_snapshot_filename != NULL);
}
@@ -781,31 +784,34 @@ int64_t ParseEntryPointsManifestLines(FILE* file,
}
-static Dart_QualifiedFunctionName* ParseEntryPointsManifestFile(
- const char* path) {
- if (path == NULL) {
- return NULL;
- }
+static Dart_QualifiedFunctionName* ParseEntryPointsManifestFiles() {
+ // Total number of entries across all manifest files.
+ int64_t entry_count = 0;
Florian Schneider 2016/04/19 22:05:23 intptr_t
- FILE* file = fopen(path, "r");
+ // Parse the files once but don't store the results. This is done to first
+ // determine the number of entries in the manifest
+ for (intptr_t i = 0; i < entry_points_files->count(); i++) {
+ const char* path = entry_points_files->GetArgument(i);
- if (file == NULL) {
- Log::PrintErr("Could not open entry points manifest file\n");
- return NULL;
- }
+ FILE* file = fopen(path, "r");
- // Parse the file once but don't store the results. This is done to first
- // determine the number of entries in the manifest
- int64_t entry_count = ParseEntryPointsManifestLines(file, NULL);
+ if (file == NULL) {
+ Log::PrintErr("Could not open entry points manifest file `%s`\n", path);
+ return NULL;
+ }
- if (entry_count <= 0) {
- Log::PrintErr(
- "Manifest file specified is invalid or contained no entries\n");
+ int64_t entries = ParseEntryPointsManifestLines(file, NULL);
Florian Schneider 2016/04/19 22:05:23 intptr_t
fclose(file);
- return NULL;
- }
- rewind(file);
+ if (entries <= 0) {
+ Log::PrintErr(
+ "Manifest file `%s` specified is invalid or contained no entries\n",
+ path);
+ return NULL;
+ }
+
+ entry_count += entries;
+ }
// Allocate enough storage for the entries in the file plus a termination
// sentinel and parse it again to populate the allocation
@@ -813,10 +819,16 @@ static Dart_QualifiedFunctionName* ParseEntryPointsManifestFile(
reinterpret_cast<Dart_QualifiedFunctionName*>(
calloc(entry_count + 1, sizeof(Dart_QualifiedFunctionName)));
- int64_t parsed_entry_count = ParseEntryPointsManifestLines(file, entries);
- ASSERT(parsed_entry_count == entry_count);
+ int64_t parsed_entry_count = 0;
Florian Schneider 2016/04/19 22:05:23 intptr_t
+ for (intptr_t i = 0; i < entry_points_files->count(); i++) {
+ const char* path = entry_points_files->GetArgument(i);
+ FILE* file = fopen(path, "r");
Florian Schneider 2016/04/19 22:05:23 Check return value of fopen.
+ parsed_entry_count +=
+ ParseEntryPointsManifestLines(file, &entries[parsed_entry_count]);
+ fclose(file);
+ }
- fclose(file);
+ ASSERT(parsed_entry_count == entry_count);
// The entries allocation must be explicitly cleaned up via
// |CleanupEntryPointsCollection|
@@ -825,8 +837,7 @@ static Dart_QualifiedFunctionName* ParseEntryPointsManifestFile(
static Dart_QualifiedFunctionName* ParseEntryPointsManifestIfPresent() {
- Dart_QualifiedFunctionName* entries =
- ParseEntryPointsManifestFile(embedder_entry_points_manifest);
+ Dart_QualifiedFunctionName* entries = ParseEntryPointsManifestFiles();
if ((entries == NULL) && IsSnapshottingForPrecompilation()) {
Log::PrintErr(
"Could not find native embedder entry points during precompilation\n");
@@ -998,6 +1009,10 @@ int main(int argc, char** argv) {
CommandLineOptions url_mapping_array(argc);
url_mapping = &url_mapping_array;
+ // Initialize the entrypoints array.
+ CommandLineOptions entry_points_files_array(argc);
+ entry_points_files = &entry_points_files_array;
+
// Parse command line arguments.
if (ParseArguments(argc,
argv,
« runtime/BUILD.gn ('K') | « runtime/bin/BUILD.gn ('k') | runtime/vm/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698