[glib/clang-cl-support: 2/2] meson: Mostly assume clang-cl is MSVC



commit 9c913a4c73b86c1f8f5d43b3ec8e328ee01ea098
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Wed Jul 10 00:22:51 2019 +0800

    meson: Mostly assume clang-cl is MSVC
    
    We need to enable building the dirent and gnulib sources for clang-cl,
    as we are still using the Microsoft-style headers and lib's and CRT.
    We need to also do this for the following, for similar reasoning:
    
    -Symbol export (via __declspec(dllexport))
    -strcasecmp() and strncasecmp() detection using _stricmp() and
     _strnicmp()
    -Dependency discovery without pkg-config files
    -long long and ssize_t detection
    -Forced-use of msvc_recommended_pragmas.h
    
    We do, however, enable the autoptr tests for clang-cl builds.  Note that
    at this point real MSVC builds are still better supported than clang-cl
    builds, and it will likely remain so for at least the near future,
    alhtough real MSVC builds of the GTK stack are consumable and are usable
    by clang-cl.

 gio/tests/meson.build                              |  4 ++--
 glib/gnulib/gl_cv_func_frexp_works/meson.build     |  2 +-
 .../gl_cv_func_printf_directive_f/meson.build      |  2 +-
 glib/gnulib/gl_cv_func_printf_infinite/meson.build |  2 +-
 .../meson.build                                    |  2 +-
 .../gl_cv_func_printf_long_double/meson.build      |  2 +-
 glib/meson.build                                   |  2 +-
 gmodule/meson.build                                |  2 +-
 meson.build                                        | 24 +++++++++++-----------
 9 files changed, 21 insertions(+), 21 deletions(-)
---
diff --git a/gio/tests/meson.build b/gio/tests/meson.build
index a0c09444b..aea8b4aba 100644
--- a/gio/tests/meson.build
+++ b/gio/tests/meson.build
@@ -97,7 +97,7 @@ test_env.set('GIO_LAUNCH_DESKTOP', meson.build_root() + '/gio/gio-launch-desktop
 # 1.2.14 required for dbus_message_set_serial
 dbus1_dep = dependency('dbus-1', required : false, version : '>= 1.2.14')
 if not dbus1_dep.found()
-  if cc.get_id() == 'msvc'
+  if cc.get_id() == 'msvc' or cc.get_id() == 'clang-cl'
     # MSVC: Search for the DBus library by the configuration, which corresponds
     # to the output of CMake builds of DBus.  Note that debugoptimized
     # is really a Release build with .PDB files.
@@ -382,7 +382,7 @@ test_extra_programs += {
   },
 }
 
