[vlc-commits] [Git][videolan/vlc][master] 7 commits: doc: vlc.1: add VLC_LIB_PATH in manpages

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Fri Aug 11 16:18:47 UTC 2023



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
6a3c5ba3 by Alexandre Janniaux at 2023-08-11T16:01:40+00:00
doc: vlc.1: add VLC_LIB_PATH in manpages

The VLC_LIB_PATH environment variable has been introduced in commit
75308a48f28fe67290d6f579657442e303452320 to override the path where to
find the executables and other architecture-dependant files.

- - - - -
3e32a4b9 by Alexandre Janniaux at 2023-08-11T16:01:40+00:00
config: move config_GetUserDir to src/config/

Rename the implementation in platforms into platform_GetUserDir() and
implement the config_GetUserDir function inside src/config/ as a common
function between every platform.

We will use this function to share common overriding behaviour between
the different platforms.

- - - - -
49c0321c by Alexandre Janniaux at 2023-08-11T16:01:40+00:00
config: dirs: implement VLC_USERDATA_PATH override

If the variable VLC_USERDATA_PATH is set, completely override the output
of config_GetUserDir for VLC_USERDATA_DIR to not output the platform
path, but the specified path instead.

This will allow overriding this variable in a VLC-specific manner,
without relying on mechanism like XDG dir overrides that might not be
implemented for every platforms.

Refs #28343

- - - - -
59a26376 by Alexandre Janniaux at 2023-08-11T16:01:40+00:00
doc: vlc.1: add VLC_USERDATA_PATH to the manpages

Like VLC_DATA_PATH AND VLC_LIB_PATH, but allows to override the path
matching with ~/.local/share on Linux or ~/Library/Application\ Support
on Darwin.

- - - - -
38f4cee2 by Alexandre Janniaux at 2023-08-11T16:01:40+00:00
test: meson.build: add TOP_SRCDIR in defines

- - - - -
40164b90 by Alexandre Janniaux at 2023-08-11T16:01:40+00:00
test: medialibrary: use VLC_USERDATA_PATH

Darwin platforms are not using XDG_DATA_DIR. With the override done in
src/config/dirs.c, every platform (now and then) will use the content of
VLC_USERDATA_PATH instead to create files.

Refs #28343

- - - - -
7aeea12a by Alexandre Janniaux at 2023-08-11T16:01:40+00:00
test: lua: use VLC_USERDATA_PATH

Darwin platforms are not using XDG_DATA_DIR. With the override done in
src/config/dirs.c, every platform (now and then) will use the content of
VLC_USERDATA_PATH instead to create files.

It also changes the way the Lua extension dir is set to be simpler to
configure in buildsystem (TOP_SRCDIR is already forwarded) and resilient
to working directory change.

Refs #28343

- - - - -


15 changed files:

- doc/vlc.1
- src/Makefile.am
- src/android/specific.c
- + src/config/dirs.c
- src/darwin/dirs.m
- src/meson.build
- src/os2/dirs.c
- src/posix/dirs.c
- src/win32/dirs-uap.c
- src/win32/dirs.c
- test/Makefile.am
- test/meson.build
- test/modules/lua/extension.c
- test/modules/meson.build
- test/modules/misc/medialibrary.c


Changes:

=====================================
doc/vlc.1
=====================================
@@ -89,10 +89,19 @@ used by the OSSv4 output plugin.
 .B VLC_DATA_PATH
 The directory containing VLC run-time data files (e.g. /usr/share/vlc).
 
+.TP
+.B VLC_LIB_PATH
+The directory containing VLC binary folder, which is used for the dynamically
+loaded libraries and architecture-dependant executables (e.g. /usr/lib/).
+
 .TP
 .B VLC_PLUGIN_PATH
 An extra directory to load VLC plugins from.
 
+.TP
+.B VLC_USERDATA_PATH
+The directory where the userdata will be stored (e.g. ~/.local/share/).
+
 .TP
 .B VLC_VERBOSE
 The level of verbosity for log messages


=====================================
src/Makefile.am
=====================================
@@ -217,6 +217,7 @@ libvlccore_la_SOURCES = \
 	config/configuration.h \
 	config/core.c \
 	config/chain.c \
+	config/dirs.c \
 	config/file.c \
 	config/help.c \
 	config/intf.c \


=====================================
src/android/specific.c
=====================================
@@ -270,7 +270,7 @@ error:
     return psz_ret;
 }
 
