Skip to content

Commit 85a863c

Browse files
committed
Meson build: Set default value of the 'warnings' option to 'min'
* MSVC_NMake/meson.build: Copy sigc++config.h with configure_file(). * Makefile.am: Remove tools/dist-cmd.py. * docs/manual/meson.build: * docs/reference/meson.build: Don't use tools/dist-cmd.py. * sigc++/meson.build: Don't use tools/dist-cmd.py. * meson.build: Use dist-warnings when a tarball is tested by 'ninja dist' or 'meson dist'. Check if doc-reference.py exists, if not maintainer-mode. Add a better error message if mm-common-get is required but not found. * meson_options.txt: Set default value of the 'warnings' to 'min'. Add 'dist-warnings' with default value 'fatal'. * tools/dist-cmd.py: Removed file. It's not necessary in add_dist_script() when the first parameter is python3.path().
1 parent 88fdb3a commit 85a863c

File tree

8 files changed

+43
-38
lines changed

8 files changed

+43
-38
lines changed

MSVC_NMake/meson.build

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
11
# MSVC_NMake
22

3-
# Input: pkg_conf_data, project_build_root, python3
4-
# Output: -
3+
# Input: pkg_conf_data, sigcxxconfig_h, project_build_root, python3
4+
# Output: sigc_rc
55

66
sigc_rc = configure_file(
77
input: 'sigc.rc.in',
88
output: '@BASENAME@',
99
configuration: pkg_conf_data,
1010
)
1111

12-
generated_sigc_config_h_orig = project_build_root / 'sigc++config.h'
13-
1412
# Copy the generated configuration header into the MSVC project directory.
15-
cmd_py = '''
16-
import shutil
17-
shutil.copy2("@0@", "@1@")
18-
'''.format(generated_sigc_config_h_orig, project_build_root / 'MSVC_NMake')
19-
meson.add_postconf_script(python3.path(), '-c', cmd_py)
13+
configure_file(
14+
input: sigcxxconfig_h,
15+
output: 'sigc++config.h',
16+
copy: true,
17+
)
2018

2119
untracked_msvc_nmake = 'untracked' / 'MSVC_NMake'
2220
handle_built_files = project_source_root / 'tools' / 'handle-built-files.py'
@@ -26,10 +24,10 @@ if not meson.is_subproject()
2624
# (add_dist_script() is not allowed in a subproject)
2725

2826
meson.add_dist_script(
29-
python3.path(), dist_cmd,
3027
python3.path(), handle_built_files, 'dist_gen_msvc_files',
3128
meson.current_build_dir(),
3229
untracked_msvc_nmake,
33-
generated_sigc_config_h_orig, meson.current_build_dir() / 'sigc.rc',
30+
project_build_root / 'sigc++config.h',
31+
meson.current_build_dir() / 'sigc.rc',
3432
)
3533
endif

Makefile.am

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ EXTRA_DIST = \
5050
examples/meson.build \
5151
sigc++/meson.build \
5252
tests/meson.build \
53-
tools/dist-cmd.py \
5453
tools/handle-built-files.py \
5554
tools/tutorial-custom-cmd.py \
5655
tools/gcc_template_specialization_operator_overload.cc \

docs/manual/meson.build

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# docs/manual
22

33
# input: install_datadir, sigcxx_pcname, tutorial_custom_cmd, python3,
4-
# build_documentation, dist_cmd, install_docdir
4+
# build_documentation, install_docdir
55
# output: can_parse_and_validate, build_pdf_by_default, can_build_pdf,
66
# install_tutorialdir
77

