[babl] build: clean up version script handling - ensure that symbol list dependency is correctly handled -



commit 5cf4fdf01da2a905553d687116b24f0242e9b6b5
Author: John Marshall <jtm home gmail com>
Date:   Wed Jun 24 18:00:38 2020 +0100

    build: clean up version script handling
    - ensure that symbol list dependency is correctly handled
    - add shebang to python script to let meson do the interpreter selection

 babl/meson.build | 77 +++++++++++++++++++++++++++++---------------------------
 gen_babl_map.py  |  2 ++
 meson.build      |  4 +--
 3 files changed, 44 insertions(+), 39 deletions(-)
---
diff --git a/babl/meson.build b/babl/meson.build
index 931a43013..c72fd80ee 100644
--- a/babl/meson.build
+++ b/babl/meson.build
@@ -1,29 +1,9 @@
-babl_library_build_dir = meson.current_build_dir()
 
+babl_library_build_dir = meson.current_build_dir()
 bablInclude = include_directories('.')
-subdir('base')
-
-python = import('python').find_installation()
-
-version_script = 'babl.map'
-version_script_clang = 'babl.map.clang'
-
-babl_gnu_sym_path = join_paths(meson.current_source_dir(), 'test-gnu.map')
-babl_clang_sym_path = join_paths(meson.current_source_dir(), 'test-clang.map')
 
+subdir('base')
 
-export_symbols = join_paths(meson.source_root(), 'export-symbols')
-version_script_target = custom_target(version_script,
-  input : [ export_symbols, ] ,
-  output: [ version_script ] ,
-  command: [
-  python,
-  join_paths(meson.source_root(), 'gen_babl_map.py'),
-  export_symbols,
-  version_script,
-  ],
-  capture: true,
-)
 
 # c compiler arguments
 babl_c_args = [
@@ -31,19 +11,44 @@ babl_c_args = [
   '-DLIBDIR="@0@"'.format(babl_libdir),
 ]
 
+# symbol maps
+version_script = custom_target('babl.map',
+  input : meson.source_root() / 'export-symbols',
+  output: ['babl.map', 'babl.map.clang'],
+  command: [
+  find_program(meson.source_root() / 'gen_babl_map.py'),
+  '@INPUT@',
+  '@OUTPUT0@',
+  ],
+)
+
 # Linker arguments
-if cc.links('', name: '-Wl,--version-script', args: ['-shared', '-Wl,--version-script=' + babl_gnu_sym_path])
-  babl_link_args = ['-Wl,--version-script,' + version_script]
-elif cc.get_id() == 'clang' 
-  if cc.links('', name: '-Wl,-exported_symbols_list', args: ['-Wl,-exported_symbols_list', 
babl_clang_sym_path])
+if cc.links('', 
+    name: '-Wl,--version-script', 
+    args: ['-shared', '-Wl,--version-script=' 
+      + meson.current_source_dir() / 'test-gnu.map']
+  )
+  babl_link_args = [
+    '-Wl,--version-script=' + version_script[0].full_path()
+  ]
+elif cc.get_id() == 'clang'
+  if cc.links('', 
+      name: '-Wl,-exported_symbols_list', 
+      args: ['-Wl,-exported_symbols_list', 
+        meson.current_source_dir() / 'test-clang.map']
+    )
     # Clang on Darwin
-    babl_link_args = ['-Wl,-exported_symbols_list',version_script_clang]
-  else
-    # Clang on windws
+    babl_link_args = [
+      '-Wl,-exported_symbols_list', version_script[1].full_path()
+    ]
+  else  
+    # Clang on msys/mingw
     babl_link_args = []
   endif
 else
-  error('Linker doesn\'t support --version-script or -exported_symbols_list')
+  error(
+    'Linker doesn\'t support --version-script or -exported_symbols_list'
+  )
 endif
 if platform_win32
   babl_link_args += no_undefined
@@ -55,12 +60,10 @@ babl_version_h = configure_file(
   configuration: conf,
 )
 
-
 # If git is available, always check if git-version.h should be
 # updated. If git is not available, don't do anything if git-version.h
 # already exists because then we are probably working with a tarball
 # in which case the git-version.h we ship is correct.
-
 if git_bin.found() and run_command(
     git_bin,
     'rev-parse',
@@ -139,12 +142,12 @@ install_headers(babl_headers,
 babl = library(
   lib_name,
   babl_sources,
-  include_directories: [ rootInclude, bablBaseInclude],
+  include_directories: [rootInclude, bablBaseInclude],
   c_args: babl_c_args,
-  link_whole: [ babl_base, ],
-  link_args: [ babl_link_args, ],
-  dependencies: [ math, thread, dl, lcms, ],
-  link_depends: [ version_script_target, ],
+  link_whole: babl_base,
+  link_args: babl_link_args,
+  dependencies: [math, thread, dl, lcms],
+  link_depends: version_script,
   version: so_version,
   install: true,
 )
diff --git a/gen_babl_map.py b/gen_babl_map.py
index 80a2d3ea3..1ed417240 100644
--- a/gen_babl_map.py
+++ b/gen_babl_map.py
@@ -1,3 +1,5 @@
+#!/usr/bin/env python3
+
 import sys
 
 export_symbols=sys.argv[1]
diff --git a/meson.build b/meson.build
index e8b908ddc..c53bd4d92 100644
--- a/meson.build
+++ b/meson.build
@@ -1,7 +1,7 @@
 project('babl', 'c',
   license: 'LGPL3+',
   version: '0.1.79',
-  meson_version: '>=0.53.0',
+  meson_version: '>=0.54.0',
   default_options: [
     'buildtype=debugoptimized'
   ],
@@ -21,7 +21,7 @@ conf = configuration_data()
 
 pkgconfig = import('pkgconfig')
 gnome     = import('gnome')
-python    = import('python')
+python    = import('python').find_installation()
 
 cc        = meson.get_compiler('c')
 prefix    = get_option('prefix')


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