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/basictypes.h"
12#include "tools/gn/source_file.h"
13#include "tools/gn/substitution_list.h"
14
15class Target;
16
17// Holds the values (outputs, args, script name, etc.) for either an action or
18// an action_foreach target.
19class ActionValues {
20 public:
21  ActionValues();
22  ~ActionValues();
23
24  // Filename of the script to execute.
25  const SourceFile& script() const { return script_; }
26  void set_script(const SourceFile& s) { script_ = s; }
27
28  // Arguments to the script.
29  SubstitutionList& args() { return args_; }
30  const SubstitutionList& args() const { return args_; }
31
32  // Files created by the script. These are strings rather than SourceFiles
33  // since they will often contain {{source expansions}}.
34  SubstitutionList& outputs() { return outputs_; }
35  const SubstitutionList& outputs() const { return outputs_; }
36
37  // Expands the outputs() above to the final SourceFile list.
38  void GetOutputsAsSourceFiles(const Target* target,
39                               std::vector<SourceFile>* result) const;
40
41  // Depfile generated by the script.
42  const SubstitutionPattern& depfile() const { return depfile_; }
43  bool has_depfile() const { return !depfile_.ranges().empty(); }
44  void set_depfile(const SubstitutionPattern& depfile) { depfile_ = depfile; }
45
46 private:
47  SourceFile script_;
48  SubstitutionList args_;
49  SubstitutionList outputs_;
50  SubstitutionPattern depfile_;
51
52  DISALLOW_COPY_AND_ASSIGN(ActionValues);
53};
54
55#endif  // TOOLS_GN_ACTION_VALUES_H_
56