diff options
Diffstat (limited to 'tools/common')
-rw-r--r-- | tools/common/debug.cpp | 8 | ||||
-rw-r--r-- | tools/common/debug.h | 1 | ||||
-rw-r--r-- | tools/common/target_detect.h | 66 | ||||
-rw-r--r-- | tools/common/toml.cpp | 6 |
4 files changed, 80 insertions, 1 deletions
diff --git a/tools/common/debug.cpp b/tools/common/debug.cpp index a3fb9956..94d8ed99 100644 --- a/tools/common/debug.cpp +++ b/tools/common/debug.cpp @@ -34,6 +34,14 @@ void Debug_DisablePhase(const char* phase_name) { gmDisabledDebug.insert( ::std::string(phase_name) ); } +void Debug_EnablePhase(const char* phase_name) +{ + auto it = gmDisabledDebug.find(phase_name); + if( it != gmDisabledDebug.end() ) + { + gmDisabledDebug.erase(it); + } +} void Debug_Print(::std::function<void(::std::ostream& os)> cb) { if( !Debug_IsEnabled() ) diff --git a/tools/common/debug.h b/tools/common/debug.h index ace00876..86c88de9 100644 --- a/tools/common/debug.h +++ b/tools/common/debug.h @@ -7,6 +7,7 @@ typedef ::std::function<void(::std::ostream& os)> dbg_cb_t; extern void Debug_SetPhase(const char* phase_name); extern void Debug_DisablePhase(const char* phase_name); +extern void Debug_EnablePhase(const char* phase_name); extern bool Debug_IsEnabled(); extern void Debug_EnterScope(const char* name, dbg_cb_t ); extern void Debug_LeaveScope(const char* name, dbg_cb_t ); diff --git a/tools/common/target_detect.h b/tools/common/target_detect.h new file mode 100644 index 00000000..995ab6a4 --- /dev/null +++ b/tools/common/target_detect.h @@ -0,0 +1,66 @@ +/* + * MRustC - Rust Compiler + * - By John Hodge (Mutabah/thePowersGang) + * + * common/target_detect.h + * - Auto-magical host target detection + */ +#pragma once + +// - Windows (MSVC) +#ifdef _MSC_VER +# if defined(_WIN64) +# define DEFAULT_TARGET_NAME "x86_64-windows-msvc" +# else +# define DEFAULT_TARGET_NAME "x86-windows-msvc" +# endif +// - Linux +#elif defined(__linux__) +# if defined(__amd64__) +# define DEFAULT_TARGET_NAME "x86_64-linux-gnu" +# elif defined(__aarch64__) +# define DEFAULT_TARGET_NAME "aarch64-linux-gnu" +# elif defined(__arm__) +# define DEFAULT_TARGET_NAME "arm-linux-gnu" +# elif defined(__i386__) +# define DEFAULT_TARGET_NAME "i586-linux-gnu" +# else +# warning "Unable to detect a suitable default target (linux-gnu)" +# endif +// - MinGW +#elif defined(__MINGW32__) +# if defined(_WIN64) +# define DEFAULT_TARGET_NAME "x86_64-windows-gnu" +# else +# define DEFAULT_TARGET_NAME "i586-windows-gnu" +# endif +// - NetBSD +#elif defined(__NetBSD__) +# if defined(__amd64__) +# define DEFAULT_TARGET_NAME "x86_64-unknown-netbsd" +# else +# warning "Unable to detect a suitable default target (NetBSD)" +# endif +// - OpenBSD +#elif defined(__OpenBSD__) +# if defined(__amd64__) +# define DEFAULT_TARGET_NAME "x86_64-unknown-openbsd" +# elif defined(__aarch64__) +# define DEFAULT_TARGET_NAME "aarch64-unknown-openbsd" +# elif defined(__arm__) +# define DEFAULT_TARGET_NAME "arm-unknown-openbsd" +# elif defined(__i386__) +# define DEFAULT_TARGET_NAME "i686-unknown-openbsd" +# else +# warning "Unable to detect a suitable default target (OpenBSD)" +# endif +// - Apple devices +#elif defined(__APPLE__) +# define DEFAULT_TARGET_NAME "x86_64-apple-macosx" +// - Unknown +#else +# warning "Unable to detect a suitable default target" +#endif +#ifndef DEFAULT_TARGET_NAME +# define DEFAULT_TARGET_NAME "" +#endif diff --git a/tools/common/toml.cpp b/tools/common/toml.cpp index 9fad0ec4..75a93810 100644 --- a/tools/common/toml.cpp +++ b/tools/common/toml.cpp @@ -170,9 +170,11 @@ TomlKeyValue TomlFile::get_next_value() throw ::std::runtime_error(::format("Unexpected token after key - ", t)); t = Token::lex_from(m_if); + // --- Value --- TomlKeyValue rv; switch(t.m_type) { + // String: Return the string value case Token::Type::String: rv.path = m_current_block; rv.path.insert(rv.path.end(), m_current_composite.begin(), m_current_composite.end()); @@ -180,6 +182,7 @@ TomlKeyValue TomlFile::get_next_value() rv.value = TomlValue { t.m_data }; break; + // Array: Parse the entire list and return as Type::List case Token::Type::SquareOpen: rv.path = m_current_block; rv.path.insert(rv.path.end(), m_current_composite.begin(), m_current_composite.end()); @@ -193,7 +196,8 @@ TomlKeyValue TomlFile::get_next_value() if( t.m_type == Token::Type::SquareClose ) break; - // TODO: Recurse parse a value + // TODO: Recursively parse a value + // TODO: OR, support other value types switch(t.m_type) { case Token::Type::String: |