[gitg/wip/valadoc: 4/12] meson: Improved linker flag support checks



commit 5375bc48732d9d80556141e11a6166933d03f1d4
Author: Iñigo Martínez <inigomartinez gmail com>
Date:   Mon Oct 1 22:20:33 2018 +0200

    meson: Improved linker flag support checks
    
    Since version 0.46, meson has support for checking support for
    linker flags[0].
    
    gitg's linker flag support checking has been improved by using
    the provided functions.
    
    [0] http://mesonbuild.com/Release-notes-for-0-46-0.html#new-functions-has_link_argument-and-friends

 gitg/meson.build        | 10 +++-------
 libgitg-ext/meson.build |  8 +-------
 libgitg/meson.build     | 17 +++--------------
 meson.build             |  6 ++----
 4 files changed, 9 insertions(+), 32 deletions(-)
---
diff --git a/gitg/meson.build b/gitg/meson.build
index 94e3c51c..e5c7e9d5 100644
--- a/gitg/meson.build
+++ b/gitg/meson.build
@@ -75,6 +75,8 @@ cflags = warn_flags + [
   '-DGITG_LOCALEDIR="@0@"'.format(gitg_localedir),
 ]
 
+ldflags = common_ldflags
+
 resources_conf = configuration_data()
 resources_conf.set('PLATFORM_NAME', platform_name)
 
@@ -137,12 +139,6 @@ executable(
   install: true,
 )
 
-ldflags = []
-
-if have_version_script
-  ldflags += '-Wl,--version-script,' + symbol_map
-endif
-
 # FIXME: to be tested on win32
 if platform_name == 'win32'
   win = import('windows')
@@ -152,7 +148,7 @@ if platform_name == 'win32'
     args: ['-O', 'coff'],
   )
 
-  ldflags += '-mwindows'
+  ldflags += cc.get_supported_link_arguments('-mwindows')
 endif
 
 gitg = shared_library(
diff --git a/libgitg-ext/meson.build b/libgitg-ext/meson.build
index 5b7f18fd..5a025666 100644
--- a/libgitg-ext/meson.build
+++ b/libgitg-ext/meson.build
@@ -47,12 +47,6 @@ cflags = warn_flags + [
   '-DLIBDIR="@0@"'.format(gitg_libdir),
 ]
 
-ldflags = []
-
-if have_version_script
-  ldflags += '-Wl,--version-script,' + symbol_map
-endif
-
 libgitg_ext = shared_library(
   api_name,
   sources: sources,
@@ -64,7 +58,7 @@ libgitg_ext = shared_library(
   vala_header: lib_name + '.h',
   vala_vapi: lib_api_name + '.vapi',
   vala_gir: gir_name,
-  link_args: ldflags,
+  link_args: common_ldflags,
   link_depends: symbol_map,
   install: true,
   install_dir: [
diff --git a/libgitg/meson.build b/libgitg/meson.build
index eea56c1b..53b3da1d 100644
--- a/libgitg/meson.build
+++ b/libgitg/meson.build
@@ -104,13 +104,8 @@ cflags = warn_flags + [
   '-DGETTEXT_PACKAGE="@0@"'.format(gitg_gettext),
 ]
 
-ldflags = []
+ldflags = common_ldflags
 
-if have_version_script
-  ldflags += '-Wl,--version-script,' + symbol_map
-endif
-
-test_ldflags = []
 if gdk_targets.contains('quartz')
   sources += files('gitg-platform-support-osx.c')
   gio_system_pkg = 'gio-unix-2.0'
@@ -120,10 +115,10 @@ if gdk_targets.contains('quartz')
   ]
   cflags += '-xobjective-c'
 
-  test_ldflags += [
+  ldflags += cc.get_supported_link_arguments([
     '-framework Foundation',
     '-framework AppKit',
-  ]
+  ])
 elif gdk_targets.contains('win32')
   sources += files('gitg-platform-support-win32.c')
   gio_system_pkg = 'gio-windows-2.0'
@@ -134,12 +129,6 @@ else
   deps += dependency(gio_system_pkg)
 endif
 
-foreach test_ldflag: test_ldflags
-  if cc.has_argument(test_ldflag)
-    ldflags += test_ldflag
-  endif
-endforeach
-
 libgitg = shared_library(
   api_name,
   sources: sources,
diff --git a/meson.build b/meson.build
index 3cab1990..867c0c93 100644
--- a/meson.build
+++ b/meson.build
@@ -100,10 +100,8 @@ vapi_dir = join_paths(meson.source_root(), 'vapi')
 
 add_project_arguments('--vapidir=' + vapi_dir, language: 'vala')
 
-ldflag = '-Wl,--version-script'
-have_version_script = host_machine.system().contains('linux') and cc.has_argument(ldflag)
-
-symbol_map = join_paths(meson.source_root(), 'libgitg.map')
+symbol_map = join_paths(meson.current_source_dir(), 'libgitg.map')
+common_ldflags = cc.get_supported_link_arguments('-Wl,--version-script,@0@'.format(symbol_map))
 
 glib_req_version = '>= 2.38'
 


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