[gjs] meson.build: Don't check for GCC-specific items on MSVC



commit 48c59b0e724a83adf7139156473a4dd74922019d
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Fri Oct 25 12:10:13 2019 +0800

    meson.build: Don't check for GCC-specific items on MSVC
    
    Instead, we use the msvc_recommended_pragmas.h as we do in the GTK
    stack, as well as in conjunction to disabling some other warnings,
    as we do in the the NMake Makefiles, so that we cover more or less the
    same items in MSVC builds.
    
    Since there is no -Bsymbolic-functions equivilant in MSVC, we just skip
    checking and using that as well.
    
    Also, make sure that we pass in the additional flags that we need for
    Visual Studio builds, as we did in the NMake Makefiles.

 meson.build       | 54 ++++++++++++++++++++++++++++++++++++++++--------------
 meson_options.txt |  2 +-
 2 files changed, 41 insertions(+), 15 deletions(-)
---
diff --git a/meson.build b/meson.build
index 36ad3302..2edd0e77 100644
--- a/meson.build
+++ b/meson.build
@@ -27,21 +27,39 @@ endif
 cxx = meson.get_compiler('cpp')
 cc = meson.get_compiler('c')
 
-add_project_arguments(cxx.get_supported_arguments([
-    '-fno-strict-aliasing',
-
-    # 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')
-
-if get_option('bsymbolic_functions')
-    if not cxx.has_link_argument('-Bsymbolic-functions')
-        error('''-Bsymbolic-functions not supported, configure with
+if cxx.get_id() == 'msvc'
+    add_project_arguments(cxx.get_supported_arguments([
+        '-utf-8',  # Use UTF-8 mode
+        '-Dssize_t=gssize',  # Visual Studio do not come with ssize_t
+        '-Zc:externConstexpr',  # Required for 'extern constexpr' on MSVC
+        '-DNOMINMAX',  # We don't want 'min' or 'max' to interfere
+
+        # Ignore spurious compiler warnings for things that
+        # GLib and SpiderMonkey header files commonly do
+        '-FImsvc_recommended_pragmas.h',
+        '-EHsc',
+        '-wd4099',
+        '-wd4251',
+        '-wd4291',
+        '-wd4800',
+    ]), language: ['cpp', 'c'])
+else
+    add_project_arguments(cxx.get_supported_arguments([
+        '-fno-strict-aliasing',
+
+        # 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')
+
+    if get_option('bsymbolic_functions')
+        if not cxx.has_link_argument('-Bsymbolic-functions')
+            error('''-Bsymbolic-functions not supported, configure with
 -Dbsymbolic_functions=false''')
+        endif
+        add_project_link_arguments('-Bsymbolic-functions', language: ['cpp', 'c'])
     endif
-    add_project_link_arguments('-Bsymbolic-functions', language: ['cpp', 'c'])
 endif
 
 # SpiderMonkey can be compiled with or without runtime type information, we must
@@ -437,10 +455,17 @@ else
     link_args += cxx.get_supported_link_arguments('-Wl,-undefined,error')
 endif
 
+libgjs_cpp_args = ['-DGJS_COMPILATION']
+
+if host_machine.system() == 'windows'
+    # We need these defines to build properly for all Windows builds
+    libgjs_cpp_args += ['-DWIN32', '-DXP_WIN']
+endif
+
 libgjs = shared_library(meson.project_name(),
     libgjs_sources, libgjs_private_sources, module_resource_srcs,
     probes_header, probes_objfile,
-    cpp_args: ['-DGJS_COMPILATION'] + directory_defines,
+    cpp_args: libgjs_cpp_args + directory_defines,
     link_args: link_args, link_depends: [symbol_map, symbol_list],
     dependencies: libgjs_dependencies,
     version: '0.0.0', soversion: '0',
@@ -466,6 +491,7 @@ gjs_private_typelib = gjs_private_gir[1]
 gjs_console_srcs = ['gjs/console.cpp']
 
 gjs_console = executable('gjs-console', gjs_console_srcs,
+    cpp_args: libgjs_cpp_args,
     dependencies: libgjs_dep, install: true)
 
 meson.add_install_script('build/symlink-gjs.py', get_option('bindir'))
diff --git a/meson_options.txt b/meson_options.txt
index 641766b0..66f66024 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')
+    description: 'Link with -Bsymbolic-functions linker flag used to avoid intra-library PLT jumps, if 
supported; not used for MSVC 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]