summaryrefslogtreecommitdiff
path: root/docs/reference/meson.build
blob: e9582df6fe592d4ec333b73842cc6489e47e0cbe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# docs/reference

# Input: built_files_root, project_source_root, glibmm_pcname, giomm_pcname,
#        perl, glibmm_hg_ccg_basenames, giomm_hg_ccg_basenames,
#        glibmm_extra_h_files, giomm_extra_h_files, glibmm_built_h_file_targets,
#        giomm_built_h_file_targets, install_datadir, python3, doc_reference_py,
#        build_documentation
# Output: install_docdir, install_devhelpdir

tag_file_modules = [
  'mm-common-libstdc++',
  'sigc++-2.0',
]
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 = glibmm_pcname
book_title = meson.project_name() + ' Reference Manual'

# Configuration data for Doxyfile.
doc_conf_data = configuration_data()
doc_conf_data.set('configure_input',
  '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', built_files_root)
doc_conf_data.set('abs_top_srcdir', project_source_root)
doc_conf_data.set('GLIBMM_MODULE_NAME', book_name)
doc_conf_data.set('DOXYGEN_TAGFILES', doxygen_tagfiles)
doc_conf_data.set('PERL', perl.found() ? 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_image_docdir = install_docdir / 'images'
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

# Built input .h files to Doxygen.
built_h_files = []
foreach file : glibmm_hg_ccg_basenames
  built_h_files += built_files_root / 'glib' / 'glibmm' / file + '.h'
endforeach
foreach file : giomm_hg_ccg_basenames
  built_h_files += built_files_root / 'gio' / 'giomm' / file + '.h'
endforeach

# Hand-coded input .h files to Doxygen.
src_h_files = []
foreach file : glibmm_extra_h_files
  if file != 'wrap_init.h'
    src_h_files += project_source_root / 'glib' / 'glibmm' / file
  endif
endforeach
foreach file : giomm_extra_h_files
  if file != 'wrap_init.h'
    src_h_files += project_source_root / 'gio' / 'giomm' / file
  endif
endforeach
src_h_files += project_source_root / 'glib' / 'glibmm.h'
src_h_files += project_source_root / 'gio' / 'giomm.h'

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

doc_h_files = src_h_files
if glibmm_built_h_file_targets.length() + giomm_built_h_file_targets.length() > 0
  # .h files have been generated from .hg files (maintainer mode).
  # Use built_h_file_targets instead of built_h_files here, or else Meson won't
  # know that Doxygen must not be executed until the .h files have been built.
  doc_h_files += glibmm_built_h_file_targets + giomm_built_h_file_targets
else
  # All .h files are stored in the source tree (not maintainer mode).
  doc_h_files += built_h_files
endif

# Can't use @INPUT@ in the command. It requires absolute file paths.
# Paths in built_h_file_targets are relative to project_build_root.
tag_file = custom_target('html_and_tag',
  input: doc_h_files,
  output: book_name + '.tag',
  command: [
    python3, doc_reference_py, 'doxygen',
    doctool_dir,
    '@OUTPUT@',
    src_h_files,
    built_h_files,
  ],
  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_py, '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_py, 'install_doc',
  doctool_dir,
  devhelp_file.full_path(),
  install_devhelpdir,
  install_reference_docdir / 'html',
  docinstall_flags
)

# Install images.
image_basefiles = [
  'gtkmm_logo.gif',
  'top.gif',
]
image_files = []
foreach file : image_basefiles
  image_files += '..' / 'images' / file
endforeach

install_data(image_files, install_dir: install_image_docdir)

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(), doc_reference_py, 'dist_doc',
    doctool_dir,
    doctool_dist_dir,
    meson.current_build_dir(),
    tag_file.full_path(),
    devhelp_file.full_path(),
  )
endif