2014-01-13 14:08:43 -05:00
|
|
|
// Copyright (C) 2011, 2012 Google Inc.
|
2013-01-18 20:22:36 -05:00
|
|
|
//
|
|
|
|
// This file is part of YouCompleteMe.
|
|
|
|
//
|
|
|
|
// YouCompleteMe is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// YouCompleteMe is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
#ifndef COMPILATIONDATABASE_H_ZT7MQXPG
|
|
|
|
#define COMPILATIONDATABASE_H_ZT7MQXPG
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
|
|
|
#include <boost/utility.hpp>
|
2013-01-23 20:23:51 -05:00
|
|
|
#include <boost/shared_ptr.hpp>
|
2013-09-30 20:30:46 -04:00
|
|
|
#include <boost/thread/mutex.hpp>
|
2013-01-18 20:22:36 -05:00
|
|
|
#include <clang-c/CXCompilationDatabase.h>
|
|
|
|
|
2013-09-30 20:30:46 -04:00
|
|
|
|
2013-01-19 23:03:32 -05:00
|
|
|
namespace YouCompleteMe {
|
2013-01-18 20:22:36 -05:00
|
|
|
|
2013-01-23 20:23:51 -05:00
|
|
|
struct CompilationInfoForFile {
|
|
|
|
std::vector< std::string > compiler_flags_;
|
|
|
|
std::string compiler_working_dir_;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-10-14 13:22:57 -04:00
|
|
|
// Access to Clang's internal CompilationDatabase. This class is thread-safe.
|
2013-01-19 23:03:32 -05:00
|
|
|
class CompilationDatabase : boost::noncopyable {
|
2013-01-18 20:22:36 -05:00
|
|
|
public:
|
2013-01-19 23:03:32 -05:00
|
|
|
CompilationDatabase( const std::string &path_to_directory );
|
2013-01-18 20:22:36 -05:00
|
|
|
~CompilationDatabase();
|
|
|
|
|
|
|
|
bool DatabaseSuccessfullyLoaded();
|
|
|
|
|
2013-10-14 13:22:57 -04:00
|
|
|
// Returns true when a separate thread is already getting flags; this is
|
|
|
|
// useful so that the caller doesn't need to block.
|
|
|
|
bool AlreadyGettingFlags();
|
|
|
|
|
|
|
|
// NOTE: Multiple calls to this function from separate threads will be
|
|
|
|
// serialized since Clang internals are not thread-safe.
|
2013-01-23 20:23:51 -05:00
|
|
|
CompilationInfoForFile GetCompilationInfoForFile(
|
2013-02-03 00:49:55 -05:00
|
|
|
const std::string &path_to_file );
|
2013-01-18 20:22:36 -05:00
|
|
|
|
|
|
|
private:
|
2013-01-23 20:23:51 -05:00
|
|
|
|
2013-01-18 20:22:36 -05:00
|
|
|
bool is_loaded_;
|
|
|
|
CXCompilationDatabase compilation_database_;
|
2013-09-30 20:30:46 -04:00
|
|
|
boost::mutex compilation_database_mutex_;
|
2013-01-18 20:22:36 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace YouCompleteMe
|
|
|
|
|
|
|
|
#endif /* end of include guard: COMPILATIONDATABASE_H_ZT7MQXPG */
|