-if cc.get_id() != 'msvc'
+if cc.get_id() != 'msvc' and cc.get_id() != 'clang-cl'
   test_extra_programs += {
     # These three are manual-run tests because they need a session bus but don't bring one up themselves
     # FIXME: these build but don't seem to work!
diff --git a/glib/gnulib/gl_cv_func_frexp_works/meson.build b/glib/gnulib/gl_cv_func_frexp_works/meson.build
index 5d0c7cfce..29f7bcabe 100644
--- a/glib/gnulib/gl_cv_func_frexp_works/meson.build
+++ b/glib/gnulib/gl_cv_func_frexp_works/meson.build
@@ -96,7 +96,7 @@ else
     gl_cv_func_frexp_works = false
     gl_cv_func_frexp_broken_beyond_repair = true
   elif host_system == 'windows'
-    if cc.get_id () == 'msvc'
+    if cc.get_id () == 'msvc' or cc.get_id() == 'clang-cl'
       gl_cv_func_frexp_works = true
       gl_cv_func_frexp_broken_beyond_repair = false
     else
diff --git a/glib/gnulib/gl_cv_func_printf_directive_f/meson.build 
b/glib/gnulib/gl_cv_func_printf_directive_f/meson.build
index 6e423dbc1..945e01885 100644
--- a/glib/gnulib/gl_cv_func_printf_directive_f/meson.build
+++ b/glib/gnulib/gl_cv_func_printf_directive_f/meson.build
@@ -70,7 +70,7 @@ else
     gl_cv_func_printf_directive_f = false
   elif host_system == 'windows'
     # Guess yes on MSVC, no on mingw.
-    if cc.get_id() == 'msvc'
+    if cc.get_id() == 'msvc' or cc.get_id() == 'clang-cl'
       gl_cv_func_printf_directive_f = true
     else
       gl_cv_func_printf_directive_f = false
diff --git a/glib/gnulib/gl_cv_func_printf_infinite/meson.build 
b/glib/gnulib/gl_cv_func_printf_infinite/meson.build
index f33ade42c..5dce54bcf 100644
--- a/glib/gnulib/gl_cv_func_printf_infinite/meson.build
+++ b/glib/gnulib/gl_cv_func_printf_infinite/meson.build
@@ -123,7 +123,7 @@ else
     gl_cv_func_printf_infinite = true
   elif host_system.startswith ('windows')
     # Guess yes on MSVC, no on mingw.
-    if cc.get_id() == 'msvc'
+    if cc.get_id() == 'msvc' or cc.get_id() == 'clang-cl'
       gl_cv_func_printf_infinite = true
     else
       gl_cv_func_printf_infinite = false
diff --git a/glib/gnulib/gl_cv_func_printf_infinite_long_double/meson.build 
b/glib/gnulib/gl_cv_func_printf_infinite_long_double/meson.build
index fbdee8d16..b7a714c81 100644
--- a/glib/gnulib/gl_cv_func_printf_infinite_long_double/meson.build
+++ b/glib/gnulib/gl_cv_func_printf_infinite_long_double/meson.build
@@ -195,7 +195,7 @@ if gl_cv_func_printf_long_double
         gl_cv_func_printf_infinite_long_double = 'true'
       elif host_system == 'windows'
         # Guess yes on MSVC, no on mingw.
-        if cc.get_id() == 'msvc'
+        if cc.get_id() == 'msvc' or cc.get_id() == 'clang-cl'
           gl_cv_func_printf_infinite = 'true'
         else
           gl_cv_func_printf_infinite = 'false'
diff --git a/glib/gnulib/gl_cv_func_printf_long_double/meson.build 
b/glib/gnulib/gl_cv_func_printf_long_double/meson.build
index 1c0d6b58b..bd68fb377 100644
--- a/glib/gnulib/gl_cv_func_printf_long_double/meson.build
+++ b/glib/gnulib/gl_cv_func_printf_long_double/meson.build
@@ -39,7 +39,7 @@ else
    gl_cv_func_printf_long_double = false
  elif host_system == 'windows'
    # Guess yes on MSVC, no on mingw.
-   if cc.get_id() == 'msvc'
+   if cc.get_id() == 'msvc' or cc.get_id() == 'clang-cl'
      gl_cv_func_printf_long_double = true
    else
      gl_cv_func_printf_long_double = false
diff --git a/glib/meson.build b/glib/meson.build
index 40b58047d..5acd0b9ee 100644
--- a/glib/meson.build
+++ b/glib/meson.build
@@ -309,7 +309,7 @@ if host_system == 'windows'
   glib_sources += [glib_win_res]
   glib_sources += files('gwin32.c', 'gspawn-win32.c', 'giowin32.c')
   platform_deps = [winsock2, cc.find_library('winmm')]
-  if cc.get_id() == 'msvc'
+  if cc.get_id() == 'msvc' or cc.get_id() == 'clang-cl'
     glib_sources += files('dirent/wdirent.c')
   endif
 else
diff --git a/gmodule/meson.build b/gmodule/meson.build
index a7a2a5c87..942f9af3c 100644
--- a/gmodule/meson.build
+++ b/gmodule/meson.build
@@ -45,7 +45,7 @@ if g_module_impl == 'G_MODULE_IMPL_DL'
   # FIXME: check for OSF1/5.0 RTLD_GLOBAL brokenness (is this still relevant?)
 
   # Check whether we need preceding underscores
-  if cc.get_id() == 'msvc'
+  if cc.get_id() == 'msvc' or cc.get_id() == 'clang-cl'
     message('Building for MSVC: assuming that symbols are prefixed with underscore')
     g_module_need_uscore = 1
   elif meson.has_exe_wrapper()
diff --git a/meson.build b/meson.build
index b85ff7661..3c0940a29 100644
--- a/meson.build
+++ b/meson.build
@@ -13,7 +13,7 @@ cxx = meson.get_compiler('cpp')
 
 cc_can_run = not meson.is_cross_build() or meson.has_exe_wrapper()
 
-if cc.get_id() == 'msvc'
+if cc.get_id() == 'msvc' or cc.get_id() == 'clang-cl'
   # Ignore several spurious warnings for things glib does very commonly
   # If a warning is completely useless and spammy, use '/wdXXXX' to suppress it
   # If a warning is harmless but hard to fix, use '/woXXXX' so it's shown once
@@ -117,7 +117,7 @@ if host_system == 'windows'
   glib_conf.set('BROKEN_POLL', true)
 endif
 
-if host_system == 'windows' and cc.get_id() != 'msvc'
+if host_system == 'windows' and cc.get_id() != 'msvc' and cc.get_id() != 'clang-cl'
   # FIXME: Ideally we shouldn't depend on this on Windows and should use
   # 64 bit capable Windows API that also works with MSVC.
   # The autotools build did set this for mingw and while meson sets it
@@ -171,7 +171,7 @@ glib_hidden_visibility_args = []
 if get_option('default_library') != 'static'
   if host_system == 'windows' or host_system == 'cygwin'
     glib_conf.set('DLL_EXPORT', true)
-    if cc.get_id() == 'msvc'
+    if cc.get_id() == 'msvc' or cc.get_id() == 'clang-cl'
       glib_conf.set('_GLIB_EXTERN', '__declspec(dllexport) extern')
     elif cc.has_argument('-fvisibility=hidden')
       glib_conf.set('_GLIB_EXTERN', '__attribute__((visibility("default"))) __declspec(dllexport) extern')
@@ -514,7 +514,7 @@ foreach f : functions
 endforeach
 
 # Check that stpcpy() is usable; must use header
-if cc.has_function('stpcpy', prefix : '#include <string.h>')
+if cc.has_function('stpcpy', prefix : '#include <string.h>') and cc.get_id() != 'clang-cl'
   glib_conf.set('HAVE_STPCPY', 1)
 endif
 
@@ -555,7 +555,7 @@ elif cc.has_function('_snprintf') or cc.has_header_symbol('stdio.h', '_snprintf'
   glib_conf_prefix = glib_conf_prefix + '#define HAVE_SNPRINTF ' + hack_define
 endif
 
-if cc.has_function('strcasecmp')
+if cc.has_function('strcasecmp') and cc.get_id() != 'clang-cl'
   glib_conf.set('HAVE_STRCASECMP', 1)
   glib_conf_prefix = glib_conf_prefix + '#define HAVE_STRCASECMP 1\n'
 elif cc.has_function('_stricmp')
@@ -564,7 +564,7 @@ elif cc.has_function('_stricmp')
   glib_conf_prefix = glib_conf_prefix + '#define HAVE_STRCASECMP ' + hack_define
 endif
 
-if cc.has_function('strncasecmp')
+if cc.has_function('strncasecmp') and cc.get_id() != 'clang-cl'
   glib_conf.set('HAVE_STRNCASECMP', 1)
   glib_conf_prefix = glib_conf_prefix + '#define HAVE_STRNCASECMP 1\n'
 elif cc.has_function('_strnicmp')
@@ -773,7 +773,7 @@ have_good_vsnprintf = false
 have_good_snprintf = false
 have_good_printf = false
 
-if host_system == 'windows' and cc.get_id() == 'msvc'
+if host_system == 'windows' and (cc.get_id() == 'msvc' or cc.get_id() == 'clang-cl')
   # Unfortunately the Visual Studio 2015+ implementations of C99-style
   # snprintf and vsnprintf don't seem to be quite good enough.
   # (Sorry, I don't know exactly what is the problem,
@@ -1122,7 +1122,7 @@ else
   long_long_size = 0
 endif
 sizet_size = cc.sizeof('size_t')
-if cc.get_id() == 'msvc'
+if cc.get_id() == 'msvc' or cc.get_id() == 'clang-cl'
   ssizet_size = cc.sizeof('SSIZE_T', prefix : '#include <BaseTsd.h>')
 else
   ssizet_size = cc.sizeof('ssize_t')
@@ -1595,7 +1595,7 @@ atomicdefine = '''
 '''
 
 # We know that we can always use real ("lock free") atomic operations with MSVC
-if cc.get_id() == 'msvc' or cc.links(atomictest, name : 'atomic ops')
+if cc.get_id() == 'msvc' or cc.get_id() == 'clang-cl' or cc.links(atomictest, name : 'atomic ops')
   have_atomic_lock_free = true
   if (host_system == 'android' or host_system == 'linux') and not cc.compiles(atomicdefine, name : 'atomic 
ops define')
     # When building for armv5 on Linux, gcc provides
@@ -1725,7 +1725,7 @@ if get_option('internal_pcre')
 else
   pcre = dependency('libpcre', version: '>= 8.31', required : false) # Should check for Unicode support, 
too. FIXME
   if not pcre.found()
-    if cc.get_id() == 'msvc'
+    if cc.get_id() == 'msvc' or cc.get_id() == 'clang-cl'
     # MSVC: Search for the PCRE library by the configuration, which corresponds
     # to the output of CMake builds of PCRE.  Note that debugoptimized
     # is really a Release build with .PDB files.
@@ -1768,7 +1768,7 @@ libffi_dep = dependency('libffi', version : '>= 3.0.0', fallback : ['libffi', 'f
 # the system
 libz_dep = dependency('zlib', required : false)
 if not libz_dep.found()
-  if cc.get_id() != 'msvc'
+  if cc.get_id() != 'msvc' and cc.get_id() != 'clang-cl'
     libz_dep = cc.find_library('z', required : false)
   else
     libz_dep = cc.find_library('zlib1', required : false)
@@ -1980,7 +1980,7 @@ endif
 
 win32_cflags = []
 win32_ldflags = []
-if host_system == 'windows' and cc.get_id() != 'msvc'
+if host_system == 'windows' and cc.get_id() != 'msvc' and cc.get_id() != 'clang-cl'
   # Ensure MSVC-compatible struct packing convention is used when
   # compiling for Win32 with gcc. It is used for the whole project and exposed
   # in glib-2.0.pc.


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