Skip to content

Commit 44eb33c

Browse files
committed
Add support for building libxml++ with Meson
libxml++-5.0 can be built with either Autotools or Meson. New files have been copied from the libxml++-4-0 branch. Some of them have been slightly changed.
1 parent 77241ee commit 44eb33c

File tree

16 files changed

+1157
-4
lines changed

16 files changed

+1157
-4
lines changed

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ stamp-h?
2626
/libtool
2727

2828
# MSVC
29-
/MSVC_Net201?/libxml++/libxml++.rc
29+
/MSVC_NMake/libxml++/libxml++.rc
3030

3131
# docs
3232
/docs/doc-install.pl
@@ -70,3 +70,7 @@ stamp-h?
7070
/tests/*/test.log
7171
/tests/*/test.trs
7272
/tests/test-suite.log
73+
74+
# untracked/
75+
untracked/build_scripts/
76+
untracked/docs/

MSVC_NMake/libxml++/meson.build

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# MSVC_NMake/libxml++
2+
3+
# Input: pkg_conf_data, xmlxxconfig_h
4+
# Output: xmlxx_rc
5+
6+
xmlxx_rc = configure_file(
7+
input: 'libxml++.rc.in',
8+
output: '@BASENAME@',
9+
configuration: pkg_conf_data,
10+
)
11+
12+
# Copy the generated configuration header into the MSVC project directory.
13+
configure_file(
14+
input: xmlxxconfig_h,
15+
output: 'libxml++config.h',
16+
copy: true,
17+
)

Makefile.am

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,20 @@ dist_noinst_SCRIPTS = autogen.sh
2424

2525
DISTCLEANFILES = MSVC_NMake/libxml++/libxml++config.h
2626

27+
# Distribute files needed when building libxml++ with Meson.
28+
EXTRA_DIST = \
29+
meson.build \
30+
meson_options.txt \
31+
libxml++config.h.meson \
32+
MSVC_NMake/libxml++/meson.build \
33+
docs/manual/meson.build \
34+
docs/reference/meson.build \
35+
examples/meson.build \
36+
libxml++/meson.build \
37+
tests/meson.build \
38+
tools/build_scripts/tutorial-custom-cmd.py \
39+
tools/conf_tests/have_exception_ptr.cc \
40+
untracked/README
41+
2742
# Optional: auto-generate the ChangeLog file from the git log on make dist
2843
include $(top_srcdir)/build/dist-changelog.am

configure.ac

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ LT_PREREQ([2.2.6])
3636
LT_INIT([dlopen win32-dll disable-static])
3737

3838
AC_SUBST([LIBXMLXX_MODULES], ['libxml-2.0 >= 2.7.7'])
39+
AC_SUBST([LIBXML2_LIB_NO_PKGCONFIG], [''])
40+
AC_SUBST([MSVC_TOOLSET_VER], [''])
3941
PKG_CHECK_MODULES([LIBXMLXX], [$LIBXMLXX_MODULES])
4042

4143
AC_LANG([C++])
@@ -48,8 +50,7 @@ MM_ARG_WITH_TAGFILE_DOC([libstdc++.tag], [mm-common-libstdc++])
4850
# Evaluate the --enable-warnings=level option.
4951
MM_ARG_ENABLE_WARNINGS([LIBXMLXX_WXXFLAGS],
5052
[-Wall],
51-
[-pedantic -Wall -Wextra -Wformat-security -Wsuggest-override -Wshadow -Wno-long-long],
52-
[G GLIBMM SIGCXX])
53+
[-pedantic -Wall -Wextra -Wformat-security -Wsuggest-override -Wshadow -Wno-long-long])
5354

5455
# Offer the ability to omit some API from the library.
5556
MM_ARG_DISABLE_DEPRECATED_API([LIBXMLXX])

