Mir

Merge lp:~andreas-pokorny/mir/unwrap-the-wrap into lp:mir

Proposed by Andreas Pokorny
Status: Rejected
Rejected by: Andreas Pokorny
Proposed branch: lp:~andreas-pokorny/mir/unwrap-the-wrap
Merge into: lp:mir
Prerequisite: lp:~mir-team/mir/server-platform-probing
Diff against target: 752 lines (+185/-151)
24 files modified
benchmarks/android-input/CMakeLists.txt (+1/-1)
benchmarks/frame-uniformity/CMakeLists.txt (+1/-1)
cmake/MirCommon.cmake (+6/-16)
examples/CMakeLists.txt (+20/-20)
playground/demo-shell/CMakeLists.txt (+1/-1)
src/CMakeLists.txt (+5/-6)
src/client/default_connection_configuration.cpp (+3/-1)
src/common/CMakeLists.txt (+13/-7)
src/common/executable_path.cpp (+76/-0)
src/common/symbols.map (+3/-0)
src/include/common/mir/executable_path.h (+32/-0)
src/platform/CMakeLists.txt (+0/-1)
src/platform/options/default_configuration.cpp (+7/-3)
src/server/CMakeLists.txt (+0/-1)
src/utils/CMakeLists.txt (+3/-3)
src/wrapper.c (+0/-66)
tests/acceptance-tests/CMakeLists.txt (+2/-1)
tests/client-language/CMakeLists.txt (+1/-1)
tests/include/mir_test_framework/executable_path.h (+4/-3)
tests/integration-tests/CMakeLists.txt (+1/-1)
tests/mir-stress/CMakeLists.txt (+1/-1)
tests/mir_test_framework/executable_path.cpp (+3/-15)
tests/performance-tests/CMakeLists.txt (+1/-1)
tests/unit-tests/CMakeLists.txt (+1/-1)
To merge this branch: bzr merge lp:~andreas-pokorny/mir/unwrap-the-wrap
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Alberto Aguirre (community) Abstain
Daniel van Vugt Needs Fixing
Robert Carr (community) Needs Information
Review via email: mp+247117@code.launchpad.net

Commit message

Remove wrapper and instead search for client and server platform paths relative to executable path but fallback to the compiled in directory in any case of failure

Description of the change

This removes the wrapper executable which was used to make running mir binaries simpler but also more painfull everytime you wanted to used gdb.

With this change client and server first peek for ../lib/mir/server-platforms and ../lib/server-modules (s/server/client for client) before settling with the compiled in path.

Alternatives not tried/proposed: have another compiled in path containing the CMAKE_BUILD_DIR.

To post a comment you must log in.
2167. By Andreas Pokorny

merge prereq

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Robert Carr (robertcarr) wrote :

>> With this change client and server first peek for ../lib/mir/server-platforms and ../lib/server-modules
>> (s/server/client for client) before settling with the compiled in path.

I'm concerned this may be the wrong choice for release builds...

review: Needs Information
Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

> >> With this change client and server first peek for ../lib/mir/server-
> platforms and ../lib/server-modules
> >> (s/server/client for client) before settling with the compiled in path.
>
> I'm concerned this may be the wrong choice for release builds...

hmmm I am not sure what would help your concerns, but we could do changes to our build directory structure to decrease the probability a deployed binary finds a directory at all... or increase the chance this initial peek hits the distribution choice for mir platform libraries.

2168. By Andreas Pokorny

dont install when noinstall

Revision history for this message
Kevin DuBois (kdub) wrote :

I suppose I prefer a search to wrapping all the binaries we have so that we load with a proper environment variable loaded, so if this works, seems a step in the right direction. (I was dreading explaining the env variable to bringup teams...). I guess my ideal approach would be to have the linker find libmirplatform.so.X, and then have the common platform library search paths, and select the best-fitting platform. At any rate, seems a bit better (if the packaging is fixed)

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alberto Aguirre (albaguirre) wrote :

===
383 + for (auto const& path : {base_path + "/../lib/server-modules/", base_path + "/../lib/mir/server-platform/"})

402 + for (auto const& path : {base_path + "/../lib/client-modules/", base_path + "/../lib/mir/client-platform/"})
===

I'm not convinced this should be in production code for the sake of running non-installed binaries.

Also MIR_CLIENT_PLATFORM_PATH and MIR_SERVER_PLATFORM_PATH could be different than the relative path described above right?

review: Needs Information
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

I like the idea of removing all wrappers if we have something else that works. Many of us argued for not wrapping from the beginning :)

Although I'm not sure what the immediate need is here... Our wrappers work perfectly both locally and on remote hosts already: rsync -avH lib bin phablet@nexus4:testmir/

(1) Not really portable outside of the Linux:
366 + auto tmp = readlink("/proc/self/exe", buf, sizeof buf);
A more portable solution is to make a path relative to argv[0]

(2) executable_path.cpp: Lines a a bit too long to be readable.

(3) Successful unwrapping is measured by our ability to remove this function, not just rename it:
34 -function (mir_add_wrapped_executable TARGET)
35 - set(REAL_EXECUTABLE .${TARGET}-uninstalled)
36 +function (mir_add_executable TARGET)

