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

Unified Diff: src/snapshot/mksnapshot.cc

Issue 1310273009: Remove all gyp BUILD rules with multiple outputs. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 3 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
« no previous file with comments | « src/flag-definitions.h ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/snapshot/mksnapshot.cc
diff --git a/src/snapshot/mksnapshot.cc b/src/snapshot/mksnapshot.cc
index 99d93aade8cc926d56f0529375bbca5528fedb2d..09cbf93e1ef3d0c9cf79a31ec538222b7a64c654 100644
--- a/src/snapshot/mksnapshot.cc
+++ b/src/snapshot/mksnapshot.cc
@@ -21,15 +21,17 @@ using namespace v8;
class SnapshotWriter {
public:
- explicit SnapshotWriter(const char* snapshot_file)
- : fp_(GetFileDescriptorOrDie(snapshot_file)),
- startup_blob_file_(NULL) {}
+ SnapshotWriter() : fp_(NULL), startup_blob_file_(NULL) {}
~SnapshotWriter() {
- fclose(fp_);
+ if (fp_) fclose(fp_);
if (startup_blob_file_) fclose(startup_blob_file_);
}
+ void SetSnapshotFile(const char* snapshot_file) {
+ if (snapshot_file != NULL) fp_ = GetFileDescriptorOrDie(snapshot_file);
+ }
+
void SetStartupBlobFile(const char* startup_blob_file) {
if (startup_blob_file != NULL)
startup_blob_file_ = GetFileDescriptorOrDie(startup_blob_file);
@@ -38,7 +40,7 @@ class SnapshotWriter {
void WriteSnapshot(v8::StartupData blob) const {
i::Vector<const i::byte> blob_vector(
reinterpret_cast<const i::byte*>(blob.data), blob.raw_size);
- WriteSnapshotFile(blob_vector);
+ MaybeWriteSnapshotFile(blob_vector);
MaybeWriteStartupBlob(blob_vector);
}
@@ -53,7 +55,9 @@ class SnapshotWriter {
}
}
- void WriteSnapshotFile(const i::Vector<const i::byte>& blob) const {
+ void MaybeWriteSnapshotFile(const i::Vector<const i::byte>& blob) const {
+ if (!fp_) return;
+
WriteFilePrefix();
WriteData(blob);
WriteFileSuffix();
@@ -142,8 +146,9 @@ int main(int argc, char** argv) {
// Print the usage if an error occurs when parsing the command line
// flags or if the help flag is set.
int result = i::FlagList::SetFlagsFromCommandLine(&argc, argv, true);
- if (result > 0 || (argc != 2 && argc != 3) || i::FLAG_help) {
- ::printf("Usage: %s [flag] ... outfile\n", argv[0]);
+ if (result > 0 || (argc != 1 && argc != 2) || i::FLAG_help) {
+ ::printf("Usage: %s --startup_src=... --startup_blob=... [extras]\n",
+ argv[0]);
i::FlagList::PrintHelp();
return !i::FLAG_help;
}
@@ -155,9 +160,10 @@ int main(int argc, char** argv) {
v8::V8::Initialize();
{
- SnapshotWriter writer(argv[1]);
+ SnapshotWriter writer;
+ if (i::FLAG_startup_src) writer.SetSnapshotFile(i::FLAG_startup_src);
if (i::FLAG_startup_blob) writer.SetStartupBlobFile(i::FLAG_startup_blob);
- char* extra_code = GetExtraCode(argc == 3 ? argv[2] : NULL);
+ char* extra_code = GetExtraCode(argc == 2 ? argv[1] : NULL);
StartupData blob = v8::V8::CreateSnapshotDataBlob(extra_code);
CHECK(blob.data);
writer.WriteSnapshot(blob);
« no previous file with comments | « src/flag-definitions.h ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698