Commit 244cc0a6 authored by vogelheim's avatar vogelheim Committed by Commit bot

Remove all gyp BUILD rules with multiple outputs.

- Modify js2c to accept --js and --nojs,
- modify mksnapshot to accept --startup_src
  (instead of a positional parameter, so that it can be omitted),
- modify v8.gyp to use the above so that no target has multiple
  output dependencies, and
- update GN to use the switches above.

(I have not succeeded in fixing the GYP->make translator to properly map
 multi-output rules, so that they work as expected in all edge cases.
 This CL signals defeat on that front, and instead I rewrite the GYP
 file to avoid that situation in the first place.)

R=jochen@chromium.org
BUG=v8:4382
LOG=N

Review URL: https://codereview.chromium.org/1310273009

Cr-Commit-Position: refs/heads/master@{#30640}
parent c9f0368a
......@@ -497,6 +497,7 @@ action("run_mksnapshot") {
"--log-snapshot-positions",
"--logfile",
rebase_path("$target_gen_dir/snapshot.log", root_build_dir),
"--startup_src",
rebase_path("$target_gen_dir/snapshot.cc", root_build_dir),
]
......
......@@ -802,6 +802,8 @@ DEFINE_STRING(testing_serialization_file, "/tmp/serdes",
#endif
// mksnapshot.cc
DEFINE_STRING(startup_src, NULL,
"Write V8 startup as C++ src. (mksnapshot only)")
DEFINE_STRING(startup_blob, NULL,
"Write V8 startup blob file. (mksnapshot only)")
......
......@@ -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);
......
......@@ -210,7 +210,7 @@
'action': [
'<(mksnapshot_exec)',
'<@(mksnapshot_flags)',
'<@(INTERMEDIATE_DIR)/snapshot.cc',
'--startup_src', '<@(INTERMEDIATE_DIR)/snapshot.cc',
'<(embed_script)',
],
},
......@@ -314,25 +314,21 @@
'target_conditions': [
['_toolset=="host"', {
'outputs': [
'<(INTERMEDIATE_DIR)/snapshot.cc',
'<(PRODUCT_DIR)/snapshot_blob_host.bin',
],
'action': [
'<(mksnapshot_exec)',
'<@(mksnapshot_flags)',
'<@(INTERMEDIATE_DIR)/snapshot.cc',
'--startup_blob', '<(PRODUCT_DIR)/snapshot_blob_host.bin',
'<(embed_script)',
],
}, {
'outputs': [
'<(INTERMEDIATE_DIR)/snapshot.cc',
'<(PRODUCT_DIR)/snapshot_blob.bin',
],
'action': [
'<(mksnapshot_exec)',
'<@(mksnapshot_flags)',
'<@(INTERMEDIATE_DIR)/snapshot.cc',
'--startup_blob', '<(PRODUCT_DIR)/snapshot_blob.bin',
'<(embed_script)',
],
......@@ -340,13 +336,11 @@
],
}, {
'outputs': [
'<(INTERMEDIATE_DIR)/snapshot.cc',
'<(PRODUCT_DIR)/snapshot_blob.bin',
],
'action': [
'<(mksnapshot_exec)',
'<@(mksnapshot_flags)',
'<@(INTERMEDIATE_DIR)/snapshot.cc',
'--startup_blob', '<(PRODUCT_DIR)/snapshot_blob.bin',
'<(embed_script)',
],
......@@ -1863,9 +1857,7 @@
'<@(library_files)',
'<@(i18n_library_files)'
],
'outputs': [
'<(SHARED_INTERMEDIATE_DIR)/libraries.cc',
],
'outputs': ['<(SHARED_INTERMEDIATE_DIR)/libraries.cc'],
'action': [
'python',
'../../tools/js2c.py',
......@@ -1874,13 +1866,24 @@
'<@(library_files)',
'<@(i18n_library_files)'
],
'conditions': [
[ 'v8_use_external_startup_data==1', {
'outputs': ['<@(libraries_bin_file)'],
'action': [
'--startup_blob', '<@(libraries_bin_file)',
],
}],
},
{
'action_name': 'js2c_bin',
'inputs': [
'../../tools/js2c.py',
'<@(library_files)',
'<@(i18n_library_files)'
],
'outputs': ['<@(libraries_bin_file)'],
'action': [
'python',
'../../tools/js2c.py',
'<(SHARED_INTERMEDIATE_DIR)/libraries.cc',
'CORE',
'<@(library_files)',
'<@(i18n_library_files)',
'--startup_blob', '<@(libraries_bin_file)',
'--nojs',
],
},
{
......@@ -1889,9 +1892,7 @@
'../../tools/js2c.py',
'<@(experimental_library_files)',
],
'outputs': [
'<(SHARED_INTERMEDIATE_DIR)/experimental-libraries.cc',
],
'outputs': ['<(SHARED_INTERMEDIATE_DIR)/experimental-libraries.cc'],
'action': [
'python',
'../../tools/js2c.py',
......@@ -1899,13 +1900,22 @@
'EXPERIMENTAL',
'<@(experimental_library_files)'
],
'conditions': [
[ 'v8_use_external_startup_data==1', {
'outputs': ['<@(libraries_experimental_bin_file)'],
'action': [
'--startup_blob', '<@(libraries_experimental_bin_file)'
],
}],
},
{
'action_name': 'js2c_experimental_bin',
'inputs': [
'../../tools/js2c.py',
'<@(experimental_library_files)',
],
'outputs': ['<@(libraries_experimental_bin_file)'],
'action': [
'python',
'../../tools/js2c.py',
'<(SHARED_INTERMEDIATE_DIR)/experimental-libraries.cc',
'EXPERIMENTAL',
'<@(experimental_library_files)',
'--startup_blob', '<@(libraries_experimental_bin_file)',
'--nojs',
],
},
{
......@@ -1914,9 +1924,7 @@
'../../tools/js2c.py',
'<@(code_stub_library_files)',
],
'outputs': [
'<(SHARED_INTERMEDIATE_DIR)/code-stub-libraries.cc',
],
'outputs': ['<(SHARED_INTERMEDIATE_DIR)/code-stub-libraries.cc'],
'action': [
'python',
'../../tools/js2c.py',
......@@ -1924,13 +1932,22 @@
'CODE_STUB',
'<@(code_stub_library_files)'
],
'conditions': [
[ 'v8_use_external_startup_data==1', {
'outputs': ['<@(libraries_code_stub_bin_file)'],
'action': [
'--startup_blob', '<@(libraries_code_stub_bin_file)'
],
}],
},
{
'action_name': 'js2c_code_stubs_bin',
'inputs': [
'../../tools/js2c.py',
'<@(code_stub_library_files)',
],
'outputs': ['<@(libraries_code_stub_bin_file)'],
'action': [
'python',
'../../tools/js2c.py',
'<(SHARED_INTERMEDIATE_DIR)/code-stub-libraries.cc',
'CODE_STUB',
'<@(code_stub_library_files)',
'--startup_blob', '<@(libraries_code_stub_bin_file)',
'--nojs',
],
},
{
......@@ -1939,23 +1956,30 @@
'../../tools/js2c.py',
'<@(v8_extra_library_files)',
],
'outputs': [
'outputs': ['<(SHARED_INTERMEDIATE_DIR)/extras-libraries.cc'],
'action': [
'python',
'../../tools/js2c.py',
'<(SHARED_INTERMEDIATE_DIR)/extras-libraries.cc',
'EXTRAS',
'<@(v8_extra_library_files)',
],
},
{
'action_name': 'js2c_extras_bin',
'inputs': [
'../../tools/js2c.py',
'<@(v8_extra_library_files)',
],
'outputs': ['<@(libraries_extras_bin_file)'],
'action': [
'python',
'../../tools/js2c.py',
'<(SHARED_INTERMEDIATE_DIR)/extras-libraries.cc',
'EXTRAS',
'<@(v8_extra_library_files)',
],
'conditions': [
[ 'v8_use_external_startup_data==1', {
'outputs': ['<@(libraries_extras_bin_file)'],
'action': [
'--startup_blob', '<@(libraries_extras_bin_file)',
],
}],
'--startup_blob', '<@(libraries_extras_bin_file)',
'--nojs',
],
},
{
......@@ -1974,13 +1998,22 @@
'EXPERIMENTAL_EXTRAS',
'<@(v8_experimental_extra_library_files)',
],
'conditions': [
[ 'v8_use_external_startup_data==1', {
'outputs': ['<@(libraries_experimental_extras_bin_file)'],
'action': [
'--startup_blob', '<@(libraries_experimental_extras_bin_file)',
],
}],
},
{
'action_name': 'js2c_experimental_extras_bin',
'inputs': [
'../../tools/js2c.py',
'<@(v8_experimental_extra_library_files)',
],
'outputs': ['<@(libraries_experimental_extras_bin_file)'],
'action': [
'python',
'../../tools/js2c.py',
'<(SHARED_INTERMEDIATE_DIR)/experimental-extras-libraries.cc',
'EXPERIMENTAL_EXTRAS',
'<@(v8_experimental_extra_library_files)',
'--startup_blob', '<@(libraries_experimental_extras_bin_file)',
'--nojs',
],
},
],
......
......@@ -586,7 +586,8 @@ def main():
help="file to write the startup blob to.")
parser.add_option("--js",
help="writes a JS file output instead of a C file",
action="store_true")
action="store_true", default=False, dest='js')
parser.add_option("--nojs", action="store_false", default=False, dest='js')
parser.set_usage("""js2c out.cc type sources.js ...
out.cc: C code to be generated.
type: type parameter for NativesCollection template.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment