[vlc-commits] [Git][videolan/vlc][master] 12 commits: tests: define vlc_static_modules consistently

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Tue Mar 7 08:41:28 UTC 2023



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


Commits:
b0904b12 by Steve Lhomme at 2023-03-07T08:23:15+00:00
tests: define vlc_static_modules consistently

- - - - -
b7340959 by Steve Lhomme at 2023-03-07T08:23:15+00:00
vlc_plugin: add macros to define custom entry points

This is usually the way tests with modules do it.

- - - - -
f240da15 by Steve Lhomme at 2023-03-07T08:23:15+00:00
demux-run: use specialized macros to access module entries

- - - - -
b919f189 by Steve Lhomme at 2023-03-07T08:23:15+00:00
bank: constify the static plugin entry list

That's how it's defined everywhere.

- - - - -
e18c1e87 by Steve Lhomme at 2023-03-07T08:23:15+00:00
bank: use the core entry name using macros

If the macros change, the code will change automatically.

- - - - -
96d2232a by Steve Lhomme at 2023-03-07T08:23:15+00:00
test: move the MODULE_STRING usage after vlc_plugin.h

So it can be deduced from MODULE_NAME.

- - - - -
914b66ed by Steve Lhomme at 2023-03-07T08:23:15+00:00
test: don't define MODULE_STRING

It can be deduced from MODULE_NAME.

- - - - -
a7c63015 by Steve Lhomme at 2023-03-07T08:23:15+00:00
package/emscripten: use vlc_plugin_cb for the static list of modules

For the static list of modules.

- - - - -
61f909ce by Steve Lhomme at 2023-03-07T08:23:15+00:00
package/apple: use vlc_plugin_cb for the static list of modules

- - - - -
0afcc30a by Steve Lhomme at 2023-03-07T08:23:15+00:00
vlc_plugin: add a macro to declare module entries

This is the same type as vlc_plugin_cb but declaring a variable with a function
type and declaring and actual function is not the same.

- - - - -
6f493a0a by Steve Lhomme at 2023-03-07T08:23:15+00:00
package/emscripten: use a vlc_plugin macro to declare the detected modules

- - - - -
1e244e3b by Steve Lhomme at 2023-03-07T08:23:15+00:00
package/apple: use a vlc_plugin macro to declare the detected modules

- - - - -


15 changed files:

- extras/package/apple/build.sh
- extras/package/wasm-emscripten/build.sh
- include/vlc_plugin.h
- src/modules/bank.c
- src/modules/modules.h
- test/iosvlc.m
- test/modules/lua/extension.c
- test/modules/misc/medialibrary.c
- test/modules/stream_out/transcode.c
- test/src/input/decoder/input_decoder.c
- test/src/input/demux-run.c
- test/src/misc/image.c
- test/src/misc/image_cvpx.c
- test/src/video_output/opengl.c
- test/src/video_output/video_output.c


Changes:

=====================================
extras/package/apple/build.sh
=====================================
@@ -423,11 +423,11 @@ gen_vlc_static_module_list()
     done
 
     printf "\
-#include <stddef.h>\\n\
-#define VLC_ENTRY_FUNC(funcname)\
-int funcname(int (*)(void *, void *, int, ...), void *)\\n\
+#include \"config.h\"\\n\
+#include <vlc_common.h>\\n\
+#include <vlc_plugin.h>\\n\
 %b\\n\
-const void *vlc_static_modules[] = {\\n
+const vlc_plugin_cb vlc_static_modules[] = {\\n
 %b
     NULL\\n
 };" \
@@ -780,7 +780,7 @@ VLC_STATIC_MODULELIST_NAME="static-module-list"
 rm -f "${VLC_STATIC_MODULELIST_NAME}.c" "${VLC_STATIC_MODULELIST_NAME}.o"
 gen_vlc_static_module_list "${VLC_STATIC_MODULELIST_NAME}.c" "${VLC_PLUGINS_SYMBOL_LIST[@]}"
 
