blob: 3785914e56d876a9dc4923a1ae32bada5855580c [file] [log] [blame]
Yun Peng66437a02017-08-25 09:59:14 +02001/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 file Copyright.txt or https://cmake.org/licensing for details. */
3
4#ifndef BAZEL_THIRD_PARTY_DEF_PARSER_DEF_PARSER_H
5#define BAZEL_THIRD_PARTY_DEF_PARSER_DEF_PARSER_H
6
7#include <set>
8#include <stdio.h>
9#include <string>
10
Yun Pengf203db02017-11-15 10:50:14 +010011std::wstring AsAbsoluteWindowsPath(const std::string& path);
12
Yun Peng66437a02017-08-25 09:59:14 +020013class DefParser{
14 public:
15 DefParser() {}
16
17 // This method adds a DEF file.
18 // It merges all the symbols found in the DEF file into final result.
19 bool AddDefinitionFile(const char* filename);
20
21 // This method adds an Object file.
22 // It parses that object file and merge symbols found into final result.
23 bool AddObjectFile(const char* filename);
24
25 // Add a file, the function itself will tell which type of file it is.
26 bool AddFile(const std::string& filename);
27
28 // Set the DLL name the output DEF file is used for.
29 // This will cause a "LIBRARY <DLLName>" entry in the output DEF file.
30 void SetDLLName(const std::string& filename);
31
32 // Write all symbols found into the output DEF file.
33 void WriteFile(FILE* file);
34
35 private:
36 std::set<std::string> Symbols;
37 std::set<std::string> DataSymbols;
38 std::string DLLName;
39
40 // Returns true if filename ends with .def (case insensitive).
41 static bool IsDefFile(const std::string& filename);
42};
43
44#endif