@@ -86,7 +86,6 @@ if not meson.is_subproject()
8686
# Distribute built files.
8787
# (add_dist_script() is not allowed in a subproject)
8888
meson.add_dist_script(
89-
python3.path(), dist_cmd,
9089
python3.path(), tutorial_custom_cmd, 'dist_doc',
9190
doc_dist_dir,
9291
meson.current_build_dir(),

docs/reference/meson.build

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Input: built_files_root, project_source_root, sigcxx_pcname,
44
# sigcxx_api_version, perl, build_documentation, source_h_files,
5-
# built_h_files, install_datadir, dist_cmd, python3,
5+
# built_h_files, install_datadir, python3, doc_reference,
66
# built_h_file_targets
77
# Output: install_docdir, install_devhelpdir
88

@@ -141,7 +141,6 @@ if not meson.is_subproject()
141141
# Distribute built files and files copied by mm-common-get.
142142
# (add_dist_script() is not allowed in a subproject)
143143
meson.add_dist_script(
144-
python3.path(), dist_cmd,
145144
python3.path(), doc_reference, 'dist_doc',
146145
doctool_dir,
147146
doctool_dist_dir,

meson.build

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,22 @@ sys.exit(os.path.isdir("@0@") or os.path.isfile("@0@"))
5656
'''.format(project_source_root / '.git')
5757
is_git_build = run_command(python3, '-c', cmd_py).returncode() != 0
5858

59+
# Are we testing a dist tarball while it's being built?
60+
# There ought to be a better way. https://github.com/mesonbuild/meson/issues/6866
61+
is_dist_check = project_source_root.contains('dist-unpack') and \
62+
project_build_root.contains('dist-build')
63+
5964
# Options.
6065
maintainer_mode_opt = get_option('maintainer-mode')
6166
maintainer_mode = maintainer_mode_opt == 'true' or \
6267
(maintainer_mode_opt == 'if-git-build' and is_git_build)
63-
warning_level = get_option('warnings')
68+
if is_dist_check
69+
message('Looks like a tarball is being tested. ' + \
70+
'Option "dist-warnings" is used instead of "warnings".')
71+
warning_level = get_option('dist-warnings')
72+
else
73+
warning_level = get_option('warnings')
74+
endif
6475
build_deprecated_api = get_option('build-deprecated-api')
6576
build_documentation_opt = get_option('build-documentation')
6677
build_documentation = build_documentation_opt == 'true' or \
@@ -92,7 +103,10 @@ endif
92103

93104
# Some dependencies are required only in maintainer mode and/or
94105
# if documentation shall be built.
95-
mm_common_get = find_program('mm-common-get', required: maintainer_mode)
106+
mm_common_get = find_program('mm-common-get', required: false)
107+
if maintainer_mode and not mm_common_get.found()
108+
error('mm-common-get not found. mm-common >= 1.0.0 is required.')
109+
endif
96110
m4 = find_program('m4', required: maintainer_mode) # For building C++ code
97111
perl = find_program('perl', required: build_documentation)
98112
doxygen = find_program('doxygen', required: build_documentation)
@@ -103,13 +117,22 @@ script_dir = project_source_root / 'untracked' / 'build_scripts'
103117
doc_reference = script_dir / 'doc-reference.py'
104118
dist_changelog = script_dir / 'dist-changelog.py'
105119
dist_build_scripts = script_dir / 'dist-build-scripts.py'
106-
dist_cmd = project_source_root / 'tools' / 'dist-cmd.py' # Must be committed to git.
107120
tutorial_custom_cmd = project_source_root / 'tools' / 'tutorial-custom-cmd.py'
108121

109-
if maintainer_mode and mm_common_get.found()
122+
if maintainer_mode
110123
# Copy files to untracked/build_scripts and untracked/docs.
111124
run_command(mm_common_get, '--force', script_dir,
112125
project_source_root / 'untracked' / 'docs')
126+
else
127+
cmd_py = '''
128+
import os
129+
import sys
130+
sys.exit(os.path.isfile("@0@"))
131+
'''.format(doc_reference)
132+
file_exists = run_command(python3, '-c', cmd_py).returncode() != 0
133+
if not file_exists
134+
warning('Missing files in untracked/. You may have to enable maintainer-mode.')
135+
endif
113136
endif
114137

115138
# Set compiler warnings.
@@ -188,7 +211,7 @@ configure_file(
188211
)
189212

190213
install_includeconfigdir = install_libdir / sigcxx_pcname / 'include'
191-
configure_file(
214+
sigcxxconfig_h = configure_file(
192215
input: 'sigc++config.h.meson',
193216
output: 'sigc++config.h',
194217
configuration: pkg_conf_data,
@@ -206,14 +229,12 @@ if not meson.is_subproject()
206229
# Add a ChangeLog file to the distribution directory.
207230
# (add_dist_script() is not allowed in a subproject)
208231
meson.add_dist_script(
209-
python3.path(), dist_cmd,
210232
python3.path(), dist_changelog,
211233
project_source_root,
212234
)
213235
# Add build scripts to the distribution directory, and delete .gitignore
214236
# files and an empty $MESON_DIST_ROOT/build/ directory.
215237
meson.add_dist_script(
216-
python3.path(), dist_cmd,
217238
python3.path(), dist_build_scripts,
218239
project_source_root,
219240
'untracked' / 'build_scripts',

meson_options.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
option('maintainer-mode', type: 'combo', choices: ['false', 'if-git-build', 'true'],
2-
value: 'if-git-build', description: 'Generate source code from .hg and .ccg files')
2+
value: 'if-git-build', description: 'Generate source code from .m4 files')
33
option('warnings', type: 'combo', choices: ['no', 'min', 'max', 'fatal'],
4-
value: 'fatal', description: 'Compiler warning level')
4+
value: 'min', description: 'Compiler warning level')
5+
option('dist-warnings', type: 'combo', choices: ['no', 'min', 'max', 'fatal'],
6+
value: 'fatal', description: 'Compiler warning level when a tarball is created')
57
option('build-deprecated-api', type: 'boolean', value: true,
68
description: 'Build deprecated API and include it in the library')
79
option('build-documentation', type: 'combo', choices: ['false', 'if-maintainer-mode', 'true'],

sigc++/meson.build

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,6 @@ if not meson.is_subproject()
231231
# Distribute built files.
232232
# (add_dist_script() is not allowed in a subproject)
233233
meson.add_dist_script(
234-
python3.path(), dist_cmd,
235234
python3.path(), handle_built_files, 'dist_built_files',
236235
built_h_cc_dir,
237236
untracked_sigcxx,

tools/dist-cmd.py

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)