-${VLC_HOST_CC:-cc} -c  ${CFLAGS} "${VLC_STATIC_MODULELIST_NAME}.c" \
+${VLC_HOST_CC:-cc} -c  ${CFLAGS} -I"${VLC_SRC_DIR}/include" -I"${VLC_BUILD_DIR}/build" "${VLC_STATIC_MODULELIST_NAME}.c" \
   || abort_err "Compiling module list file failed"
 
 echo "${VLC_BUILD_DIR}/static-lib/${VLC_STATIC_MODULELIST_NAME}.o" \


=====================================
extras/package/wasm-emscripten/build.sh
=====================================
@@ -197,14 +197,16 @@ FUN_LIST=""
 for file in "$BUILD_PATH"/modules/.libs/*plugin.a
 do
     ENTRY=$(get_entryname "$file")
-    FUN_PROTOS="$FUN_PROTOS""int $ENTRY (int (*)(void *, void *, int, ...), void *);\n"
+    FUN_PROTOS="$FUN_PROTOS""VLC_ENTRY_FUNC($ENTRY);\n"
     FUN_LIST="$FUN_LIST""$ENTRY,\n"
 done;
 
 printf "// This file is autogenerated
-#include <stddef.h>
+#include \"config.h\"
+#include <vlc_common.h>
+#include <vlc_plugin.h>
 %b\n
-const void *vlc_static_modules[] = {
+const vlc_plugin_cb vlc_static_modules[] = {
 %bNULL
 };\n" "$FUN_PROTOS" "$FUN_LIST" \
        > "$BUILD_PATH"/vlc-modules.c
@@ -216,6 +218,6 @@ if echo "${VLC_USE_SANITIZER}" | grep address > /dev/null; then
 SANITIZERS="$SANITIZERS -fsanitize=address -fsanitize-address-use-after-scope -fno-omit-frame-pointer"
 fi
 
-emcc $SANITIZERS -pthread -c "$BUILD_PATH"/vlc-modules.c -o "$BUILD_PATH"/vlc-modules.bc
+emcc $SANITIZERS -pthread -c "$BUILD_PATH"/vlc-modules.c -I"$VLC_SRCPATH"/include -I"$BUILD_PATH"  -o "$BUILD_PATH"/vlc-modules.bc
 
 echo "VLC for wasm32-unknown-emscripten built!"


=====================================
include/vlc_plugin.h
=====================================
@@ -246,6 +246,13 @@ enum vlc_config_subcat
 # define MODULE_STRING  STRINGIFY_NAME(MODULE_NAME)
 #endif
 
+// defines a statically linked module entry point
+#define VLC_ENTRY_FUNC(name)          int (name)(vlc_set_cb, void *)
+// name of the module entry point table
+#define VLC_MODULE_ENTRY(name)        CONCATENATE(vlc_entry, name)
+// declare a vlc_plugin_cb
+#define VLC_DECL_MODULE_ENTRY(name)   VLC_ENTRY_FUNC(VLC_MODULE_ENTRY(name))
+
 /* If the module is built-in, then we need to define foo_InitModule instead
  * of InitModule. Same for Activate- and DeactivateModule. */
 #ifdef VLC_DYNAMIC_PLUGIN


=====================================
src/modules/bank.c
=====================================
@@ -49,6 +49,9 @@
 #include "config/configuration.h"
 #include "modules/modules.h"
 
