blob: c147a66064b78fe22e94ac2a883159b1de20c49b [file] [log] [blame]
Dejan Mircevskib6fe02f2016-01-07 13:44:22 -05001// Copyright (c) 2015-2016 The Khronos Group Inc.
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +01002//
David Neto9fc86582016-09-01 15:33:59 -04003// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +01006//
David Neto9fc86582016-09-01 15:33:59 -04007// http://www.apache.org/licenses/LICENSE-2.0
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +01008//
David Neto9fc86582016-09-01 15:33:59 -04009// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +010014
15#include "print.h"
16
Derek Sollenberger009c4352016-04-18 10:59:47 -040017#if defined(SPIRV_ANDROID) || defined(SPIRV_LINUX) || defined(SPIRV_MAC)
David Neto01656362015-11-20 10:44:41 -050018namespace libspirv {
19
Andrew Woloszyn4c657bf2016-03-18 14:13:16 -040020clr::reset::operator const char*() { return "\x1b[0m"; }
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +010021
Andrew Woloszyn4c657bf2016-03-18 14:13:16 -040022clr::grey::operator const char*() { return "\x1b[1;30m"; }
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +010023
Andrew Woloszyn4c657bf2016-03-18 14:13:16 -040024clr::red::operator const char*() { return "\x1b[31m"; }
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +010025
Andrew Woloszyn4c657bf2016-03-18 14:13:16 -040026clr::green::operator const char*() { return "\x1b[32m"; }
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +010027
Andrew Woloszyn4c657bf2016-03-18 14:13:16 -040028clr::yellow::operator const char*() { return "\x1b[33m"; }
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +010029
Andrew Woloszyn4c657bf2016-03-18 14:13:16 -040030clr::blue::operator const char*() { return "\x1b[34m"; }
David Neto01656362015-11-20 10:44:41 -050031
32} // namespace libspirv
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +010033#elif defined(SPIRV_WINDOWS)
David Neto7c58c1d2016-02-29 01:01:04 -050034#include <windows.h>
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +010035
David Neto01656362015-11-20 10:44:41 -050036namespace libspirv {
37
Lei Zhang1a0334e2015-11-02 09:41:20 -050038clr::reset::operator const char*() {
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +010039 const DWORD color = 0Xf;
40 HANDLE hConsole;
41 hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
42 SetConsoleTextAttribute(hConsole, color);
43 hConsole = GetStdHandle(STD_ERROR_HANDLE);
44 SetConsoleTextAttribute(hConsole, color);
45 return "";
46}
47
Lei Zhang1a0334e2015-11-02 09:41:20 -050048clr::grey::operator const char*() {
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +010049 const DWORD color = 0x8;
50 HANDLE hConsole;
51 hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
52 SetConsoleTextAttribute(hConsole, color);
53 hConsole = GetStdHandle(STD_ERROR_HANDLE);
54 SetConsoleTextAttribute(hConsole, color);
55 return "";
56}
57
Lei Zhang1a0334e2015-11-02 09:41:20 -050058clr::red::operator const char*() {
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +010059 const DWORD color = 0x4;
60 HANDLE hConsole;
61 hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
62 SetConsoleTextAttribute(hConsole, color);
63 hConsole = GetStdHandle(STD_ERROR_HANDLE);
64 SetConsoleTextAttribute(hConsole, color);
65 return "";
66}
67
Lei Zhang1a0334e2015-11-02 09:41:20 -050068clr::green::operator const char*() {
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +010069 const DWORD color = 0x2;
70 HANDLE hConsole;
71 hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
72 SetConsoleTextAttribute(hConsole, color);
73 hConsole = GetStdHandle(STD_ERROR_HANDLE);
74 SetConsoleTextAttribute(hConsole, color);
75 return "";
76}
77
Lei Zhang1a0334e2015-11-02 09:41:20 -050078clr::yellow::operator const char*() {
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +010079 const DWORD color = 0x6;
80 HANDLE hConsole;
81 hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
82 SetConsoleTextAttribute(hConsole, color);
83 hConsole = GetStdHandle(STD_ERROR_HANDLE);
84 SetConsoleTextAttribute(hConsole, color);
85 return "";
86}
87
Lei Zhang1a0334e2015-11-02 09:41:20 -050088clr::blue::operator const char*() {
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +010089 const DWORD color = 0x1;
90 HANDLE hConsole;
91 hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
92 SetConsoleTextAttribute(hConsole, color);
93 hConsole = GetStdHandle(STD_ERROR_HANDLE);
94 SetConsoleTextAttribute(hConsole, color);
95 return "";
96}
David Neto01656362015-11-20 10:44:41 -050097
98} // namespace libspirv
Ben Vanik01c8d7a2015-11-22 08:32:53 -080099#else
100namespace libspirv {
101
102clr::reset::operator const char*() { return ""; }
103
104clr::grey::operator const char*() { return ""; }
105
106clr::red::operator const char*() { return ""; }
107
108clr::green::operator const char*() { return ""; }
109
110clr::yellow::operator const char*() { return ""; }
111
112clr::blue::operator const char*() { return ""; }
113
114} // namespace libspirv
Kenneth Benzie (Benie)83e5a292015-05-22 18:26:19 +0100115#endif