Fixed the NOMINMAX issue for Windows build with latest termcolor #76, replaced #pragma once with #ifndef-define pairs

This commit is contained in:
Pranav Srinivas Kumar
2021-05-03 09:37:44 -05:00
parent c338b5b280
commit 276d476d4d
18 changed files with 189 additions and 42 deletions

View File

@@ -1,5 +1,6 @@
#pragma once #ifndef INDICATORS_BLOCK_PROGRESS_BAR
#define INDICATORS_BLOCK_PROGRESS_BAR
#include <indicators/color.hpp> #include <indicators/color.hpp>
#include <indicators/details/stream_helper.hpp> #include <indicators/details/stream_helper.hpp>
@@ -285,3 +286,5 @@ public:
}; };
} // namespace indicators } // namespace indicators
#endif

View File

@@ -1,6 +1,9 @@
#pragma once #ifndef INDICATORS_COLOR
#define INDICATORS_COLOR
namespace indicators { namespace indicators {
enum class Color { grey, red, green, yellow, blue, magenta, cyan, white, unspecified }; enum class Color { grey, red, green, yellow, blue, magenta, cyan, white, unspecified };
} }
#endif

View File

@@ -1,5 +1,6 @@
#pragma once #ifndef INDICATORS_CURSOR_CONTROL
#define INDICATORS_CURSOR_CONTROL
#if defined(_MSC_VER) #if defined(_MSC_VER)
#if !defined(NOMINMAX) #if !defined(NOMINMAX)
@@ -34,3 +35,5 @@ static inline void show_console_cursor(bool const show) {
#endif #endif
} // namespace indicators } // namespace indicators
#endif

View File

@@ -1,5 +1,6 @@
#pragma once #ifndef INDICATORS_CURSOR_MOVEMENT
#define INDICATORS_CURSOR_MOVEMENT
#if defined(_MSC_VER) #if defined(_MSC_VER)
#if !defined(NOMINMAX) #if !defined(NOMINMAX)
@@ -45,3 +46,5 @@ static inline void move_left(int cols) { std::cout << "\033[" << cols << "D"; }
#endif #endif
} // namespace indicators } // namespace indicators
#endif

View File

@@ -1,5 +1,6 @@
#pragma once #ifndef INDICATORS_STREAM_HELPER
#define INDICATORS_STREAM_HELPER
#include <indicators/display_width.hpp> #include <indicators/display_width.hpp>
#include <indicators/setting.hpp> #include <indicators/setting.hpp>
@@ -218,3 +219,5 @@ private:
} // namespace details } // namespace details
} // namespace indicators } // namespace indicators
#endif

View File

@@ -1,5 +1,7 @@
#pragma once #ifndef INDICATORS_DISPLAY_WIDTH
#define INDICATORS_DISPLAY_WIDTH
#include <clocale> #include <clocale>
#if __has_include(<codecvt>) #if __has_include(<codecvt>)
#include <codecvt> #include <codecvt>
@@ -312,3 +314,5 @@ static inline int display_width(const std::wstring &input) {
#endif #endif
} // namespace unicode } // namespace unicode
#endif

View File

@@ -1,5 +1,7 @@
#pragma once #ifndef INDICATORS_DYNAMIC_PROGRESS
#define INDICATORS_DYNAMIC_PROGRESS
#include <atomic> #include <atomic>
#include <functional> #include <functional>
#include <indicators/color.hpp> #include <indicators/color.hpp>
@@ -113,3 +115,5 @@ public:
}; };
} // namespace indicators } // namespace indicators
#endif

View File

@@ -1,5 +1,9 @@
#pragma once #ifndef INDICATORS_FONT_STYLE
#define INDICATORS_FONT_STYLE
namespace indicators { namespace indicators {
enum class FontStyle { bold, dark, italic, underline, blink, reverse, concealed, crossed }; enum class FontStyle { bold, dark, italic, underline, blink, reverse, concealed, crossed };
} }
#endif

View File

