Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions .github/workflows-disabled/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Build Tests

on:
push:
branches:
- main
- master
pull_request:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-24.04

strategy:
fail-fast: false
matrix:
cxx:
- g++
- g++-13

env:
CXX: ${{ matrix.cxx }}

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y g++ g++-13 make

- name: Show compiler version
run: $CXX --version

- name: Run Preprocessor Unit Tests
run: |
cd "$GITHUB_WORKSPACE/preprocessor"
python3 ./UnitTests.py

- name: Run Library Unit Tests
run: |
cd "$GITHUB_WORKSPACE/runtime"
make test -j2
./test --gtest_filter=-NanoLogTest.StagingBuffer_finishReservation_asserts:PackerTest.nibbler_assert

- name: Build Sample App
run: |
cd "$GITHUB_WORKSPACE/sample"
make clean-all
make depend -C ../runtime
make -j"$(nproc)"

- name: Build Preprocessor Sample App
run: |
cd "$GITHUB_WORKSPACE/sample_preprocessor"
make clean-all
make depend -C ../runtime
make -j"$(nproc)"

- name: Run Integration Test
run: |
cd "$GITHUB_WORKSPACE/integrationTest"
make clean-all
./run.sh
56 changes: 0 additions & 56 deletions .github/workflows/ci.yaml

This file was deleted.

87 changes: 87 additions & 0 deletions .github/workflows/ubuntu-clang-matrix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Ubuntu Build And Test

on:
push:
branches:
- main
- master
pull_request:
workflow_dispatch:

jobs:
build-and-run-sample:
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
include:
- name: gcc
install_cmd: sudo apt-get install -y cmake ninja-build g++ python3
cc: gcc
cxx: g++
build_cmd: cmake --build build --parallel --target sampleApplication decompressor PackerTest RuntimeTest
- name: clang-21
install_cmd: |
sudo apt-get install -y ca-certificates cmake gnupg ninja-build python3 wget
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | \
sudo gpg --dearmor -o /usr/share/keyrings/llvm-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/llvm-archive-keyring.gpg] http://apt.llvm.org/noble/ llvm-toolchain-noble-21 main" | \
sudo tee /etc/apt/sources.list.d/llvm.list
sudo apt-get update
sudo apt-get install -y clang-21 lld-21
cc: clang-21
cxx: clang++-21
build_cmd: cmake --build build --parallel --verbose --target sampleApplication decompressor PackerTest RuntimeTest
- name: clang-22
install_cmd: |
sudo apt-get install -y ca-certificates cmake gnupg ninja-build python3 wget
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | \
sudo gpg --dearmor -o /usr/share/keyrings/llvm-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/llvm-archive-keyring.gpg] http://apt.llvm.org/noble/ llvm-toolchain-noble-22 main" | \
sudo tee /etc/apt/sources.list.d/llvm.list
sudo apt-get update
sudo apt-get install -y clang-22 lld-22
cc: clang-22
cxx: clang++-22
build_cmd: cmake --build build --parallel --verbose --target sampleApplication decompressor PackerTest RuntimeTest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive

- name: Install dependencies
run: |
sudo apt-get update
${{ matrix.install_cmd }}

- name: Show compiler version
if: ${{ matrix.cxx != '' }}
run: |
${{ matrix.cc }} --version
${{ matrix.cxx }} --version

- name: Configure
env:
CC: ${{ matrix.cc }}
CXX: ${{ matrix.cxx }}
run: cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DNANOLOG_BUILD_EXPERIMENTAL_TESTS=ON

- name: Build
run: ${{ matrix.build_cmd }}

- name: Run PackerTest
run: ./build/runtime/PackerTest

- name: Run RuntimeTest
run: ./build/runtime/RuntimeTest

- name: Run sample application
run: ./build/sample/sampleApplication

- name: Decompress log and verify output
run: |
./build/runtime/decompressor decompress /tmp/logFile | tee decompressed.log
grep -F "Simple log message with 0 parameters" decompressed.log
grep -F "A string, pointer, number, and float:" decompressed.log
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
.idea/
CMakeLists.txt

cmake-build-debug/
make-all.sh

._*
._*
/build
/build-cmake
/build-cmake2
21 changes: 21 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
cmake_minimum_required(VERSION 3.10)

if(WIN32)
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
endif()

project(NanoLog LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

option(NANOLOG_BUILD_EXPERIMENTAL_TESTS "Build experimental GoogleTest-based runtime tests" OFF)

if(NANOLOG_BUILD_EXPERIMENTAL_TESTS)
enable_testing()
endif()

add_subdirectory(runtime)
add_subdirectory(sample)
add_subdirectory(sample_preprocessor)
12 changes: 5 additions & 7 deletions preprocessor/FunctionGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,6 @@ def outputCompilationFiles(outputFileName="BufferStuffer.h", inputFiles=[]):
{logLevelEnum} logLevel;
}};

// Start an empty namespace to enclose all the record(debug)/compress/decompress
// and support functions
namespace {{

using namespace NanoLog::LogLevels;
""".format(logLevelEnum=LOG_LEVEL_ENUM))
for logId, code in sorted(mergedCode.items()):
Expand All @@ -207,8 +203,6 @@ def outputCompilationFiles(outputFileName="BufferStuffer.h", inputFiles=[]):
oFile.write(code["decompressFnDef"] + "\n")

oFile.write("""
} // end empty namespace

// Assignment of numerical ids to format NANO_LOG occurrences
""")

Expand All @@ -230,7 +224,7 @@ def outputCompilationFiles(outputFileName="BufferStuffer.h", inputFiles=[]):
code["logLevel"]
))

oFile.write("extern const int %s = %d; // %s:%d \"%s\"\n" % (
oFile.write("extern const uint32_t %s = %d; // %s:%d \"%s\"\n" % (
generateIdVariableNameFromLogId(logId),
count,
code["filename"],
Expand Down Expand Up @@ -465,6 +459,8 @@ def generateLogFunctions(self, logLevel, fmtString,
if (level > {getLogLevelFn}())
return;

(void) fmtStr;

uint64_t timestamp = PerfUtils::Cycles::rdtsc();
{strlen_declaration};
size_t allocSize = {primitive_size_sum} {strlen_sum} sizeof({entry});
Expand Down Expand Up @@ -664,6 +660,8 @@ def generateLogFunctions(self, logLevel, fmtString,
else:
enumType = "NONE"

enumType = "NanoLogInternal::Log::" + enumType

dictionaryFragment += """
// Fragment {count}
if (buffer + sizeof(PrintFragment)
Expand Down
2 changes: 1 addition & 1 deletion preprocessor/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ def peekNextMeaningfulChar(lines, filePos):
#
def processFile(inputFile, mapOutputFilename):
functionGenerator = FunctionGenerator()
directiveRegex = re.compile("^# (\d+) \"(.*)\"(.*)")
directiveRegex = re.compile(r'^# (\d+) "(.*)"(.*)')

with open(inputFile) as f, open(inputFile + "i", 'w') as output:
try:
Expand Down
Loading