aboutsummaryrefslogtreecommitdiffstats
path: root/epan/wslua
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2016-12-18 16:49:24 +0100
committerPeter Wu <peter@lekensteyn.nl>2016-12-20 13:16:57 +0000
commitd5fdbef7f4f103f3cd57524bc68b9a1385c61363 (patch)
treec67acc4441769909c7195c085850750da1813e84 /epan/wslua
parentbd0fa39c7b013486e680c701406c4f75daec0a5a (diff)
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 'epan/wslua')
-rw-r--r--epan/wslua/init_wslua.c19
-rw-r--r--epan/wslua/wslua_dir.c3
-rw-r--r--epan/wslua/wslua_util.c20
3 files changed, 23 insertions, 19 deletions
diff --git a/epan/wslua/init_wslua.c b/epan/wslua/init_wslua.c
index 878b38ca55..ce60aa8644 100644
--- a/epan/wslua/init_wslua.c
+++ b/epan/wslua/init_wslua.c
@@ -894,18 +894,17 @@ void wslua_init(register_cb cb, gpointer client_data) {
WSLUA_REG_GLOBAL_NUMBER(L,"DESEGMENT_ONE_MORE_SEGMENT",DESEGMENT_ONE_MORE_SEGMENT);
/* load system's init.lua */
- if (running_in_build_directory()) {
- /* Running from build directory, try the source directory (Autotools) */
+ filename = get_datafile_path("init.lua");
+ /*
+ * CMake will normally always succeed with get_datafile_path (see also
+ * comments in wslua_get_actual_filename() and get_datafile_dir()), but for
+ * autotools we need to look in the build directory for an autogenerated
+ * epan/wslua/init.lua file.
+ */
+ if (!file_exists(filename) && running_in_build_directory()) {
+ g_free(filename);
filename = g_strdup_printf("%s" G_DIR_SEPARATOR_S "epan" G_DIR_SEPARATOR_S "wslua"
G_DIR_SEPARATOR_S "init.lua", get_progfile_dir());
- if (( ! file_exists(filename))) {
- /* Try the CMake output directory */
- g_free(filename);
- filename = g_strdup_printf("%s" G_DIR_SEPARATOR_S "init.lua",
- get_progfile_dir());
- }
- } else {
- filename = get_datafile_path("init.lua");
}
if (( file_exists(filename))) {
diff --git a/epan/wslua/wslua_dir.c b/epan/wslua/wslua_dir.c
index 708683e124..c467132706 100644
--- a/epan/wslua/wslua_dir.c
+++ b/epan/wslua/wslua_dir.c
@@ -308,8 +308,7 @@ WSLUA_CONSTRUCTOR Dir_global_config_path(lua_State* L) {
if (( ! file_exists(filename))) {
/* Try the CMake output directory */
g_free(filename);
- filename = g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s",
- get_progfile_dir(), fname);
+ filename = get_datafile_path(fname);
}
} else {
filename = get_datafile_path(fname);
diff --git a/epan/wslua/wslua_util.c b/epan/wslua/wslua_util.c
index 644106a89d..d51150b8f1 100644
--- a/epan/wslua/wslua_util.c
+++ b/epan/wslua/wslua_util.c
@@ -223,22 +223,28 @@ char* wslua_get_actual_filename(const char* fname) {
}
g_free(filename);
+ /*
+ * Try to look in global data directory, nothing extraordinary for normal
+ * installations. For executions from the build dir, it will look for files
+ * copied to DATAFILE_DIR (cmake). In case autotools was used, files were
+ * not copied to that directory, so the next line will return a non-existing
+ * file.
+ */
filename = get_datafile_path(fname_clean);
if ( file_exists(filename) ) {
return filename;
}
g_free(filename);
+ /*
+ * Fallback for autotools: assume that this is not an autogenerated file
+ * (like init.lua) but something that is available in the source tree (e.g.
+ * epan/wslua/console.lua). Assume that get_datafile_dir() returns the path
+ * to the source tree (TOP_SRCDIR).
+ */
if (running_in_build_directory()) {
- /* Running in build directory, try the source directory (Autotools) */
filename = g_strdup_printf("%s" G_DIR_SEPARATOR_S "epan" G_DIR_SEPARATOR_S "wslua"
G_DIR_SEPARATOR_S "%s", get_datafile_dir(), fname_clean);
- if (( ! file_exists(filename))) {
- /* Try the CMake output directory */
- g_free(filename);
- filename = g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s",
- get_progfile_dir(), fname_clean);
- }
if ( file_exists(filename) ) {
return filename;
}