Chromium Code Reviews| Index: runtime/bin/gen_snapshot.cc |
| diff --git a/runtime/bin/gen_snapshot.cc b/runtime/bin/gen_snapshot.cc |
| index d17b0aae3e8f92d1e03ecfe916d0be92f406689b..3a72a058fa2f72e839ebf455867535fec22eed4f 100644 |
| --- a/runtime/bin/gen_snapshot.cc |
| +++ b/runtime/bin/gen_snapshot.cc |
| @@ -67,7 +67,6 @@ const uint8_t* isolate_snapshot_data = NULL; |
| // Global state that indicates whether a snapshot is to be created and |
| // if so which file to write the snapshot into. |
| enum SnapshotKind { |
| - kNone, |
| kCore, |
| kScript, |
| kAppAOTBlobs, |
| @@ -80,6 +79,7 @@ static const char* isolate_snapshot_data_filename = NULL; |
| static const char* isolate_snapshot_instructions_filename = NULL; |
| static const char* assembly_filename = NULL; |
| static const char* script_snapshot_filename = NULL; |
| +static bool dependencies_only = false; |
| static const char* dependencies_filename = NULL; |
| @@ -208,12 +208,12 @@ static const char* ProcessOption(const char* option, const char* name) { |
| static bool ProcessSnapshotKindOption(const char* option) { |
| const char* kind = ProcessOption(option, "--snapshot_kind="); |
| if (kind == NULL) { |
| + kind = ProcessOption(option, "--snapshot-kind="); |
| + } |
|
siva
2017/02/27 22:03:37
With these changes of accepting '-' and '_' gen_sn
rmacnak
2017/02/27 23:18:00
Agreed
|
| + if (kind == NULL) { |
| return false; |
| } |
| - if (strcmp(kind, "none") == 0) { |
| - snapshot_kind = kNone; |
| - return true; |
| - } else if (strcmp(kind, "core") == 0) { |
| + if (strcmp(kind, "core") == 0) { |
| snapshot_kind = kCore; |
| return true; |
| } else if (strcmp(kind, "script") == 0) { |
| @@ -236,6 +236,9 @@ static bool ProcessSnapshotKindOption(const char* option) { |
| static bool ProcessVmSnapshotDataOption(const char* option) { |
| const char* name = ProcessOption(option, "--vm_snapshot_data="); |
| + if (name == NULL) { |
| + name = ProcessOption(option, "--vm-snapshot-data="); |
| + } |
| if (name != NULL) { |
| vm_snapshot_data_filename = name; |
| return true; |
| @@ -246,6 +249,9 @@ static bool ProcessVmSnapshotDataOption(const char* option) { |
| static bool ProcessVmSnapshotInstructionsOption(const char* option) { |
| const char* name = ProcessOption(option, "--vm_snapshot_instructions="); |
| + if (name == NULL) { |
| + name = ProcessOption(option, "--vm-snapshot-instructions="); |
| + } |
| if (name != NULL) { |
| vm_snapshot_instructions_filename = name; |
| return true; |
| @@ -256,6 +262,9 @@ static bool ProcessVmSnapshotInstructionsOption(const char* option) { |
| static bool ProcessIsolateSnapshotDataOption(const char* option) { |
| const char* name = ProcessOption(option, "--isolate_snapshot_data="); |
| + if (name == NULL) { |
| + name = ProcessOption(option, "--isolate-snapshot-data="); |
| + } |
| if (name != NULL) { |
| isolate_snapshot_data_filename = name; |
| return true; |
| @@ -266,6 +275,9 @@ static bool ProcessIsolateSnapshotDataOption(const char* option) { |
| static bool ProcessIsolateSnapshotInstructionsOption(const char* option) { |
| const char* name = ProcessOption(option, "--isolate_snapshot_instructions="); |
| + if (name == NULL) { |
| + name = ProcessOption(option, "--isolate-snapshot-instructions="); |
| + } |
| if (name != NULL) { |
| isolate_snapshot_instructions_filename = name; |
| return true; |
| @@ -286,6 +298,9 @@ static bool ProcessAssemblyOption(const char* option) { |
| static bool ProcessScriptSnapshotOption(const char* option) { |
| const char* name = ProcessOption(option, "--script_snapshot="); |
| + if (name == NULL) { |
| + name = ProcessOption(option, "--script-snapshot="); |
| + } |
| if (name != NULL) { |
| script_snapshot_filename = name; |
| return true; |
| @@ -304,6 +319,19 @@ static bool ProcessDependenciesOption(const char* option) { |
| } |
| +static bool ProcessDependenciesOnlyOption(const char* option) { |
| + const char* name = ProcessOption(option, "--dependencies_only"); |
| + if (name == NULL) { |
| + name = ProcessOption(option, "--dependencies-only"); |
| + } |
| + if (name != NULL) { |
| + dependencies_only = true; |
| + return true; |
| + } |
| + return false; |
| +} |
| + |
| + |
| static bool ProcessEmbedderEntryPointsManifestOption(const char* option) { |
| const char* name = ProcessOption(option, "--embedder_entry_points_manifest="); |
| if (name != NULL) { |
| @@ -377,6 +405,7 @@ static int ParseArguments(int argc, |
| ProcessAssemblyOption(argv[i]) || |
| ProcessScriptSnapshotOption(argv[i]) || |
| ProcessDependenciesOption(argv[i]) || |
| + ProcessDependenciesOnlyOption(argv[i]) || |
| ProcessEmbedderEntryPointsManifestOption(argv[i]) || |
| ProcessURLmappingOption(argv[i]) || ProcessPackageRootOption(argv[i]) || |
| ProcessPackagesOption(argv[i]) || ProcessEnvironmentOption(argv[i])) { |
| @@ -405,15 +434,6 @@ static int ParseArguments(int argc, |
| } |
| switch (snapshot_kind) { |
| - case kNone: { |
| - if (*script_name == NULL) { |
| - Log::PrintErr( |
| - "Building without snapshot generation requires a Dart " |
| - "script.\n\n"); |
| - return -1; |
| - } |
| - break; |
| - } |
| case kCore: { |
| if ((vm_snapshot_data_filename == NULL) || |
| (isolate_snapshot_data_filename == NULL)) { |
| @@ -431,7 +451,7 @@ static int ParseArguments(int argc, |
| Log::PrintErr( |
| "Building a script snapshot requires specifying input files for " |
| "--vm_snapshot_data and --isolate_snapshot_data, an output file " |
| - "for --script-snapshot, and a Dart script.\n\n"); |
| + "for --script_snapshot, and a Dart script.\n\n"); |
| return -1; |
| } |
| break; |
| @@ -663,33 +683,32 @@ static void CreateAndWriteDependenciesFile() { |
| bool success = true; |
| // Targets: |
| - if (vm_snapshot_data_filename != NULL) { |
| - success &= |
| - file->Print("%s ", File::GetCanonicalPath(vm_snapshot_data_filename)); |
| - } |
| - if (vm_snapshot_instructions_filename != NULL) { |
| - success &= file->Print( |
| - "%s ", File::GetCanonicalPath(vm_snapshot_instructions_filename)); |
| - } |
| - if (isolate_snapshot_data_filename != NULL) { |
| - success &= file->Print( |
| - "%s ", File::GetCanonicalPath(isolate_snapshot_data_filename)); |
| - } |
| - if (isolate_snapshot_instructions_filename != NULL) { |
| - success &= file->Print( |
| - "%s ", File::GetCanonicalPath(isolate_snapshot_instructions_filename)); |
| - } |
| - if (assembly_filename != NULL) { |
| - success &= file->Print("%s ", File::GetCanonicalPath(assembly_filename)); |
| - } |
| - if (script_snapshot_filename != NULL) { |
| - success &= |
| - file->Print("%s ", File::GetCanonicalPath(script_snapshot_filename)); |
| + switch (snapshot_kind) { |
| + case kCore: |
| + success &= file->Print("%s ", vm_snapshot_data_filename); |
| + success &= file->Print("%s ", isolate_snapshot_data_filename); |
| + break; |
| + case kScript: |
| + success &= file->Print("%s ", script_snapshot_filename); |
| + break; |
| + case kAppAOTAssembly: |
| + success &= file->Print("%s ", assembly_filename); |
| + break; |
| + case kAppAOTBlobs: |
| + success &= file->Print("%s ", vm_snapshot_data_filename); |
| + success &= file->Print("%s ", vm_snapshot_instructions_filename); |
| + success &= file->Print("%s ", isolate_snapshot_data_filename); |
| + success &= file->Print("%s ", isolate_snapshot_instructions_filename); |
| + break; |
| } |
| success &= file->Print(": "); |
| // Sources: |
| + if (snapshot_kind == kScript) { |
| + success &= file->Print("%s ", vm_snapshot_data_filename); |
| + success &= file->Print("%s ", isolate_snapshot_data_filename); |
| + } |
| for (intptr_t i = 0; i < dependencies->length(); i++) { |
| char* dep = dependencies->At(i); |
| success &= file->Print("%s ", dep); |
| @@ -820,11 +839,7 @@ static void PrintUsage() { |
| " --dependencies=<output-file> Generates a Makefile with snapshot output \n" |
| " files as targets and all transitive imports\n" |
| " as sources. \n" |
| -" \n" |
| -" To discover dependencies without generating a snapshot: \n" |
| -" --snapshot_kind=none \n" |
| -" --dependencies=<output-file> \n" |
| -" <dart-script-file> \n" |
| +" --dependencies_only Don't create and output the snapshot. \n" |
| " \n" |
| " To create a core snapshot: \n" |
| " --snapshot_kind=core \n" |
| @@ -1613,21 +1628,21 @@ int main(int argc, char** argv) { |
| result = Dart_FinalizeLoading(false); |
| CHECK_RESULT(result); |
| - switch (snapshot_kind) { |
| - case kNone: |
| - break; |
| - case kCore: |
| - CreateAndWriteCoreSnapshot(); |
| - break; |
| - case kScript: |
| - CreateAndWriteScriptSnapshot(); |
| - break; |
| - case kAppAOTBlobs: |
| - case kAppAOTAssembly: |
| - CreateAndWritePrecompiledSnapshot(entry_points); |
| - break; |
| - default: |
| - UNREACHABLE(); |
| + if (!dependencies_only) { |
| + switch (snapshot_kind) { |
| + case kCore: |
| + CreateAndWriteCoreSnapshot(); |
| + break; |
| + case kScript: |
| + CreateAndWriteScriptSnapshot(); |
| + break; |
| + case kAppAOTBlobs: |
| + case kAppAOTAssembly: |
| + CreateAndWritePrecompiledSnapshot(entry_points); |
| + break; |
| + default: |
| + UNREACHABLE(); |
| + } |
| } |
| CreateAndWriteDependenciesFile(); |