@@ -1,5 +1,6 @@
#pragma once #ifndef INDICATORS_INDETERMINATE_PROGRESS_BAR
#define INDICATORS_INDETERMINATE_PROGRESS_BAR
#include <indicators/details/stream_helper.hpp> #include <indicators/details/stream_helper.hpp>
@@ -232,3 +233,5 @@ public:
}; };
} // namespace indicators } // namespace indicators
#endif

View File

@@ -1,5 +1,6 @@
#pragma once #ifndef INDICATORS_MULTI_PROGRESS
#define INDICATORS_MULTI_PROGRESS
#include <atomic> #include <atomic>
#include <functional> #include <functional>
#include <iostream> #include <iostream>
@@ -77,3 +78,5 @@ public:
}; };
} // namespace indicators } // namespace indicators
#endif

View File

@@ -1,5 +1,6 @@
#pragma once #ifndef INDICATORS_PROGRESS_BAR
#define INDICATORS_PROGRESS_BAR
#include <indicators/details/stream_helper.hpp> #include <indicators/details/stream_helper.hpp>
@@ -355,3 +356,5 @@ public:
}; };
} // namespace indicators } // namespace indicators
#endif

View File

@@ -1,5 +1,6 @@
#pragma once #ifndef INDICATORS_PROGRESS_SPINNER
#define INDICATORS_PROGRESS_SPINNER
#include <indicators/details/stream_helper.hpp> #include <indicators/details/stream_helper.hpp>
@@ -222,3 +223,5 @@ public:
}; };
} // namespace indicators } // namespace indicators
#endif

View File

@@ -1,6 +1,9 @@
#pragma once #ifndef INDICATORS_PROGRESS_TYPE
#define INDICATORS_PROGRESS_TYPE
namespace indicators { namespace indicators {
enum class ProgressType { incremental, decremental }; enum class ProgressType { incremental, decremental };
} }
#endif

View File

@@ -25,7 +25,8 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.
*/ */
#pragma once #ifndef INDICATORS_SETTING
#define INDICATORS_SETTING
#include <cstddef> #include <cstddef>
#include <indicators/color.hpp> #include <indicators/color.hpp>
@@ -217,3 +218,5 @@ using ProgressType = details::Setting<ProgressType, details::ProgressBarOption::
using Stream = details::Setting<std::ostream &, details::ProgressBarOption::stream>; using Stream = details::Setting<std::ostream &, details::ProgressBarOption::stream>;
} // namespace option } // namespace option
} // namespace indicators } // namespace indicators
#endif

View File

@@ -40,6 +40,11 @@
#if defined(TERMCOLOR_TARGET_POSIX) #if defined(TERMCOLOR_TARGET_POSIX)
# include <unistd.h> # include <unistd.h>
#elif defined(TERMCOLOR_TARGET_WINDOWS) #elif defined(TERMCOLOR_TARGET_WINDOWS)
#if defined(_MSC_VER)
#if !defined(NOMINMAX)
#define NOMINMAX
#endif
#endif
# include <io.h> # include <io.h>
# include <windows.h> # include <windows.h>
#endif #endif

View File

@@ -1,5 +1,6 @@
#pragma once #ifndef INDICATORS_TERMINAL_SIZE
#define INDICATORS_TERMINAL_SIZE
#include <utility> #include <utility>
@@ -40,3 +41,4 @@ static inline size_t terminal_width() { return terminal_size().second; }
#endif #endif
#endif

View File

