Skip to content
Merged
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
4 changes: 0 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ jobs:
fail-fast: false
matrix:
config:
- name: Linux GCC 10
os: ubuntu-22.04
compiler: g++-10

- name: Linux GCC 14
os: ubuntu-24.04
compiler: g++-14
Expand Down
29 changes: 1 addition & 28 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.20) # should be 3.23 but Python build fails with scikit-build-core
cmake_minimum_required(VERSION 3.24)

project(
openae
Expand Down Expand Up @@ -60,33 +60,6 @@ else()
target_compile_options(openae_project_options INTERFACE ${warnings})
endif()

# dependencies
include(FetchContent)
FetchContent_Declare(
fmt
GIT_REPOSITORY https://github.com/fmtlib/fmt
GIT_TAG 11.1.4
EXCLUDE_FROM_ALL
SYSTEM
FIND_PACKAGE_ARGS 11.0.0...12.0.0
)
FetchContent_MakeAvailable(fmt)
if(TARGET fmt)
set_target_properties(fmt PROPERTIES CXX_CLANG_TIDY "")
endif()

option(XXHASH_BUILD_XXHSUM "Build the xxhsum binary" OFF)
FetchContent_Declare(
xxHash
GIT_REPOSITORY https://github.com/Cyan4973/xxHash.git
GIT_TAG v0.8.3
SOURCE_SUBDIR cmake_unofficial
EXCLUDE_FROM_ALL
SYSTEM
FIND_PACKAGE_ARGS 0.8.3...0.9.0
)
FetchContent_MakeAvailable(xxHash)

# library
add_subdirectory(src)

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ Following build options are available:
- `OPENAE_BUILD_TESTS`: Build unit tests

Requirements:
- CMake 3.23 or higher
- C++20 compiler (e.g., GCC ≥ 10, Clang ≥ 11, MSVC ≥ 19.30)
- CMake 3.24 or higher
- C++20 compiler

### Build

Expand Down
2 changes: 1 addition & 1 deletion benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ FetchContent_Declare(
GIT_TAG v1.9.1
EXCLUDE_FROM_ALL
SYSTEM
FIND_PACKAGE_ARGS 1.9.0...2.0.0
FIND_PACKAGE_ARGS 1.9.1
)
FetchContent_MakeAvailable(benchmark)
if(TARGET benchmark)
Expand Down
3 changes: 1 addition & 2 deletions bindings/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ target_sources(
target_link_libraries(
openae_bindings_python
PRIVATE
openae_project_options
openae
fmt::fmt-header-only
openae_project_options
)
set_target_properties(
openae_bindings_python
Expand Down
8 changes: 5 additions & 3 deletions bindings/python/src/openae.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include <complex>
#include <format>
#include <memory_resource>
#include <string>
#include <utility>

#include <fmt/format.h>
#include <nanobind/nanobind.h>
#include <nanobind/ndarray.h>
#include <nanobind/stl/string.h>
Expand All @@ -22,7 +22,7 @@ struct PyInput {
PySpectrum spectrum;

std::string repr() const {
return fmt::format("Input(samplerate={}, timedata=..., spectrum=...)", samplerate);
return std::format("Input(samplerate={}, timedata=..., spectrum=...)", samplerate);
}

std::string str() const {
Expand Down Expand Up @@ -85,7 +85,9 @@ constexpr int py_log_level(openae::LogLevel level) noexcept {
}
}

void py_log(openae::LogLevel level, const char* msg) {
void py_log(
openae::LogLevel level, const char* msg, [[maybe_unused]] std::source_location location
) {
auto logger = nb::module_::import_("logging").attr("getLogger")("openae");
// https://docs.python.org/3/library/logging.html#logrecord-objects
nb::dict kwargs; // NOLINT(*const-correctness), false positive
Expand Down
11 changes: 9 additions & 2 deletions include/openae/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <functional>
#include <memory>
#include <memory_resource>
#include <source_location>

#include "openae/config.hpp"

Expand All @@ -18,7 +19,8 @@ enum class LogLevel : std::uint8_t {
Fatal,
};

using Logger = std::function<void(LogLevel level, const char* message)>;
using Logger =
std::function<void(LogLevel level, const char* message, std::source_location location)>;

using MemoryResource = std::pmr::memory_resource;

Expand All @@ -32,6 +34,11 @@ struct Env {
Cache* cache = nullptr;
};

OPENAE_EXPORT void log(Env& env, LogLevel level, const char* msg);
OPENAE_EXPORT void log(
Env& env,
LogLevel level,
const char* msg,
std::source_location location = std::source_location::current()
);

} // namespace openae
14 changes: 13 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
include(FetchContent)
option(XXHASH_BUILD_XXHSUM "Build the xxhsum binary" OFF)
FetchContent_Declare(
xxHash
GIT_REPOSITORY https://github.com/Cyan4973/xxHash.git
GIT_TAG v0.8.3
SOURCE_SUBDIR cmake_unofficial
EXCLUDE_FROM_ALL
SYSTEM
FIND_PACKAGE_ARGS 0.8.3
)
FetchContent_MakeAvailable(xxHash)

configure_file(
"${PROJECT_SOURCE_DIR}/include/openae/config.hpp.in"
"${PROJECT_BINARY_DIR}/include/openae/config.hpp"
Expand Down Expand Up @@ -26,7 +39,6 @@ target_link_libraries(
openae
PRIVATE
$<BUILD_INTERFACE:openae_project_options>
fmt::fmt
PUBLIC
# TODO: xxhash.h not found if PRIVATE
$<BUILD_INTERFACE:xxHash::xxhash> # effectively header-only with XXH_INLINE_ALL
Expand Down
7 changes: 5 additions & 2 deletions src/common.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#include "openae/common.hpp"

#include <memory>
#include <source_location>

#include "cache.hpp"

namespace openae {
Expand All @@ -13,9 +16,9 @@ std::unique_ptr<Cache, void (*)(Cache*)> make_cache() {
return {new Cache, &delete_func<Cache>};
}

void log(Env& env, LogLevel level, const char* msg) {
void log(Env& env, LogLevel level, const char* msg, std::source_location location) {
if (env.logger != nullptr) {
env.logger(level, msg);
env.logger(level, msg, location);
}
}

Expand Down
4 changes: 2 additions & 2 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ FetchContent_Declare(
GIT_TAG v3.8.0
EXCLUDE_FROM_ALL
SYSTEM
FIND_PACKAGE_ARGS 3.8.0...4.0.0
FIND_PACKAGE_ARGS 3.8.0
)
FetchContent_MakeAvailable(Catch2)
if(TARGET Catch2)
Expand All @@ -20,7 +20,7 @@ FetchContent_Declare(
GIT_TAG v3.4.0
EXCLUDE_FROM_ALL
SYSTEM
FIND_PACKAGE_ARGS 3.4.0...4.0.0
FIND_PACKAGE_ARGS 3.4.0
)
FetchContent_MakeAvailable(tomlplusplus)

Expand Down
3 changes: 2 additions & 1 deletion tests/test_features.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <algorithm>
#include <array>
#include <filesystem>
#include <format>
#include <map>
#include <stdexcept>
#include <string>
Expand Down Expand Up @@ -145,7 +146,7 @@ R compute_feature(
for_each(args, [&, index = size_t{0}]<typename Arg>(Arg& arg) mutable {
const auto& param_name = param_names.at(index++);
if (not param_values.contains(param_name)) {
throw std::runtime_error(std::string{"Parameter not found: "}.append(param_name));
throw std::runtime_error(std::format("Parameter not found: {}", param_name));
}
arg = static_cast<Arg>(param_values.at(param_name));
});
Expand Down
6 changes: 2 additions & 4 deletions tests/tostring.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <sstream>
#include <format>
#include <string>
#include <utility>

Expand All @@ -9,9 +9,7 @@ namespace Catch {
template <typename T1, typename T2>
struct StringMaker<std::pair<T1, T2>> {
static std::string convert(const std::pair<T1, T2>& pair) {
std::ostringstream oss;
oss << "(" << pair.first << "," << pair.second << ")";
return oss.str();
return std::format("({},{})", pair.first, pair.second);
}
};

Expand Down
Loading