diff options
author | Peter Wu <peter@lekensteyn.nl> | 2016-12-18 16:49:24 +0100 |
---|---|---|
committer | Peter Wu <peter@lekensteyn.nl> | 2016-12-20 13:16:57 +0000 |
commit | d5fdbef7f4f103f3cd57524bc68b9a1385c61363 (patch) | |
tree | c67acc4441769909c7195c085850750da1813e84 /wsutil | |
parent | bd0fa39c7b013486e680c701406c4f75daec0a5a (diff) | |
download | wireshark-d5fdbef7f4f103f3cd57524bc68b9a1385c61363.tar.gz |
cmake,wslua,wsutil: load files from run/ instead of source tree
Fixes Lua on macOS, tested with an out-of-tree build:
WS_BIN_PATH=$PWD/run ../wireshark/test/test.sh -s wslua
Previously programs that were ran from the build directory would load
data files (radius/, diameter/, init.lua) from the source directory.
Then in the case of Lua, files were loaded from the program directory
($BUILDDIR/run/init.lua on Linux) or source directory
(sSOURCEDIR/epan/wslua/console.lua).
On macOS, this does not work for Lua since files are installed into
$BUILDDIR/run/Wireshark.app/Contents/Resources/share/wireshark/init.lua
instead. Since CMake always copies data files (radius, console.lua,
etc.) into the build directory, make get_datafile_dir() return this
"run" directory instead.
Change-Id: If97d2f5686271caf9ad4d4e4fc58e902dc592a98
Reviewed-on: https://code.wireshark.org/review/19330
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Graham Bloice <graham.bloice@trihedral.com>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Diffstat (limited to 'wsutil')
-rw-r--r-- | wsutil/CMakeLists.txt | 7 | ||||
-rw-r--r-- | wsutil/filesystem.c | 15 |
2 files changed, 20 insertions, 2 deletions
diff --git a/wsutil/CMakeLists.txt b/wsutil/CMakeLists.txt index 8b9cf011d8..84a3e1465e 100644 --- a/wsutil/CMakeLists.txt +++ b/wsutil/CMakeLists.txt @@ -249,7 +249,12 @@ if(NOT ${ENABLE_STATIC}) ) endif() -add_definitions( -DTOP_SRCDIR=\"${CMAKE_SOURCE_DIR}\" ) +# Export build-time datadir (note: the macro "DATAFILE_DIR" is defined in +# config.h and points to the install-time data directory, hence the different +# name). +set_property(SOURCE filesystem.c APPEND PROPERTY + COMPILE_DEFINITIONS BUILD_TIME_DATAFILE_DIR="${DATAFILE_DIR}" +) CHECKAPI( NAME diff --git a/wsutil/filesystem.c b/wsutil/filesystem.c index a7b2329f90..4fffcd4016 100644 --- a/wsutil/filesystem.c +++ b/wsutil/filesystem.c @@ -886,7 +886,20 @@ get_datafile_dir(void) * Use the top-level source directory as the datafile directory * because most of our data files (radius/, COPYING) are there. */ - datafile_dir = g_strdup(TOP_SRCDIR); +#ifdef TOP_SRCDIR + /* + * When TOP_SRCDIR is defined, assume autotools where files are not + * copied to the build directory. This fallback location is relied on by + * wslua_get_actual_filename(). + */ + datafile_dir = TOP_SRCDIR; +#else + /* + * Otherwise assume CMake. Here, data files (console.lua, radius/, etc.) + * are copied to the build directory during the build. + */ + datafile_dir = BUILD_TIME_DATAFILE_DIR; +#endif return datafile_dir; } else { if (g_getenv("WIRESHARK_DATA_DIR") && !started_with_special_privs()) { |