diff options
author | Bertrand Bellenot <Bertrand.Bellenot@cern.ch> | 2016-12-09 11:22:23 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2017-03-21 14:02:33 (GMT) |
commit | 845c482448e5b60f4934a48eea9c8c1e466f8fea (patch) | |
tree | 84e3174d3516bd1efd4986e7c238ca636fa8b911 /Source/bindexplib.cxx | |
parent | 4f90e7931487195b5d540fbaa5dad1c90b26cee1 (diff) | |
download | CMake-845c482448e5b60f4934a48eea9c8c1e466f8fea.zip CMake-845c482448e5b60f4934a48eea9c8c1e466f8fea.tar.gz CMake-845c482448e5b60f4934a48eea9c8c1e466f8fea.tar.bz2 |
bindexplib: Add method for parsing and integrating `.def` files
Diffstat (limited to 'Source/bindexplib.cxx')
-rw-r--r-- | Source/bindexplib.cxx | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/Source/bindexplib.cxx b/Source/bindexplib.cxx index 7d61ea6..47c7565 100644 --- a/Source/bindexplib.cxx +++ b/Source/bindexplib.cxx @@ -64,7 +64,7 @@ #include "bindexplib.h" #include <cmsys/Encoding.hxx> -#include <fstream> +#include <cmsys/FStream.hxx> #include <iostream> #include <windows.h> @@ -429,6 +429,34 @@ bool bindexplib::AddObjectFile(const char* filename) return DumpFile(filename, this->Symbols, this->DataSymbols); } +bool bindexplib::AddDefinitionFile(const char* filename) +{ + cmsys::ifstream infile(filename); + if (!infile) { + fprintf(stderr, "Couldn't open definition file '%s'\n", filename); + return false; + } + std::string str; + while (std::getline(infile, str)) { + // skip the LIBRAY and EXPORTS lines (if any) + if ((str.compare(0,7,"LIBRARY") == 0) || + (str.compare(0,7,"EXPORTS") == 0)) { + continue; + } + // remove leading tabs & spaces + str.erase(0, str.find_first_not_of(" \t")); + std::size_t found = str.find(" \t DATA"); + if (found != std::string::npos) { + str.erase (found, std::string::npos); + this->DataSymbols.insert(str); + } else { + this->Symbols.insert(str); + } + } + infile.close(); + return true; +} + void bindexplib::WriteFile(FILE* file) { fprintf(file,"EXPORTS \n"); |