[gsettings-desktop-schemas/msvc-introspection: 3/3] build: Fix introspection on Visual Studio



commit d6520c4813dc5536070b7a2138ade21436c0cafa
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Wed Jul 1 17:49:37 2020 +0800

    build: Fix introspection on Visual Studio
    
    Meson requires a library or an executable for building introspection files, but
    unfortunately Visual Studio requires at least an object file to be built in
    order to create a library or executable, which means a source file must be
    present.
    
    To satisfy this requirement, just use a dummy C source file on Visual Studio
    builds and use it also to build our dummy library, so that we can generate the
    introspection files properly, out of the box.

 headers/dummy-msvc.c |  5 +++++
 headers/meson.build  | 10 +++++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)
---
diff --git a/headers/dummy-msvc.c b/headers/dummy-msvc.c
new file mode 100644
index 0000000..8da963c
--- /dev/null
+++ b/headers/dummy-msvc.c
@@ -0,0 +1,5 @@
+/* dummy source file required for building Introspection files on Visual Studio */
+void dummy()
+{
+  return;
+}
diff --git a/headers/meson.build b/headers/meson.build
index 3ce8b61..16dd7bd 100644
--- a/headers/meson.build
+++ b/headers/meson.build
@@ -20,8 +20,16 @@ enums_xml = custom_target(
   install_dir: schemasdir)
 
 if not meson.is_cross_build() and get_option('introspection')
+  gir_sources = headers
+
+  # Use a dummy .c source for Visual Studio builds-it is not enough
+  # to send in just a header file to build a dummy library on MSVC
+  if cc.get_id() == 'msvc'
+    gir_sources += ['dummy-msvc.c']
+  endif
+
   noinst_lib = shared_library('noinst',
-                              headers,
+                              gir_sources,
                               install: false)
 
   gnome.generate_gir(noinst_lib,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]