+/** Core module */
+VLC_DECL_MODULE_ENTRY(core);
+
 typedef struct vlc_modcap
 {
     char *name;
@@ -183,7 +186,7 @@ static vlc_plugin_t *module_InitStatic(vlc_plugin_cb entry)
     || (defined(__MACH__) && defined(HAVE_DYLIB_DYNAMIC_LOOKUP)) \
     || !defined(HAVE_DYNAMIC_PLUGINS)
 VLC_WEAK
-extern vlc_plugin_cb vlc_static_modules[];
+extern const vlc_plugin_cb vlc_static_modules[];
 
 static void module_InitStaticModules(void)
 {
@@ -723,7 +726,7 @@ void module_InitBank (void)
          * library just as another module, and for instance the configuration
          * options of core will be available in the module bank structure just
          * as for every other module. */
-        vlc_plugin_t *plugin = module_InitStatic(vlc_entry__core);
+        vlc_plugin_t *plugin = module_InitStatic(VLC_MODULE_ENTRY(core));
         if (likely(plugin != NULL))
             vlc_plugin_store(plugin);
         config_SortConfig ();


=====================================
src/modules/modules.h
=====================================
@@ -69,9 +69,6 @@ extern struct vlc_plugin_t *vlc_plugins;
 /** Plugin deactivation callback */
 typedef void (*vlc_deactivate_cb)(vlc_object_t*);
 
-/** Core module */
-int vlc_entry__core (vlc_set_cb, void *);
-
 /**
  * Internal module descriptor
  */


=====================================
test/iosvlc.m
=====================================
@@ -24,9 +24,9 @@
 #ifdef HAVE_CONFIG_H
 # include "config.h"
 #endif
+#undef VLC_DYNAMIC_PLUGINS
 
 #define MODULE_NAME ios_interface
-#define MODULE_STRING "ios_interface"
 #undef VLC_DYNAMIC_PLUGINS
 
 #import <UIKit/UIKit.h>


=====================================
test/modules/lua/extension.c
=====================================
@@ -26,9 +26,7 @@
 
 /* Define a builtin module for mocked parts */
 #define MODULE_NAME test_lua_extension
-#define MODULE_STRING "test_lua_extension"
 #undef VLC_DYNAMIC_PLUGIN
-const char vlc_module_name[] = MODULE_STRING;
 
 #include "../../libvlc/test.h"
 
@@ -45,6 +43,8 @@ const char vlc_module_name[] = MODULE_STRING;
 
 #include <limits.h>
 
+const char vlc_module_name[] = MODULE_STRING;
+
 static int exitcode = 0;
 
 static int OnLuaEventTriggered(vlc_object_t *obj, const char *name,


=====================================
test/modules/misc/medialibrary.c
=====================================
@@ -26,9 +26,7 @@
 
 /* Define a builtin module for mocked parts */
 #define MODULE_NAME test_misc_medialibrary
-#define MODULE_STRING "test_misc_medialibrary"
 #undef VLC_DYNAMIC_PLUGIN
-const char vlc_module_name[] = MODULE_STRING;
 
 #include "../../libvlc/test.h"
 
@@ -45,6 +43,8 @@ const char vlc_module_name[] = MODULE_STRING;
 #include <vlc_media_library.h>
 #include <ftw.h>
 
+const char vlc_module_name[] = MODULE_STRING;
+
 static int exitcode = 0;
 
 static void ValidateThumbnail(void *data, const vlc_ml_event_t *event)


=====================================
test/modules/stream_out/transcode.c
=====================================
@@ -26,13 +26,8 @@
 
 /* Define a builtin module for mocked parts */
 #define MODULE_NAME test_transcode_mock
-#define MODULE_STRING "test_transcode_mock"
 #undef VLC_DYNAMIC_PLUGIN
 
-static const char dec_dev_arg[] = "--dec-dev=" MODULE_STRING;
-
-const char vlc_module_name[] = MODULE_STRING;
-
 #include "../../libvlc/test.h"
 #include <vlc_common.h>
 #include <vlc_plugin.h>
@@ -50,6 +45,11 @@ const char vlc_module_name[] = MODULE_STRING;
 #include <limits.h>
 
 #include "transcode.h"
+
+static const char dec_dev_arg[] = "--dec-dev=" MODULE_STRING;
+
+const char vlc_module_name[] = MODULE_STRING;
+
 static size_t current_scenario = 0;
 
 static vlc_cond_t player_cond = VLC_STATIC_COND;


=====================================
test/src/input/decoder/input_decoder.c
=====================================
@@ -26,11 +26,8 @@
 
 /* Define a builtin module for mocked parts */
 #define MODULE_NAME test_input_decoder_mock
-#define MODULE_STRING "test_input_decoder_mock"
 #undef VLC_DYNAMIC_PLUGIN
 
-const char vlc_module_name[] = MODULE_STRING;
-
 #include "../../../libvlc/test.h"
 #include <vlc_common.h>
 #include <vlc_plugin.h>
@@ -48,6 +45,9 @@ const char vlc_module_name[] = MODULE_STRING;
 #include <limits.h>
 
 #include "input_decoder.h"
+
+const char vlc_module_name[] = MODULE_STRING;
+
 static size_t current_scenario = 0;
 
 static vlc_cond_t player_cond = VLC_STATIC_COND;


=====================================
test/src/input/demux-run.c
=====================================
@@ -477,11 +477,9 @@ int vlc_demux_process_memory(const struct vlc_run_args *args,
 # define PLUGIN_MKV(f)
 #endif
 
-#define DECL_PLUGIN(p) \
-    vlc_plugin_cb CONCATENATE(vlc_entry,p);
+#define DECL_PLUGIN(p)   VLC_DECL_MODULE_ENTRY(p);
 
-#define FUNC_PLUGIN(p) \
-    CONCATENATE(vlc_entry,p),
+#define FUNC_PLUGIN(p)   VLC_MODULE_ENTRY(p),
 
 PLUGINS(DECL_PLUGIN)
 


=====================================
test/src/misc/image.c
=====================================
@@ -26,9 +26,7 @@
 
 /* Define a builtin module for mocked parts */
 #define MODULE_NAME test_misc_image
-#define MODULE_STRING "test_misc_image"
 #undef VLC_DYNAMIC_PLUGIN
-const char vlc_module_name[] = MODULE_STRING;
 
 #include "../../libvlc/test.h"
 
@@ -44,6 +42,8 @@ const char vlc_module_name[] = MODULE_STRING;
 
 #include <limits.h>
 
+const char vlc_module_name[] = MODULE_STRING;
+
 static atomic_bool encoder_opened = false;
 
 static int OpenIntf(vlc_object_t *root)


=====================================
test/src/misc/image_cvpx.c
=====================================
@@ -26,9 +26,7 @@
 
 /* Define a builtin module for mocked parts */
 #define MODULE_NAME test_misc_image_cvpx
-#define MODULE_STRING "test_misc_image_cvpx"
 #undef VLC_DYNAMIC_PLUGIN
-const char vlc_module_name[] = MODULE_STRING;
 
 #include "../../libvlc/test.h"
 #include "../../../modules/codec/vt_utils.h"
@@ -43,6 +41,8 @@ const char vlc_module_name[] = MODULE_STRING;
 
 #include <limits.h>
 
+const char vlc_module_name[] = MODULE_STRING;
+
 static int OpenIntf(vlc_object_t *root)
 {
     image_handler_t *ih = image_HandlerCreate(root);


=====================================
test/src/video_output/opengl.c
=====================================
@@ -24,7 +24,6 @@
 
 /* Define a builtin module for mocked parts */
 #define MODULE_NAME test_offscreen_mock
-#define MODULE_STRING "test_offscreen_mock"
 #undef VLC_DYNAMIC_PLUGIN
 
 #include "../../libvlc/test.h"
@@ -199,7 +198,7 @@ vlc_module_begin()
         set_callback_opengl_es2_offscreen(OpenOpenGLESOffscreen, 1)
 vlc_module_end()
 
-VLC_EXPORT vlc_plugin_cb vlc_static_modules[] = {
+VLC_EXPORT const vlc_plugin_cb vlc_static_modules[] = {
     VLC_SYMBOL(vlc_entry),
     NULL
 };


=====================================
test/src/video_output/video_output.c
=====================================
@@ -26,13 +26,8 @@
 
 /* Define a builtin module for mocked parts */
 #define MODULE_NAME test_vout_mock
-#define MODULE_STRING "test_vout_mock"
 #undef VLC_DYNAMIC_PLUGIN
 
-static const char dec_dev_arg[] = "--dec-dev=" MODULE_STRING;
-
-const char vlc_module_name[] = MODULE_STRING;
-
 #include "../../libvlc/test.h"
 #include <vlc_common.h>
 #include <vlc_plugin.h>
@@ -48,6 +43,11 @@ const char vlc_module_name[] = MODULE_STRING;
 #include <limits.h>
 
 #include "video_output.h"
+
+static const char dec_dev_arg[] = "--dec-dev=" MODULE_STRING;
+
+const char vlc_module_name[] = MODULE_STRING;
+
 static size_t current_scenario;
 
 static void DecoderDeviceClose(struct vlc_decoder_device *device)



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/3cb6645b947a33b157528e653e25267ed0045b09...1e244e3b5605a00c653be6632c5638d81385b3b9

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/3cb6645b947a33b157528e653e25267ed0045b09...1e244e3b5605a00c653be6632c5638d81385b3b9
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