From bcb8c108b27859dcb749fa6f5ed87d5947c57073 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Fri, 5 Mar 2021 21:45:37 -0600 Subject: [PATCH] [ox/std] Add option for building trace hook in shared library --- deps/ox/src/ox/std/CMakeLists.txt | 17 +++++++++++++++-- deps/ox/src/ox/std/trace.cpp | 4 +--- deps/ox/src/ox/std/tracehook.cpp | 13 +++++++++++++ 3 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 deps/ox/src/ox/std/tracehook.cpp diff --git a/deps/ox/src/ox/std/CMakeLists.txt b/deps/ox/src/ox/std/CMakeLists.txt index 459404da..0abcc9c8 100644 --- a/deps/ox/src/ox/std/CMakeLists.txt +++ b/deps/ox/src/ox/std/CMakeLists.txt @@ -1,3 +1,15 @@ +if(OX_USE_STDLIB AND OX_ENABLE_TRACEHOOK) + add_library( + OxTraceHook SHARED + tracehook.cpp + ) +else() + add_library( + OxTraceHook + tracehook.cpp + ) +endif() + add_library( OxStd assert.cpp @@ -26,7 +38,7 @@ if(NOT OX_BARE_METAL) ) endif() -if(${OX_USE_STDLIB}) +if(OX_USE_STDLIB) target_compile_definitions( OxStd PUBLIC OX_USE_STDLIB @@ -36,6 +48,7 @@ endif() target_link_libraries( OxStd PUBLIC $<$:gcc> + OxTraceHook ) install( @@ -70,7 +83,7 @@ install( include/ox/std ) -install(TARGETS OxStd +install(TARGETS OxStd OxTraceHook LIBRARY DESTINATION lib/ox ARCHIVE DESTINATION lib/ox ) diff --git a/deps/ox/src/ox/std/trace.cpp b/deps/ox/src/ox/std/trace.cpp index 15e134fd..86d14b2f 100644 --- a/deps/ox/src/ox/std/trace.cpp +++ b/deps/ox/src/ox/std/trace.cpp @@ -14,9 +14,7 @@ #include "trace.hpp" extern "C" -void oxTraceHook([[maybe_unused]] const char *file, [[maybe_unused]] int line, - [[maybe_unused]] const char *ch, [[maybe_unused]] const char *msg) { -} +void oxTraceHook(const char *file, int line, const char *ch, const char *msg); namespace ox::trace { diff --git a/deps/ox/src/ox/std/tracehook.cpp b/deps/ox/src/ox/std/tracehook.cpp new file mode 100644 index 00000000..131ba397 --- /dev/null +++ b/deps/ox/src/ox/std/tracehook.cpp @@ -0,0 +1,13 @@ +/* + * Copyright 2015 - 2021 gary@drinkingtea.net + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +extern "C" +void oxTraceHook([[maybe_unused]] const char *file, [[maybe_unused]] int line, + [[maybe_unused]] const char *ch, [[maybe_unused]] const char *msg) { +} +