Merge pull request #651 from centricular/gtkdoc-new-runtarget-syntax

Port gtk-doc module to the latest RunTarget syntax
This commit is contained in:
Jussi Pakkanen 2016-07-25 21:59:02 +03:00 committed by GitHub
commit 5942baa2d1
2 changed files with 24 additions and 14 deletions

View File

@ -290,7 +290,7 @@ class GnomeModule:
args += self.unpack_args('--htmlargs=', 'html_args', kwargs) args += self.unpack_args('--htmlargs=', 'html_args', kwargs)
args += self.unpack_args('--scanargs=', 'scan_args', kwargs) args += self.unpack_args('--scanargs=', 'scan_args', kwargs)
args += self.unpack_args('--fixxrefargs=', 'fixxref_args', kwargs) args += self.unpack_args('--fixxrefargs=', 'fixxref_args', kwargs)
res = [build.RunTarget(targetname, command[0], command[1:] + args, state.subdir)] res = [build.RunTarget(targetname, command[0], command[1:] + args, [], state.subdir)]
if kwargs.get('install', True): if kwargs.get('install', True):
res.append(build.InstallScript(command + args)) res.append(build.InstallScript(command + args))
return res return res

View File

@ -17,6 +17,7 @@ import sys, os
import subprocess import subprocess
import shutil import shutil
import argparse import argparse
from mesonbuild.mesonlib import MesonException
from mesonbuild.scripts import destdir_join from mesonbuild.scripts import destdir_join
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
@ -31,6 +32,18 @@ parser.add_argument('--htmlargs', dest='htmlargs', default='')
parser.add_argument('--scanargs', dest='scanargs', default='') parser.add_argument('--scanargs', dest='scanargs', default='')
parser.add_argument('--fixxrefargs', dest='fixxrefargs', default='') parser.add_argument('--fixxrefargs', dest='fixxrefargs', default='')
def gtkdoc_run_check(cmd, cwd):
p = subprocess.Popen(cmd, cwd=cwd,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(stde, stdo) = p.communicate()
if p.returncode != 0:
err_msg = ["{!r} failed with status {:d}".format(cmd[0], p.returncode)]
if stde:
err_msg.append(stde.decode(errors='ignore'))
if stdo:
err_msg.append(stdo.decode(errors='ignore'))
raise MesonException('\n'.join(err_msg))
def build_gtkdoc(source_root, build_root, doc_subdir, src_subdir, def build_gtkdoc(source_root, build_root, doc_subdir, src_subdir,
main_file, module, html_args, scan_args, fixxref_args): main_file, module, html_args, scan_args, fixxref_args):
abs_src = os.path.join(source_root, src_subdir) abs_src = os.path.join(source_root, src_subdir)
@ -39,10 +52,9 @@ def build_gtkdoc(source_root, build_root, doc_subdir, src_subdir,
scan_cmd = ['gtkdoc-scan', scan_cmd = ['gtkdoc-scan',
'--module=' + module, '--module=' + module,
'--source-dir=' + abs_src] + scan_args '--source-dir=' + abs_src] + scan_args
# print(scan_cmd) gtkdoc_run_check(scan_cmd, abs_out)
# sys.exit(1)
subprocess.check_call(scan_cmd, # Make docbook files
cwd=abs_out)
if main_file.endswith('sgml'): if main_file.endswith('sgml'):
modeflag = '--sgml-mode' modeflag = '--sgml-mode'
else: else:
@ -56,9 +68,9 @@ def build_gtkdoc(source_root, build_root, doc_subdir, src_subdir,
if len(main_file) > 0: if len(main_file) > 0:
# Yes, this is the flag even if the file is in xml. # Yes, this is the flag even if the file is in xml.
mkdb_cmd.append('--main-sgml-file=' + main_file) mkdb_cmd.append('--main-sgml-file=' + main_file)
# print(mkdb_cmd) gtkdoc_run_check(mkdb_cmd, abs_out)
# sys.exit(1)
subprocess.check_call(mkdb_cmd, cwd=abs_out) # Make HTML documentation
shutil.rmtree(htmldir, ignore_errors=True) shutil.rmtree(htmldir, ignore_errors=True)
try: try:
os.mkdir(htmldir) os.mkdir(htmldir)
@ -73,15 +85,13 @@ def build_gtkdoc(source_root, build_root, doc_subdir, src_subdir,
else: else:
mkhtml_cmd.append('%s-docs.xml' % module) mkhtml_cmd.append('%s-docs.xml' % module)
# html gen must be run in the HTML dir # html gen must be run in the HTML dir
# print(mkhtml_cmd) gtkdoc_run_check(mkhtml_cmd, os.path.join(abs_out, 'html'))
# sys.exit(1)
subprocess.check_call(mkhtml_cmd, cwd=os.path.join(abs_out, 'html'), shell=False) # Fix cross-references in HTML files
fixref_cmd = ['gtkdoc-fixxref', fixref_cmd = ['gtkdoc-fixxref',
'--module=' + module, '--module=' + module,
'--module-dir=html'] + fixxref_args '--module-dir=html'] + fixxref_args
# print(fixref_cmd) gtkdoc_run_check(fixref_cmd, abs_out)
# sys.exit(1)
subprocess.check_call(fixref_cmd, cwd=abs_out)
def install_gtkdoc(build_root, doc_subdir, install_prefix, datadir, module): def install_gtkdoc(build_root, doc_subdir, install_prefix, datadir, module):
source = os.path.join(build_root, doc_subdir, 'html') source = os.path.join(build_root, doc_subdir, 'html')