[babl] Another project can add babl as a subproject
- From: Øyvind "pippin" Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [babl] Another project can add babl as a subproject
- Date: Thu, 25 Feb 2021 21:43:57 +0000 (UTC)
commit fbf3dd9301dbe8afbfca915051cb936f7c2bd59a
Author: santouits <santouits users noreply github com>
Date: Sun Sep 6 15:16:52 2020 +0300
Another project can add babl as a subproject
.gitignore | 2 ++
babl/meson.build | 21 +++++++++++++++------
docs/build_as_meson_subproject.md | 23 +++++++++++++++++++++++
docs/meson.build | 8 ++++----
extensions/meson.build | 2 +-
meson.build | 13 +++++++++++--
6 files changed, 56 insertions(+), 13 deletions(-)
---
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 000000000..a3523b715
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+# Meson
+_build
diff --git a/babl/meson.build b/babl/meson.build
index fed8fe91b..623367804 100644
--- a/babl/meson.build
+++ b/babl/meson.build
@@ -13,10 +13,10 @@ babl_c_args = [
# symbol maps
version_script = custom_target('babl.map',
- input : meson.source_root() / 'export-symbols',
+ input : export_symbols_file,
output: ['babl.map', 'babl.map.clang'],
command: [
- find_program(meson.source_root() / 'gen_babl_map.py'),
+ find_program(gen_babl_map_file),
'@INPUT@',
'@OUTPUT0@',
],
@@ -76,7 +76,7 @@ if git_bin.found() and run_command(
command: [ git_bin.path(), 'describe', '--always' ],
)
- if env_bin.found()
+ if env_bin.found() and not meson.is_subproject()
meson.add_dist_script(
[ 'ninja', 'babl/git-version.h', ],
)
@@ -139,19 +139,28 @@ install_headers(babl_headers,
subdir: join_paths(lib_name, 'babl')
)
+babl_deps = [math, thread, dl, lcms]
+babl_includes = [rootInclude, bablBaseInclude]
+
babl = library(
lib_name,
babl_sources,
- include_directories: [rootInclude, bablBaseInclude],
+ include_directories: babl_includes,
c_args: babl_c_args,
link_whole: babl_base,
link_args: babl_link_args,
- dependencies: [math, thread, dl, lcms],
+ dependencies: babl_deps,
link_depends: version_script,
version: so_version,
install: true,
)
+libbabl_dep = declare_dependency(
+ include_directories: babl_includes,
+ link_with: babl,
+ dependencies: babl_deps
+)
+
if build_gir
# identity filter, so GIR doesn't choke on the Babl type
# (since it has the same name as the Babl namespace)
@@ -169,7 +178,7 @@ if build_gir
)
if build_vapi
- gnome.generate_vapi(lib_name,
+ babl_vapi = gnome.generate_vapi(lib_name,
sources: babl_gir[0],
install: true,
)
diff --git a/docs/build_as_meson_subproject.md b/docs/build_as_meson_subproject.md
new file mode 100644
index 000000000..d6e1c6556
--- /dev/null
+++ b/docs/build_as_meson_subproject.md
@@ -0,0 +1,23 @@
+
+Including babl as a meson subproject in your project:
+
+You create a babl.wrap file inside a folder named 'subprojects'
+which contains a way to download the babl source.
+See https://mesonbuild.com/Wrap-dependency-system-manual.html.
+An example will be:
+```
+[wrap-git]
+url = https://gitlab.gnome.org/GNOME/babl
+revision = master
+depth = 1
+```
+
+Next, include in your meson.build file something like this:
+```
+babl = dependency('babl', fallback: ['babl', 'libbabl_dep'])
+```
+
+If babl is installed in your system, meson will use that one,
+otherwise it will download and build babl.
+
+
diff --git a/docs/meson.build b/docs/meson.build
index eefeb915c..1aa52ed42 100644
--- a/docs/meson.build
+++ b/docs/meson.build
@@ -6,7 +6,7 @@ scptarget = host + ':' + location + '/'
xml_insert = find_program(
- meson.source_root() / 'tools' / 'xml-insert.py',
+ xml_insert_file,
native: true
)
@@ -46,9 +46,9 @@ endif
TOC = files('toc')
html_files = {
'index': [index_static_html, [
- ['AUTHORS', files(meson.source_root() / 'AUTHORS')],
- ['TODO', files(meson.source_root() / 'TODO')],
- ['NEWS', files(meson.source_root() / 'NEWS')],
+ ['AUTHORS', authors_file],
+ ['TODO', todo_file],
+ ['NEWS', news_file],
['TOC', TOC],
]],
'Reference': ['auto', [
diff --git a/extensions/meson.build b/extensions/meson.build
index 850793f75..598857c0d 100644
--- a/extensions/meson.build
+++ b/extensions/meson.build
@@ -54,7 +54,7 @@ extensions = [
]
foreach ext : extensions
- library(
+ shared_library(
ext[0],
ext[0] + '.c',
c_args: ext[1],
diff --git a/meson.build b/meson.build
index f6089a33d..1362b6acf 100644
--- a/meson.build
+++ b/meson.build
@@ -415,6 +415,15 @@ configure_file(
configuration: conf
)
+################################################################################
+# Global variables
+
+xml_insert_file = files('tools' / 'xml-insert.py')
+authors_file = files('AUTHORS')
+news_file = files('NEWS')
+todo_file = files('TODO')
+export_symbols_file = files('export-symbols')
+gen_babl_map_file = files('gen_babl_map.py')
################################################################################
# Subdirs
@@ -447,11 +456,11 @@ endif
# pkg-config file
-pkgconfig.generate(filebase: 'babl',
+pkgconfig.generate(babl,
+ filebase: 'babl',
name: 'babl',
description: 'Pixel encoding and color space conversion engine.',
version: meson.project_version(),
- libraries: [ babl ],
libraries_private: [
'-lm',
],
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]