review: Needs Fixing
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Still needs fixing. Mainly on (3) as a successful removal of wrapping involves removing our wrapping of CMake's add_executable() too.

Although we don't need this branch right now either. I've proposed a simple fix for the original problem:
https://code.launchpad.net/~vanvugt/mir/append-libpath/+merge/247255

Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

> Still needs fixing. Mainly on (3) as a successful removal of wrapping involves
> removing our wrapping of CMake's add_executable() too.
>
> Although we don't need this branch right now either. I've proposed a simple
> fix for the original problem:
> https://code.launchpad.net/~vanvugt/mir/append-libpath/+merge/247255

Another problem that occurred was that gdb fails to restart when you go through the wrapper. So if you want to use it you have to use the '.uninstalled' binaries.

(3) the function still fulfills a purpose it installs executables to bin and provides a NOINSTALL flag, so I left it there.

2169. By Andreas Pokorny

simplified a bit - {server,client}-platorms is only used when deployed,
but library directories could be arbitrary

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
2170. By Andreas Pokorny

merged prereq

Revision history for this message
Alberto Aguirre (albaguirre) wrote :

I suppose I prefer just a simple launcher script (not the current wrapper) for dev purposes - which is what uninstalled binaries and libraries are mostly used for.

review: Abstain
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Robert Carr (robertcarr) wrote :

Maybe only for build-type = DEBUG?

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

> (3) the function still fulfills a purpose it installs executables to bin and provides a NOINSTALL flag, so I left it there.

It's a hack we only added last month. And NOINSTALL is a hack I only added last month to fix other bugs with the first wrapping system. We should get back to clean and pure CMake without leaving behind any remnants of the wrapping work if we can. That means using add_executable and explicit install rules.

And yeah I know gdb is a problem. We all knew it would be a problem. I too was one of the people who originally opposed wrapping for that and other reasons :)

Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

> > (3) the function still fulfills a purpose it installs executables to bin and
> provides a NOINSTALL flag, so I left it there.
>
> It's a hack we only added last month. And NOINSTALL is a hack I only added
> last month to fix other bugs with the first wrapping system. We should get
> back to clean and pure CMake without leaving behind any remnants of the
> wrapping work if we can. That means using add_executable and explicit install
> rules.
>
> And yeah I know gdb is a problem. We all knew it would be a problem. I too was
> one of the people who originally opposed wrapping for that and other reasons
> :)

hm cmake is meant to be programmable/extendable. The base set of function requires one to write rather verbose configurations. There is nothing negative about adding intent and reducing noise.

I will put this back to WIP, as we discussed a better approach yesterday during standup, while there is still there is a lack of broad agreement...

Unmerged revisions

2170. By Andreas Pokorny

merged prereq

2169. By Andreas Pokorny

simplified a bit - {server,client}-platorms is only used when deployed,
but library directories could be arbitrary

2168. By Andreas Pokorny

dont install when noinstall

2167. By Andreas Pokorny

merge prereq

2166. By Andreas Pokorny

