Make work dir configurable

This commit is contained in:
Victor Zverovich 2016-05-26 07:35:10 -07:00
parent fcaf8a0cdc
commit 9071daebe9

View File

@ -47,11 +47,13 @@ def create_build_env(dirname='virtualenv'):
def build_docs(version='dev', **kwargs): def build_docs(version='dev', **kwargs):
doc_dir = kwargs.get('doc_dir', os.path.dirname(os.path.realpath(__file__))) doc_dir = kwargs.get('doc_dir', os.path.dirname(os.path.realpath(__file__)))
work_dir = kwargs.get('work_dir', '.')
include_dir = kwargs.get('include_dir', include_dir = kwargs.get('include_dir',
os.path.join(os.path.dirname(doc_dir), 'fmt')) os.path.join(os.path.dirname(doc_dir), 'fmt'))
# Build docs. # Build docs.
cmd = ['doxygen', '-'] cmd = ['doxygen', '-']
p = Popen(cmd, stdin=PIPE) p = Popen(cmd, stdin=PIPE)
doxyxml_dir = os.path.join(work_dir, 'doxyxml')
p.communicate(input=r''' p.communicate(input=r'''
PROJECT_NAME = fmt PROJECT_NAME = fmt
GENERATE_LATEX = NO GENERATE_LATEX = NO
@ -64,7 +66,7 @@ def build_docs(version='dev', **kwargs):
AUTOLINK_SUPPORT = NO AUTOLINK_SUPPORT = NO
GENERATE_HTML = NO GENERATE_HTML = NO
GENERATE_XML = YES GENERATE_XML = YES
XML_OUTPUT = doxyxml XML_OUTPUT = {1}
ALIASES = "rst=\verbatim embed:rst" ALIASES = "rst=\verbatim embed:rst"
ALIASES += "endrst=\endverbatim" ALIASES += "endrst=\endverbatim"
MACRO_EXPANSION = YES MACRO_EXPANSION = YES
@ -74,26 +76,26 @@ def build_docs(version='dev', **kwargs):
FMT_USE_USER_DEFINED_LITERALS=1 \ FMT_USE_USER_DEFINED_LITERALS=1 \
FMT_API= FMT_API=
EXCLUDE_SYMBOLS = fmt::internal::* StringValue write_str EXCLUDE_SYMBOLS = fmt::internal::* StringValue write_str
'''.format(include_dir).encode('UTF-8')) '''.format(include_dir, doxyxml_dir).encode('UTF-8'))
if p.returncode != 0: if p.returncode != 0:
raise CalledProcessError(p.returncode, cmd) raise CalledProcessError(p.returncode, cmd)
doxyxml_dir = os.path.join(os.getcwd(), 'doxyxml') html_dir = os.path.join(work_dir, 'html')
check_call(['sphinx-build', check_call(['sphinx-build',
'-Dbreathe_projects.format=' + doxyxml_dir, '-Dbreathe_projects.format=' + doxyxml_dir,
'-Dversion=' + version, '-Drelease=' + version, '-Dversion=' + version, '-Drelease=' + version,
'-Aversion=' + version, '-b', 'html', doc_dir, 'html']) '-Aversion=' + version, '-b', 'html', doc_dir, html_dir])
try: try:
check_call(['lessc', #'--clean-css', check_call(['lessc', #'--clean-css',
'--include-path=' + os.path.join(doc_dir, 'bootstrap'), '--include-path=' + os.path.join(doc_dir, 'bootstrap'),
os.path.join(doc_dir, 'fmt.less'), os.path.join(doc_dir, 'fmt.less'),
'html/_static/fmt.css']) os.path.join(html_dir, '_static', 'fmt.css')])
except OSError as e: except OSError as e:
if e.errno != errno.ENOENT: if e.errno != errno.ENOENT:
raise raise
print('lessc not found; make sure that Less (http://lesscss.org/) ' + print('lessc not found; make sure that Less (http://lesscss.org/) ' +
'is installed') 'is installed')
sys.exit(1) sys.exit(1)
return 'html' return html_dir
if __name__ == '__main__': if __name__ == '__main__':
create_build_env() create_build_env()