-char *config_GetUserDir (vlc_userdir_t type)
+char *platform_GetUserDir (vlc_userdir_t type)
 {
     switch (type)
     {


=====================================
src/config/dirs.c
=====================================
@@ -0,0 +1,48 @@
+/*****************************************************************************
+ * dirs.c: Platform directories configuration
+ *****************************************************************************
+ * Copyright (C) 2023 Videolabs
+ *
+ * Authors: Alexandre Janniaux <ajanni at videolabs.io>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <vlc_common.h>
+#include <vlc_configuration.h>
+
+static const char *userdir_to_env[] =
+{
+    [VLC_USERDATA_DIR] = "VLC_USERDATA_PATH",
+};
+
+/* Platforms must implement this function */
+char *platform_GetUserDir( vlc_userdir_t ) VLC_USED VLC_MALLOC;
+
+char *config_GetUserDir (vlc_userdir_t type)
+{
+    if (type >= 0 && type < ARRAY_SIZE(userdir_to_env) &&
+        userdir_to_env[type] != NULL)
+    {
+        const char * path = getenv(userdir_to_env[type]);
+        if (path != NULL)
+            return strdup(path);
+    }
+    return platform_GetUserDir(type);
+}


=====================================
src/darwin/dirs.m
=====================================
@@ -198,7 +198,7 @@ static char *getAppDependentDir(vlc_userdir_t type)
     return strdup(result.UTF8String);
 }
 
-char *config_GetUserDir (vlc_userdir_t type)
+char *platform_GetUserDir (vlc_userdir_t type)
 {
     const char *psz_path;
     switch (type) {


=====================================
src/meson.build
=====================================
@@ -77,6 +77,7 @@ libvlccore_sources_base = files(
     'config/configuration.h',
     'config/core.c',
     'config/chain.c',
+    'config/dirs.c',
     'config/file.c',
     'config/help.c',
     'config/intf.c',


=====================================
src/os2/dirs.c
=====================================
@@ -158,7 +158,7 @@ static char *config_GetHomeDir (void)
     return config_GetLibDir();
 }
 
-char *config_GetUserDir (vlc_userdir_t type)
+char *platform_GetUserDir (vlc_userdir_t type)
 {
     switch (type)
     {


=====================================
src/posix/dirs.c
=====================================
@@ -265,7 +265,7 @@ static char *config_GetTypeDir (const char *xdg_name)
 }
 
 
-char *config_GetUserDir (vlc_userdir_t type)
+char *platform_GetUserDir (vlc_userdir_t type)
 {
     switch (type)
     {


=====================================
src/win32/dirs-uap.c
=====================================
@@ -319,7 +319,7 @@ static inline char *config_GetCacheDir(void)
 }
 #endif // HAVE___X_ABI_CWINDOWS_CSTORAGE_CIAPPLICATIONDATA2
 
-char *config_GetUserDir (vlc_userdir_t type)
+char *platform_GetUserDir (vlc_userdir_t type)
 {
     switch (type)
     {


=====================================
src/win32/dirs.c
=====================================
@@ -143,7 +143,7 @@ static char *config_GetAppDir (void)
     return psz_dir;
 }
 
-char *config_GetUserDir (vlc_userdir_t type)
+char *platform_GetUserDir (vlc_userdir_t type)
 {
     switch (type)
     {


=====================================
test/Makefile.am
=====================================
@@ -184,8 +184,7 @@ test_src_misc_image_LDADD = $(LIBVLCCORE) $(LIBVLC)
 
 test_modules_lua_extension_SOURCES = modules/lua/extension.c
 test_modules_lua_extension_LDADD = $(LIBVLCCORE) $(LIBVLC)
-test_modules_lua_extension_CPPFLAGS = $(AM_CPPFLAGS) \
-	-DLUA_EXTENSION_DIR=\"$(srcdir)/modules/\"
+test_modules_lua_extension_CPPFLAGS = $(AM_CPPFLAGS)
 test_modules_misc_medialibrary_SOURCES = modules/misc/medialibrary.c
 test_modules_misc_medialibrary_LDADD = $(LIBVLCCORE) $(LIBVLC)
 test_modules_packetizer_helpers_SOURCES = modules/packetizer/helpers.c


=====================================
test/meson.build
=====================================
@@ -35,6 +35,7 @@ foreach vlc_test: vlc_tests
     common_args = [
         '-DSRCDIR="@0@"'.format(vlc_src_root + '/test/'),
         '-DTOP_BUILDDIR="@0@"'.format(vlc_build_root),
+        '-DTOP_SRCDIR="@0@"'.format(vlc_src_root),
     ]
 
     test_modules_deps = []


=====================================
test/modules/lua/extension.c
=====================================
@@ -68,9 +68,7 @@ static int OpenIntf(vlc_object_t *root)
         vlc_object_create(root, sizeof *mgr);
     assert(mgr);
 
-    setenv("XDG_DATA_HOME", LUA_EXTENSION_DIR, 1);
-    setenv("VLC_DATA_PATH", LUA_EXTENSION_DIR, 1);
-    setenv("VLC_LIB_PATH", LUA_EXTENSION_DIR, 1);
+    setenv("VLC_USERDATA_PATH", TOP_SRCDIR "/test/modules/", 1);
 
     vlc_playlist_t *playlist = vlc_intf_GetMainPlaylist(intf);
     vlc_player_t *player = vlc_playlist_GetPlayer(playlist);


=====================================
test/modules/meson.build
=====================================
@@ -3,8 +3,6 @@ vlc_tests += {
     'sources' : files('lua/extension.c'),
     'suite' : ['modules', 'test_modules'],
     'link_with' : [libvlc, libvlccore],
-    'c_args' : ['-DLUA_EXTENSION_DIR="@0@"'.format(
-                vlc_src_root + '/test/modules/')],
     'module_depends' : vlc_plugins_targets.keys()
 }
 


=====================================
test/modules/misc/medialibrary.c
=====================================
@@ -113,8 +113,8 @@ int main()
         assert(tempdir != NULL);
         return -1;
     }
-    fprintf(stderr, "Using XDG_DATA_HOME directory %s\n", tempdir);
-    setenv("XDG_DATA_HOME", tempdir, 1);
+    fprintf(stderr, "Using VLC_USERDATA_PATH directory %s\n", tempdir);
+    setenv("VLC_USERDATA_PATH", tempdir, 1);
 
     test_init();
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/c49166f43588bd9dccb85620316ae4f5c28ae797...7aeea12aadc36ad84b57a83119aeba1acfabebe8

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/c49166f43588bd9dccb85620316ae4f5c28ae797...7aeea12aadc36ad84b57a83119aeba1acfabebe8
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list