Skip to content

Commit

Permalink
renamed GOOGLE_GLOG_DLL_DECL to GLOG_EXPORT
Browse files Browse the repository at this point in the history
Use a consistent naming and avoid platform specific terms. Also remove
copy and paste code.
  • Loading branch information
sergiud committed Dec 23, 2021
1 parent 43fc3bf commit 7d70137
Show file tree
Hide file tree
Showing 15 changed files with 106 additions and 259 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -663,8 +663,8 @@ if (gflags_FOUND)
endif (TARGET gflags::gflags)

target_compile_definitions (glog PRIVATE
GFLAGS_DLL_DECLARE_FLAG=GOOGLE_GLOG_DLL_DECL
GFLAGS_DLL_DEFINE_FLAG=GOOGLE_GLOG_DLL_DECL
GFLAGS_DLL_DECLARE_FLAG=GLOG_EXPORT
GFLAGS_DLL_DEFINE_FLAG=GLOG_EXPORT
)
endif (gflags_FOUND)

Expand Down Expand Up @@ -711,7 +711,7 @@ target_compile_definitions (glogbase PUBLIC
PRIVATE GOOGLE_GLOG_IS_A_DLL)

generate_export_header (glog
EXPORT_MACRO_NAME GOOGLE_GLOG_DLL_DECL
EXPORT_MACRO_NAME GLOG_EXPORT
EXPORT_FILE_NAME ${CMAKE_CURRENT_BINARY_DIR}/glog/export.h)

# Unit testing
Expand Down
8 changes: 6 additions & 2 deletions bazel/glog.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,12 @@ def glog_library(namespace = "google", with_gflags = 1, **kwargs):
]

linux_or_darwin_copts = wasm_copts + [
"-DGLOG_EXPORT=__attribute__((visibility(\\\"default\\\")))",
# For src/utilities.cc.
"-DHAVE_SYS_SYSCALL_H",
# For src/logging.cc to create symlinks.
"-DHAVE_UNISTD_H",
"-fvisibility=hidden",
]

freebsd_only_copts = [
Expand All @@ -97,6 +99,7 @@ def glog_library(namespace = "google", with_gflags = 1, **kwargs):
]

windows_only_copts = [
"-DGLOG_EXPORT=__declspec(dllexport)",
"-DGLOG_NO_ABBREVIATED_SEVERITIES",
"-DHAVE_SNPRINTF",
"-I" + src_windows,
Expand Down Expand Up @@ -150,15 +153,16 @@ def glog_library(namespace = "google", with_gflags = 1, **kwargs):
],
strip_include_prefix = "src",
defines = select({
# GOOGLE_GLOG_DLL_DECL is normally set by export.h, but that's not
# GLOG_EXPORT is normally set by export.h, but that's not
# generated for Bazel.
"@bazel_tools//src/conditions:windows": [
"GOOGLE_GLOG_DLL_DECL=__declspec(dllexport)",
"GLOG_EXPORT=",
"GLOG_DEPRECATED=__declspec(deprecated)",
"GLOG_NO_ABBREVIATED_SEVERITIES",
],
"//conditions:default": [
"GLOG_DEPRECATED=__attribute__((deprecated))",
"GLOG_EXPORT=__attribute__((visibility(\\\"default\\\")))",
],
}),
copts =
Expand Down
38 changes: 19 additions & 19 deletions src/base/commandlineflags.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,16 @@

#include <glog/logging.h>

#define DECLARE_VARIABLE(type, shorttype, name, tn) \
namespace fL##shorttype { \
extern GOOGLE_GLOG_DLL_DECL type FLAGS_##name; \
} \
#define DECLARE_VARIABLE(type, shorttype, name, tn) \
namespace fL##shorttype { \
extern GLOG_EXPORT type FLAGS_##name; \
} \
using fL##shorttype::FLAGS_##name
#define DEFINE_VARIABLE(type, shorttype, name, value, meaning, tn) \
namespace fL##shorttype { \
GOOGLE_GLOG_DLL_DECL type FLAGS_##name(value); \
char FLAGS_no##name; \
} \
#define DEFINE_VARIABLE(type, shorttype, name, value, meaning, tn) \
namespace fL##shorttype { \
GLOG_EXPORT type FLAGS_##name(value); \
char FLAGS_no##name; \
} \
using fL##shorttype::FLAGS_##name

// bool specialization
Expand All @@ -87,17 +87,17 @@

// Special case for string, because we have to specify the namespace
// std::string, which doesn't play nicely with our FLAG__namespace hackery.
#define DECLARE_string(name) \
namespace fLS { \
extern GOOGLE_GLOG_DLL_DECL std::string& FLAGS_##name; \
} \
#define DECLARE_string(name) \
namespace fLS { \
extern GLOG_EXPORT std::string& FLAGS_##name; \
} \
using fLS::FLAGS_##name
#define DEFINE_string(name, value, meaning) \
namespace fLS { \
std::string FLAGS_##name##_buf(value); \
GOOGLE_GLOG_DLL_DECL std::string& FLAGS_##name = FLAGS_##name##_buf; \
char FLAGS_no##name; \
} \
#define DEFINE_string(name, value, meaning) \
namespace fLS { \
std::string FLAGS_##name##_buf(value); \
GLOG_EXPORT std::string& FLAGS_##name = FLAGS_##name##_buf; \
char FLAGS_no##name; \
} \
using fLS::FLAGS_##name

#endif // HAVE_LIB_GFLAGS
Expand Down
2 changes: 1 addition & 1 deletion src/demangle.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ _START_GOOGLE_NAMESPACE_
// Demangle "mangled". On success, return true and write the
// demangled symbol name to "out". Otherwise, return false.
// "out" is modified even if demangling is unsuccessful.
bool GOOGLE_GLOG_DLL_DECL Demangle(const char *mangled, char *out, size_t out_size);
bool GLOG_EXPORT Demangle(const char *mangled, char *out, size_t out_size);

_END_GOOGLE_NAMESPACE_

Expand Down
13 changes: 2 additions & 11 deletions src/glog/log_severity.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,7 @@
// whenever an ERROR occurs in production.
// FATAL:
// Use for undesired and unexpected events that the program cannot recover
// from.

// Annoying stuff for windows -- makes sure clients can import these functions
#ifndef GOOGLE_GLOG_DLL_DECL
# if defined(_WIN32) && !defined(__CYGWIN__)
# define GOOGLE_GLOG_DLL_DECL __declspec(dllimport)
# else
# define GOOGLE_GLOG_DLL_DECL
# endif
#endif
// from.

// Variables of type LogSeverity are widely taken to lie in the range
// [0, NUM_SEVERITIES-1]. Be careful to preserve this assumption if
Expand All @@ -76,7 +67,7 @@ const int INFO = GLOG_INFO, WARNING = GLOG_WARNING,
#define DFATAL_LEVEL FATAL
#endif

extern GOOGLE_GLOG_DLL_DECL const char* const LogSeverityNames[NUM_SEVERITIES];
extern GLOG_EXPORT const char* const LogSeverityNames[NUM_SEVERITIES];

// NDEBUG usage helpers related to (RAW_)DCHECK:
//
Expand Down
Loading

0 comments on commit 7d70137

Please sign in to comment.