-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support of system includes via clang invoke.
- Loading branch information
Showing
20 changed files
with
1,126 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#pragma once | ||
|
||
#include <type_traits> | ||
|
||
|
||
namespace rg3::cpp | ||
{ | ||
struct NullMutex | ||
{ | ||
void lock() {} | ||
void unlock() {} | ||
bool try_lock() { return true; } // NOLINT(*-convert-member-functions-to-static) | ||
}; | ||
|
||
template <typename T> | ||
concept IsMutex = requires(T t) | ||
{ | ||
t.lock(); | ||
t.unlock(); | ||
{ t.try_lock() } -> std::same_as<bool>; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#pragma once | ||
|
||
#include <RG3/Cpp/AbstractMutex.h> | ||
#include <boost/noncopyable.hpp> | ||
|
||
|
||
namespace rg3::cpp | ||
{ | ||
template <typename TMutex> requires (IsMutex<TMutex>) | ||
struct TransactionGuard : boost::noncopyable | ||
{ | ||
TMutex& owned; | ||
|
||
explicit TransactionGuard(TMutex& toBeLocked) : owned(toBeLocked) | ||
{ | ||
owned.lock(); | ||
} | ||
|
||
~TransactionGuard() | ||
{ | ||
owned.unlock(); | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
#include <variant> | ||
|
||
#include <RG3/LLVM/CompilerConfig.h> | ||
|
||
|
||
namespace rg3::llvm | ||
{ | ||
struct CompilerEnvironment | ||
{ | ||
CompilerConfig config {}; | ||
std::string triple {}; | ||
std::string options {}; | ||
std::string versionString {}; | ||
}; | ||
|
||
struct CompilerEnvError | ||
{ | ||
std::string message {}; // Error message | ||
enum class ErrorKind { | ||
EK_UNKNOWN, ///< Really unknown error | ||
EK_NO_PATHS, ///< Failed to get PATH | ||
EK_NO_CLANG_INSTANCE, ///< Failed to invoke clang (Clang instance not found or running with errors) | ||
EK_BAD_CLANG_OUTPUT, ///< Malformed output of clang instance | ||
EK_NO_SYSTEM_INCLUDE_DIRS_FOUND, ///< Not found any system include dirs. Platform specific failure! | ||
EK_UNSUPPORTED_OS ///< Requested feature or whole env recognition not supported yet | ||
} kind { ErrorKind::EK_UNKNOWN }; | ||
}; | ||
|
||
using CompilerEnvResult = std::variant<CompilerEnvError, CompilerEnvironment>; | ||
|
||
struct CompilerConfigDetector | ||
{ | ||
/** | ||
* @brief Trying to recognize where located system compiler and trying to get all information about it's environment | ||
* @return CompilerEnvError on error, CompilerEnvironment when everything is ok | ||
*/ | ||
static CompilerEnvResult detectSystemCompilerEnvironment(); | ||
}; | ||
} |
Oops, something went wrong.