Remove wrapper and instead search for client and server platform paths relative to executable path but fallback to the compiled in directory in any case of failure

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'benchmarks/android-input/CMakeLists.txt'
2--- benchmarks/android-input/CMakeLists.txt 2015-01-16 02:57:31 +0000
3+++ benchmarks/android-input/CMakeLists.txt 2015-01-22 16:32:05 +0000
4@@ -7,7 +7,7 @@
5 ${MIR_3RD_PARTY_INCLUDE_DIRECTORIES}
6 )
7
8-mir_add_wrapped_executable(input-reader-perf NOINSTALL
9+mir_add_executable(input-reader-perf NOINSTALL
10 input_reader_perf.cpp
11 )
12
13
14=== modified file 'benchmarks/frame-uniformity/CMakeLists.txt'
15--- benchmarks/frame-uniformity/CMakeLists.txt 2015-01-16 02:57:31 +0000
16+++ benchmarks/frame-uniformity/CMakeLists.txt 2015-01-22 16:32:05 +0000
17@@ -11,7 +11,7 @@
18 ${MIR_3RD_PARTY_INCLUDE_DIRECTORIES}
19 )
20
21-mir_add_wrapped_executable(frame_uniformity_test_client NOINSTALL
22+mir_add_executable(frame_uniformity_test_client NOINSTALL
23 touch_measuring_client.cpp
24 touch_producing_server.cpp
25 frame_uniformity_test.cpp
26
27=== modified file 'cmake/MirCommon.cmake'
28--- cmake/MirCommon.cmake 2015-01-16 02:57:31 +0000
29+++ cmake/MirCommon.cmake 2015-01-22 16:32:05 +0000
30@@ -169,27 +169,17 @@
31 endif()
32 endfunction()
33
34-function (mir_add_wrapped_executable TARGET)
35- set(REAL_EXECUTABLE .${TARGET}-uninstalled)
36+function (mir_add_executable TARGET)
37
38+ # TODO this can be done nicer with cmakes argument parser
39 list(GET ARGN 0 modifier)
40 if ("${modifier}" STREQUAL "NOINSTALL")
41- list(REMOVE_AT ARGN 0)
42- else()
43- install(PROGRAMS ${CMAKE_BINARY_DIR}/bin/${REAL_EXECUTABLE}
44- DESTINATION ${CMAKE_INSTALL_BINDIR}
45- RENAME ${TARGET}
46- )
47+ list(REMOVE_AT ARGN 0)
48 endif()
49
50 add_executable(${TARGET} ${ARGN})
51- set_target_properties(${TARGET} PROPERTIES
52- OUTPUT_NAME ${REAL_EXECUTABLE}
53- SKIP_BUILD_RPATH TRUE
54- )
55
56- add_custom_target(${TARGET}-wrapped
57- ln -fs wrapper ${CMAKE_BINARY_DIR}/bin/${TARGET}
58- )
59- add_dependencies(${TARGET} ${TARGET}-wrapped)
60+ if (NOT "${modifier}" STREQUAL "NOINSTALL")
61+ install(TARGETS ${TARGET} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
62+ endif()
63 endfunction()
64
65=== modified file 'examples/CMakeLists.txt'
66--- examples/CMakeLists.txt 2015-01-16 02:57:31 +0000
67+++ examples/CMakeLists.txt 2015-01-22 16:32:05 +0000
68@@ -1,4 +1,4 @@
69-mir_add_wrapped_executable(mir_demo_standalone_render_surfaces
70+mir_add_executable(mir_demo_standalone_render_surfaces
71 render_surfaces.cpp
72 buffer_render_target.cpp
73 image_renderer.cpp
74@@ -31,44 +31,44 @@
75 ${EGL_LIBRARIES}
76 ${GLESv2_LIBRARIES}
77 )
78-mir_add_wrapped_executable(mir_demo_client_eglflash
79+mir_add_executable(mir_demo_client_eglflash
80 eglflash.c
81 )
82 target_link_libraries(mir_demo_client_eglflash
83 eglapp
84 )
85-mir_add_wrapped_executable(mir_demo_client_egltriangle
86+mir_add_executable(mir_demo_client_egltriangle
87 egltriangle.c
88 )
89 target_link_libraries(mir_demo_client_egltriangle
90 eglapp
91 )
92-mir_add_wrapped_executable(mir_demo_client_eglcounter
93+mir_add_executable(mir_demo_client_eglcounter
94 eglcounter.cpp
95 )
96 target_link_libraries(mir_demo_client_eglcounter
97 eglapp
98 )
99-mir_add_wrapped_executable(mir_demo_client_eglplasma
100+mir_add_executable(mir_demo_client_eglplasma
101 eglplasma.c
102 )
103 target_link_libraries(mir_demo_client_eglplasma
104 eglapp
105 )
106-mir_add_wrapped_executable(mir_demo_client_cursors
107+mir_add_executable(mir_demo_client_cursors
108 cursors_demo_client.c
109 )
110 target_link_libraries(mir_demo_client_cursors
111 eglapp
112 )
113-mir_add_wrapped_executable(mir_demo_client_eglstateswitcher
114+mir_add_executable(mir_demo_client_eglstateswitcher
115 eglstateswitcher.c
116 )
117 target_link_libraries(mir_demo_client_eglstateswitcher
118 eglapp
119 )
120
121-mir_add_wrapped_executable(mir_demo_client_basic
122+mir_add_executable(mir_demo_client_basic
123 basic.c
124 )
125
126@@ -80,22 +80,22 @@
127 ${CMAKE_THREAD_LIBS_INIT}
128 )
129
130-mir_add_wrapped_executable(mir_demo_client_release_at_exit release_at_exit.c)
131+mir_add_executable(mir_demo_client_release_at_exit release_at_exit.c)
132 target_link_libraries(mir_demo_client_release_at_exit mirclient)
133
134-mir_add_wrapped_executable(mir_demo_client_multiwin multiwin.c)
135+mir_add_executable(mir_demo_client_multiwin multiwin.c)
136 target_link_libraries(mir_demo_client_multiwin mirclient)
137
138-mir_add_wrapped_executable(mir_demo_client_fingerpaint fingerpaint.c)
139+mir_add_executable(mir_demo_client_fingerpaint fingerpaint.c)
140 target_link_libraries(mir_demo_client_fingerpaint mirclient)
141
142-mir_add_wrapped_executable(mir_demo_client_progressbar progressbar.c)
143+mir_add_executable(mir_demo_client_progressbar progressbar.c)
144 target_link_libraries(mir_demo_client_progressbar mirclient)
145
146-mir_add_wrapped_executable(mir_demo_client_display_config demo_client_display_config.c)
147+mir_add_executable(mir_demo_client_display_config demo_client_display_config.c)
148 target_link_libraries(mir_demo_client_display_config eglapp)
149
150-mir_add_wrapped_executable(mir_demo_client_flicker
151+mir_add_executable(mir_demo_client_flicker
152 flicker.c
153 )
154
155@@ -107,7 +107,7 @@
156 ${CMAKE_THREAD_LIBS_INIT}
157 )
158
159-mir_add_wrapped_executable(mir_demo_client_scroll
160+mir_add_executable(mir_demo_client_scroll
161 scroll.cpp
162 )
163
164@@ -123,7 +123,7 @@
165
166 )
167
168-mir_add_wrapped_executable(mir_demo_client_prompt_session prompt_session.c)
169+mir_add_executable(mir_demo_client_prompt_session prompt_session.c)
170 target_link_libraries(mir_demo_client_prompt_session mirclient)
171
172 add_library(mirdraw STATIC graphics_utils.cpp)
173@@ -136,7 +136,7 @@
174 ${GLESv2_INCLUDE_DIRS}
175 )
176
177-mir_add_wrapped_executable(mir_demo_standalone_render_to_fb
178+mir_add_executable(mir_demo_standalone_render_to_fb
179 render_to_fb.cpp
180 )
181
182@@ -146,7 +146,7 @@
183 ${Boost_LIBRARIES}
184 )
185
186-mir_add_wrapped_executable(mir_demo_server
187+mir_add_executable(mir_demo_server
188 server_example.cpp
189 glog_logger.cpp
190 server_example_test_client.cpp
191@@ -160,10 +160,10 @@
192 ${Boost_LIBRARIES}
193 )
194
195-mir_add_wrapped_executable(mir_demo_server_minimal server_minimal.cpp)
196+mir_add_executable(mir_demo_server_minimal server_minimal.cpp)
197 target_link_libraries(mir_demo_server_minimal mirserver)
198
199-mir_add_wrapped_executable(mir_demo_standalone_render_overlays
200+mir_add_executable(mir_demo_standalone_render_overlays
201 render_overlays.cpp
202 )
203
204
205=== modified file 'playground/demo-shell/CMakeLists.txt'
206--- playground/demo-shell/CMakeLists.txt 2015-01-14 06:39:13 +0000
207+++ playground/demo-shell/CMakeLists.txt 2015-01-22 16:32:05 +0000
208@@ -4,7 +4,7 @@
209 window_manager.cpp
210 )
211
212-mir_add_wrapped_executable(mir_proving_server
213+mir_add_executable(mir_proving_server
214 demo_shell.cpp
215 )
216
217
218=== modified file 'src/CMakeLists.txt'
219--- src/CMakeLists.txt 2015-01-22 16:32:04 +0000
220+++ src/CMakeLists.txt 2015-01-22 16:32:05 +0000
221@@ -11,6 +11,11 @@
222 # Add the platform implementations before exposing any private APIs
223 add_subdirectory(platforms/)
224
225+# required in common
226+set(MIR_CLIENT_PLATFORM_PATH
227+ ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/mir/client-platform
228+)
229+
230 # the src/include/... directories should be private to the implementation
231 include_directories(${PROJECT_SOURCE_DIR}/src/include/common)
232 set(MIR_GENERATED_INCLUDE_DIRECTORIES)
233@@ -23,12 +28,6 @@
234 add_subdirectory(client/)
235 add_subdirectory(utils/)
236
237-add_executable(wrapper wrapper.c)
238-set_property(TARGET wrapper
239- APPEND_STRING PROPERTY COMPILE_FLAGS " -DEXECUTABLE_FORMAT=\\\".%s-uninstalled\\\"")
240-set_property(TARGET wrapper
241- APPEND_STRING PROPERTY COMPILE_FLAGS " -D_BSD_SOURCE")
242-
243 set(
244 MIR_GENERATED_INCLUDE_DIRECTORIES
245 ${MIR_GENERATED_INCLUDE_DIRECTORIES}
246
247=== modified file 'src/client/default_connection_configuration.cpp'
248--- src/client/default_connection_configuration.cpp 2015-01-22 16:32:04 +0000
249+++ src/client/default_connection_configuration.cpp 2015-01-22 16:32:05 +0000
250@@ -34,6 +34,7 @@
251 #include "connection_surface_map.h"
252 #include "lifecycle_control.h"
253 #include "mir/shared_library.h"
254+#include "mir/executable_path.h"
255 #include "mir/client_platform_factory.h"
256 #include "probing_client_platform_factory.h"
257 #include "mir_event_distributor.h"
258@@ -122,7 +123,8 @@
259 else
260 {
261 auto const platform_path_override = getenv("MIR_CLIENT_PLATFORM_PATH");
262- auto const platform_path = platform_path_override ? platform_path_override : MIR_CLIENT_PLATFORM_PATH;
263+ auto const builtin_path = mir::default_client_platform_path();
264+ auto const platform_path = platform_path_override ? platform_path_override : builtin_path.c_str();
265 platform_plugins = mir::libraries_for_path(platform_path, *the_shared_library_prober_report());
266 }
267
268
269=== modified file 'src/common/CMakeLists.txt'
270--- src/common/CMakeLists.txt 2015-01-14 06:39:13 +0000
271+++ src/common/CMakeLists.txt 2015-01-22 16:32:05 +0000
272@@ -1,4 +1,8 @@
273-add_definitions(-DMIR_LOG_COMPONENT_FALLBACK="mircommon")
274+add_definitions(
275+ -DMIR_LOG_COMPONENT_FALLBACK="mircommon"
276+ -DMIR_SERVER_PLATFORM_PATH="${MIR_SERVER_PLATFORM_PATH}"
277+ -DMIR_CLIENT_PLATFORM_PATH="${MIR_CLIENT_PLATFORM_PATH}"
278+)
279
280 set(MIR_GENERATED_INCLUDE_DIRECTORIES)
281 set(MIR_COMMON_SOURCES)
282@@ -17,9 +21,16 @@
283 add_subdirectory(sharedlibrary)
284 add_subdirectory(thread)
285 add_subdirectory(time)
286+
287+add_library(mircommonbaseobjects
288+ OBJECT
289+ event.cpp
290+ log.cpp
291+ executable_path.cpp
292+)
293 list(APPEND MIR_COMMON_SOURCES
294 $<TARGET_OBJECTS:mirtime>
295- ${CMAKE_CURRENT_SOURCE_DIR}/log.cpp
296+ $<TARGET_OBJECTS:mircommonbaseobjects>
297 )
298
299 set(PREFIX "${CMAKE_INSTALL_PREFIX}")
300@@ -32,14 +43,9 @@
301 ${MIR_GENERATED_INCLUDE_DIRECTORIES}
302 PARENT_SCOPE)
303
304-
305 MESSAGE( STATUS "MIR_COMMON_SOURCES. . . : ${MIR_COMMON_SOURCES}" )
306 MESSAGE( STATUS "MIR_COMMON_REFERENCES . : ${MIR_COMMON_REFERENCES}" )
307
308-list(APPEND MIR_COMMON_SOURCES
309- ${CMAKE_CURRENT_SOURCE_DIR}/event.cpp
310-)
311-
312 add_library(mircommon
313 SHARED
314 ${MIR_COMMON_SOURCES}
315
316=== added file 'src/common/executable_path.cpp'
317--- src/common/executable_path.cpp 1970-01-01 00:00:00 +0000
318+++ src/common/executable_path.cpp 2015-01-22 16:32:05 +0000
319@@ -0,0 +1,76 @@
320+/*
321+ * Copyright © 2015 Canonical Ltd.
322+ *
323+ * This program is free software: you can redistribute it and/or modify
324+ * it under the terms of the GNU Lesser General Public License version 3,
325+ * as published by the Free Software Foundation.
326+ *
327+ * This program is distributed in the hope that it will be useful,
328+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
329+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
330+ * GNU Lesser General Public License for more details.
331+ *
332+ * You should have received a copy of the GNU Lesser General Public License
333+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
334+ *
335+ * Authored by:
336+ * Andreas Pokorny <andreas.pokorny@canonical.com>
337+ */
338+
339+#include "mir/executable_path.h"
340+
341+#include <libgen.h>
342+#include <stdexcept>
343+#include <boost/throw_exception.hpp>
344+#include <boost/exception/errinfo_errno.hpp>
345+#include <boost/filesystem.hpp>
346+
347+std::string mir::executable_path()
348+{
349+ char buf[1024];
350+ auto tmp = readlink("/proc/self/exe", buf, sizeof buf);
351+ if (tmp < 0)
352+ BOOST_THROW_EXCEPTION(boost::enable_error_info(
353+ std::runtime_error("Failed to find our executable path"))
354+ << boost::errinfo_errno(errno));
355+ if (tmp > static_cast<ssize_t>(sizeof(buf) - 1))
356+ BOOST_THROW_EXCEPTION(std::runtime_error("Path to executable is too long!"));
357+ buf[tmp] = '\0';
358+ return dirname(buf);
359+}
360+
361+std::string mir::default_server_platform_path()
362+{
363+ try
364+ {
365+ auto inside_build_dir = executable_path() + "/../lib/server-modules/";
366+ if (boost::filesystem::exists(inside_build_dir))
367+ return inside_build_dir;
368+ }
369+ catch(boost::exception &)
370+ {
371+ // a failure in searching the module path inside build directories is nothing the deployed server libraries
372+ // should have to handle, hence ignored here
373+ }
374+
375+ return MIR_SERVER_PLATFORM_PATH;
376+}
377+
378+std::string mir::default_client_platform_path()
379+{
380+ try
381+ {
382+ auto inside_build_dir = executable_path() + "/../lib/client-modules/";
383+
384+ if (boost::filesystem::exists(inside_build_dir))
385+ return inside_build_dir;
386+ }
387+ catch(boost::exception &)
388+ {
389+ // a failure in searching the module path inside build directories is nothing the deployed client libraries
390+ // should have to handle, hence ignored here
391+ }
392+
393+ return MIR_CLIENT_PLATFORM_PATH;
394+}
395+
396
397=== modified file 'src/common/symbols.map'
398--- src/common/symbols.map 2015-01-14 06:39:13 +0000
399+++ src/common/symbols.map 2015-01-22 16:32:05 +0000
400@@ -11,6 +11,9 @@
401 mir_diagonal_resize_bottom_to_top_cursor_name*;
402 mir_diagonal_resize_top_to_bottom_cursor_name*;
403 mir_disabled_cursor_name*;
404+ mir::default_server_platform_path*;
405+ mir::default_client_platform_path*;
406+ mir::executable_path*;
407 mir::Fd::Fd*;
408 mir::Fd::invalid*;
409 mir::Fd::operator*;
410
411=== added file 'src/include/common/mir/executable_path.h'
412--- src/include/common/mir/executable_path.h 1970-01-01 00:00:00 +0000
413+++ src/include/common/mir/executable_path.h 2015-01-22 16:32:05 +0000
414@@ -0,0 +1,32 @@
415+/*
416+ * Copyright © 2015 Canonical Ltd.
417+ *
418+ * This program is free software: you can redistribute it and/or modify
419+ * it under the terms of the GNU Lesser General Public License version 3,
420+ * as published by the Free Software Foundation.
421+ *
422+ * This program is distributed in the hope that it will be useful,
423+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
424+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
425+ * GNU Lesser General Public License for more details.
426+ *
427+ * You should have received a copy of the GNU Lesser General Public License
428+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
429+ *
430+ * Authored by:
431+ * Andreas Pokorny <andreas.pokorny@canonical.com>
432+ */
433+
434+#ifndef MIR_EXECUTABLE_PATH_H_
435+#define MIR_EXECUTABLE_PATH_H_
436+
437+#include <string>
438+
439+namespace mir
440+{
441+std::string executable_path();
442+std::string default_server_platform_path();
443+std::string default_client_platform_path();
444+}
445+
446+#endif
447
448=== modified file 'src/platform/CMakeLists.txt'
449--- src/platform/CMakeLists.txt 2015-01-22 16:32:04 +0000
450+++ src/platform/CMakeLists.txt 2015-01-22 16:32:05 +0000
451@@ -7,7 +7,6 @@
452
453 set(symbol_map ${CMAKE_CURRENT_SOURCE_DIR}/symbols.map)
454
455-add_definitions(-DMIR_SERVER_PLATFORM_PATH="${MIR_SERVER_PLATFORM_PATH}")
456 add_definitions(-DMIR_SERVER_GRAPHICS_PLATFORM_VERSION="${MIR_SERVER_GRAPHICS_PLATFORM_VERSION}")
457
458 set(MIR_PLATFORM_OBJECTS
459
460=== modified file 'src/platform/options/default_configuration.cpp'
461--- src/platform/options/default_configuration.cpp 2015-01-22 16:32:04 +0000
462+++ src/platform/options/default_configuration.cpp 2015-01-22 16:32:05 +0000
463@@ -21,6 +21,7 @@
464 #include "mir/graphics/platform.h"
465 #include "mir/default_configuration.h"
466 #include "mir/abnormal_exit.h"
467+#include "mir/executable_path.h"
468 #include "mir/shared_library_prober.h"
469 #include "mir/logging/null_shared_library_prober_report.h"
470 #include "mir/graphics/platform_probe.h"
471@@ -110,6 +111,9 @@
472 using namespace options;
473 namespace po = boost::program_options;
474
475+ auto default_platform_path = default_server_platform_path();
476+ auto server_path_description = "Directory to look for platform libraries (default: " + default_platform_path + ")";
477+
478 add_options()
479 (host_socket_opt, po::value<std::string>(),
480 "Host socket filename")
481@@ -119,8 +123,8 @@
482 (prompt_socket_opt, "Provide a \"..._trusted\" filename for prompt helper connections")
483 (platform_graphics_lib, po::value<std::string>(),
484 "Library to use for platform graphics support (default: autodetect)")
485- (platform_path, po::value<std::string>()->default_value(MIR_SERVER_PLATFORM_PATH),
486- "Directory to look for platform libraries (default: " MIR_SERVER_PLATFORM_PATH ")")
487+ (platform_path, po::value<std::string>()->default_value(default_platform_path),
488+ server_path_description.c_str())
489 (enable_input_opt, po::value<bool>()->default_value(enable_input_default),
490 "Enable input.")
491 (compositor_report_opt, po::value<std::string>()->default_value(off_opt_value),
492@@ -166,7 +170,7 @@
493 po::value<std::string>(), "");
494 program_options.add_options()
495 (platform_path,
496- po::value<std::string>()->default_value(MIR_SERVER_PLATFORM_PATH),
497+ po::value<std::string>()->default_value(default_server_platform_path()),
498 "");
499 mo::ProgramOption options;
500 options.parse_arguments(program_options, argc, argv);
501
502=== modified file 'src/server/CMakeLists.txt'
503--- src/server/CMakeLists.txt 2015-01-22 16:32:04 +0000
504+++ src/server/CMakeLists.txt 2015-01-22 16:32:05 +0000
505@@ -11,7 +11,6 @@
506 ${GLIB_INCLUDE_DIRS}
507 )
508
509-add_definitions(-DMIR_SERVER_PLATFORM_PATH="${MIR_SERVER_PLATFORM_PATH}")
510 add_definitions(-DMIR_SERVER_GRAPHICS_PLATFORM_VERSION="${MIR_SERVER_GRAPHICS_PLATFORM_VERSION}")
511
512 add_subdirectory(compositor/)
513
514=== modified file 'src/utils/CMakeLists.txt'
515--- src/utils/CMakeLists.txt 2015-01-16 02:57:31 +0000
516+++ src/utils/CMakeLists.txt 2015-01-22 16:32:05 +0000
517@@ -7,13 +7,13 @@
518 )
519
520 # Note that production binaries don't have underscores in their names
521-mir_add_wrapped_executable(mirping ping.c)
522+mir_add_executable(mirping ping.c)
523 target_link_libraries(mirping mirclient)
524
525-mir_add_wrapped_executable(mirout out.c)
526+mir_add_executable(mirout out.c)
527 target_link_libraries(mirout mirclient)
528
529-mir_add_wrapped_executable(mirscreencast screencast.cpp)
530+mir_add_executable(mirscreencast screencast.cpp)
531
532 target_link_libraries(mirscreencast
533 mirclient
534
535=== removed file 'src/wrapper.c'
536--- src/wrapper.c 2015-01-22 16:32:04 +0000
537+++ src/wrapper.c 1970-01-01 00:00:00 +0000
538@@ -1,66 +0,0 @@
539-/*
540- * Copyright © 2014 Canonical Ltd.
541- *
542- * This program is free software: you can redistribute it and/or modify it
543- * under the terms of the GNU General Public License version 3,
544- * as published by the Free Software Foundation.
545- *
546- * This program is distributed in the hope that it will be useful,
547- * but WITHOUT ANY WARRANTY; without even the implied warranty of
548- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
549- * GNU General Public License for more details.
550- *
551- * You should have received a copy of the GNU General Public License
552- * along with this program. If not, see <http://www.gnu.org/licenses/>.
553- *
554- * Author: Daniel van Vugt <daniel.van.vugt@canonical.com>
555- */
556-
557-#include <string.h>
558-#include <stdlib.h>
559-#include <stdio.h>
560-#include <unistd.h>
561-
562-int main(int argc, char** argv)
563-{
564- char path[1024], *dest = path, *dest_max = path+sizeof(path)-1;
565- char *pivot = path;
566- size_t pivot_max = 0;
567- const char *src = argv[0], *name = argv[0];
568-
569- (void)argc;
570- while (*src && dest < dest_max)
571- {
572- *dest = *src;
573- if (*dest == '/')
574- {
575- pivot = dest + 1;
576- name = src + 1;
577- }
578- ++src;
579- ++dest;
580- }
581- pivot_max = dest_max - pivot;
582-
583- strncpy(pivot, "../lib/client-modules/", pivot_max);
584- *dest_max = '\0';
585- setenv("MIR_CLIENT_PLATFORM_PATH", path, 1);
586- printf("MIR_CLIENT_PLATFORM_PATH=%s\n", path);
587- strncpy(pivot+7, "server-modules/", pivot_max-7);
588- setenv("MIR_SERVER_PLATFORM_PATH", path, 1);
589- printf("MIR_SERVER_PLATFORM_PATH=%s\n", path);
590-
591- pivot[6] = '\0'; /* truncate lib/client-modules to just lib */
592- setenv("LD_LIBRARY_PATH", path, 1);
593- printf("LD_LIBRARY_PATH=%s\n", path);
594-
595- snprintf(pivot, pivot_max, EXECUTABLE_FORMAT, name);
596- *dest_max = '\0';
597- printf("exec=%s\n", path);
598-
599- argv[0] = path;
600- execv(argv[0], argv);
601-
602- fprintf(stderr, "Failed to execute: %s\n", path);
603- return 1;
604-}
605
606=== modified file 'tests/acceptance-tests/CMakeLists.txt'
607--- tests/acceptance-tests/CMakeLists.txt 2015-01-22 16:32:04 +0000
608+++ tests/acceptance-tests/CMakeLists.txt 2015-01-22 16:32:05 +0000
609@@ -2,6 +2,7 @@
610
611 include_directories(
612 ${CMAKE_SOURCE_DIR}
613+ ${CMAKE_SOURCE_DIR}/src/include/common/
614 )
615
616 set(
617@@ -43,7 +44,7 @@
618
619 add_subdirectory(throwback)
620
621-mir_add_wrapped_executable(
622+mir_add_executable(
623 mir_acceptance_tests
624
625 ${SOURCES}
626
627=== modified file 'tests/client-language/CMakeLists.txt'
628--- tests/client-language/CMakeLists.txt 2015-01-16 02:57:31 +0000
629+++ tests/client-language/CMakeLists.txt 2015-01-22 16:32:05 +0000
630@@ -1,5 +1,5 @@
631 set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
632
633-mir_add_wrapped_executable(client-language-test-c99 NOINSTALL
634+mir_add_executable(client-language-test-c99 NOINSTALL
635 c99.c
636 )
637
638=== modified file 'tests/include/mir_test_framework/executable_path.h'
639--- tests/include/mir_test_framework/executable_path.h 2015-01-22 16:32:04 +0000
640+++ tests/include/mir_test_framework/executable_path.h 2015-01-22 16:32:05 +0000
641@@ -1,5 +1,5 @@
642 /*
643- * Copyright © 2014 Canonical Ltd.
644+ * Copyright © 2014-2015 Canonical Ltd.
645 *
646 * This program is free software: you can redistribute it and/or modify
647 * it under the terms of the GNU General Public License version 3 as
648@@ -20,10 +20,11 @@
649 #ifndef MIR_TEST_FRAMEWORK_EXECUTABLE_PATH_H_
650 #define MIR_TEST_FRAMEWORK_EXECUTABLE_PATH_H_
651
652-#include <string>
653+#include "mir/executable_path.h"
654+
655 namespace mir_test_framework
656 {
657-std::string executable_path();
658+using mir::executable_path;
659
660 std::string library_path();
661 std::string server_platform(std::string const& name);
662
663=== modified file 'tests/integration-tests/CMakeLists.txt'
664--- tests/integration-tests/CMakeLists.txt 2015-01-22 16:32:04 +0000
665+++ tests/integration-tests/CMakeLists.txt 2015-01-22 16:32:05 +0000
666@@ -65,7 +65,7 @@
667 endif()
668
669 link_directories(${LIBRARY_OUTPUT_PATH})
670-mir_add_wrapped_executable(
671+mir_add_executable(
672 mir_integration_tests
673 ${INTEGRATION_TESTS_SRCS}
674 ${MIR_SERVER_OBJECTS}
675
676=== modified file 'tests/mir-stress/CMakeLists.txt'
677--- tests/mir-stress/CMakeLists.txt 2015-01-16 02:57:31 +0000
678+++ tests/mir-stress/CMakeLists.txt 2015-01-22 16:32:05 +0000
679@@ -1,6 +1,6 @@
680 project(mir_stress)
681
682-mir_add_wrapped_executable(mir_stress
683+mir_add_executable(mir_stress
684 src/client.cpp
685 src/mir-stress.cpp
686 src/results.cpp
687
688=== modified file 'tests/mir_test_framework/executable_path.cpp'
689--- tests/mir_test_framework/executable_path.cpp 2015-01-22 16:32:04 +0000
690+++ tests/mir_test_framework/executable_path.cpp 2015-01-22 16:32:05 +0000
691@@ -1,5 +1,5 @@
692 /*
693- * Copyright © 2013,2014 Canonical Ltd.
694+ * Copyright © 2013-2015 Canonical Ltd.
695 *
696 * This program is free software: you can redistribute it and/or modify
697 * it under the terms of the GNU General Public License version 3 as
698@@ -20,26 +20,14 @@
699
700 #include "mir_test_framework/executable_path.h"
701
702+#include "mir/executable_path.h"
703+
704 #include <libgen.h>
705 #include <stdexcept>
706 #include <boost/throw_exception.hpp>
707 #include <boost/exception/errinfo_errno.hpp>
708 #include <boost/filesystem.hpp>
709
710-std::string mir_test_framework::executable_path()
711-{
712- char buf[1024];
713- auto tmp = readlink("/proc/self/exe", buf, sizeof buf);
714- if (tmp < 0)
715- BOOST_THROW_EXCEPTION(boost::enable_error_info(
716- std::runtime_error("Failed to find our executable path"))
717- << boost::errinfo_errno(errno));
718- if (tmp > static_cast<ssize_t>(sizeof(buf) - 1))
719- BOOST_THROW_EXCEPTION(std::runtime_error("Path to executable is too long!"));
720- buf[tmp] = '\0';
721- return dirname(buf);
722-}
723-
724 std::string mir_test_framework::library_path()
725 {
726 return executable_path() + "/../lib";
727
728=== modified file 'tests/performance-tests/CMakeLists.txt'
729--- tests/performance-tests/CMakeLists.txt 2015-01-16 02:57:31 +0000
730+++ tests/performance-tests/CMakeLists.txt 2015-01-22 16:32:05 +0000
731@@ -4,7 +4,7 @@
732 test_glmark2-es2-mir.cpp
733 )
734
735-mir_add_wrapped_executable(
736+mir_add_executable(
737 mir_performance_tests
738
739 ${PERFORMANCE_TESTS_SOURCES}
740
741=== modified file 'tests/unit-tests/CMakeLists.txt'
742--- tests/unit-tests/CMakeLists.txt 2015-01-22 16:32:04 +0000
743+++ tests/unit-tests/CMakeLists.txt 2015-01-22 16:32:05 +0000
744@@ -66,7 +66,7 @@
745
746 link_directories(${LIBRARY_OUTPUT_PATH})
747
748-mir_add_wrapped_executable(mir_unit_tests
749+mir_add_executable(mir_unit_tests
750 ${UNIT_TEST_SOURCES}
751 ${MIR_SERVER_OBJECTS}
752 $<TARGET_OBJECTS:mirclientobjects>

Subscribers

People subscribed via source and target branches