[pangomm/pangomm-2-42] Meson build: Avoid some recompilations, and other changes
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pangomm/pangomm-2-42] Meson build: Avoid some recompilations, and other changes
- Date: Tue, 7 Apr 2020 14:20:12 +0000 (UTC)
commit 3076a8417dfcb8737f78df0961d030cf5ff8f298
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date: Tue Apr 7 15:41:39 2020 +0200
Meson build: Avoid some recompilations, and other changes
* MSVC_NMake/filelist.am: Remove pangomm/copy-pangommconfig-h.py.
* MSVC_NMake/pangomm/copy-pangommconfig-h.py: Removed file.
* MSVC_NMake/pangomm/meson.build: Copy pangommconfig.h with configure_file().
* Makefile.am: Distribute tools/dummy-header.py instead of tools/dist-cmd.py.
* docs/reference/meson.build: Rename a variable.
* meson.build: Rename some variables. Always set gmmproc_dir.
In maintainer-mode, show its value in the summary.
* pango/meson.build: Set pangommconfig_h.
* pango/pangomm/meson.build: Create dummy_header.h, depending on all
generated headers. It guarantees that all generated headers are built
before pangomm_library is built, at the same time avoiding unnecessary
recompilations.
* tools/dist-cmd.py: Removed file. It's not necessary in add_dist_script()
when the first parameter is python3.path().
* tools/dummy-header.py: New file.
* untracked/README: Mention check-dllexport-usage.py.
MSVC_NMake/filelist.am | 1 -
MSVC_NMake/pangomm/copy-pangommconfig-h.py | 13 ---------
MSVC_NMake/pangomm/meson.build | 10 +++----
Makefile.am | 4 +--
docs/reference/meson.build | 11 ++++---
meson.build | 42 ++++++++++++++++-----------
pango/meson.build | 4 +--
pango/pangomm/meson.build | 46 +++++++++++++++++++-----------
tools/dist-cmd.py | 12 --------
tools/dummy-header.py | 15 ++++++++++
untracked/README | 3 +-
11 files changed, 85 insertions(+), 76 deletions(-)
---
diff --git a/MSVC_NMake/filelist.am b/MSVC_NMake/filelist.am
index 647275a..058d07f 100644
--- a/MSVC_NMake/filelist.am
+++ b/MSVC_NMake/filelist.am
@@ -14,5 +14,4 @@ msvc_nmake_data = \
install.mak \
Makefile.vc \
pangomm/pangomm.rc \
- pangomm/copy-pangommconfig-h.py \
pangomm/pangommconfig.h
diff --git a/MSVC_NMake/pangomm/meson.build b/MSVC_NMake/pangomm/meson.build
index 34c5ce6..d7c88d2 100644
--- a/MSVC_NMake/pangomm/meson.build
+++ b/MSVC_NMake/pangomm/meson.build
@@ -1,6 +1,6 @@
# MSVC_NMake/pangomm
-# Input: pkg_conf_data, project_build_root
+# Input: pkg_conf_data, pangommconfig_h
# Output: pangomm_rc
pangomm_rc = configure_file(
@@ -10,8 +10,8 @@ pangomm_rc = configure_file(
)
# Copy the generated configuration header into the MSVC project directory.
-meson.add_postconf_script(
- 'copy-pangommconfig-h.py',
- project_build_root,
- meson.current_build_dir(),
+configure_file(
+ input: pangommconfig_h,
+ output: 'pangommconfig.h',
+ copy: true,
)
diff --git a/Makefile.am b/Makefile.am
index f5bb023..f6b6551 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -48,7 +48,7 @@ dist_noinst_SCRIPTS = autogen.sh
DISTCLEANFILES = MSVC_NMake/pangomm/pangommconfig.h
-# Distribute files needed when building mm-common with meson.
+# Distribute files needed when building pangomm with Meson.
EXTRA_DIST = \
meson.build \
meson_options.txt \
@@ -57,7 +57,7 @@ EXTRA_DIST = \
pango/meson.build \
pango/pangomm/meson.build \
pango/pangommconfig.h.meson \
- tools/dist-cmd.py \
+ tools/dummy-header.py \
tools/extra_defs_gen/meson.build \
untracked/README
diff --git a/docs/reference/meson.build b/docs/reference/meson.build
index 2ce55e0..de7476d 100644
--- a/docs/reference/meson.build
+++ b/docs/reference/meson.build
@@ -2,7 +2,7 @@
# Input: built_files_root, project_source_root, pangomm_pcname, perl,
# hg_ccg_basenames, extra_h_files, built_h_file_targets, install_datadir,
-# dist_cmd, python3
+# python3, doc_reference_py
# Output: install_docdir, install_devhelpdir
tag_file_modules = [
@@ -100,7 +100,7 @@ tag_file = custom_target('html_and_tag',
input: doc_h_files,
output: book_name + '.tag',
command: [
- python3, doc_reference, 'doxygen',
+ python3, doc_reference_py, 'doxygen',
doctool_dir,
'@OUTPUT@',
src_h_files,
@@ -115,7 +115,7 @@ devhelp_file = custom_target('devhelp',
input: tag_file,
output: book_name + '.devhelp2',
command: [
- python3, doc_reference, 'devhelp',
+ python3, doc_reference_py, 'devhelp',
doctool_dir,
'@INPUT@',
'@OUTPUT@',
@@ -127,7 +127,7 @@ devhelp_file = custom_target('devhelp',
# Install Devhelp file and html files.
meson.add_install_script(
- python3.path(), doc_reference, 'install_doc',
+ python3.path(), doc_reference_py, 'install_doc',
doctool_dir,
devhelp_file.full_path(),
install_devhelpdir,
@@ -151,8 +151,7 @@ if not meson.is_subproject()
# Distribute built files and files copied by mm-common-prepare.
# (add_dist_script() is not allowed in a subproject)
meson.add_dist_script(
- python3.path(), dist_cmd,
- python3.path(), doc_reference, 'dist_doc',
+ python3.path(), doc_reference_py, 'dist_doc',
doctool_dir,
doctool_dist_dir,
meson.current_build_dir(),
diff --git a/meson.build b/meson.build
index 86e39ab..efeef25 100644
--- a/meson.build
+++ b/meson.build
@@ -96,6 +96,9 @@ glibmm_dep = dependency('glibmm-2.@0@'.format(glibmm_req_minor_ver), version: gl
# Where to find gmmproc and generate_wrap_init.pl.
if glibmm_dep.found() and glibmm_dep.type_name() == 'pkgconfig'
gmmproc_dir = glibmm_dep.get_pkgconfig_variable('gmmprocdir')
+else
+ # We don't have a pkg-config file for glibmm, so use build option.
+ gmmproc_dir = get_option('gmmproc-dir')
endif
if is_msvc
@@ -110,8 +113,6 @@ if is_msvc
assert(cpp_compiler.has_header('glibmm-2.@0@/glibmm.h'.format(glibmm_req_minor_ver)) and
cpp_compiler.has_header('glibmm-2.@0@/include/glibmmconfig.h'.format(glibmm_req_minor_ver)),
'glibmm-2.@0@ headers are required'.format(glibmm_req_minor_ver))
- # We don't have a pkg-config file for glibmm, so use build options
- gmmproc_dir = get_option('gmmproc-dir')
else
sigc_dep = dependency('', required: false) # glibmm covers for libsigc++ in its pkg-config file
endif
@@ -177,6 +178,7 @@ if is_msvc
pangomm_build_dep = [glibmm_dep, cairomm_dep, sigc_dep, pangocairo_dep]
else
+ # not MSVC
cairomm_req = '>= 1.2.2'
cairomm_dep = dependency('cairomm-1.@0@'.format(cairomm_req_minor_ver), version: cairomm_req)
pangomm_build_dep = [glibmm_dep, cairomm_dep, pangocairo_dep]
@@ -198,13 +200,13 @@ doxygen = find_program('doxygen', required: build_documentation)
dot = find_program('dot', required: build_documentation) # Used by Doxygen
xsltproc = find_program('xsltproc', required: build_documentation)
+# Script files copied to 'untracked' by mm-common-get.
script_dir = project_source_root / 'untracked' / 'build_scripts'
-generate_binding = script_dir / 'generate-binding.py'
-doc_reference = script_dir / 'doc-reference.py'
-dist_changelog = script_dir / 'dist-changelog.py'
-dist_build_scripts = script_dir / 'dist-build-scripts.py'
-check_dllexport_usage = script_dir / 'check-dllexport-usage.py'
-dist_cmd = project_source_root / 'tools' / 'dist-cmd.py' # Must be committed to git.
+generate_binding_py = script_dir / 'generate-binding.py'
+doc_reference_py = script_dir / 'doc-reference.py'
+dist_changelog_py = script_dir / 'dist-changelog.py'
+dist_build_scripts_py = script_dir / 'dist-build-scripts.py'
+check_dllexport_usage_py = script_dir / 'check-dllexport-usage.py'
if maintainer_mode and mm_common_get.found()
# Copy files to untracked/build_scripts and untracked/docs.
@@ -212,8 +214,9 @@ if maintainer_mode and mm_common_get.found()
project_source_root / 'untracked' / 'docs')
endif
-# Set compiler warnings.
-warning_flags = []
+# pangomm's own script files.
+pangomm_script_dir = project_source_root / 'tools'
+dummy_header_py = pangomm_script_dir / 'dummy-header.py'
if is_msvc
add_project_arguments(cpp_compiler.get_supported_arguments([ '/utf-8', '/wd4828']), language: 'cpp')
@@ -222,12 +225,12 @@ if is_msvc
# to see which gmmproc version was used
if maintainer_mode
check_gmmproc_ver_cmd = [
- python3, check_dllexport_usage,
+ python3, check_dllexport_usage_py,
'--gmmprocdir=@0@'.format(gmmproc_dir),
]
else
check_gmmproc_ver_cmd = [
- python3, check_dllexport_usage,
+ python3, check_dllexport_usage_py,
'--file=@0@/untracked/pango/pangomm/attributes.h'.format('/'.join(project_source_root.split('\\')))
]
endif
@@ -238,6 +241,8 @@ if is_msvc
message('Using __declspec(dllexport) to build pangomm: @0@'.format(build_shared_libs_directly ? 'YES' :
'NO'))
endif
+# Set compiler warnings.
+warning_flags = []
if warning_level == 'min'
if is_msvc
warning_flags = ['/W3']
@@ -286,15 +291,13 @@ if not meson.is_subproject()
# Add a ChangeLog file to the distribution directory.
# (add_dist_script() is not allowed in a subproject)
meson.add_dist_script(
- python3.path(), dist_cmd,
- python3.path(), dist_changelog,
+ python3.path(), dist_changelog_py,
project_source_root,
)
# Add build scripts to the distribution directory, and delete .gitignore
# files and an empty $MESON_DIST_ROOT/build/ directory.
meson.add_dist_script(
- python3.path(), dist_cmd,
- python3.path(), dist_build_scripts,
+ python3.path(), dist_build_scripts_py,
project_source_root,
'untracked' / 'build_scripts',
)
@@ -331,7 +334,12 @@ summary = [
' datadir: @0@'.format(install_prefix / install_datadir),
' docdir: @0@'.format(install_prefix / install_docdir),
' devhelpdir: @0@'.format(install_prefix / install_devhelpdir),
- '------'
]
+if maintainer_mode
+ summary += [
+ ' gmmprocdir: @0@'.format(gmmproc_dir),
+ ]
+endif
+summary += ['------']
message('\n'.join(summary))
diff --git a/pango/meson.build b/pango/meson.build
index 368bd35..4cb992b 100644
--- a/pango/meson.build
+++ b/pango/meson.build
@@ -4,7 +4,7 @@
# pangomm_pcname, pangomm_api_version, pangomm_requires,
# install_pkgconfigdir, install_libdir, build_deprecated_api,
# pangomm_major_version, pangomm_minor_version, pangomm_micro_version
-# Output: pkg_conf_data, install_includeconfigdir
+# Output: pkg_conf_data, install_includeconfigdir, pangommconfig_h
pkg_conf_data = configuration_data()
pkg_conf_data.set('prefix', install_prefix)
@@ -41,7 +41,7 @@ configure_file(
)
install_includeconfigdir = install_libdir / pangomm_pcname / 'include'
-configure_file(
+pangommconfig_h = configure_file(
input: 'pangommconfig.h.meson',
output: 'pangommconfig.h',
configuration: pkg_conf_data,
diff --git a/pango/pangomm/meson.build b/pango/pangomm/meson.build
index c375b00..e3361cb 100644
--- a/pango/pangomm/meson.build
+++ b/pango/pangomm/meson.build
@@ -1,8 +1,8 @@
# pango/pangomm
# Input: pangomm_build_dep, pangomm_pcname, maintainer_mode, project_source_root,
-# generate_binding, m4_files, pangomm_libversion, install_includedir,
-# dist_cmd, python3, pangomm_rc
+# generate_binding_py, m4_files, pangomm_libversion, install_includedir,
+# python3, pangomm_rc, dummy_header_py, gmmproc_dir
# Output: hg_ccg_basenames, extra_h_files, built_h_file_targets, built_files_root,
# pangomm_dep
@@ -75,7 +75,7 @@ if maintainer_mode
# Maintainer mode. Generate .h and .cc files from .hg and .ccg files in ../src.
- # docs/reference/meson.build needs this.
+ # docs/reference/meson.build needs these.
built_files_root = project_build_root
built_h_file_targets = []
@@ -93,7 +93,7 @@ if maintainer_mode
input: hg_files,
output: 'wrap_init.cc',
command: [
- python3, generate_binding, 'generate_wrap_init',
+ python3, generate_binding_py, 'generate_wrap_init',
gmmproc_dir,
'@OUTPUT@',
'Pango', # namespace
@@ -111,7 +111,7 @@ if maintainer_mode
input: [hg_file, ccg_file],
output: [file + '.stamp', file + '.cc', file + '.h'],
command: [
- python3, generate_binding, 'gmmproc',
+ python3, generate_binding_py, 'gmmproc',
gmmproc_dir,
'@OUTPUT0@',
file,
@@ -126,10 +126,27 @@ if maintainer_mode
built_h_file_targets += built_file_target[2]
endforeach
+ # Create dummy_header.h, depending on all generated headers.
+ # It's created if it does not exist, but it's never updated.
+ # It guarantees that all generated headers are built before pangomm_library
+ # is built, at the same time avoiding unnecessary recompilations.
+ # If built_h_file_targets would be listed as sources to pangomm_library,
+ # all generated .cc files could be recompiled if one generated .h file has
+ # been changed.
+ built_dummy_h_file_target = custom_target('dummy_header.h',
+ input: built_h_file_targets,
+ output: 'dummy_header.h',
+ command: [
+ python3, dummy_header_py,
+ '@OUTPUT@',
+ ],
+ build_by_default: maintainer_mode,
+ install: false,
+ )
+
extra_include_dirs = ['..']
pango_gen_sources = built_cc_file_targets
- pango_built_headers = built_h_file_targets
built_h_cc_dir = meson.current_build_dir()
@@ -152,7 +169,7 @@ else # not maintainer_mode
# Try to copy built source code files to the source tree.
run_command(
- python3, generate_binding, 'copy_built_files',
+ python3, generate_binding_py, 'copy_built_files',
meson.current_build_dir(),
src_untracked_pangomm,
hg_ccg_basenames,
@@ -164,11 +181,10 @@ else # not maintainer_mode
endforeach
pango_gen_sources = built_cc_files
- pango_built_headers = []
+ built_dummy_h_file_target = []
extra_include_dirs = [ '..', '..' / '..' / 'untracked' / 'pango' ]
-
built_h_cc_dir = src_untracked_pangomm
endif
@@ -184,7 +200,7 @@ endif
if build_shared_libs_directly
pangomm_library = library(pangomm_pcname, extra_pangomm_objects,
- pango_gen_sources, pango_built_headers, extra_cc_files,
+ pango_gen_sources, built_dummy_h_file_target, extra_cc_files,
include_directories: extra_include_dirs,
cpp_args: pangomm_cpp_args,
version: pangomm_libversion,
@@ -197,16 +213,13 @@ else
# that we can run gendef.exe to get the .def file
# needed for obtaining the .lib file for the pangomm DLL
pango_int_lib = static_library('pangomm-int',
- pango_gen_sources, pango_built_headers, extra_cc_files,
+ pango_gen_sources, built_dummy_h_file_target, extra_cc_files,
include_directories: extra_include_dirs,
cpp_args: pangomm_cpp_args,
dependencies: pangomm_build_dep,
install: false,
)
- pangomm_def = []
- pangomm_extra_link_args = []
-
pangomm_def = custom_target('pangomm.def',
output: 'pangomm.def',
depends: pango_int_lib,
@@ -232,7 +245,7 @@ endif
# Install built .h and _p.h files.
meson.add_install_script(
- python3.path(), generate_binding, 'install_built_h_files',
+ python3.path(), generate_binding_py, 'install_built_h_files',
built_h_cc_dir,
install_includedir / pangomm_pcname / 'pangomm', # subdir below {prefix}
hg_ccg_basenames
@@ -242,8 +255,7 @@ if not meson.is_subproject()
# Distribute built files.
# (add_dist_script() is not allowed in a subproject)
meson.add_dist_script(
- python3.path(), dist_cmd,
- python3.path(), generate_binding, 'dist_built_files',
+ python3.path(), generate_binding_py, 'dist_built_files',
built_h_cc_dir,
untracked_pangomm,
hg_ccg_basenames,
diff --git a/tools/dummy-header.py b/tools/dummy-header.py
new file mode 100755
index 0000000..8c61464
--- /dev/null
+++ b/tools/dummy-header.py
@@ -0,0 +1,15 @@
+#!/usr/bin/env python3
+
+# External command, intended to be called with custom_target() in meson.build.
+
+# dummy-header.py <output_file>
+
+import os
+import sys
+
+output_file = sys.argv[1]
+
+# A dummy header file is created if it does not exist, but it's never updated.
+if not os.path.isfile(output_file):
+ with open(output_file, 'w') as f:
+ f.write('// Dummy header file. Created and used by meson.build\n')
diff --git a/untracked/README b/untracked/README
index 4b91cc4..b1e65b9 100644
--- a/untracked/README
+++ b/untracked/README
@@ -19,7 +19,8 @@ untracked/docs/doc-install.pl
doc-postprocess.pl
doxygen-extra.css
tagfile-to-devhelp2.xsl
-untracked/build_scripts/dist-build-scripts.py
+untracked/build_scripts/check-dllexport-usage.py
+ dist-build-scripts.py
dist-changelog.py
doc-reference.py
generate-binding.py
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]