summaryrefslogtreecommitdiffstats
path: root/tools/gn/gyp_helper.h
blob: d3b15eccd186bb402fa77760bc6f9dab1131850f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef TOOLS_GN_GYP_HELPER_H_
#define TOOLS_GN_GYP_HELPER_H_

#include <string>

#include "base/basictypes.h"

class Err;
class SourceDir;
class SourceFile;
class Target;

// Danger this class is NOT threadsafe and reads the targets in a
// non-threadsafe way, so this should only be used in single-threaded mode.
class GypHelper {
 public:
  GypHelper();
  ~GypHelper();

  SourceFile GetGypFileForTarget(const Target* target, Err* err) const;

  // Returns the name part of the given target. Example "base". This will
  // include toolchain info for non-default toolchains.
  std::string GetNameForTarget(const Target* target) const;

  // Returns a full reference to the given target, including the GYP file
  // and name. Example "<(DEPTH)/base/base.gyp:base".
  std::string GetFullRefForTarget(const Target* target) const;

  std::string GetFileReference(const SourceFile& file) const;
  std::string GetDirReference(const SourceDir& dir, bool include_slash) const;

 private:
  DISALLOW_COPY_AND_ASSIGN(GypHelper);
};

#endif  // TOOLS_GN_GYP_HELPER_H_