Skip to content

Commit 965a1df

Browse files
authored
Enable appveyor builds. (#3)
1 parent bb7db4f commit 965a1df

File tree

8 files changed

+77
-25
lines changed

8 files changed

+77
-25
lines changed

.appveyor.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
branches:
2+
only:
3+
- master
4+
- appveyor
5+
6+
version: '{branch}-{build}'
7+
8+
os:
9+
- Visual Studio 2019 Preview
10+
11+
configuration:
12+
#- Debug
13+
- Release
14+
15+
skip_commits:
16+
files:
17+
- support/**/*
18+
- .build_scripts/**/*
19+
20+
environment:
21+
matrix:
22+
- GENERATOR: Visual Studio 16 2019
23+
24+
init: []
25+
26+
install:
27+
- git submodule update --init --recursive
28+
- cd external_libs
29+
- cd ..
30+
31+
before_build:
32+
- if defined BINDIR (set "PATH=%BINDIR%;%PATH:C:\Program Files\Git\usr\bin;=%")
33+
- md build_dir
34+
- cd build_dir
35+
- cmake -Wno-dev -DEXTLOG_TESTS=ON -DEXTLOG_EXAMPLES=ON --config "%CONFIGURATION%" -G "%GENERATOR%" ..
36+
37+
build_script:
38+
- cmake --build . --config "%CONFIGURATION%"
39+
40+
test_script:
41+
- ctest -C "%CONFIGURATION%" --output-on-failure

CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ set(ext_common_compile_definitions
6161
)
6262

6363

64-
add_library(ext-logging ${ext-logging-source} ${ext-logging-header})
64+
add_library(ext-logging SHARED ${ext-logging-source} ${ext-logging-header})
6565
target_include_directories(ext-logging PUBLIC
6666
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
6767
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include>
@@ -122,9 +122,9 @@ if(COMMAND ext_install)
122122
endif()
123123

124124
add_custom_target(
125-
update_logging_version ALL
125+
ext_logging_version_update ALL
126126
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
127127
COMMAND ${CMAKE_COMMAND}
128-
-D "EXT_GIT_VERSION_OUT_FILE=${CMAKE_CURRENT_BINARY_DIR}/ext_version.hpp"
128+
-D "EXT_GIT_VERSION_OUT_FILE=${CMAKE_CURRENT_BINARY_DIR}/ext_logging_version.hpp"
129129
-P "${CMAKE_CURRENT_SOURCE_DIR}/cmake/ext_script_git_version.cmake"
130130
)

README.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
|travis|
1+
|travis| |appveyor|
22

33
Simple Logging Library
44
======================
5+
Known Issues:
6+
- Fails on Windows/VC - `init_seg` problem (used to work)
57

68
Advantages:
79
- Has variable and constexpr activation level checks. The constexpr check
@@ -26,3 +28,6 @@ Disadvantages:
2628

2729
.. |travis| image:: https://travis-ci.org/extcpp/logging.svg?branch=master
2830
:target: https://travis-ci.org/extcpp/logging
31+
32+
.. |appveyor| image:: https://ci.appveyor.com/api/projects/status/7evseehi5ejvbgpc/branch/master?svg=true
33+
:target: https://ci.appveyor.com/project/obiwahn/logging

include/ext/logging.hpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,16 @@
8383
#define EXT_LOGCONST2(id, macro_level_) _EXT_LOG_INTERNAL_ADD_PREFIX_CONST(id, no_topic, macro_level_, true)
8484
#define EXT_LOGCONST1(id) _EXT_LOG_INTERNAL_ADD_PREFIX_CONST(id, no_topic, EXT_LOGGING_DEFAULT_LEVEL, true)
8585

86-
#define EXT_LOGCONST(...) \
87-
_EXT_LOG_SELECT5TH_PARAMETER(__VA_ARGS__, EXT_LOGCONST4, EXT_LOGCONST3, EXT_LOGCONST2, EXT_LOGCONST1, ) \
88-
(__VA_ARGS__)
86+
#ifdef EXT_COMPILER_VC
87+
#define _EXT_LOG_EXPAND(x) x
88+
#define EXT_LOGCONST(...) \
89+
_EXT_LOG_SELECT5TH_PARAMETER(_EXT_LOG_EXPAND(__VA_ARGS__), EXT_LOGCONST4, EXT_LOGCONST3, EXT_LOGCONST2, EXT_LOGCONST1, ) \
90+
(_EXT_LOG_EXPAND(__VA_ARGS__))
91+
#else
92+
#define EXT_LOGCONST(...) \
93+
_EXT_LOG_SELECT5TH_PARAMETER(__VA_ARGS__, EXT_LOGCONST4, EXT_LOGCONST3, EXT_LOGCONST2, EXT_LOGCONST1, ) \
94+
(__VA_ARGS__)
95+
#endif // EXT_COMPILER_VC
8996

9097
#define EXT_DEV _EXT_LOG_INTERNAL_ADD_PREFIX_CONST("@@@@", dev, EXT_LOGGING_DEFAULT_LEVEL, true)
9198
#define EXT_DEV_IF_CONST(cond_) _EXT_LOG_INTERNAL_ADD_PREFIX_CONST("@@@@", dev, EXT_LOGGING_DEFAULT_LEVEL, cond_)

include/ext/logging/definitions.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ struct logtopic {
6161
} // namespace _detail
6262

6363
namespace configuration {
64-
extern std::map<int, _detail::logtopic*> topics;
64+
EXT_EXPORT_VC extern std::map<int, _detail::logtopic*> topics;
6565
// logging is configured globally via these variables
6666
// configure logging before you start logging!!!
6767
EXT_EXPORT_VC extern bool prefix_newline;

src/logging.cpp

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ bool configuration::vim{false};
3434
bool configuration::gdb{false};
3535
#endif
3636
std::ostream* configuration::stream = &std::cout;
37-
38-
EXT_INIT_PRIORITY_VC_LOW
3937
/////////////////////////////////////////////////////////////////////////////
4038

4139
// the logger is a class that creates the log stream and writes
@@ -55,15 +53,12 @@ _detail::logger::logger(
5553
}
5654

5755
if (configuration::gdb) {
58-
#ifndef _WIN32
59-
_ss << "# break " << ext::util::filename(file_name) << ":" << line_no << "\n";
60-
#endif
56+
_ss << "# break " << ext::util::filename(file_name, true, true) << ":" << line_no << "\n";
6157
}
6258
#endif
6359

64-
if (true) {
65-
_ss << "[" << id << "] ";
66-
}
60+
// id
61+
_ss << "[" << id << "] ";
6762
// log level
6863
_ss << level_to_str(level_);
6964

@@ -75,11 +70,7 @@ _detail::logger::logger(
7570
// log filename
7671
if (configuration::filename) {
7772
_ss << " "
78-
#ifndef _WIN32
79-
<< ext::util::filename(file_name)
80-
#else
81-
<< file_name
82-
#endif
73+
<< ext::util::filename(file_name, true, true)
8374
<< ":" << line_no;
8475
}
8576

tests/logging.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ struct LoggingTest : public ::testing::Test {
2323
#ifdef EXT_LOGGING_ENABLE_VIM_GDB
2424
configuration::gdb = false;
2525
configuration::vim = false;
26-
#endif
26+
#endif // EXT_LOGGING_ENABLE_VIM_GDB
2727
configuration::prefix_newline = false;
2828
configuration::append_newline = true;
2929
configuration::filename = true;
@@ -37,9 +37,13 @@ struct LoggingTest : public ::testing::Test {
3737
}
3838

3939
std::string path() {
40+
#ifdef EXT_COMPILER_VC
41+
return "logging.cpp";
42+
#else
4043
auto path = std::filesystem::current_path().parent_path().parent_path().parent_path() / "logging" / "tests" /
4144
"logging.cpp";
4245
return path.string();
46+
#endif // EXT_COMPILER_VC
4347
};
4448

4549
std::string line() {
@@ -57,6 +61,7 @@ TEST_F(LoggingTest, logging_dev) {
5761
compare("[@@@@] warning (development) logging.cpp:" + line() + " in TestBody(): 'development'\n");
5862
}
5963

64+
#ifndef EXT_COMPILER_VC
6065
TEST_F(LoggingTest, logging_dev_if_static) {
6166
_line = __LINE__ + 1;
6267
ASSERT_NO_THROW(EXT_DEV_IF_CONST(true) << "development");
@@ -151,7 +156,7 @@ TEST_F(LoggingTest, logging_gdb_vim) {
151156
#ifdef EXT_LOGGING_ENABLE_VIM_GDB
152157
configuration::gdb = true;
153158
configuration::vim = true;
154-
#endif
159+
#endif // EXT_LOGGING_ENABLE_VIM_GDB
155160

156161
_line = __LINE__ + 1;
157162
ASSERT_NO_THROW(EXT_LOG("babe") << "cafe?");
@@ -160,7 +165,7 @@ TEST_F(LoggingTest, logging_gdb_vim) {
160165
#ifdef EXT_LOGGING_ENABLE_VIM_GDB
161166
"# vim "s + path() + " +" + line() + "\n"
162167
"# break logging.cpp:" + line() + "\n"
163-
#endif
168+
#endif // EXT_LOGGING_ENABLE_VIM_GDB
164169
"[babe] warning logging.cpp:"s +
165170
line() + " in TestBody(): 'cafe?'\n");
166171
}
@@ -174,6 +179,7 @@ TEST_F(LoggingTest, logging_prepend_newline) {
174179
ASSERT_NO_THROW(EXT_LOG("babe") << "2cafe?");
175180
compare("\n[babe] warning logging.cpp:" + line() + " in TestBody(): '2cafe?'");
176181
}
182+
#endif // EXT_COMPILER_VC
177183

178184
// does not die
179185
#ifndef EXT_COMPILER_VC
@@ -184,6 +190,7 @@ TEST_F(LoggingDeathTest, fatal) {
184190
}
185191
#endif // EXT_COMPILER_VC
186192

193+
#ifndef EXT_COMPILER_VC
187194
TEST_F(LoggingTest, change_all_levels) {
188195
using namespace ext::logging;
189196

@@ -229,3 +236,4 @@ TEST_F(LoggingTest, levels_to_string) {
229236
EXPECT_STREQ(_detail::level_to_str(level::trace).c_str(), "trace");
230237
EXPECT_STREQ(_detail::level_to_str(static_cast<level>(1337)).c_str(), "unknown");
231238
}
239+
#endif // EXT_COMPILER_VC

0 commit comments

Comments
 (0)