docs/manual/meson.build

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# docs/manual
2+
3+
# input: install_datadir, xmlxx_pcname, tutorial_custom_cmd_py, python3,
4+
# build_documentation, book_name, perl
5+
# output: can_parse_and_validate, build_pdf_by_default, can_build_pdf,
6+
# install_tutorialdir
7+
8+
# xsltproc is required by tutorial_custom_cmd_py html.
9+
xsltproc = find_program('xsltproc', required: build_documentation)
10+
xmllint = find_program('xmllint', required: false)
11+
12+
can_parse_and_validate = xmllint.found()
13+
14+
validate = get_option('validation') ? 'true' : 'false'
15+
16+
dblatex = find_program('dblatex', required: false)
17+
can_build_pdf = dblatex.found() or (xmllint.found() and \
18+
find_program('docbook2pdf', required: false).found())
19+
build_pdf_by_default = get_option('build-pdf')
20+
21+
# Installation directories are relative to {prefix}.
22+
install_tutorialdir = install_datadir / 'doc' / book_name / 'manual'
23+
24+
if not build_documentation
25+
# Documentation shall not be built or installed.
26+
# Return to the calling meson.build file.
27+
subdir_done()
28+
endif
29+
30+
doc_dist_dir = 'untracked' / 'docs' / 'manual' # Relative to MESON_DIST_ROOT
31+
32+
# Create a DocBook XML file with the examples' source code included.
33+
xml_manual_docbook = custom_target('libxml++.xml',
34+
input: 'libxml++_without_code.xml',
35+
output: 'libxml++.xml',
36+
command: [
37+
python3, tutorial_custom_cmd_py, 'insert_example_code',
38+
meson.current_source_dir() / 'insert_example_code.pl',
39+
project_source_root / 'examples',
40+
'@INPUT@',
41+
'@OUTPUT@',
42+
],
43+
build_by_default: true
44+
)
45+
46+
# Create an html version of the DocBook.
47+
custom_target('manual_html',
48+
input: xml_manual_docbook,
49+
output: 'html',
50+
command: [
51+
python3, tutorial_custom_cmd_py, 'html',
52+
meson.current_source_dir() / 'docbook-customisation.xsl', # stylesheet
53+
'@INPUT@',
54+
'@OUTPUT@',
55+
],
56+
build_by_default: true,
57+
install: true,
58+
install_dir: install_tutorialdir
59+
)
60+
61+
if can_parse_and_validate
62+
# Parse and possibly validate the DocBook.
63+
custom_target('manual_xmllint',
64+
input: xml_manual_docbook,
65+
output: 'manual_xmllint.stamp',
66+
command: [
67+
python3, tutorial_custom_cmd_py, 'xmllint',
68+
validate,
69+
'@INPUT@',
70+
'@OUTPUT@'
71+
],
72+
build_by_default: true,
73+
)
74+
endif
75+
76+
if can_build_pdf
77+
# Create a PDF file of the DocBook.
78+
# Prefer dblatex, if both dblatex and docbook2pdf are available.
79+
custom_target('manual_pdf',
80+
input: xml_manual_docbook,
81+
output: 'libxml++.pdf',
82+
command: [
83+
python3, tutorial_custom_cmd_py,
84+
dblatex.found() ? 'dblatex' : 'docbook2pdf',
85+
'@INPUT@',
86+
'@OUTPUT@'
87+
],
88+
build_by_default: build_pdf_by_default,
89+
)
90+
endif
91+
92+
if not meson.is_subproject()
93+
# Distribute built files.
94+
# (add_dist_script() is not allowed in a subproject)
95+
meson.add_dist_script(
96+
python3.path(), tutorial_custom_cmd_py, 'dist_doc',
97+
doc_dist_dir,
98+
meson.current_build_dir(),
99+
meson.current_build_dir() / 'libxml++.xml',
100+
meson.current_build_dir() / 'libxml++.pdf',
101+
)
102+
endif

