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



commit c330de0bcf1b402b6c7831d0fd98a4224ceb903c
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 generate 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/meson.build | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)
---
diff --git a/headers/meson.build b/headers/meson.build
index 3ce8b61..be31288 100644
--- a/headers/meson.build
+++ b/headers/meson.build
@@ -20,8 +20,27 @@ enums_xml = custom_target(
   install_dir: schemasdir)
 
 if not meson.is_cross_build() and get_option('introspection')
+  gir_sources = headers
+
+  # Generate 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'
+    script = '''
+f = open('@0@', 'w')
+f.write('void dummy() { return; }')
+f.close()'''.format(meson.current_build_dir() + '/' + 'dummy.c')
+
+    dummy_c = custom_target('dummy.c',
+      input : 'gdesktop-enums.h',
+      output : 'dummy.c',
+      command : [import('python').find_installation(),
+                 '-c',
+                 script])
+    gir_sources += dummy_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]