Skip to content

Commit

Permalink
w4
Browse files Browse the repository at this point in the history
  • Loading branch information
jslee02 committed Apr 5, 2024
1 parent f237b49 commit 3e767d1
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 64 deletions.
64 changes: 34 additions & 30 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -162,24 +162,11 @@ endif()
#===============================================================================
# Build type settings
#===============================================================================
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: Debug | Release | RelWithDebInfo | MinSizeRel" FORCE)
endif()
string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_UPPERCASE)

set(DART_BUILD_MODE_DEBUG FALSE)
set(DART_BUILD_MODE_RELEASE FALSE)

if("${CMAKE_BUILD_TYPE_UPPERCASE}" STREQUAL "DEBUG")
set(DART_BUILD_MODE_DEBUG TRUE)
elseif("${CMAKE_BUILD_TYPE_UPPERCASE}" STREQUAL "RELEASE")
set(DART_BUILD_MODE_RELEASE TRUE)
elseif("${CMAKE_BUILD_TYPE_UPPERCASE}" STREQUAL "RELWITHDEBINFO")
set(DART_BUILD_MODE_RELEASE TRUE)
elseif("${CMAKE_BUILD_TYPE_UPPERCASE}" STREQUAL "MINSIZEREL")
set(DART_BUILD_MODE_RELEASE TRUE)
else()
message(WARNING "CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} unknown. Valid options are: Debug | Release | RelWithDebInfo | MinSizeRel")
if(NOT CMAKE_CONFIGURATION_TYPES)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
endif()

# Active log level:
Expand All @@ -191,14 +178,33 @@ endif()
# - ERROR: To enable log with DART_ERROR() and below
# - FATAL: To enable log with DART_FATAL()
# - OFF: To turn off all the logs
if(DART_BUILD_MODE_DEBUG)
set(DART_ACTIVE_LOG_LEVEL "DEBUG" CACHE STRING "Compile time active log level to enable")
if(NOT DART_ACTIVE_LOG_LEVEL)
if(NOT CMAKE_CONFIGURATION_TYPES AND CMAKE_BUILD_TYPE STREQUAL "Debug")
set(DART_ACTIVE_LOG_LEVEL "DEBUG" CACHE STRING "Compile time active log level to enable")
else()
set(DART_ACTIVE_LOG_LEVEL "INFO" CACHE STRING "Compile time active log level to enable")
endif()
set_property(CACHE DART_ACTIVE_LOG_LEVEL PROPERTY STRINGS TRACE DEBUG INFO WARN ERROR FATAL OFF)
endif()
if(DART_ACTIVE_LOG_LEVEL STREQUAL "TRACE")
set(DART_ACTIVE_LOG_LEVEL_VALUE 0)
elseif(DART_ACTIVE_LOG_LEVEL STREQUAL "DEBUG")
set(DART_ACTIVE_LOG_LEVEL_VALUE 1)
elseif(DART_ACTIVE_LOG_LEVEL STREQUAL "INFO")
set(DART_ACTIVE_LOG_LEVEL_VALUE 2)
elseif(DART_ACTIVE_LOG_LEVEL STREQUAL "WARN")
set(DART_ACTIVE_LOG_LEVEL_VALUE 3)
elseif(DART_ACTIVE_LOG_LEVEL STREQUAL "ERROR")
set(DART_ACTIVE_LOG_LEVEL_VALUE 4)
elseif(DART_ACTIVE_LOG_LEVEL STREQUAL "FATAL")
set(DART_ACTIVE_LOG_LEVEL_VALUE 5)
elseif(DART_ACTIVE_LOG_LEVEL STREQUAL "OFF")
set(DART_ACTIVE_LOG_LEVEL_VALUE 6)
else()
set(DART_ACTIVE_LOG_LEVEL "INFO" CACHE STRING "Compile time active log level to enable")
message(FATAL_ERROR "Unknown DART_ACTIVE_LOG_LEVEL: ${DART_ACTIVE_LOG_LEVEL}")
endif()
set_property(CACHE DART_ACTIVE_LOG_LEVEL PROPERTY STRINGS TRACE DEBUG INFO WARN ERROR FATAL OFF)

