Skip to content

Commit 4ef82cc

Browse files
committed
Strip absolute paths from binaries #302
1 parent 6227ccc commit 4ef82cc

File tree

6 files changed

+20
-12
lines changed

6 files changed

+20
-12
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# WIP
2+
3+
- Strip absolute paths from binaries #302
4+
15
# 0.4.23 - Jan 18, 2025
26

37
- Don't reset DirectContext on LayerGLSkija resize #301 via @dzaima

linux/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ endif()
3636
target_include_directories(jwm PRIVATE ${CMAKE_CURRENT_LIST_DIR}/../shared/cc ${JAVA_HOME}/include ${JAVA_HOME}/include/linux)
3737
set_target_properties(jwm PROPERTIES OUTPUT_NAME "jwm_${JWM_ARCH}")
3838

39+
# https://github.com/HumbleUI/JWM/issues/302
40+
target_compile_options(jwm PRIVATE -ffile-prefix-map=${CMAKE_SOURCE_DIR}/=)
41+
3942

4043
target_link_libraries(jwm PRIVATE X11::X11 X11::Xrandr X11::Xcursor X11::Xi)
4144
target_link_libraries(jwm PRIVATE OpenGL::GL)

macos/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ add_library(jwm SHARED ${SOURCES_OBJC} ${SOURCES_CXX} ${SOURCES_CXX_IMPL})
1818
target_include_directories(jwm PRIVATE ${CMAKE_CURRENT_LIST_DIR}/../shared/cc $ENV{JAVA_HOME}/include $ENV{JAVA_HOME}/include/darwin)
1919
set_target_properties(jwm PROPERTIES OUTPUT_NAME "jwm_${JWM_ARCH}")
2020

21+
# https://github.com/HumbleUI/JWM/issues/302
22+
target_compile_options(jwm PRIVATE -ffile-prefix-map=${CMAKE_SOURCE_DIR}/=)
23+
2124
target_link_libraries(jwm
2225
"-framework AppKit"
2326
"-framework Cocoa"

shared/cc/Log.cc

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,8 @@ namespace jwm {
2222

2323
void notify(const LogEntry& entry) const {
2424
std::wstringstream finalMessageBuilder;
25-
const std::string& file = entry.getFile();
26-
27-
#ifdef WIN32
28-
const char sep[] = "\\";
29-
#else
30-
const char sep[] = "/";
31-
#endif
32-
33-
auto pos = file.find_last_of(sep);
3425
finalMessageBuilder
35-
<< (pos == std::string::npos? file.c_str(): file.substr(pos + 1).c_str()) << ":"
26+
<< entry.getFile().c_str() << ":"
3627
<< entry.getLine() << " "
3728
<< entry.getMessage();
3829

shared/cc/Log.hh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#pragma once
2+
#include <cstring>
23
#include <string>
34
#include <sstream>
45
#include <vector>
@@ -79,14 +80,18 @@ namespace jwm {
7980
#define JWM_LEVEL_VERBOSE true
8081
#define JWM_LEVEL_LOG false
8182

83+
// https://github.com/HumbleUI/JWM/issues/302
84+
#define JWM_FILENAME (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : \
85+
strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
86+
8287
// Macro to check if message can be logged, if can than
8388
// create builder and assemble message
8489
#define JWM_LOG_CAT(verbose, message) \
8590
do { \
8691
auto& __log = ::jwm::Log::getInstance(); \
8792
if (__log.checkLevel(verbose)) { \
8893
::jwm::LogBuilder __builder( \
89-
__FILE__, \
94+
JWM_FILENAME, \
9095
__FUNCTION__, \
9196
static_cast<unsigned long int>(__LINE__), \
9297
verbose, \

windows/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,10 @@ target_compile_definitions(jwm
102102
PRIVATE _CRT_SECURE_NO_WARNINGS
103103
PRIVATE _SCL_SECURE_NO_WARNINGS)
104104

105+
# https://github.com/HumbleUI/JWM/issues/302
105106
target_compile_options(jwm
106-
PRIVATE /source-charset:utf-8)
107+
PRIVATE /source-charset:utf-8
108+
PRIVATE "/d1trimfile:${CMAKE_SOURCE_DIR}/")
107109

108110
target_link_options(jwm
109111
PRIVATE /INCREMENTAL:NO

0 commit comments

Comments
 (0)