Skip to content

Commit 2e683ff

Browse files
committed
CHANGE(ipc): cwalk is hard to compile for both 32bit and 64bit. Now using snprintf()
1 parent 04bc3af commit 2e683ff

File tree

5 files changed

+50
-33
lines changed

5 files changed

+50
-33
lines changed

CMakeLists.txt

+25
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ endif()
9898

9999
option(lto "Enables link-time optimizations for release builds" ${LTO_DEFAULT})
100100

101+
# option(bundled-cwalk "Build the included version of CWalk instead of looking for one on the system." ON)
102+
101103
include(compiler)
102104
include(os)
103105

@@ -165,6 +167,29 @@ if(client OR server)
165167
add_subdirectory(src)
166168
endif()
167169

170+
# if(client OR overlay)
171+
# if(bundled-cwalk)
172+
# add_subdirectory("${3RDPARTY_DIR}/cwalk" "${CMAKE_CURRENT_BINARY_DIR}/cwalk" EXCLUDE_FROM_ALL)
173+
# if(overlay-xcompile)
174+
# # Just check for this header file while using a 32bit target as a really small and incomplete check whether g++-multilib seems to be
175+
# # installed. If we don't find it, we can assume it's not there but if we do find it, we still don't know. Thus we still print the
176+
# # message about the 32bit target potentially failing due to missing g++-multilib.
177+
# CHECK_INCLUDE_FILE("sys/cdefs.h" FOUND_CDEFS "-m32")
178+
# if(NOT FOUND_CDEFS)
179+
# message(FATAL_ERROR "Can't find the 32bit version of sys/cdefs.h - did you install g++-multilib?")
180+
# else()
181+
# message(STATUS "\nIf the 32 bit overlay library fails to compile, make sure the requirements are installed (\"g++-multilib\" package on Debian-based distributions).\n")
182+
# endif()
183+
184+
185+
# add_subdirectory("${3RDPARTY_DIR}/cwalk" "${CMAKE_CURRENT_BINARY_DIR}/cwalk_x86" EXCLUDE_FROM_ALL)
186+
# set_target_properties(cwalk PROPERTIES COMPILE_OPTIONS "-m32" LINK_OPTIONS "-m32")
187+
# endif()
188+
# else()
189+
# find_pkg(Cwalk REQUIRED)
190+
# endif()
191+
# endif()
192+
168193
if(g15 AND WIN32)
169194
add_subdirectory("helpers/g15helper")
170195
endif()

overlay/ipc_utils.c

+14-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// Mumble source tree or at <https://www.mumble.info/LICENSE>.
55

66
#include "ipc_utils.h"
7-
#include <cwalk.h>
7+
// #include <cwalk.h>
88
#include <string.h>
99

1010
#ifdef _WIN32
@@ -20,19 +20,26 @@
2020
# include <unistd.h>
2121
#endif
2222

