Skip to content

Commit

Permalink
Subprojects can use meson.add_dist_script() if meson.version() >= 0.58.0
Browse files Browse the repository at this point in the history
* meson.build:
* MSVC_NMake/meson.build:
* docs/docs/manual/meson.build:
* docs/docs/reference/meson.build:
Call add_dist_script() in a subproject, if meson.version() >= 0.58.0.
* tools/handle-built-files.py:
* tools/tutorial-custom-cmd.py:
Use MESON_PROJECT_DIST_ROOT if it exists, else MESON_DIST_ROOT.
It exists if meson.version() >= 0.58.0.
  • Loading branch information
kjellahl committed May 5, 2021
1 parent de48a71 commit 8960f32
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 19 deletions.
7 changes: 3 additions & 4 deletions MSVC_NMake/meson.build
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# MSVC_NMake

# Input: pkg_conf_data, sigcxxconfig_h, project_build_root, python3
# Input: pkg_conf_data, sigcxxconfig_h, project_build_root, python3,
# can_add_dist_script
# Output: sigc_rc

sigc_rc = configure_file(
Expand All @@ -19,10 +20,8 @@ configure_file(
untracked_msvc_nmake = 'untracked' / 'MSVC_NMake'
handle_built_files = project_source_root / 'tools' / 'handle-built-files.py'

if not meson.is_subproject()
if can_add_dist_script
# Distribute built files.
# (add_dist_script() is not allowed in a subproject)

meson.add_dist_script(
python3.path(), handle_built_files, 'dist_gen_msvc_files',
meson.current_build_dir(),
Expand Down
5 changes: 2 additions & 3 deletions docs/docs/manual/meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# docs/docs/manual

# input: install_datadir, sigcxx_pcname, tutorial_custom_cmd, python3,
# build_documentation, book_name
# build_documentation, book_name, can_add_dist_script
# output: can_parse_and_validate, build_pdf_by_default, can_build_pdf,
# install_tutorialdir

Expand Down Expand Up @@ -77,9 +77,8 @@ if can_build_pdf
)
endif

if not meson.is_subproject()
if can_add_dist_script
# Distribute built files.
# (add_dist_script() is not allowed in a subproject)
meson.add_dist_script(
python3.path(), tutorial_custom_cmd, 'dist_doc',
doc_dist_dir,
Expand Down
6 changes: 3 additions & 3 deletions docs/docs/reference/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

# Input: project_build_root, project_source_root, sigcxx_pcname,
# sigcxx_api_version, build_documentation, source_h_files,
# hg_ccg_basenames, install_datadir, python3, doc_reference
# hg_ccg_basenames, install_datadir, python3, doc_reference,
# can_add_dist_script
# Output: install_docdir, install_devhelpdir, book_name, tag_file

# There are no built source files in libsigc++-3.0.
Expand Down Expand Up @@ -121,9 +122,8 @@ meson.add_install_script(
docinstall_flags
)

if not meson.is_subproject()
if can_add_dist_script
# Distribute built files and files copied by mm-common-get.
# (add_dist_script() is not allowed in a subproject)
meson.add_dist_script(
python3.path(), doc_reference, 'dist_doc',
doctool_dir,
Expand Down
13 changes: 8 additions & 5 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,9 @@ sigcxxconfig_h = configure_file(
install_dir: install_includeconfigdir,
)

# add_dist_script() is not allowed in a subproject if meson.version() < 0.58.0.
can_add_dist_script = not meson.is_subproject() or meson.version().version_compare('>= 0.58.0')

#subdir('cmake')
subdir('MSVC_NMake')
subdir('sigc++')
Expand All @@ -228,22 +231,22 @@ subdir('tests')
subdir('docs/docs/reference')
subdir('docs/docs/manual')

if not meson.is_subproject()
if can_add_dist_script
# Add a ChangeLog file to the distribution directory.
# (add_dist_script() is not allowed in a subproject)
meson.add_dist_script(
python3.path(), dist_changelog,
project_source_root,
)
# Add build scripts to the distribution directory, and delete .gitignore
# files and an empty $MESON_DIST_ROOT/build/ directory.
# files and an empty $MESON_PROJECT_DIST_ROOT/build/ directory.
meson.add_dist_script(
python3.path(), dist_build_scripts,
project_source_root,
'untracked' / 'build_scripts',
)
else
# This is a subproject.
endif

if meson.is_subproject()
sigcxx_dep = declare_dependency(
dependencies: sigcxx_own_dep,
variables: {
Expand Down
7 changes: 5 additions & 2 deletions tools/handle-built-files.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@ def dist_built_files(is_msvc_files=False):
# <built_h_cc_dir> <dist_dir> <built_files>...

# <built_h_cc_dir> is an absolute path in the build directory or source directory.
# <dist_dir> is a distribution directory, relative to MESON_DIST_ROOT.
# <dist_dir> is a distribution directory, relative to MESON_PROJECT_DIST_ROOT.

# MESON_PROJECT_DIST_ROOT is set only if meson.version() >= 0.58.0.
project_dist_root = os.getenv('MESON_PROJECT_DIST_ROOT', os.getenv('MESON_DIST_ROOT'))
built_h_cc_dir = sys.argv[2]
dist_dir_root = os.path.join(os.getenv('MESON_DIST_ROOT'), sys.argv[3])
dist_dir_root = os.path.join(project_dist_root, sys.argv[3])
dist_dir = dist_dir_root

# Distribute .h and .cc files built from .m4 files, or generated MSVC files.
Expand Down
7 changes: 5 additions & 2 deletions tools/tutorial-custom-cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,14 @@ def dist_doc():
# argv[2] argv[3] argv[4] argv[5]
# <doc_dist_dir> <doc_build_dir> <xml_file> <pdf_file>

# <doc_dist_dir> is a distribution directory, relative to MESON_DIST_ROOT.
# <doc_dist_dir> is a distribution directory, relative to MESON_PROJECT_DIST_ROOT.
# <doc_build_dir> is a relative or absolute path in the build directory.
# <xml_file> is a relative or absolute path in the source directory.
# <pdf_file> is a relative or absolute path in the build directory.
doc_dist_dir = os.path.join(os.getenv('MESON_DIST_ROOT'), sys.argv[2])

# MESON_PROJECT_DIST_ROOT is set only if meson.version() >= 0.58.0.
project_dist_root = os.getenv('MESON_PROJECT_DIST_ROOT', os.getenv('MESON_DIST_ROOT'))
doc_dist_dir = os.path.join(project_dist_root, sys.argv[2])
doc_build_dir = sys.argv[3]
xml_file = sys.argv[4]
pdf_file = sys.argv[5]
Expand Down

0 comments on commit 8960f32

Please sign in to comment.