[babl] Meson build: Improve host environment detection / handling
- From: Øyvind Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [babl] Meson build: Improve host environment detection / handling
- Date: Sat, 19 May 2018 11:35:44 +0000 (UTC)
commit 3e25c8f93f6bb3076a9e5e875bfdab651c818cc9
Author: John Marshall <jtm home gmail com>
Date: Sat May 19 11:36:45 2018 +0100
Meson build: Improve host environment detection / handling
babl/meson.build | 6 ++--
docs/graphics/meson.build | 38 ++++++++++++++-------------
docs/meson.build | 6 +++-
meson.build | 62 ++++++++++++++++++++++++++++++++++----------
tests/meson.build | 22 ++++++++++------
5 files changed, 89 insertions(+), 45 deletions(-)
---
diff --git a/babl/meson.build b/babl/meson.build
index b3058cc..b5b6cba 100644
--- a/babl/meson.build
+++ b/babl/meson.build
@@ -10,21 +10,21 @@ babl_version_h = configure_file(
gitversion_h1 = vcs_tag(
input : 'git-version.h.in',
output: 'git-version.h.in.1',
- command: [ 'git', 'describe', '--always', ],
+ command: [ git_bin.path(), 'describe', '--always', ],
replace_string: '@BABL_GIT_VERSION@',
fallback: '',
)
gitversion_h2 = vcs_tag(
input : gitversion_h1,
output: 'git-version.h.in.2',
- command: [ 'git', 'rev-parse', '--short', 'HEAD', ],
+ command: [ git_bin.path(), 'rev-parse', '--short', 'HEAD', ],
replace_string: '@BABL_GIT_VERSION_ABBREV@',
fallback: '',
)
gitversion_h = vcs_tag(
input : gitversion_h2,
output: 'git-version.h',
- command: [ 'git', 'log', '-n1', '--date=format:%Y', '--pretty=%cd', ],
+ command: [ git_bin.path(), 'log', '-n1', '--date=format:%Y', '--pretty=%cd', ],
replace_string: '@BABL_GIT_LAST_COMMIT_YEAR@',
fallback: '',
)
diff --git a/docs/graphics/meson.build b/docs/graphics/meson.build
index 5b1715a..e7fe9f7 100644
--- a/docs/graphics/meson.build
+++ b/docs/graphics/meson.build
@@ -9,22 +9,24 @@ graphic_files_install = [
files('index.html'),
]
-foreach file : graphic_files
- sizeinfo = (
- file.contains('a4poster')
- ? [ '-w', '256', ]
- : []
- )
+if rsvg_convert_bin.found()
+ foreach file : graphic_files
+ sizeinfo = (
+ file.contains('a4poster')
+ ? [ '-w', '256', ]
+ : []
+ )
- graphic_files_install += custom_target(file,
- input : [ file + '.svg' ],
- output: [ file + '.png' ],
- command: [
- rsvg_convert,
- sizeinfo,
- '-o', '@OUTPUT@',
- '@INPUT@',
- ],
- install: false,
- )
-endforeach
+ graphic_files_install += custom_target(file,
+ input : [ file + '.svg' ],
+ output: [ file + '.png' ],
+ command: [
+ rsvg_convert_bin,
+ sizeinfo,
+ '-o', '@OUTPUT@',
+ '@INPUT@',
+ ],
+ install: false,
+ )
+ endforeach
+endif
diff --git a/docs/meson.build b/docs/meson.build
index 95f77a2..1c33c44 100644
--- a/docs/meson.build
+++ b/docs/meson.build
@@ -18,7 +18,8 @@ index_static_html = configure_file(
index_html_tmp = custom_target('index.html.tmp',
input : [ babl_html_dump, ],
output: [ 'index.html.tmp', ],
- command: [ find_program('env'),
+ command: [
+ env_bin,
'BABL_PATH='+ join_paths(meson.build_root(), 'extensions'),
babl_html_dump
],
@@ -34,7 +35,8 @@ index_html = custom_target('index.html',
join_paths(meson.source_root(), 'NEWS'),
],
output: [ 'index.html', ],
- command: [ find_program('env'),
+ command: [
+ env_bin,
'cp', '@INPUT0@', '@OUTPUT@',
'&&', xml_insert, '@OUTPUT@', 'BablBase', '@INPUT1@',
'&&', xml_insert, '@OUTPUT@', 'AUTHORS', '@INPUT2@',
diff --git a/meson.build b/meson.build
index 8909092..d53ae46 100644
--- a/meson.build
+++ b/meson.build
@@ -3,6 +3,7 @@ project('babl', 'c',
version: '0.1.49',
meson_version: '>=0.40.0',
default_options: [
+ 'libdir=lib',
'sysconfdir=/etc',
'localstatedir=/var',
'sharedstatedir=/var/lib'
@@ -68,7 +69,11 @@ conf.set_quoted('BABL_CURRENT_MINUS_AGE','@0@'.format(0))
conf.set_quoted('BABL_LIBRARY', '@0@'.format(lib_name))
################################################################################
-# Host system detection
+# Host system environment
+
+platform_android = false
+platform_osx = false
+platform_win32 = false
host_cpu = host_machine.cpu()
message('Architecture: ' + host_cpu)
@@ -91,16 +96,17 @@ else
error('Unknown host architecture')
endif
-
host_os = host_machine.system()
message('Host os: ' + host_os)
-platform_win32 = host_os.startswith('mingw') or host_os.startswith('cygwin') or host_os.startswith('windows')
+platform_win32 = (host_os.startswith('mingw') or
+ host_os.startswith('cygwin') or
+ host_os.startswith('windows'))
platform_osx = host_os.startswith('darwin')
if platform_osx
if cc.get_id() != 'clang'
- error('You should use CLang++ on OSx.')
+ error('You should use Clang/Clang++ on OSX.')
endif
endif
@@ -108,12 +114,31 @@ 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 + '\'')
conf.set_quoted('BABL_DIR_SEPARATOR', dirs_sep)
conf.set_quoted('SHREXT', lib_ext)
+# assume *nix if not android/osx/win32
+platform_unix = not (
+ platform_android or
+ platform_osx or
+ platform_win32
+)
+
+# Build system environment
+build_os = build_machine.system()
+message('Build os: ' + build_os)
+
+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
@@ -210,20 +235,29 @@ endif
conf.set('HAVE_DLFCN_H', have_dlfcn_h)
conf.set('HAVE_DL_H', have_dl_h)
+
################################################################################
-# Utilities
+# Dependencies
-rsvg_convert = find_program('rsvg-convert', required: false)
-w3m = find_program('w3m', required: false)
+math = cc.find_library('m', required: false)
+log = cc.find_library('log', required: false)
+dl = cc.find_library('dl', required: false)
+
+thread = dependency('threads', required: false)
################################################################################
-# Dependencies
+# 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,
+ native: true)
-math = cc.find_library('m', required: false)
-thread= cc.find_library('pthread', required: false)
-log = cc.find_library('log', required: false)
-dl = cc.find_library('dl', required: false)
pkgconfig.generate(filebase: 'babl',
@@ -263,12 +297,12 @@ if get_option('with-docs')
endif
-if w3m.found()
+if w3m_bin.found()
custom_target('README',
input : [ join_paths('docs', 'index.html'), ] ,
output: [ 'README' ] ,
command: [
- w3m,
+ w3m_bin,
'-cols', '72',
'-dump',
'@INPUT@',
diff --git a/tests/meson.build b/tests/meson.build
index 0490c2c..46313c5 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -21,25 +21,31 @@ test_names = [
'transparent',
'types',
]
-if true or os_unix
- test_names += [ 'concurrency-stress-test', 'palette-concurrency-stress-test' ]
+if platform_unix
+ test_names += [
+ 'concurrency-stress-test',
+ 'palette-concurrency-stress-test',
+ ]
endif
+test_env = environment()
+test_env.prepend('LD_LIBRARY_PATH', join_paths(meson.build_root(), 'babl'))
+test_env.set('GI_TYPELIB_PATH', join_paths(meson.build_root(), 'babl'))
+test_env.set('BABL_PATH', join_paths(meson.build_root(), 'extensions'))
foreach test_name : test_names
- test = executable(test_name,
+ test = executable(
+ test_name,
test_name + '.c',
include_directories: [ rootInclude, bablInclude, ],
link_with: [ babl, ],
dependencies: [ thread, ],
+ export_dynamic: true,
install: false,
)
test(test_name,
test,
- env: [
- 'LD_LIBRARY_PATH='+ join_paths(meson.build_root(), 'babl') + ':$LD_LIBRARY_PATH',
- 'GI_TYPELIB_PATH='+ join_paths(meson.build_root(), 'babl'),
- 'BABL_PATH=' + join_paths(meson.build_root(), 'extensions'),
- ],
+ env: test_env,
+ workdir: meson.current_build_dir(),
)
endforeach
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]