23+
// can't trust POSIX's nor Window's PATH_MAX constants
24+
// see: https://eklitzke.org/path-max-is-tricky
25+
// https://stackoverflow.com/a/56385296
26+
const int MUMBLE_MAX_PATH = 1024;
27+
2328
char *getRuntimePath__() {
2429
char *path = NULL;
2530

2631
#ifdef __linux__
2732
char buffer[MUMBLE_MAX_PATH];
2833
char *xdgRuntimeDir = getenv("XDG_RUNTIME_DIR");
2934
if (xdgRuntimeDir == NULL || !xdgRuntimeDir) {
30-
char uid[10];
31-
sprintf(uid, "%d", getuid());
35+
// char uid[10];
36+
// sprintf(uid, "%d", getuid());
3237
xdgRuntimeDir = "/run/user/";
33-
cwk_path_join(xdgRuntimeDir, uid, buffer, sizeof(buffer));
38+
// cwk_path_join(xdgRuntimeDir, uid, buffer, sizeof(buffer));
39+
snprintf(buffer, sizeof(buffer), "%s/%d", xdgRuntimeDir, getuid());
3440
}
35-
size_t path_len = cwk_path_join(xdgRuntimeDir, "mumble", buffer, sizeof(buffer));
41+
// size_t path_len = cwk_path_join(xdgRuntimeDir, "mumble", buffer, sizeof(buffer));
42+
int path_len = snprintf(buffer, sizeof(buffer), "%s/mumble", xdgRuntimeDir);
3643
// if (path_len != strlen(buffer))
3744
// buffer is too small. Result is truncated
3845
if ((path = malloc(path_len)) == NULL)
@@ -76,7 +83,8 @@ char *getAndCreateOverlayPipePath__() {
7683
#else
7784
overlapyPipeFile = "MumbleOverlayPipe";
7885
#endif
79-
size_t path_len = cwk_path_join(runtimePath, overlapyPipeFile, buffer, sizeof(buffer));
86+
// size_t path_len = cwk_path_join(runtimePath, overlapyPipeFile, buffer, sizeof(buffer));
87+
int path_len = snprintf(buffer, sizeof(buffer), "%s/%s", runtimePath, overlapyPipeFile);
8088
// if (path_len != strlen(path))
8189
// path is too small. Result is truncated
8290
if ((path = malloc(path_len)) == NULL)

overlay/ipc_utils.h

-5
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@
66
#ifndef MUMBLE_OVERLAY_IPC_UTILS_H__
77
#define MUMBLE_OVERLAY_IPC_UTILS_H__
88

9-
// can't trust POSIX's nor Window's PATH_MAX constants
10-
// see: https://eklitzke.org/path-max-is-tricky
11-
// https://stackoverflow.com/a/56385296
12-
const int MUMBLE_MAX_PATH = 1024;
13-
149
char *getRuntimePath__();
1510

1611
char *getAndCreateOverlayPipePath__();

overlay_gl/CMakeLists.txt

+10-12
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@ if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64" OR ${CMAKE_SYSTEM_PROCESSOR} STRE
1313
endif()
1414
endif()
1515

16-
add_library(overlay_gl SHARED "overlay.c")
16+
set(OVERLAY_SOURCES
17+
"${CMAKE_SOURCE_DIR}/overlay/ipc_utils.c"
18+
"overlay.c"
19+
)
20+
add_library(overlay_gl SHARED ${OVERLAY_SOURCES})
21+
22+
# target_link_libraries(overlay_gl PRIVATE cwalk)
1723

1824
set_target_properties(overlay_gl
1925
PROPERTIES
@@ -37,22 +43,13 @@ if(NOT APPLE)
3743
)
3844

3945
if(overlay-xcompile)
40-
# Just check for this header file while using a 32bit target as a really small and incomplete check whether g++-multilib seems to be
41-
# installed. If we don't find it, we can assume it's not there but if we do find it, we still don't know. Thus we still print the
42-
# message about the 32bit target potentially failing due to missing g++-multilib.
43-
CHECK_INCLUDE_FILE("sys/cdefs.h" FOUND_CDEFS "-m32")
44-
if(NOT FOUND_CDEFS)
45-
message(FATAL_ERROR "Can't find the 32bit version of sys/cdefs.h - did you install g++-multilib?")
46-
else()
47-
message(STATUS "\nIf the 32 bit overlay library fails to compile, make sure the requirements are installed (\"g++-multilib\" package on Debian-based distributions).\n")
48-
endif()
49-
5046
set_target_properties(overlay_gl
5147
PROPERTIES
5248
OUTPUT_NAME "mumbleoverlay.x86_64"
5349
)
5450

55-
add_library(overlay_gl_x86 SHARED "overlay.c")
51+
add_library(overlay_gl_x86 SHARED ${OVERLAY_SOURCES})
52+
# target_link_libraries(overlay_gl_x86 PRIVATE cwalk)
5653

5754
target_compile_definitions(overlay_gl_x86
5855
PRIVATE
@@ -77,6 +74,7 @@ if(NOT APPLE)
7774
set_target_properties(overlay_gl_x86
7875
PROPERTIES
7976
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
77+
# LINK_FLAGS -m32
8078
OUTPUT_NAME "mumbleoverlay.x86"
8179
VERSION ${CMAKE_PROJECT_VERSION}
8280
)

src/mumble/CMakeLists.txt

+1-10
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ option(bundled-speex "Build the included version of Speex instead of looking for
2626
option(rnnoise "Use RNNoise for machine learning noise reduction." ON)
2727
option(bundled-rnnoise "Build the included version of RNNoise instead of looking for one on the system." ${rnnoise})
2828
option(bundled-json "Build the included version of nlohmann_json instead of looking for one on the system" ON)
29-
option(bundled-cwalk "Build the included version of CWalk instead of looking for one on the system." ON)
3029

3130
option(manual-plugin "Include the built-in \"manual\" positional audio plugin." ON)
3231

@@ -513,15 +512,7 @@ else()
513512
find_pkg("nlohmann_json" REQUIRED)
514513
endif()
515514

516-
if(bundled-cwalk)
517-
add_subdirectory("${3RDPARTY_DIR}/cwalk" "${CMAKE_CURRENT_BINARY_DIR}/cwalk" EXCLUDE_FROM_ALL)
518-
target_link_libraries(mumble_client_object_lib PUBLIC cwalk)
519-
install_library(cwalk mumble_client)
520-
else()
521-
find_pkg(Cwalk REQUIRED)
522-
target_link_libraries(mumble_client_object_lib PUBLIC cwalk)
523-
endif()
524-
515+
# target_link_libraries(mumble_client_object_lib PUBLIC cwalk)
525516
target_link_libraries(mumble_client_object_lib PUBLIC nlohmann_json::nlohmann_json)
526517

527518
find_pkg("SndFile;LibSndFile;sndfile" REQUIRED)

0 commit comments

Comments
 (0)