if(DART_BUILD_MODE_DEBUG)
if(NOT CMAKE_CONFIGURATION_TYPES AND CMAKE_BUILD_TYPE STREQUAL "Debug")
option(DART_TREAT_WARNINGS_AS_ERRORS "Treat warnings as errors" OFF)
else()
option(DART_TREAT_WARNINGS_AS_ERRORS "Treat warnings as errors" ON)
Expand Down Expand Up @@ -355,14 +361,12 @@ if(DART_VERBOSE)
message(STATUS "Build gui::osg : ${DART_BUILD_GUI_OSG}")
message(STATUS "Install path : ${CMAKE_INSTALL_PREFIX}")
message(STATUS "CXX_FLAGS : ${CMAKE_CXX_FLAGS}")
if(${CMAKE_BUILD_TYPE_UPPERCASE} STREQUAL "RELEASE")
message(STATUS "CXX_FLAGS_RELEASE: ${CMAKE_CXX_FLAGS_RELEASE}")
elseif(${CMAKE_BUILD_TYPE_UPPERCASE} STREQUAL "DEBUG")
message(STATUS "CXX_FLAGS_DEBUG : ${CMAKE_CXX_FLAGS_DEBUG}")
elseif(${CMAKE_BUILD_TYPE_UPPERCASE} STREQUAL "RELWITHDEBINFO")
if(NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "CXX_FLAGS_RELEASE : ${CMAKE_CXX_FLAGS_RELEASE}")
message(STATUS "CXX_FLAGS_DEBUG : ${CMAKE_CXX_FLAGS_DEBUG}")
message(STATUS "CXX_FLAGS_MINSIZEREL : ${CXX_FLAGS_MINSIZEREL}")
message(STATUS "CXX_FLAGS_RELWITHDEBINFO: ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
elseif(${CMAKE_BUILD_TYPE_UPPERCASE} STREQUAL "PROFILE")
message(STATUS "CXX_FLAGS_PROFILE: ${CMAKE_CXX_FLAGS_PROFILE}")
message(STATUS "CXX_FLAGS_PROFILE : ${CMAKE_CXX_FLAGS_PROFILE}")
endif()
message(STATUS "DART_SOURCE_DIR : ${DART_SOURCE_DIR}")
message(STATUS "DART_BINARY_DIR : ${DART_BINARY_DIR}")
Expand Down
7 changes: 2 additions & 5 deletions dart/common/Logging.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
#ifndef DART_COMMON_LOGGING_HPP_
#define DART_COMMON_LOGGING_HPP_

#include <dart/config.hpp>

// clang-format off
#define DART_LOG_LEVEL_TRACE 0
#define DART_LOG_LEVEL_DEBUG 1
Expand All @@ -43,11 +45,6 @@
#define DART_LOG_LEVEL_OFF 6
// clang-format on

// Default active log level
#if !defined(DART_ACTIVE_LOG_LEVEL)
#define DART_ACTIVE_LOG_LEVEL DART_LOG_LEVEL_INFO
#endif

#if DART_ACTIVE_LOG_LEVEL <= DART_LOG_LEVEL_TRACE
#define DART_TRACE(...) ::dart::common::trace(__VA_ARGS__)
#else
Expand Down
2 changes: 2 additions & 0 deletions dart/config.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,5 @@
#cmakedefine01 DART_USE_SYSTEM_IMGUI

#cmakedefine01 DART_BUILD_PROFILE

#define DART_ACTIVE_LOG_LEVEL @DART_ACTIVE_LOG_LEVEL_VALUE@
34 changes: 7 additions & 27 deletions dart/constraint/BoxedLcpConstraintSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,33 +51,7 @@ namespace constraint {

namespace {

//==============================================================================
#ifndef NDEBUG
bool isSymmetric(std::size_t n, double* A)
{
std::size_t nSkip = dPAD(n);
for (std::size_t i = 0; i < n; ++i) {
for (std::size_t j = 0; j < n; ++j) {
if (std::abs(A[nSkip * i + j] - A[nSkip * j + i]) > 1e-6) {
std::cout << "A: " << std::endl;
for (std::size_t k = 0; k < n; ++k) {
for (std::size_t l = 0; l < nSkip; ++l) {
std::cout << std::setprecision(4) << A[k * nSkip + l] << " ";
}
std::cout << std::endl;
}

std::cout << "A(" << i << ", " << j << "): " << A[nSkip * i + j]
<< std::endl;
std::cout << "A(" << j << ", " << i << "): " << A[nSkip * j + i]
<< std::endl;
return false;
}
}
}

return true;
}

//==============================================================================
bool isSymmetric(std::size_t n, double* A, std::size_t begin, std::size_t end)
Expand Down Expand Up @@ -107,7 +81,13 @@ bool isSymmetric(std::size_t n, double* A, std::size_t begin, std::size_t end)
}

//==============================================================================
void print(
bool isSymmetric(std::size_t n, double* A)
{
return isSymmetric(n, A, 0, n - 1);
}

//==============================================================================
[[maybe_unused]] void print(
std::size_t n,
double* A,
double* x,
Expand Down
2 changes: 1 addition & 1 deletion dart/constraint/DantzigLCPSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ bool isSymmetric(
}

//==============================================================================
void print(
[[maybe_unused]] void print(
std::size_t _n,
double* _A,
double* _x,
Expand Down
2 changes: 1 addition & 1 deletion dart/constraint/PGSLCPSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ bool isSymmetric(
}

//==============================================================================
void print(
[[maybe_unused]] void print(
std::size_t _n,
double* _A,
double* _x,
Expand Down
7 changes: 7 additions & 0 deletions pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ install-local = { cmd = "cmake --install build --prefix $CONDA_PREFIX", depends_
] }

configure = { cmd = "cmake -G Ninja -S . -B build -DCMAKE_BUILD_TYPE=Release -DDART_VERBOSE=ON -DDART_USE_SYSTEM_IMGUI=ON" }
configure-dev = { cmd = "cmake -G Ninja -S . -B build -DCMAKE_BUILD_TYPE=Debug -DDART_VERBOSE=ON -DDART_USE_SYSTEM_IMGUI=ON" }

lint = { cmd = "cmake --build build --target format && black . && isort .", depends_on = [
"configure",
Expand All @@ -57,6 +58,9 @@ check-lint = { cmd = "cmake --build build --target check-format && black . --che
build = { cmd = "cmake --build build -j --target all", depends_on = [
"configure",
] }
build-dev = { cmd = "cmake --build build -j --target all", depends_on = [
"configure-dev",
] }
build-tests = { cmd = "cmake --build build -j --target tests", depends_on = [
"configure",
] }
Expand Down Expand Up @@ -151,6 +155,9 @@ check-lint = { cmd = "black . --check && isort . --check", depends_on = [
build = { cmd = "cmake --build build --config Release -j", depends_on = [
"configure",
] }
build-dev = { cmd = "cmake --build build --config Debug -j", depends_on = [
"configure",
] }
build-tests = { cmd = "cmake --build build --config Release -j --target tests", depends_on = [
"configure",
] }
Expand Down

0 comments on commit 3e767d1

Please sign in to comment.