[pangomm/master.msvc-meson.improvements: 1/4] Meson: allow maintainer builds on Visual Studio too



commit 436ec34efa6ca82e392f5d33b25d686e53d6b25f
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Wed Mar 11 17:33:30 2020 +0800

    Meson: allow maintainer builds on Visual Studio too
    
    glibmm recently gained the ability to build with Visual Studio from a GIT
    checkout and to install the PERL scripts used to generate the C++ sources from
    the respective templates, so enable this support for pangomm as well as the
    needed infrastructure are largely in place.
    
    Note that a new configuration option has been added for Visual Studio builds
    to specify the directory for gmmproc, although there is Meson build support
    for building glibmm, but NMake Makefiles could have been used to build
    glibmm, meaning glibmm built with Visual Studio may not have pkg-config
    files, so it is used to specify the location if gmmproc if necessary.
    
    Since some portions that we use for non-maintainer builds can be used for
    maintainer builds as well, make them shared to keep changes minimal.

 meson.build               | 10 +++---
 meson_options.txt         |  2 ++
 pango/pangomm/meson.build | 78 ++++++++++++++++++++++++-----------------------
 3 files changed, 47 insertions(+), 43 deletions(-)
---
diff --git a/meson.build b/meson.build
index 120e0a4..4aee909 100644
--- a/meson.build
+++ b/meson.build
@@ -55,10 +55,6 @@ sys.exit(os.path.isdir("@0@") or os.path.isfile("@0@"))
 '''.format(project_source_root / '.git')
 is_git_build = run_command(python3, '-c', cmd_py).returncode() != 0
 
-# Unfortunately due to m4 requirements, we cannot support MSVC builds
-# directly from GIT checkouts
-assert(not is_msvc or not is_git_build, 'Direct builds from GIT is not supported for MSVC builds')
-
 # Options.
 maintainer_mode_opt = get_option('maintainer-mode')
 maintainer_mode = maintainer_mode_opt == 'true' or \
@@ -160,8 +156,12 @@ dot = find_program('dot', required: build_documentation) # Used by Doxygen
 xsltproc = find_program('xsltproc', required: build_documentation)
 
 # Where to find gmmproc and generate_wrap_init.pl. (N/A on MSVC builds)
-if not is_msvc
+if glibmm_dep.type_name() == 'pkgconfig'
   gmmproc_dir = glibmm_dep.get_pkgconfig_variable('gmmprocdir')
+else
+  if is_msvc
+    gmmproc_dir = get_option('gmmproc-dir')
+  endif
 endif
 
 script_dir = project_source_root / 'untracked' / 'build_scripts'
diff --git a/meson_options.txt b/meson_options.txt
index 1c4e122..e137e93 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -6,3 +6,5 @@ option('build-deprecated-api', type: 'boolean', value: true,
   description: 'Build deprecated API and include it in the library')
 option('build-documentation', type: 'combo', choices: ['false', 'if-maintainer-mode', 'true'],
   value: 'if-maintainer-mode', description: 'Build and install the documentation')
+option('gmmproc-dir', type : 'string',
+  value : '', description : 'Directory containing gmmproc and its PERL modules (for MSVC builds only)')
diff --git a/pango/pangomm/meson.build b/pango/pangomm/meson.build
index 4ca20cb..9f4c3a8 100644
--- a/pango/pangomm/meson.build
+++ b/pango/pangomm/meson.build
@@ -121,12 +121,14 @@ if maintainer_mode
   endforeach
 
   extra_include_dirs = ['..']
-  pangomm_library = library(pangomm_pcname,
+
+  # We need this so that we can run gendef.exe to get the .def file
+  # needed for obtaining the .lib file for the pangomm DLL
+  pango_int_lib = static_library('pangomm-int',
     built_cc_file_targets, built_h_file_targets, extra_cc_files,
-    version: pangomm_libversion,
     include_directories: extra_include_dirs,
     dependencies: pangomm_build_dep,
-    install: true,
+    install: false,
   )
 
   built_h_cc_dir = meson.current_build_dir()
@@ -171,45 +173,45 @@ else # not maintainer_mode
     dependencies: pangomm_build_dep,
     install: false,)
 
-  pangomm_def = []
-  pangomm_extra_link_args = []
-  extra_pangomm_objects = []
-
-  if is_msvc
-    pangomm_def = custom_target('pangomm.def',
-      output: 'pangomm.def',
-      depends: pango_int_lib,
-      command: [ gendef,
-        '@OUTPUT@',
-        '@0@-@1@.dll'.format(pangomm_pcname,
-                             libtool_soversion[0] - libtool_soversion[2]),
-        pango_int_lib.full_path(),
-      ],
-      install: false,
-    )
-    pangomm_extra_link_args = ['/def:@0@'.format(pangomm_def.full_path())]
-  endif
-
-  # Build the .rc file for Windows builds and link to it
-  if host_machine.system() == 'windows'
-    windows = import('windows')
-    pangomm_res = windows.compile_resources(pangomm_rc)
-    extra_pangomm_objects += pangomm_res
-  endif
-
-  pangomm_library = library(pangomm_pcname, extra_pangomm_objects,
-    objects: pango_int_lib.extract_all_objects(),
-    version: pangomm_libversion,
-    dependencies: pangomm_build_dep,
-    link_depends: pangomm_def,
-    link_args: pangomm_extra_link_args,
-    install: true,
-  )
-
   built_h_cc_dir = src_untracked_pangomm
 
 endif
 
+pangomm_def = []
+pangomm_extra_link_args = []
+extra_pangomm_objects = []
+
+if is_msvc
+  pangomm_def = custom_target('pangomm.def',
+    output: 'pangomm.def',
+    depends: pango_int_lib,
+    command: [ gendef,
+      '@OUTPUT@',
+      '@0@-@1@.dll'.format(pangomm_pcname,
+                           libtool_soversion[0] - libtool_soversion[2]),
+      pango_int_lib.full_path(),
+    ],
+    install: false,
+  )
+  pangomm_extra_link_args = ['/def:@0@'.format(pangomm_def.full_path())]
+endif
+
+# Build the .rc file for Windows builds and link to it
+if host_machine.system() == 'windows'
+  windows = import('windows')
+  pangomm_res = windows.compile_resources(pangomm_rc)
+  extra_pangomm_objects += pangomm_res
+endif
+
+pangomm_library = library(pangomm_pcname, extra_pangomm_objects,
+  objects: pango_int_lib.extract_all_objects(),
+  version: pangomm_libversion,
+  dependencies: pangomm_build_dep,
+  link_depends: pangomm_def,
+  link_args: pangomm_extra_link_args,
+  install: true,
+)
+
 # Install built .h and _p.h files.
 meson.add_install_script(
   python3.path(), generate_binding, 'install_built_h_files',


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