aboutsummaryrefslogtreecommitdiffhomepage
path: root/third_party/def_parser/def_parser.h
blob: 3785914e56d876a9dc4923a1ae32bada5855580c (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
42
43
44
/* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
   file Copyright.txt or https://cmake.org/licensing for details.  */

#ifndef BAZEL_THIRD_PARTY_DEF_PARSER_DEF_PARSER_H
#define BAZEL_THIRD_PARTY_DEF_PARSER_DEF_PARSER_H

#include <set>
#include <stdio.h>
#include <string>

std::wstring AsAbsoluteWindowsPath(const std::string& path);

class DefParser{
 public:
  DefParser() {}

  // This method adds a DEF file.
  // It merges all the symbols found in the DEF file into final result.
  bool AddDefinitionFile(const char* filename);

  // This method adds an Object file.
  // It parses that object file and merge symbols found into final result.
  bool AddObjectFile(const char* filename);

  // Add a file, the function itself will tell which type of file it is.
  bool AddFile(const std::string& filename);

  // Set the DLL name the output DEF file is used for.
  // This will cause a "LIBRARY <DLLName>" entry in the output DEF file.
  void SetDLLName(const std::string& filename);

  // Write all symbols found into the output DEF file.
  void WriteFile(FILE* file);

 private:
  std::set<std::string> Symbols;
  std::set<std::string> DataSymbols;
  std::string DLLName;

  // Returns true if filename ends with .def (case insensitive).
  static bool IsDefFile(const std::string& filename);
};

#endif