From d5fdbef7f4f103f3cd57524bc68b9a1385c61363 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Sun, 18 Dec 2016 16:49:24 +0100 Subject: cmake,wslua,wsutil: load files from run/ instead of source tree MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Petri-Dish: Stig Bjørlykke Tested-by: Petri Dish Buildbot Reviewed-by: Graham Bloice Reviewed-by: Peter Wu --- wsutil/filesystem.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'wsutil/filesystem.c') 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()) { -- cgit v1.2.1