Skip to content

Add support for building libsigc++-3.0 with Meson #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ Makefile.in
/sigc++config.h
/sigc++-*.pc
/stamp-h?
untracked/build_scripts/
untracked/docs/
17 changes: 17 additions & 0 deletions MSVC_NMake/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# MSVC_NMake

# Input: pkg_conf_data, project_build_root, python3
# Output: -

configure_file(
input: 'sigc.rc.in',
output: '@BASENAME@',
configuration: pkg_conf_data,
)

# Copy the generated configuration header into the MSVC project directory.
cmd_py = '''
import shutil
shutil.copy2("@0@", "@1@")
'''.format(project_build_root / 'sigc++config.h', meson.current_build_dir())
meson.add_postconf_script(python3.path(), '-c', cmd_py)
15 changes: 15 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,21 @@ dist_noinst_DATA = \

DISTCLEANFILES = MSVC_NMake/sigc++config.h

# Distribute files needed when building libsigc++ with meson.
EXTRA_DIST = \
meson.build \
meson_options.txt \
sigc++config.h.meson \
MSVC_NMake/meson.build \
docs/docs/manual/meson.build \
docs/docs/reference/meson.build \
examples/meson.build \
sigc++/meson.build \
tests/meson.build \
tools/dist-cmd.py \
tools/tutorial-custom-cmd.py \
untracked/README

# Optional: auto-generate the ChangeLog file from the git log on make dist
include $(top_srcdir)/build/dist-changelog.am

Expand Down
91 changes: 91 additions & 0 deletions docs/docs/manual/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# docs/docs/manual

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

# xsltproc is required by tutorial_custom_cmd html.
xsltproc = find_program('xsltproc', required: build_documentation)
xmllint = find_program('xmllint', required: false)

can_parse_and_validate = xmllint.found()

validate = get_option('validation') ? 'true' : 'false'

dblatex = find_program('dblatex', required: false)
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 are relative to {prefix}.
install_tutorialdir = install_datadir / 'doc' / book_name / 'tutorial'

if not build_documentation
# Documentation shall not be built or installed.
# Return to the calling meson.build file.
subdir_done()
endif

doc_dist_dir = 'untracked' / 'docs' / 'docs' / 'manual' # Relative to MESON_DIST_ROOT

sigc_manual_xml = 'libsigc_manual.xml'
sigc_manual_pdf = 'libsigc_manual.pdf'

# Create an html version of the DocBook.
custom_target('manual_html',
input: sigc_manual_xml,
output: 'html',
command: [
python3, tutorial_custom_cmd, 'html',
'@INPUT@',
'@OUTPUT@',
],
build_by_default: true,
install: true,
install_dir: install_tutorialdir
)

if can_parse_and_validate
# Parse and possibly validate the DocBook.
custom_target('manual_xmllint',
input: sigc_manual_xml,
output: 'manual_xmllint.stamp',
command: [
python3, tutorial_custom_cmd, 'xmllint',
validate,
'@INPUT@',
'@OUTPUT@'
],
build_by_default: true,
)
endif

if can_build_pdf
# Create a PDF file of the DocBook.
# Prefer dblatex, if both dblatex and docbook2pdf are available.
custom_target('manual_pdf',
input: sigc_manual_xml,
output: sigc_manual_pdf,
command: [
python3, tutorial_custom_cmd,
dblatex.found() ? 'dblatex' : 'docbook2pdf',
'@INPUT@',
'@OUTPUT@'
],
build_by_default: build_pdf_by_default,
)
endif

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(), tutorial_custom_cmd, 'dist_doc',
doc_dist_dir,
meson.current_build_dir(),
meson.current_source_dir() / sigc_manual_xml,
meson.current_build_dir() / sigc_manual_pdf,
)
endif
126 changes: 126 additions & 0 deletions docs/docs/reference/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# docs/docs/reference

# Input: project_build_root, project_source_root, sigcxx_pcname,
# sigcxx_api_version, perl, build_documentation, source_h_files,
# hg_ccg_basenames, install_datadir, dist_cmd, python3
# Output: install_docdir, install_devhelpdir, book_name

# There are no built source files in libsigc++-3.0.

