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_GYP_HELPER_H_
6#define TOOLS_GN_GYP_HELPER_H_
7
8#include <string>
9
10#include "base/basictypes.h"
11
12class Err;
13class SourceDir;
14class SourceFile;
15class Target;
16
17// Danger this class is NOT threadsafe and reads the targets in a
18// non-threadsafe way, so this should only be used in single-threaded mode.
19class GypHelper {
20 public:
21  GypHelper();
22  ~GypHelper();
23
24  SourceFile GetGypFileForTarget(const Target* target, Err* err) const;
25
26  // Returns the name part of the given target. Example "base". This will
27  // include toolchain info for non-default toolchains.
28  std::string GetNameForTarget(const Target* target) const;
29
30  // Returns a full reference to the given target, including the GYP file
31  // and name. Example "<(DEPTH)/base/base.gyp:base".
32  std::string GetFullRefForTarget(const Target* target) const;
33
34  std::string GetFileReference(const SourceFile& file) const;
35  std::string GetDirReference(const SourceDir& dir, bool include_slash) const;
36
37 private:
38  DISALLOW_COPY_AND_ASSIGN(GypHelper);
39};
40
41#endif  // TOOLS_GN_GYP_HELPER_H_
42