@@ -1,20 +1,35 @@
#pragma once #ifndef INDICATORS_COLOR
#define INDICATORS_COLOR
namespace indicators { namespace indicators {
enum class Color { grey, red, green, yellow, blue, magenta, cyan, white, unspecified }; enum class Color { grey, red, green, yellow, blue, magenta, cyan, white, unspecified };
} }
#pragma once #endif
#ifndef INDICATORS_FONT_STYLE
#define INDICATORS_FONT_STYLE
namespace indicators { namespace indicators {
enum class FontStyle { bold, dark, italic, underline, blink, reverse, concealed, crossed }; enum class FontStyle { bold, dark, italic, underline, blink, reverse, concealed, crossed };
} }
#pragma once #endif
#ifndef INDICATORS_PROGRESS_TYPE
#define INDICATORS_PROGRESS_TYPE
namespace indicators { namespace indicators {
enum class ProgressType { incremental, decremental }; enum class ProgressType { incremental, decremental };
} }
#endif
//! //!
//! termcolor //! termcolor
//! ~~~~~~~~~ //! ~~~~~~~~~
@@ -57,6 +72,11 @@ enum class ProgressType { incremental, decremental };
#if defined(TERMCOLOR_TARGET_POSIX) #if defined(TERMCOLOR_TARGET_POSIX)
# include <unistd.h> # include <unistd.h>
#elif defined(TERMCOLOR_TARGET_WINDOWS) #elif defined(TERMCOLOR_TARGET_WINDOWS)
#if defined(_MSC_VER)
#if !defined(NOMINMAX)
#define NOMINMAX
#endif
#endif
# include <io.h> # include <io.h>
# include <windows.h> # include <windows.h>
#endif #endif
@@ -927,7 +947,10 @@ namespace termcolor
#endif // TERMCOLOR_HPP_ #endif // TERMCOLOR_HPP_
#pragma once
#ifndef INDICATORS_TERMINAL_SIZE
#define INDICATORS_TERMINAL_SIZE
#include <utility> #include <utility>
@@ -968,6 +991,8 @@ static inline size_t terminal_width() { return terminal_size().second; }
#endif #endif
#endif
/* /*
Activity Indicators for Modern C++ Activity Indicators for Modern C++
@@ -995,29 +1020,39 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.
*/ */
#pragma once #ifndef INDICATORS_SETTING
#define INDICATORS_SETTING
#include <cstddef> #include <cstddef>
// #include <indicators/color.hpp> // #include <indicators/color.hpp>
#ifndef INDICATORS_COLOR
#define INDICATORS_COLOR
namespace indicators { namespace indicators {
enum class Color { grey, red, green, yellow, blue, magenta, cyan, white, unspecified }; enum class Color { grey, red, green, yellow, blue, magenta, cyan, white, unspecified };
} }
#endif
// #include <indicators/font_style.hpp> // #include <indicators/font_style.hpp>
#ifndef INDICATORS_FONT_STYLE
#define INDICATORS_FONT_STYLE
namespace indicators { namespace indicators {
enum class FontStyle { bold, dark, italic, underline, blink, reverse, concealed, crossed }; enum class FontStyle { bold, dark, italic, underline, blink, reverse, concealed, crossed };
} }
// #include <indicators/progress_type.hpp> #endif
// #include <indicators/progress_type.hpp>
#ifndef INDICATORS_PROGRESS_TYPE
#define INDICATORS_PROGRESS_TYPE
namespace indicators { namespace indicators {
enum class ProgressType { incremental, decremental }; enum class ProgressType { incremental, decremental };
} }
#endif
#include <string> #include <string>
#include <tuple> #include <tuple>
#include <type_traits> #include <type_traits>
@@ -1205,7 +1240,11 @@ using Stream = details::Setting<std::ostream &, details::ProgressBarOption::stre
} // namespace option } // namespace option
} // namespace indicators } // namespace indicators
#pragma once #endif
#ifndef INDICATORS_CURSOR_CONTROL
#define INDICATORS_CURSOR_CONTROL
#if defined(_MSC_VER) #if defined(_MSC_VER)
#if !defined(NOMINMAX) #if !defined(NOMINMAX)
@@ -1240,7 +1279,12 @@ static inline void show_console_cursor(bool const show) {
#endif #endif
} // namespace indicators } // namespace indicators
#pragma once
#endif
#ifndef INDICATORS_CURSOR_MOVEMENT
#define INDICATORS_CURSOR_MOVEMENT
#if defined(_MSC_VER) #if defined(_MSC_VER)
#if !defined(NOMINMAX) #if !defined(NOMINMAX)
@@ -1286,9 +1330,16 @@ static inline void move_left(int cols) { std::cout << "\033[" << cols << "D"; }
#endif #endif
} // namespace indicators } // namespace indicators
#pragma once
#endif
#ifndef INDICATORS_STREAM_HELPER
#define INDICATORS_STREAM_HELPER
// #include <indicators/display_width.hpp> // #include <indicators/display_width.hpp>
#ifndef INDICATORS_DISPLAY_WIDTH
#define INDICATORS_DISPLAY_WIDTH
#include <clocale> #include <clocale>
#if __has_include(<codecvt>) #if __has_include(<codecvt>)
@@ -1603,6 +1654,7 @@ static inline int display_width(const std::wstring &input) {
} // namespace unicode } // namespace unicode
#endif
// #include <indicators/setting.hpp> // #include <indicators/setting.hpp>
/* /*
Activity Indicators for Modern C++ Activity Indicators for Modern C++
@@ -1630,7 +1682,8 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.
*/ */
#ifndef INDICATORS_SETTING
#define INDICATORS_SETTING
#include <cstddef> #include <cstddef>
// #include <indicators/color.hpp> // #include <indicators/color.hpp>
@@ -1823,6 +1876,7 @@ using Stream = details::Setting<std::ostream &, details::ProgressBarOption::stre
} // namespace option } // namespace option
} // namespace indicators } // namespace indicators
#endif
// #include <indicators/termcolor.hpp>//! // #include <indicators/termcolor.hpp>//!
//! termcolor //! termcolor
//! ~~~~~~~~~ //! ~~~~~~~~~
@@ -1865,6 +1919,11 @@ using Stream = details::Setting<std::ostream &, details::ProgressBarOption::stre
#if defined(TERMCOLOR_TARGET_POSIX) #if defined(TERMCOLOR_TARGET_POSIX)
# include <unistd.h> # include <unistd.h>
#elif defined(TERMCOLOR_TARGET_WINDOWS) #elif defined(TERMCOLOR_TARGET_WINDOWS)
#if defined(_MSC_VER)
#if !defined(NOMINMAX)
#define NOMINMAX
#endif
#endif
# include <io.h> # include <io.h>
# include <windows.h> # include <windows.h>
#endif #endif
@@ -2949,10 +3008,16 @@ private:
} // namespace details } // namespace details
} // namespace indicators } // namespace indicators
#pragma once
#endif
#ifndef INDICATORS_PROGRESS_BAR
#define INDICATORS_PROGRESS_BAR
// #include <indicators/details/stream_helper.hpp> // #include <indicators/details/stream_helper.hpp>
#ifndef INDICATORS_STREAM_HELPER
#define INDICATORS_STREAM_HELPER
// #include <indicators/display_width.hpp> // #include <indicators/display_width.hpp>
// #include <indicators/setting.hpp> // #include <indicators/setting.hpp>
@@ -3172,6 +3237,8 @@ private:
} // namespace details } // namespace details
} // namespace indicators } // namespace indicators
#endif
#include <algorithm> #include <algorithm>
#include <atomic> #include <atomic>
#include <chrono> #include <chrono>
@@ -3179,7 +3246,8 @@ private:
// #include <indicators/color.hpp> // #include <indicators/color.hpp>
// #include <indicators/setting.hpp> // #include <indicators/setting.hpp>
// #include <indicators/terminal_size.hpp> // #include <indicators/terminal_size.hpp>
#ifndef INDICATORS_TERMINAL_SIZE
#define INDICATORS_TERMINAL_SIZE
#include <utility> #include <utility>
@@ -3220,7 +3288,7 @@ static inline size_t terminal_width() { return terminal_size().second; }
#endif #endif
#endif
#include <iomanip> #include <iomanip>
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
@@ -3567,7 +3635,11 @@ public:
} // namespace indicators } // namespace indicators
#pragma once #endif
#ifndef INDICATORS_BLOCK_PROGRESS_BAR
#define INDICATORS_BLOCK_PROGRESS_BAR
// #include <indicators/color.hpp> // #include <indicators/color.hpp>
// #include <indicators/details/stream_helper.hpp> // #include <indicators/details/stream_helper.hpp>
@@ -3854,7 +3926,11 @@ public:
} // namespace indicators } // namespace indicators
#pragma once #endif
#ifndef INDICATORS_INDETERMINATE_PROGRESS_BAR
#define INDICATORS_INDETERMINATE_PROGRESS_BAR
// #include <indicators/details/stream_helper.hpp> // #include <indicators/details/stream_helper.hpp>
@@ -4088,7 +4164,11 @@ public:
} // namespace indicators } // namespace indicators
#pragma once #endif
#ifndef INDICATORS_MULTI_PROGRESS
#define INDICATORS_MULTI_PROGRESS
#include <atomic> #include <atomic>
#include <functional> #include <functional>
#include <iostream> #include <iostream>
@@ -4097,7 +4177,8 @@ public:
// #include <indicators/color.hpp> // #include <indicators/color.hpp>
// #include <indicators/cursor_movement.hpp> // #include <indicators/cursor_movement.hpp>
#ifndef INDICATORS_CURSOR_MOVEMENT
#define INDICATORS_CURSOR_MOVEMENT
#if defined(_MSC_VER) #if defined(_MSC_VER)
#if !defined(NOMINMAX) #if !defined(NOMINMAX)
@@ -4143,6 +4224,8 @@ static inline void move_left(int cols) { std::cout << "\033[" << cols << "D"; }
#endif #endif
} // namespace indicators } // namespace indicators
#endif
// #include <indicators/details/stream_helper.hpp> // #include <indicators/details/stream_helper.hpp>
namespace indicators { namespace indicators {
@@ -4213,7 +4296,12 @@ public:
} // namespace indicators } // namespace indicators
#pragma once #endif
#ifndef INDICATORS_DYNAMIC_PROGRESS
#define INDICATORS_DYNAMIC_PROGRESS
#include <atomic> #include <atomic>
#include <functional> #include <functional>
// #include <indicators/color.hpp> // #include <indicators/color.hpp>
@@ -4328,7 +4416,11 @@ public:
} // namespace indicators } // namespace indicators
#pragma once #endif
#ifndef INDICATORS_PROGRESS_SPINNER
#define INDICATORS_PROGRESS_SPINNER
// #include <indicators/details/stream_helper.hpp> // #include <indicators/details/stream_helper.hpp>
@@ -4551,3 +4643,6 @@ public:
}; };
} // namespace indicators } // namespace indicators
#endif

