[babl] Meson build: fixes for windows build



commit 944e3489de3bfe5caef5b6e94d09ec583d2ec08d
Author: John Marshall <jtm home gmail com>
Date:   Sat May 19 12:08:12 2018 +0100

    Meson build: fixes for windows build

 babl/meson.build |   28 ++++++++++++++++------------
 meson.build      |   39 ++++++++++++++++++++++++---------------
 2 files changed, 40 insertions(+), 27 deletions(-)
---
diff --git a/babl/meson.build b/babl/meson.build
index d467ab3..29ac00b 100644
--- a/babl/meson.build
+++ b/babl/meson.build
@@ -22,18 +22,23 @@ babl_version_h = configure_file(
 # already exists because then we are probably working with a tarball
 # in which case the git-version.h we ship is correct.
 
-if run_command(
-  ['test', '-d', join_paths(meson.source_root(), '.git')]
-  ).returncode() == 0 and git_bin.found()
-  # git repo and git is available
-  git_version = run_command([git_bin.path(), 'describe', '--always']
-    ).stdout().strip()
-  git_last_commit_year = run_command([git_bin.path(),
-    'log', '-n1', '--date=format:%Y', '--pretty=%cd']
-    ).stdout().strip()
+if test_bin.found() and git_bin.found()
+  if run_command(
+      [test_bin.path(), '-d', join_paths(meson.source_root(), '.git')]
+    ).returncode() == 0
+    # git repo and git is available
+    git_version = run_command([git_bin.path(), 'describe', '--always']
+      ).stdout().strip()
+    git_last_commit_year = run_command([git_bin.path(), 
+      'log', '-n1', '--date=format:%Y', '--pretty=%cd']
+      ).stdout().strip()
+  endif
 else
   # Not a git repo so expect git-version.h to exist
-  if run_command(['test', '-f', 'git-version.h']).returncode() == 0
+  if test_bin.found() and git_bin.found() and
+    run_command(
+      [test_bin.path(), '-f', 'git-version.h']
+    ).returncode() == 0
     git_version_h = 'git-version.h'
   else
     git_version = 'Unknown, shouldn\'t happen'
@@ -43,8 +48,7 @@ endif
 if not is_variable('git_version_h')
   git_conf = configuration_data()
   git_conf.set('BABL_GIT_VERSION', git_version)
-  git_conf.set('BABL_GIT_LAST_COMMIT_YEAR', git_last_commit_year
-  )
+  git_conf.set('BABL_GIT_LAST_COMMIT_YEAR', git_last_commit_year)
   git_version_h = configure_file(
     input:  'git-version.h.in',
     output: 'git-version.h',
diff --git a/meson.build b/meson.build
index afd3907..cd42845 100644
--- a/meson.build
+++ b/meson.build
@@ -114,7 +114,6 @@ platform_android = host_os.contains('android')
 
 path_sep = ( platform_win32 ? ';'     : ':' )
 dirs_sep = ( platform_win32 ? '\\\\'  : '/' )
-bin_ext  = ( platform_win32 ? '.exe'  : '' )
 lib_ext  = ( platform_win32 ? '.dll'  : '.so' )
 
 conf.set       ('BABL_PATH_SEPARATOR', '\'' + path_sep + '\'')
@@ -136,8 +135,6 @@ build_platform_win32 = (build_os.startswith('mingw') or
                         build_os.startswith('cygwin') or
                         build_os.startswith('windows'))
 
-native_bin_ext  = ( build_platform_win32 ? '.exe'  : '' )
-
 
 ################################################################################
 # Extra warnings
@@ -228,9 +225,14 @@ endif
 
 # Check headers
 check_headers = [
-  ['HAVE_DLFCN_H',      'dlfcn.h'],
-  ['HAVE_DL_H',         'dl.h'],
 ]
+# Don't check for dynamic load on windows
+if not platform_win32
+  check_headers += [
+    ['HAVE_DLFCN_H', 'dlfcn.h'],
+    ['HAVE_DL_H', 'dl.h'],
+  ]
+endif
 foreach header: check_headers
   if cc.has_header(header[1])
     conf.set(header[0], 1, description: 
@@ -265,9 +267,13 @@ endif
 ################################################################################
 # Dependencies
 
-math   = cc.find_library('m',   required: false)
-log    = cc.find_library('log', required: false)
-dl     = cc.find_library('dl',  required: false)
+math = cc.find_library('m',   required: false)
+log  = cc.find_library('log', required: false)
+if platform_win32 
+  dl = []
+else
+  dl = cc.find_library('dl',  required: false)
+endif
 
 thread = dependency('threads',  required: false)
 
@@ -275,14 +281,12 @@ thread = dependency('threads',  required: false)
 ################################################################################
 # Build utilities
 
-env_bin = find_program('env' + native_bin_ext, required: true,
-  native: true)
-git_bin = find_program('git' + native_bin_ext, required: true,
-  native: true)
-rsvg_convert_bin = find_program('rsvg-convert' + native_bin_ext,
-  required: false, native: true)
-w3m_bin = find_program('w3m' + native_bin_ext, required: false,
+env_bin = find_program('env', required: true, native: true)
+git_bin = find_program('git', required: false, native: true)
+rsvg_convert_bin = find_program('rsvg-convert', required: false,
   native: true)
+test_bin = find_program('test', required: false, native: true)
+w3m_bin = find_program('w3m', required: false, native: true)
 
 
 ################################################################################
@@ -311,6 +315,11 @@ pkgconfig.generate(filebase: 'babl',
   ],
 )
 
+configure_file(
+  output: 'config.h',
+  configuration: conf
+)
+
 
 ################################################################################
 # Subdirs


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