1 // Copyright (c) 2023 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef TOOLS_GN_NINJA_OUTPUTS_WRITER_H_ 6 #define TOOLS_GN_NINJA_OUTPUTS_WRITER_H_ 7 8 #include <string> 9 #include <unordered_map> 10 #include <vector> 11 12 #include "gn/err.h" 13 #include "gn/output_file.h" 14 #include "gn/string_output_buffer.h" 15 #include "gn/target.h" 16 17 class Builder; 18 class BuildSettings; 19 class StringOutputBuffer; 20 21 // Generates the --ninja-outputs-file content 22 class NinjaOutputsWriter { 23 public: 24 // A map from targets to list of corresponding Ninja output paths. 25 using MapType = std::unordered_map<const Target*, std::vector<OutputFile>>; 26 27 static bool RunAndWriteFiles(const MapType& outputs_map, 28 const BuildSettings* build_setting, 29 const std::string& file_name, 30 const std::string& exec_script, 31 const std::string& exec_script_extra_args, 32 bool quiet, 33 Err* err); 34 35 private: 36 FRIEND_TEST_ALL_PREFIXES(NinjaOutputsWriterTest, OutputsFile); 37 38 static StringOutputBuffer GenerateJSON(const MapType& outputs_map); 39 }; 40 41 #endif 42