View File

@@ -62,7 +62,7 @@ class Amalgamation(object):
return None return None
def __init__(self, args): def __init__(self, args):
with open(args.config, 'r', encoding="utf8") as f: with open(args.config, 'r') as f:
config = json.loads(f.read()) config = json.loads(f.read())
for key in config: for key in config:
setattr(self, key, config[key]) setattr(self, key, config[key])
@@ -77,7 +77,7 @@ class Amalgamation(object):
amalgamation = "" amalgamation = ""
if self.prologue: if self.prologue:
with open(self.prologue, 'r', encoding="utf8") as f: with open(self.prologue, 'r') as f:
amalgamation += datetime.datetime.now().strftime(f.read()) amalgamation += datetime.datetime.now().strftime(f.read())
if self.verbose: if self.verbose:
@@ -92,7 +92,7 @@ class Amalgamation(object):
# actual_path = self.actual_path(file_path) # actual_path = self.actual_path(file_path)
print(" - processing \"{0}\"".format(file_path)) print(" - processing \"{0}\"".format(file_path))
t = TranslationUnit(file_path, self, True) t = TranslationUnit(file_path, self, True)
amalgamation += t.content amalgamation += t.content + "\n\n"
with open(self.target, 'w', encoding="utf8") as f: with open(self.target, 'w', encoding="utf8") as f:
f.write(amalgamation) f.write(amalgamation)