Skip to content

Commit 7fc4d56

Browse files
authored
Fix Loggers (#309)
* Fix Loggers * code rev * Fix Sonarcloud * Fix Sonarcloud * code rev * code rev * Fix Sonarcloud * Fix Sonarcloud * Fix Sonarcloud * Fix Sonarcloud * Fix Sonarcloud * Fix Sonarcloud * Fix Sonarcloud * Fix Sonarcloud
1 parent efc0d7c commit 7fc4d56

6 files changed

Lines changed: 61 additions & 38 deletions

File tree

.github/workflows/ci-sonarcloud.yml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,12 @@ jobs:
5454
msys/unzip
5555
mingw-w64-ucrt-x86_64-python-lxml
5656
mingw-w64-ucrt-x86_64-python-pip
57-
- name: Set up JDK 17
58-
uses: actions/setup-java@v4
59-
with:
60-
distribution: temurin
61-
java-version: 17
62-
# - uses: actions/checkout@v5
57+
# - name: Set up JDK 21
58+
# uses: actions/setup-java@v5
6359
# with:
64-
# fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
60+
# distribution: temurin
61+
# java-version: 21
62+
# architecture: x64
6563
- name: install gcovr
6664
run: pip install gcovr
6765
- name: create build dir
@@ -97,13 +95,18 @@ jobs:
9795
run: |
9896
echo "${{ env.HOME }}/sonar/sonar-scanner-${{ env.SONAR_SCANNER_VERSION }}-windows/bin" >> $GITHUB_PATH
9997
echo "${{ env.HOME }}/sonar/build-wrapper-win-x86" >> $GITHUB_PATH
98+
export JAVA_HOME="${{ env.HOME }}/hostedtoolcache/windows/Java_Temurin-Hotspot_jdk/21.0.11-10.0/x64"
99+
echo "JAVA_HOME=\"${{ env.HOME }}/hostedtoolcache/windows/Java_Temurin-Hotspot_jdk/21.0.11-10.0/x64\"" >> $GITHUB_ENV
100+
echo "PATH=$JAVA_HOME/bin:$PATH" >> $GITHUB_ENV
100101
- name: cmake generator
101102
run: |
102103
cmake -G Ninja -DGENERATE_CODE_COVERAGE=ON -DCMAKE_BUILD_TYPE=Debug ..
103104
working-directory: build
104105
- name: cmake build sonar wrapper
105106
run: |
106107
echo $PATH
108+
export JAVA_HOME="${{ env.HOME }}/hostedtoolcache/windows/Java_Temurin-Hotspot_jdk/21.0.11-10.0/x64"
109+
export PATH=$JAVA_HOME/bin:$PATH
107110
${{ env.HOME }}/sonar/build-wrapper-win-x86/build-wrapper-win-x86-64 --out-dir . cmake --build . --config=Debug -j4
108111
working-directory: build
109112
- name: CTest (gcov)
@@ -130,6 +133,11 @@ jobs:
130133
# ls -l ${{ env.HOME }}/sonar
131134
# ls -l ${{ env.HOME }}/sonar/sonar-scanner-${{ env.SONAR_SCANNER_VERSION }}-windows
132135
# ls -l ${{ env.HOME }}/sonar/sonar-scanner-${{ env.SONAR_SCANNER_VERSION }}-windows/bin
136+
$env:JAVA_HOME = "C:\hostedtoolcache\windows\Java_Temurin-Hotspot_jdk\21.0.3-7\x64"
137+
[System.Environment]::SetEnvironmentVariable("JAVA_HOME", $env:JAVA_HOME, "Machine")
138+
$env:PATH = "$env:JAVA_HOME\bin;$env:PATH"
139+
# $env:SONAR_SCANNER_OPTS = "-Djava.home=$env:JAVA_HOME"
140+
133141
# ${{ env.HOME }}/sonar/sonar-scanner-${{ env.SONAR_SCANNER_VERSION }}-windows/bin/sonar-scanner.bat --define sonar.host.url="${{ env.SONAR_SERVER_URL }}" --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}"
134142
135143
# echo "${{ env.SONAR_DIR }}\sonar-scanner-${{ env.SONAR_SCANNER_VERSION }}-windows\bin" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)
55
endif()
66

77

8-
project ("hyper-sonic-drivers" VERSION 0.19.5 DESCRIPTION "Hyper-Sonic Drivers for emulating old soundcards")
8+
project ("hyper-sonic-drivers" VERSION 0.19.6 DESCRIPTION "Hyper-Sonic Drivers for emulating old soundcards")
99
include (TestBigEndian)
1010
TEST_BIG_ENDIAN(IS_BIG_ENDIAN)
1111
if(IS_BIG_ENDIAN)

cspell.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"DCMAKE",
2222
"devel",
2323
"DGENERATE",
24+
"Djava",
2425
"dosbox",
2526
"DRRATE",
2627
"DRVR",
@@ -42,6 +43,8 @@
4243
"gcovr",
4344
"genmidi",
4445
"gtest",
46+
"hostedtoolcache",
47+
"Hotspot",
4548
"IPCM",
4649
"kcode",
4750
"KEYON",
@@ -87,6 +90,7 @@
8790
"sbpro",
8891
"SCUMM",
8992
"scummvm",
93+
"SDLCALL",
9094
"SDLK",
9195
"seminote",
9296
"sinwave",

hyper-sonic-drivers/CMakeLists.txt

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -80,21 +80,6 @@ install(
8080
PUBLIC_HEADER DESTINATION static/include
8181
)
8282

83-
# install(
84-
# TARGETS spdlog
85-
# EXPORT ${LIB_CONF}
86-
# DESTINATION static/lib
87-
# PUBLIC_HEADER DESTINATION static/include
88-
# )
89-
90-
# install(
91-
# TARGETS fmt
92-
# EXPORT ${LIB_CONF}
93-
# DESTINATION static/lib
94-
# PUBLIC_HEADER DESTINATION static/include
95-
# )
96-
97-
9883
## TODO: this is ok, but some includes files i don't want to be "public",
9984
## so it looks like it must be built manually..
10085
# try defining PUBLIC_HEADER than do an install target (it is at line 31)
@@ -119,11 +104,6 @@ write_basic_package_version_file(
119104
COMPATIBILITY AnyNewerVersion
120105
)
121106

122-
export(TARGETS ${LIB_NAME}
123-
FILE ${CMAKE_BINARY_DIR}/${LIB_NAME}.cmake
124-
NAMESPACE HyperSonicDrivers::
125-
)
126-
127107
install(EXPORT ${LIB_CONF}
128108
DESTINATION static/cmake
129109
NAMESPACE HyperSonicDrivers::
@@ -267,9 +247,37 @@ target_link_libraries(${LIB_NAME}
267247

268248
if(USE_SPDLOG)
269249
install(FILES
270-
$<TARGET_FILE:${LIB_SPDLOG}
271-
DESTINATION static/lib
272-
)
250+
$<TARGET_FILE:${LIB_SPDLOG}
251+
$<TARGET_LINKER_FILE:${LIB_SPDLOG}>
252+
DESTINATION static/lib
253+
)
254+
255+
install(
256+
TARGETS fmt
257+
EXPORT ${LIB_CONF}
258+
DESTINATION static/lib
259+
PUBLIC_HEADER DESTINATION static/include
260+
)
261+
262+
install(
263+
TARGETS spdlog
264+
EXPORT ${LIB_CONF}
265+
DESTINATION static/lib
266+
PUBLIC_HEADER DESTINATION static/include
267+
)
268+
269+
export(TARGETS
270+
${LIB_NAME}
271+
fmt
272+
spdlog
273+
FILE ${CMAKE_BINARY_DIR}/${LIB_NAME}.cmake
274+
NAMESPACE HyperSonicDrivers::
275+
)
276+
else()
277+
export(TARGETS ${LIB_NAME}
278+
FILE ${CMAKE_BINARY_DIR}/${LIB_NAME}.cmake
279+
NAMESPACE HyperSonicDrivers::
280+
)
273281
endif()
274282

275283
if(USE_SDL3 OR USE_SDL2)

hyper-sonic-drivers/src/HyperSonicDrivers/utils/sdl2/Logger.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ constexpr SDL_LogPriority level2sdl(const Logger::eLevel level)
5454
static SDL_LogOutputFunction default_log_output_function = nullptr;
5555
static void* default_log_output_function_userdata = nullptr;
5656

57-
[[maybe_unused]] static void log_output([[maybe_unused]] void* userdata, int category, SDL_LogPriority priority, const char* msg)
57+
static void SDLCALL log_output([[maybe_unused]] void* userdata, int category, SDL_LogPriority priority, const char* msg)
5858
{
5959
std::string p;
6060
std::string c;
@@ -129,11 +129,13 @@ Logger::Logger() : ILogger()
129129
SDL_LogGetOutputFunction(&default_log_output_function, &default_log_output_function_userdata);
130130
instance = this;
131131
setLevel(eLevel::Info);
132+
enable();
132133
}
133134

134135
Logger::~Logger()
135136
{
136137
fflush(nullptr);
138+
disable();
137139
}
138140

139141
void Logger::setLevelAll(const eLevel level)
@@ -180,12 +182,11 @@ void Logger::critical(const std::string& str, const eCategory cat)
180182

181183
void Logger::enable()
182184
{
183-
// SDL_LogSetOutputFunction(&log_output, nullptr);
184-
SDL_LogSetOutputFunction(default_log_output_function, default_log_output_function_userdata);
185+
SDL_LogSetOutputFunction(&log_output, nullptr);
185186
}
186187

187188
void Logger::disable()
188189
{
189-
SDL_LogSetOutputFunction(nullptr, nullptr);
190+
SDL_LogSetOutputFunction(default_log_output_function, default_log_output_function_userdata);
190191
}
191192
} // namespace HyperSonicDrivers::utils::sdl2

hyper-sonic-drivers/src/HyperSonicDrivers/utils/sdl3/Logger.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ constexpr SDL_LogPriority level2sdl(const Logger::eLevel level)
5454
static SDL_LogOutputFunction default_log_output_function = nullptr;
5555
static void* default_log_output_function_userdata = nullptr;
5656

57-
[[maybe_unused]] static void log_output([[maybe_unused]] void* userdata, int category, SDL_LogPriority priority, const char* msg)
57+
[[maybe_unused]] static void SDLCALL log_output([[maybe_unused]] void* userdata, int category, SDL_LogPriority priority, const char* msg)
5858
{
5959
std::string p;
6060
std::string c;
@@ -129,11 +129,13 @@ Logger::Logger() : ILogger()
129129
SDL_GetLogOutputFunction(&default_log_output_function, &default_log_output_function_userdata);
130130
instance = this;
131131
setLevel(eLevel::Info);
132+
enable();
132133
}
133134

134135
Logger::~Logger()
135136
{
136137
fflush(nullptr);
138+
disable();
137139
}
138140

139141
void Logger::setLevelAll(const eLevel level)
@@ -180,12 +182,12 @@ void Logger::critical(const std::string& str, const eCategory cat)
180182

181183
void Logger::enable()
182184
{
183-
SDL_SetLogOutputFunction(default_log_output_function, default_log_output_function_userdata);
185+
SDL_SetLogOutputFunction(&log_output, nullptr);
184186
}
185187

186188
void Logger::disable()
187189
{
188-
SDL_SetLogOutputFunction(nullptr, nullptr);
190+
SDL_SetLogOutputFunction(default_log_output_function, default_log_output_function_userdata);
189191
}
190192

191193

0 commit comments

Comments
 (0)