Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add debug builds to CI #36

Merged
merged 6 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

matrix:
os: [ubuntu-latest, macos-latest]
build_type: [Release]
build_type: [Release, Debug]

steps:
- uses: actions/checkout@v4
Expand Down
21 changes: 13 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 3.5)

project(autolab-cli)

Expand All @@ -11,15 +11,20 @@ set(variant "" CACHE STRING "build variant")
# command line options
option(release "build release version (no debug output)" OFF)

if(NOT release)
# build debug
set(CMAKE_BUILD_TYPE Debug)
# Existing CMAKE_BUILD_TYPE takes priority if directly defined
if(NOT CMAKE_BUILD_TYPE)
damianhxy marked this conversation as resolved.
Show resolved Hide resolved
if(release)
set(CMAKE_BUILD_TYPE Release)
else()
set(CMAKE_BUILD_TYPE Debug)
endif()
endif()

if(CMAKE_BUILD_TYPE MATCHES Debug)
set(PRINT_DEBUG TRUE)
else(NOT release)
# build release
set(CMAKE_BUILD_TYPE Release)
else()
set(PRINT_DEBUG FALSE)
endif(NOT release)
endif()

message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
message(STATUS "Build variant: ${variant}")
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,10 @@ This will move our autocompletion script out of a local folder and into the bash

#### Release vs Debug

There are two kinds of builds available: release and non-release. Release builds do not contain debug output (output that use Logger::debug).
There are two kinds of builds available: release and non-release. Release builds do not contain debug output (output that use `Logger::debug`).

The default is non-release builds. To build a release version, when inside the 'build' directory, run `cmake -Drelease=ON ..` (note the periods at the end), then run `make`.
The default is non-release builds. To build a release version, when inside the 'build' directory, run `cmake -DCMAKE_BUILD_TYPE=Release ..` (note the periods at the end), then run `make`.
Alternatively (but less preferable), you can use the flag `-Drelease=ON`.
damianhxy marked this conversation as resolved.
Show resolved Hide resolved

#### Build Variant

Expand Down
2 changes: 1 addition & 1 deletion lib/logger/logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ namespace Logger {
};
struct debug_logger {
template<class T>
debug_logger &operator<<(T val) {
debug_logger &operator<<([[maybe_unused]] T val) {
#ifdef PRINT_DEBUG
std::cout << val;
#endif
Expand Down