Compare commits
1 Commits
master
...
ci-ubuntu-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7a4c79f7a8 |
@ -2,6 +2,7 @@
|
||||
Checks: 'clang-diagnostic-*,clang-analyzer-*,google-*,modernize-*,-modernize-use-trailing-return-type,readability-*,portability-*,performance-*,bugprone-*,android-*,darwin-*,clang-analyzer-*'
|
||||
WarningsAsErrors: ''
|
||||
HeaderFilterRegex: ''
|
||||
AnalyzeTemporaryDtors: false
|
||||
FormatStyle: file
|
||||
CheckOptions:
|
||||
- key: cert-dcl16-c.NewSuffixes
|
||||
|
||||
37
.github/workflows/linux.yml
vendored
37
.github/workflows/linux.yml
vendored
@ -7,8 +7,8 @@ jobs:
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
name: GCC-C++${{matrix.std}}-${{matrix.build_type}}-${{matrix.lib}}
|
||||
runs-on: ubuntu-22.04
|
||||
name: ${{matrix.os}}-GCC-C++${{matrix.std}}-${{matrix.build_type}}-${{matrix.lib}}
|
||||
runs-on: ${{matrix.os}}
|
||||
permissions:
|
||||
actions: read
|
||||
contents: read
|
||||
@ -16,6 +16,7 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: true
|
||||
matrix:
|
||||
os: [ubuntu-22.04, ubuntu-24.04]
|
||||
build_type: [Release, Debug]
|
||||
lib: [shared, static]
|
||||
std: [14, 17, 20, 23]
|
||||
@ -31,20 +32,42 @@ jobs:
|
||||
- name: Setup Dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
DEBIAN_FRONTEND=noninteractive sudo apt-get install -y --no-install-suggests --no-install-recommends \
|
||||
g++ \
|
||||
DEBIAN_FRONTEND=noninteractive sudo apt-get install -y \
|
||||
build-essential \
|
||||
cmake \
|
||||
gcovr \
|
||||
libgflags-dev \
|
||||
libgmock-dev \
|
||||
libgtest-dev \
|
||||
libunwind-dev \
|
||||
ninja-build
|
||||
|
||||
- name: Cache GTest
|
||||
id: cache-gtest
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: gtest/
|
||||
key: ${{runner.os}}-gtest-1.11
|
||||
|
||||
- name: Download GTest
|
||||
if: steps.cache-gtest.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
wget https://github.com/google/googletest/archive/refs/tags/release-1.11.0.tar.gz
|
||||
tar xvf release-1.11.0.tar.gz
|
||||
|
||||
- name: Build GTest
|
||||
if: steps.cache-gtest.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
cmake -S googletest-release-1.11.0 -B build-googletest \
|
||||
-DBUILD_SHARED_LIBS=${{matrix.shared}} \
|
||||
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
|
||||
-DCMAKE_INSTALL_PREFIX=${{github.workspace}}/gtest \
|
||||
-G Ninja
|
||||
cmake --build build-googletest --target install
|
||||
|
||||
- name: Setup Environment
|
||||
if: matrix.build_type == 'Debug'
|
||||
run: |
|
||||
echo 'CXXFLAGS=--coverage' >> $GITHUB_ENV
|
||||
echo 'GTest_ROOT=${{github.workspace}}/gtest' >> $GITHUB_ENV
|
||||
|
||||
- name: Configure
|
||||
env:
|
||||
@ -109,7 +132,7 @@ jobs:
|
||||
|
||||
- name: Upload Coverage to Codecov
|
||||
if: matrix.build_type == 'Debug'
|
||||
uses: codecov/codecov-action@v5
|
||||
uses: codecov/codecov-action@v4
|
||||
with:
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
files: build_${{matrix.build_type}}/coverage.xml
|
||||
|
||||
2
.github/workflows/macos.yml
vendored
2
.github/workflows/macos.yml
vendored
@ -68,7 +68,7 @@ jobs:
|
||||
|
||||
- name: Upload Coverage to Codecov
|
||||
if: matrix.build_type == 'Debug'
|
||||
uses: codecov/codecov-action@v5
|
||||
uses: codecov/codecov-action@v4
|
||||
with:
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
files: build_${{matrix.build_type}}/coverage.xml
|
||||
|
||||
10
.github/workflows/windows.yml
vendored
10
.github/workflows/windows.yml
vendored
@ -45,18 +45,18 @@ jobs:
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: gtest/
|
||||
key: ${{runner.os}}-gtest-1.14-${{matrix.lib}}-${{matrix.arch}}-${{matrix.build_type}}
|
||||
key: ${{runner.os}}-gtest-1.11-${{matrix.lib}}-${{matrix.arch}}-${{matrix.build_type}}
|
||||
|
||||
- name: Download GTest
|
||||
if: steps.cache-gtest.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
(New-Object System.Net.WebClient).DownloadFile("https://github.com/google/googletest/archive/refs/tags/v1.14.0.zip", "v1.14.0.zip")
|
||||
Expand-Archive v1.14.0.zip .
|
||||
(New-Object System.Net.WebClient).DownloadFile("https://github.com/google/googletest/archive/refs/tags/release-1.11.0.zip", "release-1.11.0.zip")
|
||||
Expand-Archive release-1.11.0.zip .
|
||||
|
||||
- name: Build GTest
|
||||
if: steps.cache-gtest.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
cmake -S googletest-1.14.0 -B build-googletest `
|
||||
cmake -S googletest-release-1.11.0 -B build-googletest `
|
||||
-A ${{matrix.arch}} `
|
||||
-DBUILD_SHARED_LIBS=${{matrix.lib == 'shared'}} `
|
||||
-Dgtest_force_shared_crt=ON `
|
||||
@ -234,7 +234,7 @@ jobs:
|
||||
|
||||
- name: Upload Coverage to Codecov
|
||||
if: matrix.build_type == 'Debug'
|
||||
uses: codecov/codecov-action@v5
|
||||
uses: codecov/codecov-action@v4
|
||||
with:
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
files: build_${{matrix.build_type}}/coverage.xml
|
||||
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@ -2,5 +2,3 @@
|
||||
/build*/
|
||||
/site/
|
||||
bazel-*
|
||||
# Bzlmod lockfile
|
||||
/MODULE.bazel.lock
|
||||
|
||||
@ -17,6 +17,6 @@ platform(
|
||||
constraint_values = [
|
||||
"@platforms//cpu:x86_64",
|
||||
"@platforms//os:windows",
|
||||
"@rules_cc//cc/private/toolchain:clang-cl",
|
||||
"@bazel_tools//tools/cpp:clang-cl",
|
||||
],
|
||||
)
|
||||
|
||||
@ -64,7 +64,7 @@ set (CMAKE_VISIBILITY_INLINES_HIDDEN ON)
|
||||
|
||||
set (CMAKE_DEBUG_POSTFIX d)
|
||||
|
||||
find_package (GTest 1.11 COMPONENTS GTest OPTIONAL_COMPONENTS GMock NO_MODULE)
|
||||
find_package (GTest NO_MODULE)
|
||||
|
||||
if (GTest_FOUND)
|
||||
set (HAVE_LIB_GTEST 1)
|
||||
@ -278,12 +278,12 @@ if (WITH_SYMBOLIZE)
|
||||
if (HAVE_SYMBOLIZE)
|
||||
set (HAVE_STACKTRACE 1)
|
||||
endif (HAVE_SYMBOLIZE)
|
||||
elseif (APPLE AND HAVE_DLADDR)
|
||||
set (HAVE_SYMBOLIZE 1)
|
||||
elseif (UNIX)
|
||||
if (HAVE_ELF_H OR HAVE_SYS_EXEC_ELF_H)
|
||||
set (HAVE_SYMBOLIZE 1)
|
||||
endif (HAVE_ELF_H OR HAVE_SYS_EXEC_ELF_H)
|
||||
elseif (APPLE AND HAVE_DLADDR)
|
||||
set (HAVE_SYMBOLIZE 1)
|
||||
endif (WIN32 OR CYGWIN)
|
||||
endif (WITH_SYMBOLIZE)
|
||||
|
||||
|
||||
@ -5,9 +5,3 @@ module(
|
||||
|
||||
bazel_dep(name = "gflags", version = "2.2.2")
|
||||
bazel_dep(name = "googletest", version = "1.14.0", dev_dependency = True)
|
||||
bazel_dep(name = "platforms", version = "0.0.10")
|
||||
bazel_dep(name = "rules_cc", version = "0.0.12")
|
||||
|
||||
# Required for Windows clang-cl build: --extra_toolchains=@local_config_cc//:cc-toolchain-arm64_windows
|
||||
cc_configure = use_extension("@rules_cc//cc:extensions.bzl", "cc_configure_extension")
|
||||
use_repo(cc_configure, "local_config_cc")
|
||||
|
||||
@ -91,14 +91,12 @@ def glog_library(with_gflags = 1, **kwargs):
|
||||
# Enable declaration of _Unwind_Backtrace
|
||||
"-D_GNU_SOURCE",
|
||||
"-DHAVE_LINK_H",
|
||||
"-DHAVE_SYMBOLIZE", # Supported by <link.h>
|
||||
]
|
||||
|
||||
linux_only_copts = [
|
||||
# For utilities.h.
|
||||
"-DHAVE_EXECINFO_H",
|
||||
"-DHAVE_LINK_H",
|
||||
"-DHAVE_SYMBOLIZE", # Supported by <link.h>
|
||||
]
|
||||
|
||||
darwin_only_copts = [
|
||||
|
||||
@ -3,20 +3,27 @@
|
||||
## Bazel
|
||||
|
||||
To use glog within a project which uses the [Bazel](https://bazel.build/) build
|
||||
tool, add the following lines to your `MODULE.bazel` file:
|
||||
tool, add the following lines to your `WORKSPACE` file:
|
||||
|
||||
``` bazel title="MODULE.bazel"
|
||||
bazel_dep(name = "glog")
|
||||
``` bazel title="WORKSPACE"
|
||||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
||||
|
||||
archive_override(
|
||||
module_name = "glog",
|
||||
urls = "https://github.com/google/glog/archive/cc0de6c200375b33d907ee7632eee2f173b33a09.tar.gz",
|
||||
strip_prefix = "glog-cc0de6c200375b33d907ee7632eee2f173b33a09", # Latest commit as of 2024-06-08.
|
||||
integrity = "sha256-rUrv4EBkdc+4Wbhfxp+KoRstlj2Iw842/OpLfDq0ivg=",
|
||||
http_archive(
|
||||
name = "gflags",
|
||||
sha256 = "34af2f15cf7367513b352bdcd2493ab14ce43692d2dcd9dfc499492966c64dcf",
|
||||
strip_prefix = "gflags-2.2.2",
|
||||
urls = ["https://github.com/gflags/gflags/archive/v2.2.2.tar.gz"],
|
||||
)
|
||||
|
||||
http_archive(
|
||||
name = "com_github_google_glog",
|
||||
sha256 = "c17d85c03ad9630006ef32c7be7c65656aba2e7e2fbfc82226b7e680c771fc88",
|
||||
strip_prefix = "glog-0.7.1",
|
||||
urls = ["https://github.com/google/glog/archive/v0.7.1.zip"],
|
||||
)
|
||||
```
|
||||
|
||||
You can then add `@glog//:glog` to
|
||||
You can then add `@com_github_google_glog//:glog` to
|
||||
the deps section of a `cc_binary` or
|
||||
`cc_library` rule, and `#!cpp #include <glog/logging.h>` to
|
||||
include it in your source code.
|
||||
@ -26,7 +33,7 @@ include it in your source code.
|
||||
cc_binary(
|
||||
name = "main",
|
||||
srcs = ["main.cc"],
|
||||
deps = ["@glog//:glog"],
|
||||
deps = ["@com_github_google_glog//:glog"],
|
||||
)
|
||||
```
|
||||
|
||||
|
||||
@ -1419,7 +1419,7 @@ T CheckNotNull(const char* file, int line, const char* names, T&& t) {
|
||||
struct LogMessageVoidify {
|
||||
// This has to be an operator with a precedence lower than << but
|
||||
// higher than ?:
|
||||
constexpr void operator&(std::ostream&) const noexcept {}
|
||||
void operator&(std::ostream&) noexcept {}
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
|
||||
@ -995,22 +995,7 @@ bool LogFileObject::CreateLogfile(const string& time_pid_string) {
|
||||
if (FLAGS_timestamp_in_logfile_name) {
|
||||
// demand that the file is unique for our timestamp (fail if it exists).
|
||||
flags = flags | O_EXCL;
|
||||
} else {
|
||||
// logs are written to a single file, where: a log file is created for the
|
||||
// the first time or a file is being recreated due to exceeding max size
|
||||
|
||||
struct stat statbuf;
|
||||
if (stat(filename, &statbuf) == 0) {
|
||||
// truncate the file if it exceeds the max size
|
||||
if ((static_cast<uint32>(statbuf.st_size) >> 20U) >= MaxLogSize()) {
|
||||
flags |= O_TRUNC;
|
||||
}
|
||||
|
||||
// update file length to sync file size
|
||||
file_length_ = static_cast<uint32>(statbuf.st_size);
|
||||
}
|
||||
}
|
||||
|
||||
FileDescriptor fd{
|
||||
open(filename, flags, static_cast<mode_t>(FLAGS_logfile_mode))};
|
||||
if (!fd) return false;
|
||||
|
||||
@ -110,7 +110,6 @@ static void TestLogSinkWaitTillSent();
|
||||
static void TestCHECK();
|
||||
static void TestDCHECK();
|
||||
static void TestSTREQ();
|
||||
static void TestMaxLogSizeWhenNoTimestamp();
|
||||
static void TestBasename();
|
||||
static void TestBasenameAppendWhenNoTimestamp();
|
||||
static void TestTwoProcessesWrite();
|
||||
@ -289,7 +288,6 @@ int main(int argc, char** argv) {
|
||||
MungeAndDiffTestStdout(FLAGS_test_srcdir + "/src/logging_unittest.out"));
|
||||
FLAGS_logtostdout = false;
|
||||
|
||||
TestMaxLogSizeWhenNoTimestamp();
|
||||
TestBasename();
|
||||
TestBasenameAppendWhenNoTimestamp();
|
||||
TestTwoProcessesWrite();
|
||||
@ -808,47 +806,6 @@ static void CheckFile(const string& name, const string& expected_string,
|
||||
<< expected_string << " in " << files[0];
|
||||
}
|
||||
|
||||
static void TestMaxLogSizeWhenNoTimestamp() {
|
||||
fprintf(stderr, "==== Test setting max log size without timestamp\n");
|
||||
const string dest = FLAGS_test_tmpdir + "/logging_test_max_log_size";
|
||||
DeleteFiles(dest + "*");
|
||||
|
||||
auto original_max_log_size = FLAGS_max_log_size;
|
||||
auto original_timestamp_in_logfile_name = FLAGS_timestamp_in_logfile_name;
|
||||
|
||||
FLAGS_max_log_size = 1; // Set max log size to 1MB
|
||||
FLAGS_timestamp_in_logfile_name = false;
|
||||
|
||||
// Set log destination
|
||||
SetLogDestination(GLOG_INFO, dest.c_str());
|
||||
|
||||
// 1e4 info logs -> is about 772 KB in size
|
||||
// 2e4 info logs -> is around 1500 KB in size -> 1.5MB
|
||||
// If our max_log_size constraint is respected, it will truncate earlier logs
|
||||
// and the file size will be lesser than 1MB (around 0.5MB)
|
||||
const int num_logs = 2e4;
|
||||
for (int i = 0; i < num_logs; i++) {
|
||||
LOG(INFO) << "Hello world";
|
||||
}
|
||||
FlushLogFiles(GLOG_INFO);
|
||||
|
||||
// Check log file size
|
||||
struct stat statbuf;
|
||||
stat(dest.c_str(), &statbuf);
|
||||
|
||||
// Verify file size is less than the max log size limit
|
||||
CHECK_LT(static_cast<unsigned int>(statbuf.st_size),
|
||||
FLAGS_max_log_size << 20U);
|
||||
|
||||
// Reset flag values to their original values
|
||||
FLAGS_max_log_size = original_max_log_size;
|
||||
FLAGS_timestamp_in_logfile_name = original_timestamp_in_logfile_name;
|
||||
|
||||
// Release file handle for the destination file to unlock the file in Windows.
|
||||
LogToStderr();
|
||||
DeleteFiles(dest + "*");
|
||||
}
|
||||
|
||||
static void TestBasename() {
|
||||
fprintf(stderr, "==== Test setting log file basename\n");
|
||||
const string dest = FLAGS_test_tmpdir + "/logging_test_basename";
|
||||
|
||||
@ -55,10 +55,6 @@
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#if defined(HAVE_SYS_SYSCALL_H) && defined(HAVE_SYS_TYPES_H)
|
||||
# include <sys/syscall.h>
|
||||
# include <sys/types.h>
|
||||
#endif
|
||||
|
||||
namespace google {
|
||||
|
||||
@ -220,14 +216,8 @@ void DumpSignalInfo(int signal_number, siginfo_t* siginfo) {
|
||||
std::ostringstream oss;
|
||||
oss << std::showbase << std::hex << std::this_thread::get_id();
|
||||
formatter.AppendString(oss.str().c_str());
|
||||
# if defined(GLOG_OS_LINUX) && defined(HAVE_SYS_SYSCALL_H) && \
|
||||
defined(HAVE_SYS_TYPES_H)
|
||||
pid_t tid = syscall(SYS_gettid);
|
||||
formatter.AppendString(" LWP ");
|
||||
formatter.AppendUint64(static_cast<uint64>(tid), 10);
|
||||
# endif
|
||||
formatter.AppendString(") ");
|
||||
|
||||
formatter.AppendString(") ");
|
||||
// Only linux has the PID of the signal sender in si_pid.
|
||||
# ifdef GLOG_OS_LINUX
|
||||
formatter.AppendString("from PID ");
|
||||
|
||||
@ -77,10 +77,6 @@
|
||||
# error "symbolize.h" was not included correctly.
|
||||
#endif
|
||||
|
||||
// We prefer to let the build system detect the availability of certain features
|
||||
// such as symbolization support. HAVE_SYMBOLIZE should therefore be defined by
|
||||
// the build system in general unless there is a good reason to perform the
|
||||
// detection using the preprocessor.
|
||||
#ifndef GLOG_NO_SYMBOLIZE_DETECTION
|
||||
# ifndef HAVE_SYMBOLIZE
|
||||
// defined by gcc
|
||||
|
||||
Loading…
Reference in New Issue
Block a user