tag_file_modules = [
'mm-common-libstdc++',
]
doxygen_tagfiles = ''
docinstall_flags = []
foreach module : tag_file_modules
depmod = dependency(module, required: false)
if depmod.found()
doxytagfile = depmod.get_pkgconfig_variable('doxytagfile')
htmlrefpub = depmod.get_pkgconfig_variable('htmlrefpub', default: '')
htmlrefdir = depmod.get_pkgconfig_variable('htmlrefdir', default: '')
if htmlrefpub == ''
htmlrefpub = htmlrefdir
elif htmlrefdir == ''
htmlrefdir = htmlrefpub
endif
doxygen_tagfiles += ' "' + doxytagfile + '=' + htmlrefpub + '"'
if not htmlrefdir.endswith('/')
htmlrefdir += '/'
endif
docinstall_flags += ['-l', doxytagfile.split('/')[-1] + '@' + htmlrefdir]
endif
endforeach

book_name = 'lib' + sigcxx_pcname
book_title = meson.project_name() + ' Reference Manual'

# Configuration data for Doxyfile.
doc_conf_data = configuration_data()
doc_conf_data.set('configure_input',
'docs/docs/reference/Doxyfile. Generated from Doxyfile.in by meson.configure_file().')
doc_conf_data.set('PACKAGE_NAME', meson.project_name())
doc_conf_data.set('PACKAGE_VERSION', meson.project_version())
doc_conf_data.set('abs_top_builddir', project_build_root)
doc_conf_data.set('abs_top_srcdir', project_source_root)
doc_conf_data.set('SIGCXX_API_VERSION', sigcxx_api_version)
doc_conf_data.set('DOXYGEN_TAGFILES', doxygen_tagfiles)
doc_conf_data.set('PERL', perl.path())

configure_file(
input: 'Doxyfile.in',
output: '@BASENAME@',
configuration: doc_conf_data,
)

# Installation directories relative to {prefix}.
install_docdir = install_datadir / 'doc' / book_name
install_reference_docdir = install_docdir / 'reference'
install_devhelpdir = install_datadir / 'devhelp' / 'books' / book_name

if not build_documentation
# Documentation shall not be built or installed.
# Return to the calling meson.build file.
subdir_done()
endif

# Input .h files to Doxygen.
src_h_files = []
foreach file : source_h_files
src_h_files += project_source_root / 'sigc++' / file
endforeach
src_h_files += project_source_root / 'sigc++' / 'sigc++.h'

doctool_dir = project_source_root / 'untracked' / 'docs' / 'docs' # MMDOCTOOLDIR
doctool_dist_dir = 'untracked' / 'docs' / 'docs' # Relative to MESON_DIST_ROOT

tag_file = custom_target('html_and_tag',
input: src_h_files,
output: book_name + '.tag',
command: [
python3, doc_reference, 'doxygen',
doctool_dir,
'@OUTPUT@',
'@INPUT@',
],
build_by_default: build_documentation,
install: true,
install_dir: install_reference_docdir,
)

devhelp_file = custom_target('devhelp',
input: tag_file,
output: book_name + '.devhelp2',
command: [
python3, doc_reference, 'devhelp',
doctool_dir,
'@INPUT@',
'@OUTPUT@',
book_name,
book_title,
],
build_by_default: build_documentation,
)

# Install Devhelp file and html files.
meson.add_install_script(
python3.path(), doc_reference, 'install_doc',
doctool_dir,
devhelp_file.full_path(),
install_devhelpdir,
install_reference_docdir / 'html',
docinstall_flags
)

if not meson.is_subproject()
# 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(), dist_cmd,
python3.path(), doc_reference, 'dist_doc',
doctool_dir,
doctool_dist_dir,
meson.current_build_dir(),
tag_file.full_path(),
devhelp_file.full_path(),
)
endif
27 changes: 27 additions & 0 deletions examples/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# examples

# input: sigcxx_dep, build_examples

examples = [
# [[dir-name], exe-name, [sources]]
[[], 'hello_world', ['hello_world.cc']],
[[], 'member_method', ['member_method.cc']],
]

foreach ex : examples
dir = ''
foreach dir_part : ex[0]
dir = dir / dir_part
endforeach
ex_name = (dir / ex[1]).underscorify()
ex_sources = []
foreach src : ex[2]
ex_sources += dir / src
endforeach

exe_file = executable(ex_name, ex_sources,
dependencies: sigcxx_dep,
gui_app: false,
build_by_default: build_examples
)
endforeach
Loading