[gjs/restore-msvc-build: 2/3] meson: Bring back Visual Studio build support




commit 167a679791fd3f5033f7c11a044411bd9cb7e40e
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Tue Aug 25 14:45:38 2020 +0800

    meson: Bring back Visual Studio build support
    
    After applying the workarounds in the sources, we can now restore support for
    builds that are done using Visual Studio.  Builds on Windows are now supported
    both via Visual Studio and clang-cl.

 meson.build       | 41 +++++++++++++++++++++++++++--------------
 meson_options.txt |  2 +-
 2 files changed, 28 insertions(+), 15 deletions(-)
---
diff --git a/meson.build b/meson.build
index 06860da0..783de568 100644
--- a/meson.build
+++ b/meson.build
@@ -25,23 +25,36 @@ endif
 cxx = meson.get_compiler('cpp')
 cc = meson.get_compiler('c')
 
-add_project_arguments(cxx.get_supported_arguments([
-    '-fno-strict-aliasing',
-
+if cc.get_id() == 'msvc'
+    add_project_arguments(cxx.get_supported_arguments([
+        '-utf-8',  # Use UTF-8 mode
+        '/Zc:externConstexpr',  # Required for 'extern constexpr' on MSVC
+
+        # Ignore spurious compiler warnings for things that GLib and SpiderMonkey
+        # header files commonly do
+        '-FImsvc_recommended_pragmas.h',
+        '-EHsc',
+        '-D_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS', # Don't worry about the C++17 deprecations
+        '-wd4099',
+        '-wd4251',
+        '-wd4291',
+        '-wd4800',
+    ]), language: ['cpp', 'c'])
+else
     # Ignore spurious compiler warnings for things that GLib and SpiderMonkey
-    # header files commonly do
-    '-Wno-variadic-macros',  # GLib uses these in header files
-    '-Wno-missing-field-initializers',  # SpiderMonkey JSClass, among others
-]), language: 'cpp')
-
-add_project_arguments(cc.get_supported_arguments([
-    '-Wno-typedef-redefinition',  # GLib does this in header files
-]), language: 'c')
+    # header files commonly do 
+    add_project_arguments(cxx.get_supported_arguments([
+        '-fno-strict-aliasing',
+        '-Wno-variadic-macros',  # GLib uses these in header files
+        '-Wno-missing-field-initializers',  # SpiderMonkey JSClass, among others
+    ]), language: 'cpp')
+
+    add_project_arguments(cc.get_supported_arguments([
+        '-Wno-typedef-redefinition',  # GLib does this in header files
+    ]), language: 'c')
+endif
 
 if cc.get_argument_syntax() == 'msvc'
-    if cc.get_id() == 'msvc'
-        error('Buliding GJS with Visual Studio compilers is no longer supported.  Please use `clang-cl`.')
-    endif
     add_project_arguments(cxx.get_supported_arguments([
         '-Dssize_t=gssize',  # Windows SDK/MSVC headers do not come with ssize_t
         '-DNOMINMAX',  # We don't want 'min' or 'max' to interfere
diff --git a/meson_options.txt b/meson_options.txt
index edf61ca3..825ba77a 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -16,7 +16,7 @@ option('dtrace', type: 'boolean', value: false,
 option('systemtap', type: 'boolean', value: false,
     description: 'Include systemtap trace support (requires -Ddtrace=true)')
 option('bsymbolic_functions', type: 'boolean', value: true,
-    description: 'Link with -Bsymbolic-functions linker flag used to avoid intra-library PLT jumps, if 
supported; not used for clang-cl builds')
+    description: 'Link with -Bsymbolic-functions linker flag used to avoid intra-library PLT jumps, if 
supported; not used for Visual Studio and clang-cl builds')
 option('spidermonkey_rtti', type: 'boolean', value: false,
     description: 'Needs to match SpiderMonkey\'s config option')
 option('skip_dbus_tests', type: 'boolean', value: false,


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