1
- From 26ba5099f19ba2e00f84aff797be7740fead4aee Mon Sep 17 00:00:00 2001
1
+ From e9ceecb54cdfbf45b6eeb296fb078072e83327c2 Mon Sep 17 00:00:00 2001
2
2
From: Philippe Normand <
[email protected] >
3
3
Date: Wed, 29 Sep 2021 10:22:00 +0100
4
4
Subject: [PATCH] cmake: Look for resources in cmake's install lib dir
5
5
6
6
---
7
7
CMakeLists.txt | 4 ++++
8
- src/config.h.in | 6 ++++++
9
- src/util.cc | 11 +++--------
10
- 3 files changed, 13 insertions(+), 8 deletions(-)
8
+ src/config.h.in | 7 + ++++++
9
+ src/util.cc | 30 ++++++++++------------ --------
10
+ 3 files changed, 21 insertions(+), 20 deletions(-)
11
11
create mode 100644 src/config.h.in
12
12
13
13
diff --git a/CMakeLists.txt b/CMakeLists.txt
@@ -27,18 +27,19 @@ index e28d95aa..d38b3df2 100644
27
27
set(supports32bit true)
28
28
diff --git a/src/config.h.in b/src/config.h.in
29
29
new file mode 100644
30
- index 00000000..059aeb43
30
+ index 00000000..b1188ba7
31
31
--- /dev/null
32
32
+++ b/src/config.h.in
33
- @@ -0,0 +1,6 @@
33
+ @@ -0,0 +1,7 @@
34
34
+ #ifndef RR_CONFIG_H_
35
35
+ #define RR_CONFIG_H_
36
36
+
37
- + #define RESOURCES_LIB_DIR "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/"
37
+ + #define RESOURCES_PATH "@CMAKE_INSTALL_PREFIX@/"
38
+ + #define RESOURCES_LIB_PATH "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/"
38
39
+
39
40
+ #endif
40
41
diff --git a/src/util.cc b/src/util.cc
41
- index c57ae7b6..b2ac7bac 100644
42
+ index c57ae7b6..debc3310 100644
42
43
--- a/src/util.cc
43
44
+++ b/src/util.cc
44
45
@@ -45,6 +45,7 @@
@@ -49,22 +50,47 @@ index c57ae7b6..b2ac7bac 100644
49
50
50
51
void good_random(uint8_t* out, size_t out_len);
51
52
52
- @@ -1261,8 +1262,7 @@ static string read_exe_dir() {
53
- string resource_path() {
53
+ @@ -1245,26 +1246,20 @@ string real_path(const string& path) {
54
+ return path;
55
+ }
56
+
57
+ - static string read_exe_dir() {
58
+ - KernelMapping km =
59
+ - AddressSpace::read_local_kernel_mapping((uint8_t*)&read_exe_dir);
60
+ - string exe_path = km.fsname();
61
+ - int end = exe_path.length();
62
+ - // Chop off the filename
63
+ - while (end > 0 && exe_path[end - 1] != '/') {
64
+ - --end;
65
+ + string resource_path() {
66
+ + string resource_path = Flags::get().resource_path;
67
+ + if (resource_path.empty()) {
68
+ + return RESOURCES_PATH;
69
+ }
70
+ - exe_path.erase(end);
71
+ - return exe_path;
72
+ + return resource_path;
73
+ }
74
+
75
+ - string resource_path() {
76
+ + string resource_lib_path() {
54
77
string resource_path = Flags::get().resource_path;
55
78
if (resource_path.empty()) {
56
79
- static string exe_path = read_exe_dir() + "../";
57
80
- return exe_path;
58
- + return RESOURCES_LIB_DIR ;
81
+ + return RESOURCES_LIB_PATH ;
59
82
}
60
- return resource_path;
83
+ - return resource_path;
84
+ + return resource_path + "/lib/";
61
85
}
62
- @@ -1294,16 +1294,11 @@ bool running_under_rr(bool cache) {
86
+
87
+ /**
88
+ @@ -1294,16 +1289,11 @@ bool running_under_rr(bool cache) {
63
89
64
90
string find_helper_library(const char *basepath)
65
91
{
66
92
- string lib_path = resource_path() + "lib64/rr/";
67
- + string lib_path = resource_path () + "rr/";
93
+ + string lib_path = resource_lib_path () + "rr/";
68
94
string file_name = lib_path + basepath;
69
95
if (access(file_name.c_str(), F_OK) == 0) {
70
96
return lib_path;
0 commit comments