docs/reference/meson.build

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# docs/reference
2+
3+
# Input: project_build_root, project_source_root, xmlxx_pcname,
4+
# xmlxx_api_version, build_documentation, source_h_files,
5+
# install_datadir, python3, doc_reference_py
6+
# Output: install_docdir, install_devhelpdir, book_name
7+
8+
# There are no built source files in libxml++-5.0.
9+
10+
tag_file_modules = [
11+
'mm-common-libstdc++',
12+
]
13+
doxygen_tagfiles = ''
14+
docinstall_flags = []
15+
foreach module : tag_file_modules
16+
depmod = dependency(module, required: false)
17+
if depmod.found()
18+
doxytagfile = depmod.get_pkgconfig_variable('doxytagfile')
19+
htmlrefpub = depmod.get_pkgconfig_variable('htmlrefpub', default: '')
20+
htmlrefdir = depmod.get_pkgconfig_variable('htmlrefdir', default: '')
21+
if htmlrefpub == ''
22+
htmlrefpub = htmlrefdir
23+
elif htmlrefdir == ''
24+
htmlrefdir = htmlrefpub
25+
endif
26+
doxygen_tagfiles += ' "' + doxytagfile + '=' + htmlrefpub + '"'
27+
28+
# Doxygen <= 1.8.15
29+
docinstall_flags += ['-l', doxytagfile.split('/')[-1] + '@' + htmlrefdir]
30+
if htmlrefpub != htmlrefdir
31+
# Doxygen >= 1.8.16
32+
docinstall_flags += ['-l', 's@' + htmlrefpub + '@' + htmlrefdir]
33+
endif
34+
endif
35+
endforeach
36+
37+
book_name = xmlxx_pcname
38+
book_title = meson.project_name() + ' Reference Manual'
39+
40+
# Configuration data for Doxyfile.
41+
doc_conf_data = configuration_data()
42+
doc_conf_data.set('configure_input',
43+
'docs/reference/Doxyfile. Generated from Doxyfile.in by meson.configure_file().')
44+
doc_conf_data.set('PACKAGE_NAME', meson.project_name())
45+
doc_conf_data.set('PACKAGE_VERSION', meson.project_version())
46+
doc_conf_data.set('abs_top_builddir', project_build_root)
47+
doc_conf_data.set('abs_top_srcdir', project_source_root)
48+
doc_conf_data.set('LIBXMLXX_MODULE_NAME', book_name)
49+
doc_conf_data.set('DOXYGEN_TAGFILES', doxygen_tagfiles)
50+
51+
configure_file(
52+
input: 'Doxyfile.in',
53+
output: '@BASENAME@',
54+
configuration: doc_conf_data,
55+
)
56+
57+
# Installation directories relative to {prefix}.
58+
install_docdir = install_datadir / 'doc' / book_name
59+
install_reference_docdir = install_docdir / 'reference'
60+
install_devhelpdir = install_datadir / 'devhelp' / 'books' / book_name
61+
62+
if not build_documentation
63+
# Documentation shall not be built or installed.
64+
# Return to the calling meson.build file.
65+
subdir_done()
66+
endif
67+
68+
# Input .h files to Doxygen.
69+
src_h_files = []
70+
foreach file : source_h_files
71+
src_h_files += project_source_root / 'libxml++' / file
72+
endforeach
73+
src_h_files += project_source_root / 'libxml++' / 'libxml++.h'
74+
75+
doctool_dir = project_source_root / 'untracked' / 'docs' # MMDOCTOOLDIR
76+
doctool_dist_dir = 'untracked' / 'docs' # Relative to MESON_DIST_ROOT
77+
78+
tag_file = custom_target('html_and_tag',
79+
input: src_h_files,
80+
output: book_name + '.tag',
81+
command: [
82+
python3, doc_reference_py, 'doxygen',
83+
doctool_dir,
84+
'@OUTPUT@',
85+
'@INPUT@',
86+
],
87+
build_by_default: build_documentation,
88+
install: true,
89+
install_dir: install_reference_docdir,
90+
)
91+
92+
devhelp_file = custom_target('devhelp',
93+
input: tag_file,
94+
output: book_name + '.devhelp2',
95+
command: [
96+
python3, doc_reference_py, 'devhelp',
97+
doctool_dir,
98+
'@INPUT@',
99+
'@OUTPUT@',
100+
book_name,
101+
book_title,
102+
],
103+
build_by_default: build_documentation,
104+
)
105+
106+
# Install Devhelp file and html files.
107+
meson.add_install_script(
108+
python3.path(), doc_reference_py, 'install_doc',
109+
doctool_dir,
110+
devhelp_file.full_path(),
111+
install_devhelpdir,
112+
install_reference_docdir / 'html',
113+
docinstall_flags
114+
)
115+
116+
if not meson.is_subproject()
117+
# Distribute built files and files copied by mm-common-get.
118+
# (add_dist_script() is not allowed in a subproject)
119+
meson.add_dist_script(
120+
python3.path(), doc_reference_py, 'dist_doc',
121+
doctool_dir,
122+
doctool_dist_dir,
123+
meson.current_build_dir(),
124+
tag_file.full_path(),
125+
devhelp_file.full_path(),
126+
)
127+
endif

