[gtkmm-documentation] meson.build: Several minor improvements
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm-documentation] meson.build: Several minor improvements
- Date: Tue, 3 Sep 2019 09:48:49 +0000 (UTC)
commit 02b2e2f87b49801cb5e1cc6193d9c4ea1d6fafd4
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date: Tue Sep 3 09:42:03 2019 +0200
meson.build: Several minor improvements
Use the / operator instead of join_paths().
Directory paths for installation are relative to {prefix} instead of absolute.
Don't call meson.add_dist_script(), if it's a subproject.
Use MESON_DIST_ROOT in extra-dist-cmd.sh.
docs/tutorial/meson.build | 28 ++++++++++++++--------------
examples/book/buildapp/meson.build | 12 ++++++------
examples/book/giomm/meson.build | 10 +++++-----
examples/book/meson.build | 10 +++++-----
examples/book/treeview/meson.build | 10 +++++-----
examples/others/meson.build | 10 +++++-----
meson.build | 33 +++++++++++++++++++--------------
tools/meson_aux/extra-dist-cmd.sh | 15 +++++++--------
8 files changed, 66 insertions(+), 62 deletions(-)
---
diff --git a/docs/tutorial/meson.build b/docs/tutorial/meson.build
index ce56a6c..f9c70f9 100644
--- a/docs/tutorial/meson.build
+++ b/docs/tutorial/meson.build
@@ -1,8 +1,8 @@
# docs/tutorial
-# input: gnome, gtkmm_datadir, gtkmm_pcname, tutorial_custom_cmd_sh, project_source_root
+# input: gnome, install_datadir, gtkmm_pcname, tutorial_custom_cmd_sh, project_source_root
# output: can_parse_and_validate, build_translations_by_default, can_build_translations,
-# build_pdf_by_default, can_build_pdf
+# build_pdf_by_default, can_build_pdf, tutorialdir
# xsltproc is required by tutorial_custom_cmd_sh html.
xsltproc = find_program('xsltproc', required: true)
@@ -22,11 +22,11 @@ can_build_pdf = dblatex.found() or (xmllint.found() and \
find_program('docbook2pdf', required: false).found())
build_pdf_by_default = get_option('build-pdf')
-# Installation directories
-tutorialdir = join_paths(gtkmm_datadir, 'doc', gtkmm_pcname, 'tutorial')
-tutorial_htmldir = join_paths(tutorialdir, 'html')
-tutorial_figuresdir = join_paths(tutorial_htmldir, 'figures')
-tutorial_iconsdir = join_paths(tutorial_htmldir, 'icons')
+# Installation directories are relative to {prefix}.
+tutorialdir = install_datadir / 'doc' / gtkmm_pcname / 'tutorial'
+tutorial_htmldir = tutorialdir / 'html'
+tutorial_figuresdir = tutorial_htmldir / 'figures'
+tutorial_iconsdir = tutorial_htmldir / 'icons'
tutorial_figurefiles = [
'aspectframe.png',
@@ -114,8 +114,8 @@ tutorial_figurefiles = [
tutorial_figures = []
tutorial_C_figures = []
foreach f : tutorial_figurefiles
- tutorial_figures += join_paths('figures', f)
- tutorial_C_figures += join_paths('C', 'figures', f)
+ tutorial_figures += 'figures' / f
+ tutorial_C_figures += 'C' / 'figures' / f
endforeach
tutorial_iconfiles = [
@@ -131,18 +131,18 @@ tutorial_iconfiles = [
]
tutorial_icons = []
foreach i : tutorial_iconfiles
- tutorial_icons += join_paths('icons', i)
+ tutorial_icons += 'icons' / i
endforeach
# Create a DocBook C locale XML file with the examples' source code included.
# Copy it to the source directory, where gnome.yelp() expects to find it.
index_docbook = custom_target('index.docbook',
- input: join_paths('C', 'index-in.docbook'),
+ input: 'C' / 'index-in.docbook',
output: 'index.docbook',
command: [
tutorial_custom_cmd_sh, 'insert_example_code',
- join_paths(meson.current_source_dir(), 'insert_example_code.pl'),
- join_paths(project_source_root, 'examples', 'book'),
+ meson.current_source_dir() / 'insert_example_code.pl',
+ project_source_root / 'examples' / 'book',
'@INPUT@',
'@OUTPUT@',
],
@@ -190,7 +190,7 @@ if can_build_pdf
tutorial_custom_cmd_sh,
dblatex.found() ? 'dblatex' : 'docbook2pdf',
'@INPUT@',
- join_paths(meson.current_source_dir(), 'C', 'figures'),
+ meson.current_source_dir() / 'C' / 'figures',
'@OUTPUT@'
],
build_by_default: build_pdf_by_default,
diff --git a/examples/book/buildapp/meson.build b/examples/book/buildapp/meson.build
index 8a31339..724cfb8 100644
--- a/examples/book/buildapp/meson.build
+++ b/examples/book/buildapp/meson.build
@@ -26,22 +26,22 @@ glib_compile_schemas = find_program('glib-compile-schemas', required: false)
foreach ex : examples_book_buildapp
dir = ''
foreach dir_part : ex[0]
- dir = join_paths(dir, dir_part)
+ dir = dir / dir_part
endforeach
- ex_name = join_paths(dir, ex[1]).underscorify()
+ ex_name = (dir / ex[1]).underscorify()
ex_sources = []
resources = []
schemas = []
foreach src : ex[2]
if src.endswith('.gresource.xml')
resources = gnome.compile_resources(dir.underscorify() + '_resources',
- join_paths(dir, src),
+ dir / src,
source_dir: dir
)
elif src.endswith('.gschema.xml')
if glib_compile_schemas.found()
schemas = custom_target(dir.underscorify() + '_schemas',
- input: join_paths(dir, src),
+ input: dir / src,
output: dir.underscorify() + '_gschemas.compiled',
command: [
compile_schemas_sh,
@@ -53,7 +53,7 @@ foreach ex : examples_book_buildapp
)
endif
else
- ex_sources += join_paths(dir, src)
+ ex_sources += dir / src
endif
endforeach
@@ -77,7 +77,7 @@ foreach ex : examples_book_buildapp
build_by_default: build_examples_by_default
)
- target_name = join_paths('examples', 'book', 'buildapp', stamp_file_name)
+ target_name = 'examples' / 'book' / 'buildapp' / stamp_file_name
examples_targets += target_name
test('book_buildapp_' + ex_name, meson_backend,
diff --git a/examples/book/giomm/meson.build b/examples/book/giomm/meson.build
index 85d9f75..62675f1 100644
--- a/examples/book/giomm/meson.build
+++ b/examples/book/giomm/meson.build
@@ -19,19 +19,19 @@ examples_book_giomm = [
foreach ex : examples_book_giomm
dir = ''
foreach dir_part : ex[0]
- dir = join_paths(dir, dir_part)
+ dir = dir / dir_part
endforeach
- ex_name = join_paths(dir, ex[1]).underscorify()
+ ex_name = (dir / ex[1]).underscorify()
ex_sources = []
resources = []
foreach src : ex[2]
if src.endswith('.gresource.xml')
resources = gnome.compile_resources(dir.underscorify() + '_resources',
- join_paths(dir, src),
+ dir / src,
source_dir: dir
)
else
- ex_sources += join_paths(dir, src)
+ ex_sources += dir / src
endif
endforeach
@@ -54,7 +54,7 @@ foreach ex : examples_book_giomm
build_by_default: build_examples_by_default
)
- target_name = join_paths('examples', 'book', 'giomm', stamp_file_name)
+ target_name = 'examples' / 'book' / 'giomm' / stamp_file_name
examples_targets += target_name
# These example programs build quite fast. No need for extra timeout time.
diff --git a/examples/book/meson.build b/examples/book/meson.build
index b6e015d..b1ce70e 100644
--- a/examples/book/meson.build
+++ b/examples/book/meson.build
@@ -103,19 +103,19 @@ thread_dep = dependency('threads')
foreach ex : examples_book
dir = ''
foreach dir_part : ex[0]
- dir = join_paths(dir, dir_part)
+ dir = dir / dir_part
endforeach
- ex_name = join_paths(dir, ex[1]).underscorify()
+ ex_name = (dir / ex[1]).underscorify()
ex_sources = []
resources = []
foreach src : ex[2]
if src.endswith('.gresource.xml')
resources = gnome.compile_resources(dir.underscorify() + '_resources',
- join_paths(dir, src),
+ dir / src,
source_dir: dir
)
else
- ex_sources += join_paths(dir, src)
+ ex_sources += dir / src
endif
endforeach
@@ -151,7 +151,7 @@ foreach ex : examples_book
build_by_default: build_examples_by_default
)
- target_name = join_paths('examples', 'book', stamp_file_name)
+ target_name = 'examples' / 'book' / stamp_file_name
examples_targets += target_name
test('book_' + ex_name, meson_backend,
diff --git a/examples/book/treeview/meson.build b/examples/book/treeview/meson.build
index 6eac69c..80eed31 100644
--- a/examples/book/treeview/meson.build
+++ b/examples/book/treeview/meson.build
@@ -23,19 +23,19 @@ examples_book_treeview = [
foreach ex : examples_book_treeview
dir = ''
foreach dir_part : ex[0]
- dir = join_paths(dir, dir_part)
+ dir = dir / dir_part
endforeach
- ex_name = join_paths(dir, ex[1]).underscorify()
+ ex_name = (dir / ex[1]).underscorify()
ex_sources = []
resources = []
foreach src : ex[2]
if src.endswith('.gresource.xml')
resources = gnome.compile_resources(dir.underscorify() + '_resources',
- join_paths(dir, src),
+ dir / src,
source_dir: dir
)
else
- ex_sources += join_paths(dir, src)
+ ex_sources += dir / src
endif
endforeach
@@ -59,7 +59,7 @@ foreach ex : examples_book_treeview
build_by_default: build_examples_by_default
)
- target_name = join_paths('examples', 'book', 'treeview', stamp_file_name)
+ target_name = 'examples' / 'book' / 'treeview' / stamp_file_name
examples_targets += target_name
test('book_treeview_' + ex_name, meson_backend,
diff --git a/examples/others/meson.build b/examples/others/meson.build
index 051bb3a..0599cf7 100644
--- a/examples/others/meson.build
+++ b/examples/others/meson.build
@@ -24,19 +24,19 @@ examples_others = [
foreach ex : examples_others
dir = ''
foreach dir_part : ex[0]
- dir = join_paths(dir, dir_part)
+ dir = dir / dir_part
endforeach
- ex_name = join_paths(dir, ex[1]).underscorify()
+ ex_name = (dir / ex[1]).underscorify()
ex_sources = []
resources = []
foreach src : ex[2]
if src.endswith('.gresource.xml')
resources = gnome.compile_resources(dir.underscorify() + '_resources',
- join_paths(dir, src),
+ dir / src,
source_dir: dir
)
else
- ex_sources += join_paths(dir, src)
+ ex_sources += dir / src
endif
endforeach
@@ -60,7 +60,7 @@ foreach ex : examples_others
build_by_default: build_examples_by_default
)
- target_name = join_paths('examples', 'others', stamp_file_name)
+ target_name = 'examples' / 'others' / stamp_file_name
examples_targets += target_name
test('others_' + ex_name, meson_backend,
diff --git a/meson.build b/meson.build
index 5255d07..c5c73fa 100644
--- a/meson.build
+++ b/meson.build
@@ -14,13 +14,16 @@ gtkmm_dep = dependency(gtkmm_pcname, version: '>=3.95.1')
giomm_dep = dependency('giomm-2.62', version: '>=2.61.1')
gnome = import('gnome')
-gtkmm_prefix = get_option('prefix')
-gtkmm_datadir = join_paths(gtkmm_prefix, get_option('datadir'))
+# Installation directories are relative to {prefix}.
+install_prefix = get_option('prefix')
+install_datadir = get_option('datadir')
-compile_schemas_sh = files(join_paths('tools', 'meson_aux', 'compile-schemas.sh'))
-copy_to_subdir_sh = files(join_paths('tools', 'meson_aux', 'copy-to-subdir.sh'))
-tutorial_custom_cmd_sh = files(join_paths('tools', 'meson_aux', 'tutorial-custom-cmd.sh'))
+compile_schemas_sh = files('tools' / 'meson_aux' / 'compile-schemas.sh')
+copy_to_subdir_sh = files('tools' / 'meson_aux' / 'copy-to-subdir.sh')
+tutorial_custom_cmd_sh = files('tools' / 'meson_aux' / 'tutorial-custom-cmd.sh')
+# Use these instead of meson.source_root() and meson.build_root() in subdirectories.
+# source_root() and build_root() are not useful, if this is a subproject.
project_source_root = meson.current_source_dir()
project_build_root = meson.current_build_dir()
@@ -47,13 +50,14 @@ add_project_arguments(warning_flags, language: 'cpp')
subdir('docs/tutorial')
subdir('examples')
-# Modify the contents of the distribution directory.
-meson.add_dist_script(
- join_paths('tools', 'meson_aux', 'extra-dist-cmd.sh'),
- meson.current_source_dir(),
- meson.current_build_dir(),
- join_paths('meson-dist', meson.project_name() + '-' + meson.project_version()),
-)
+if not meson.is_subproject()
+ # Modify the contents of the distribution directory. (not allowed in a subproject)
+ meson.add_dist_script(
+ 'tools' / 'meson_aux' / 'extra-dist-cmd.sh',
+ meson.current_source_dir(),
+ meson.current_build_dir(),
+ )
+endif
# Print a summary.
validate = get_option('validation') and can_parse_and_validate
@@ -85,8 +89,9 @@ summary = [
'Build translations: @0@@1@'.format(build_translations, explain_trans),
' Build PDF: @0@@1@'.format(build_pdf, explain_pdf),
'Directories:',
- ' prefix: @0@'.format(gtkmm_prefix),
- ' datadir: @0@'.format(gtkmm_datadir),
+ ' prefix: @0@'.format(install_prefix),
+ ' datadir: @0@'.format(install_prefix / install_datadir),
+ ' tutorialdir: @0@'.format(install_prefix / tutorialdir),
'------'
]
diff --git a/tools/meson_aux/extra-dist-cmd.sh b/tools/meson_aux/extra-dist-cmd.sh
index aa970c2..bd8c9da 100755
--- a/tools/meson_aux/extra-dist-cmd.sh
+++ b/tools/meson_aux/extra-dist-cmd.sh
@@ -2,18 +2,17 @@
# External command, intended to be called with add_dist_script() in meson.build
-# extra-dist-cmd.sh <root_source_dir> <root_build_dir> <relative_dist_dir>
+# extra-dist-cmd.sh <root_source_dir> <root_build_dir>
-# <relative_dist_dir> is the distribution directory path relative to root_build_dir.
# Meson does not preserve timestamps on distributed files. Neither does this script.
# Make a ChangeLog file for distribution.
git --git-dir="$1/.git" --work-tree="$1" log --no-merges --date=short --max-count=200 \
- --pretty='tformat:%cd %an <%ae>%n%n %s%n%w(0,0,2)%+b' > "$2/$3/ChangeLog"
+ --pretty='tformat:%cd %an <%ae>%n%n %s%n%w(0,0,2)%+b' > "$MESON_DIST_ROOT/ChangeLog"
# Distribute some built files in addition to the files in the local git clone.
cd "$2"
-dist_docs_tutorial="$3/docs/tutorial"
+dist_docs_tutorial="$MESON_DIST_ROOT/docs/tutorial"
# English index.docbook and html files.
cp "docs/tutorial/index.docbook" "$dist_docs_tutorial/C/"
@@ -44,9 +43,9 @@ else
echo "--- Info: No updated PDF file found."
fi
-# Remove all .gitignore files and an empty $3/build directory.
-find "$3" -name ".gitignore" -exec rm '{}' \;
-if [ -d "$3/build" ]; then
+# Remove all .gitignore files and an empty $MESON_DIST_ROOT/build directory.
+find "$MESON_DIST_ROOT" -name ".gitignore" -exec rm '{}' \;
+if [ -d "$MESON_DIST_ROOT/build" ]; then
# Ignore the error, if not empty.
- rmdir "$3/build" 2>/dev/null || true
+ rmdir "$MESON_DIST_ROOT/build" 2>/dev/null || true
fi
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]