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