1 // Copyright (c) 2013 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_ACTION_VALUES_H_ 6 #define TOOLS_GN_ACTION_VALUES_H_ 7 8 #include <string> 9 #include <vector> 10 11 #include "gn/label_ptr.h" 12 #include "gn/source_file.h" 13 #include "gn/substitution_list.h" 14 15 class Pool; 16 class Target; 17 18 // Holds the values (outputs, args, script name, etc.) for either an action or 19 // an action_foreach target. 20 class ActionValues { 21 public: 22 ActionValues(); 23 ~ActionValues(); 24 25 // Filename of the script to execute. script()26 const SourceFile& script() const { return script_; } set_script(const SourceFile & s)27 void set_script(const SourceFile& s) { script_ = s; } 28 29 // Arguments to the script. args()30 SubstitutionList& args() { return args_; } args()31 const SubstitutionList& args() const { return args_; } 32 33 // Files created by the script. These are strings rather than SourceFiles 34 // since they will often contain {{source expansions}}. outputs()35 SubstitutionList& outputs() { return outputs_; } outputs()36 const SubstitutionList& outputs() const { return outputs_; } 37 38 // Expands the outputs() above to the final SourceFile list. 39 void GetOutputsAsSourceFiles(const Target* target, 40 std::vector<SourceFile>* result) const; 41 42 // Depfile generated by the script. depfile()43 const SubstitutionPattern& depfile() const { return depfile_; } has_depfile()44 bool has_depfile() const { return !depfile_.ranges().empty(); } set_depfile(const SubstitutionPattern & depfile)45 void set_depfile(const SubstitutionPattern& depfile) { depfile_ = depfile; } 46 47 // Response file contents. Empty means no response file. rsp_file_contents()48 SubstitutionList& rsp_file_contents() { return rsp_file_contents_; } rsp_file_contents()49 const SubstitutionList& rsp_file_contents() const { 50 return rsp_file_contents_; 51 } uses_rsp_file()52 bool uses_rsp_file() const { return !rsp_file_contents_.list().empty(); } 53 54 // Pool option pool()55 const LabelPtrPair<Pool>& pool() const { return pool_; } set_pool(LabelPtrPair<Pool> pool)56 void set_pool(LabelPtrPair<Pool> pool) { pool_ = std::move(pool); } 57 58 private: 59 SourceFile script_; 60 SubstitutionList args_; 61 SubstitutionList outputs_; 62 SubstitutionPattern depfile_; 63 SubstitutionList rsp_file_contents_; 64 LabelPtrPair<Pool> pool_; 65 66 ActionValues(const ActionValues&) = delete; 67 ActionValues& operator=(const ActionValues&) = delete; 68 }; 69 70 #endif // TOOLS_GN_ACTION_VALUES_H_ 71