| OLD | NEW |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "tools/gn/json_project_writer.h" | 5 #include "tools/gn/json_project_writer.h" |
| 6 | 6 |
| 7 #include <iostream> | 7 #include <iostream> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 }); | 79 }); |
| 80 | 80 |
| 81 return true; | 81 return true; |
| 82 } | 82 } |
| 83 | 83 |
| 84 std::string RenderJSON(const BuildSettings* build_settings, | 84 std::string RenderJSON(const BuildSettings* build_settings, |
| 85 const Builder& builder, | 85 const Builder& builder, |
| 86 std::vector<const Target*>& all_targets) { | 86 std::vector<const Target*>& all_targets) { |
| 87 Label default_toolchain_label; | 87 Label default_toolchain_label; |
| 88 | 88 |
| 89 auto targets = base::WrapUnique(new base::DictionaryValue()); | 89 auto targets = base::MakeUnique<base::DictionaryValue>(); |
| 90 for (const auto* target : all_targets) { | 90 for (const auto* target : all_targets) { |
| 91 if (default_toolchain_label.is_null()) | 91 if (default_toolchain_label.is_null()) |
| 92 default_toolchain_label = target->settings()->default_toolchain_label(); | 92 default_toolchain_label = target->settings()->default_toolchain_label(); |
| 93 auto description = | 93 auto description = |
| 94 DescBuilder::DescriptionForTarget(target, "", false, false, false); | 94 DescBuilder::DescriptionForTarget(target, "", false, false, false); |
| 95 // Outputs need to be asked for separately. | 95 // Outputs need to be asked for separately. |
| 96 auto outputs = DescBuilder::DescriptionForTarget(target, "source_outputs", | 96 auto outputs = DescBuilder::DescriptionForTarget(target, "source_outputs", |
| 97 false, false, false); | 97 false, false, false); |
| 98 base::DictionaryValue* outputs_value = nullptr; | 98 base::DictionaryValue* outputs_value = nullptr; |
| 99 if (outputs->GetDictionary("source_outputs", &outputs_value) && | 99 if (outputs->GetDictionary("source_outputs", &outputs_value) && |
| 100 !outputs_value->empty()) { | 100 !outputs_value->empty()) { |
| 101 description->MergeDictionary(outputs.get()); | 101 description->MergeDictionary(outputs.get()); |
| 102 } | 102 } |
| 103 targets->Set(target->label().GetUserVisibleName(default_toolchain_label), | 103 targets->Set(target->label().GetUserVisibleName(default_toolchain_label), |
| 104 std::move(description)); | 104 std::move(description)); |
| 105 } | 105 } |
| 106 | 106 |
| 107 auto settings = base::WrapUnique(new base::DictionaryValue()); | 107 auto settings = base::MakeUnique<base::DictionaryValue>(); |
| 108 settings->SetString("root_path", build_settings->root_path_utf8()); | 108 settings->SetString("root_path", build_settings->root_path_utf8()); |
| 109 settings->SetString("build_dir", build_settings->build_dir().value()); | 109 settings->SetString("build_dir", build_settings->build_dir().value()); |
| 110 settings->SetString("default_toolchain", | 110 settings->SetString("default_toolchain", |
| 111 default_toolchain_label.GetUserVisibleName(false)); | 111 default_toolchain_label.GetUserVisibleName(false)); |
| 112 | 112 |
| 113 auto output = base::WrapUnique(new base::DictionaryValue()); | 113 auto output = base::MakeUnique<base::DictionaryValue>(); |
| 114 output->Set("targets", std::move(targets)); | 114 output->Set("targets", std::move(targets)); |
| 115 output->Set("build_settings", std::move(settings)); | 115 output->Set("build_settings", std::move(settings)); |
| 116 | 116 |
| 117 std::string s; | 117 std::string s; |
| 118 base::JSONWriter::WriteWithOptions( | 118 base::JSONWriter::WriteWithOptions( |
| 119 *output.get(), base::JSONWriter::OPTIONS_PRETTY_PRINT, &s); | 119 *output.get(), base::JSONWriter::OPTIONS_PRETTY_PRINT, &s); |
| 120 return s; | 120 return s; |
| 121 } | 121 } |
| 122 | 122 |
| 123 bool InvokePython(const BuildSettings* build_settings, | 123 bool InvokePython(const BuildSettings* build_settings, |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 script_file = SourceFile(exec_script); | 208 script_file = SourceFile(exec_script); |
| 209 } | 209 } |
| 210 base::FilePath script_path = build_settings->GetFullPath(script_file); | 210 base::FilePath script_path = build_settings->GetFullPath(script_file); |
| 211 return InvokePython(build_settings, script_path, exec_script_extra_args, | 211 return InvokePython(build_settings, script_path, exec_script_extra_args, |
| 212 output_path, quiet, err); | 212 output_path, quiet, err); |
| 213 } | 213 } |
| 214 } | 214 } |
| 215 | 215 |
| 216 return true; | 216 return true; |
| 217 } | 217 } |
| OLD | NEW |