examples/meson.build

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# examples
2+
3+
# Input: xmlxx_dep, build_examples
4+
# Output: -
5+
6+
example_programs = [
7+
# [[dir-name], exe-name, [sources], [arguments]]
8+
[['dom_build'], 'example', ['main.cc'], []],
9+
[['dom_parse_entities'], 'example', ['main.cc'], []],
10+
[['dom_parser'], 'example', ['main.cc'], []],
11+
[['dom_parser_raw'], 'example', ['main.cc'], []],
12+
[['dom_read_write'], 'example', ['main.cc'],
13+
['example.xml', meson.current_build_dir() / 'dom_read_write_example_output.xml']],
14+
[['dom_update_namespace'], 'example', ['main.cc'], []],
15+
[['dom_xinclude'], 'example', ['main.cc'], []],
16+
[['dom_xpath'], 'example', ['main.cc'], []],
17+
[['dtdvalidation'], 'example', ['main.cc'], []],
18+
[['import_node'], 'example', ['main.cc'], []],
19+
[['sax_exception'], 'example', ['main.cc', 'myparser.cc'], []],
20+
[['sax_parser'], 'example', ['main.cc', 'myparser.cc'], []],
21+
[['sax_parser_build_dom'], 'example', ['main.cc', 'svgparser.cc',
22+
'svgdocument.cc', 'svgelement.cc'], []],
23+
[['sax_parser_entities'], 'example', ['main.cc', 'myparser.cc'], []],
24+
[['schemavalidation'], 'example', ['main.cc'], []],
25+
[['textreader'], 'example', ['main.cc'], []],
26+
]
27+
28+
foreach ex : example_programs
29+
dir = ''
30+
foreach dir_part : ex[0]
31+
dir = dir / dir_part
32+
endforeach
33+
ex_name = (dir / ex[1]).underscorify()
34+
ex_sources = []
35+
foreach src : ex[2]
36+
ex_sources += dir / src
37+
endforeach
38+
39+
exe_file = executable(ex_name, ex_sources,
40+
dependencies: xmlxx_dep,
41+
gui_app: false,
42+
build_by_default: build_examples
43+
)
44+
45+
if build_examples
46+
# Some programs can find their input file(s) only if the current directory,
47+
# when they are executed, is the program's own source directory.
48+
# To make these program invocations as consistent as possible, and to avoid
49+
# having to specify parameters for the programs, the programs are executed
50+
# from their own source directory.
51+
#
52+
# dom_read_write shall write its output file in the build directory.
53+
# It's necessary to specify parameters when the input file and the output
54+
# file are located in different directories.
55+
56+
test(ex_name, exe_file,
57+
workdir: meson.current_source_dir() / dir,
58+
args: ex[3],
59+
)
60+
endif
61+
endforeach

libxml++.pc.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ Description: C++ wrapper for libxml
1515
Version: @PACKAGE_VERSION@
1616
URL: http://libxmlplusplus.sourceforge.net/
1717
Requires: @LIBXMLXX_MODULES@
18-
Libs: -L${libdir} -lxml++-@LIBXMLXX_API_VERSION@
18+
Libs: -L${libdir} -lxml++@MSVC_TOOLSET_VER@-@LIBXMLXX_API_VERSION@ @LIBXML2_LIB_NO_PKGCONFIG@
1919
Cflags: -I${includedir}/@LIBXMLXX_MODULE_NAME@ -I${libdir}/@LIBXMLXX_MODULE_NAME@/include

0 commit comments

Comments
 (0)