The Meson Build System
http://mesonbuild.com/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
123 lines
4.3 KiB
123 lines
4.3 KiB
9 years ago
|
#!/usr/bin/env python3
|
||
9 years ago
|
# Copyright 2015-2016 The Meson development team
|
||
9 years ago
|
|
||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||
|
# you may not use this file except in compliance with the License.
|
||
|
# You may obtain a copy of the License at
|
||
|
|
||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||
|
|
||
|
# Unless required by applicable law or agreed to in writing, software
|
||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||
|
# See the License for the specific language governing permissions and
|
||
|
# limitations under the License.
|
||
|
|
||
|
import sys, os
|
||
|
import subprocess
|
||
|
import shutil
|
||
9 years ago
|
import argparse
|
||
|
|
||
|
parser = argparse.ArgumentParser()
|
||
|
|
||
|
parser.add_argument('--sourcedir', dest='sourcedir')
|
||
|
parser.add_argument('--builddir', dest='builddir')
|
||
|
parser.add_argument('--subdir', dest='subdir')
|
||
|
parser.add_argument('--headerdir', dest='headerdir')
|
||
|
parser.add_argument('--mainfile', dest='mainfile')
|
||
|
parser.add_argument('--modulename', dest='modulename')
|
||
9 years ago
|
parser.add_argument('--htmlargs', dest='htmlargs', default='')
|
||
9 years ago
|
parser.add_argument('--scanargs', dest='scanargs', default='')
|
||
9 years ago
|
|
||
9 years ago
|
def build_gtkdoc(source_root, build_root, doc_subdir, src_subdir,
|
||
9 years ago
|
main_file, module, html_args, scan_args):
|
||
9 years ago
|
abs_src = os.path.join(source_root, src_subdir)
|
||
|
abs_out = os.path.join(build_root, doc_subdir)
|
||
|
htmldir = os.path.join(abs_out, 'html')
|
||
9 years ago
|
scan_cmd = ['gtkdoc-scan',
|
||
|
'--module=' + module,
|
||
|
'--source-dir=' + abs_src] + scan_args
|
||
9 years ago
|
# print(scan_cmd)
|
||
|
# sys.exit(1)
|
||
9 years ago
|
subprocess.check_call(scan_cmd,
|
||
9 years ago
|
cwd=abs_out)
|
||
9 years ago
|
if main_file.endswith('sgml'):
|
||
|
modeflag = '--sgml-mode'
|
||
|
else:
|
||
|
modeflag = '--xml-mode'
|
||
9 years ago
|
mkdb_cmd = ['gtkdoc-mkdb',
|
||
|
'--module=' + module,
|
||
|
'--output-format=xml',
|
||
9 years ago
|
modeflag,
|
||
9 years ago
|
'--source-dir=' + abs_src]
|
||
9 years ago
|
main_abs = os.path.join(source_root, doc_subdir, main_file)
|
||
9 years ago
|
if len(main_file) > 0:
|
||
9 years ago
|
# Yes, this is the flag even if the file is in xml.
|
||
9 years ago
|
mkdb_cmd.append('--main-sgml-file=' + main_file)
|
||
|
# print(mkdb_cmd)
|
||
|
# sys.exit(1)
|
||
9 years ago
|
subprocess.check_call(mkdb_cmd, cwd=abs_out)
|
||
9 years ago
|
shutil.rmtree(htmldir, ignore_errors=True)
|
||
|
try:
|
||
|
os.mkdir(htmldir)
|
||
|
except Exception:
|
||
|
pass
|
||
9 years ago
|
mkhtml_cmd = ['gtkdoc-mkhtml',
|
||
|
'--path=' + abs_src,
|
||
|
module,
|
||
|
] + html_args
|
||
9 years ago
|
if len(main_file) > 0:
|
||
9 years ago
|
mkhtml_cmd.append('../' + main_file)
|
||
9 years ago
|
else:
|
||
9 years ago
|
mkhtml_cmd.append('%s-docs.xml' % module)
|
||
|
# html gen must be run in the HTML dir
|
||
|
# print(mkhtml_cmd)
|
||
|
# sys.exit(1)
|
||
|
subprocess.check_call(mkhtml_cmd, cwd=os.path.join(abs_out, 'html'), shell=False)
|
||
|
fixref_cmd = ['gtkdoc-fixxref',
|
||
|
'--module=' + module,
|
||
|
'--module-dir=html']
|
||
|
# print(fixref_cmd)
|
||
|
# sys.exit(1)
|
||
|
subprocess.check_call(fixref_cmd, cwd=abs_out)
|
||
9 years ago
|
|
||
|
def install_gtkdoc(build_root, doc_subdir, install_prefix, datadir, module):
|
||
|
source = os.path.join(build_root, doc_subdir, 'html')
|
||
|
final_destination = os.path.join(install_prefix, datadir, module)
|
||
|
shutil.rmtree(final_destination, ignore_errors=True)
|
||
|
shutil.copytree(source, final_destination)
|
||
|
|
||
9 years ago
|
def run(args):
|
||
|
options = parser.parse_args(args)
|
||
9 years ago
|
if len(options.htmlargs) > 0:
|
||
9 years ago
|
htmlargs = options.htmlargs.split('@@')
|
||
|
else:
|
||
|
htmlargs = []
|
||
9 years ago
|
if len(options.scanargs) > 0:
|
||
|
scanargs = options.scanargs.split('@@')
|
||
|
else:
|
||
|
scanargs = []
|
||
9 years ago
|
build_gtkdoc(options.sourcedir,
|
||
|
options.builddir,
|
||
|
options.subdir,
|
||
|
options.headerdir,
|
||
|
options.mainfile,
|
||
9 years ago
|
options.modulename,
|
||
9 years ago
|
htmlargs,
|
||
|
scanargs)
|
||
9 years ago
|
|
||
|
if 'MESON_INSTALL_PREFIX' in os.environ:
|
||
|
if 'DESTDIR' in os.environ:
|
||
|
installdir = os.environ['DESTDIR'] + os.environ['MESON_INSTALL_PREFIX']
|
||
|
else:
|
||
|
installdir = os.environ['MESON_INSTALL_PREFIX']
|
||
9 years ago
|
install_gtkdoc(options.builddir,
|
||
|
options.subdir,
|
||
|
installdir,
|
||
|
'share/gtk-doc/html',
|
||
|
options.modulename)
|
||
9 years ago
|
return 0
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
sys.exit(run(sys.argv[1:]))
|