diff options
author | Christoph Reiter <reiter.christoph@gmail.com> | 2019-09-28 12:27:13 +0200 |
---|---|---|
committer | Christoph Reiter <reiter.christoph@gmail.com> | 2019-09-28 12:31:01 +0200 |
commit | 1cb3b2b27f824f3bbdab1a2e3fedf45a39689019 (patch) | |
tree | 77316a989ea260f0976fc32321c5d7dbdc46cbea | |
parent | aec85eaf4d41fbc82889a2dfe1c0e672f036cbae (diff) | |
download | gobject-introspection-1cb3b2b27f824f3bbdab1a2e3fedf45a39689019.tar.gz |
meson: change "cairo" from a boolean to a feature option
We require cairo only to run all tests and thus default it to false.
This usually results in developers not using it when working on changes and
tests depending on cairo then failing in CI.
This changes it to a feature option that defaults to auto, so that devs that
have cairo headers installed will automatically use it.
-rw-r--r-- | .gitlab-ci.yml | 4 | ||||
-rw-r--r-- | .gitlab-ci/test-msys2-meson.sh | 2 | ||||
-rw-r--r-- | meson.build | 26 | ||||
-rw-r--r-- | meson_options.txt | 2 | ||||
-rw-r--r-- | tests/scanner/meson.build | 14 |
5 files changed, 30 insertions, 18 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 72d6f7a1..800f07bc 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -16,7 +16,7 @@ fedora-x86_64-meson: CFLAGS: "-Werror" script: - python3 -m pip install --user mako markdown - - meson --prefix /usr --libdir /usr/lib64 --buildtype debug -Ddoctool=true -Dgtk_doc=true -Dcairo=true -Dpython=python3 _build . + - meson --prefix /usr --libdir /usr/lib64 --buildtype debug -Ddoctool=true -Dgtk_doc=true -Dcairo=enabled -Dpython=python3 _build . - cd _build - ninja - meson test --print-errorlogs --suite=gobject-introspection --no-suite=glib @@ -43,7 +43,7 @@ fedora-x86_64-python3.5: PYENV_VERSION: "3.5.6" script: - python3 -m pip install --user mako markdown - - meson --prefix /usr --libdir /usr/lib64 --buildtype debug -Ddoctool=true -Dgtk_doc=true -Dcairo=true -Dpython=python3 _build . + - meson --prefix /usr --libdir /usr/lib64 --buildtype debug -Ddoctool=true -Dgtk_doc=true -Dcairo=enabled -Dpython=python3 _build . - cd _build - ninja - meson test --print-errorlogs --suite=gobject-introspection --no-suite=glib diff --git a/.gitlab-ci/test-msys2-meson.sh b/.gitlab-ci/test-msys2-meson.sh index ce1768c4..37a0f913 100644 --- a/.gitlab-ci/test-msys2-meson.sh +++ b/.gitlab-ci/test-msys2-meson.sh @@ -38,7 +38,7 @@ export PATH="$HOME/.local/bin:$PATH" # Passing the full interpreter path works around the issue PYTHON="$(which python3)" export CFLAGS="-Werror" -meson -Dcairo=true -Ddoctool=true -Dpython="${PYTHON}" --buildtype debug _build +meson -Dcairo=enabled -Ddoctool=true -Dpython="${PYTHON}" --buildtype debug _build cd _build ninja diff --git a/meson.build b/meson.build index 9025388f..c71d2d84 100644 --- a/meson.build +++ b/meson.build @@ -144,19 +144,31 @@ endif libffi_dep = dependency('libffi', fallback : ['libffi', 'ffi_dep']) -with_cairo = get_option('cairo') +# cairo +cairo_option = get_option('cairo') +if cc.get_id() == 'msvc' + if cairo_option.disabled() + req = cairo_option + else + req = false + endif -if with_cairo - cairo_dep = dependency('cairo', required: cc.get_id() != 'msvc') - cairo_gobject_dep = dependency('cairo-gobject', required: cc.get_id() != 'msvc') + cairo_dep = dependency('cairo', required: req) + cairo_gobject_dep = dependency('cairo-gobject', required: req) - if cc.get_id() == 'msvc' and (not cairo_gobject_dep.found() or not cairo_dep.found()) + if not cairo_gobject_dep.found() or not cairo_dep.found() if cc.has_header('cairo.h') and cc.has_header ('cairo-gobject.h') - cairo_dep = cc.find_library ('cairo') - cairo_gobject_dep = cc.find_library ('cairo-gobject') + cairo_dep = cc.find_library('cairo', required: cairo_option) + cairo_gobject_dep = cc.find_library('cairo-gobject', required: cairo_option) endif endif else + cairo_dep = dependency('cairo', required: cairo_option) + cairo_gobject_dep = dependency('cairo-gobject', required: cairo_option) +endif +cairo_deps_found = cairo_gobject_dep.found() and cairo_dep.found() + +if not cairo_deps_found warning('Not building with cairo support, not all tests will be run') endif diff --git a/meson_options.txt b/meson_options.txt index 445a68a4..2bf2876f 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,4 +1,4 @@ -option('cairo', type: 'boolean', value : false, +option('cairo', type: 'feature', value : 'auto', description: 'Use cairo for tests' ) diff --git a/tests/scanner/meson.build b/tests/scanner/meson.build index a028e3d2..022d1829 100644 --- a/tests/scanner/meson.build +++ b/tests/scanner/meson.build @@ -87,7 +87,7 @@ if cc.get_id() != 'msvc' ]) endif -if with_cairo +if cairo_deps_found regress_deps = [cairo_dep, cairo_gobject_dep] regress_c_args = [] else @@ -455,7 +455,7 @@ if glib_dep.type_name() == 'pkgconfig' command: gircompiler_command, ) - if with_cairo + if cairo_deps_found regress_scanner_cairo_args = ['--include=cairo-1.0'] else regress_scanner_cairo_args = ['-D_GI_DISABLE_CAIRO',] @@ -492,7 +492,7 @@ if glib_dep.type_name() == 'pkgconfig' # The reference gir is generated with cairo support, so we can only compare # things if we build with cairo as well - if with_cairo + if cairo_deps_found test_girs += regress_gir endif @@ -527,7 +527,7 @@ if with_doctool and glib_dep.type_name() == 'pkgconfig' 'generate-docs-' + language, input: regress_gir, depends: [doc_templates], - build_by_default: not with_cairo, + build_by_default: not cairo_deps_found, output: 'Regress-1.0-' + language, command: [ python, girdoctool, @@ -537,7 +537,7 @@ if with_doctool and glib_dep.type_name() == 'pkgconfig' '@INPUT@', '-o', '@OUTPUT@'], ) - if with_cairo + if cairo_deps_found test( 'gi-tester-docs-Regress-1.0-' + language, python, @@ -555,7 +555,7 @@ if with_doctool and glib_dep.type_name() == 'pkgconfig' 'generate-docs-sections', input: regress_gir, depends: [doc_templates], - build_by_default: not with_cairo, + build_by_default: not cairo_deps_found, output: 'Regress-1.0-sections.txt', command: [ python, girdoctool, @@ -565,7 +565,7 @@ if with_doctool and glib_dep.type_name() == 'pkgconfig' '@INPUT@', '-o', '@OUTPUT@'], ) - if with_cairo + if cairo_deps_found test( 'gi-tester-docs-Regress-1.0-sections.txt', python, |