dynarmic/doc/build.py
MerryMage 097203968f Squashed 'externals/fmt/' changes from 39834389..135ab5cf
135ab5cf Update version
93d95f17 Fix markup
4f15c72f Fix markup
e9b19414 Automatically add package to release
c3d1f604 Fix markup
c96062bf Update changelog and version number
f9c97de4 Add note about errno to the documentation
62df6f27 CMakeLists: Use GNUInstallDirs to set install location
493586cb Fix overflow check
1d751bc6 fix warning in header: signed/unsigned comparison
11415bce Update usage.rst
9982dd01 Fix for warning C5030 in VS2015
42e88c4f Silenced MSVC 2017 constant if expression warning
7a9c1ba1 FMT_VARIADIC_CONST - Support for const variadic methods (#591)
324415c0 Use allocator_traits if available.
5f39721c Fix a warning
ca96acbe Add examples
708d9509 fix(Clang CodeGen): remove warnings
9328a074 Fix handling of fixed enums in clang (#580)
2c077dd4 Enable stream exceptions (#581)
933a33a7 Added MSVC checking for support for string_view.
bef89db6 Fix a bogus -Wduplicated-branches gcc warning (#573)
2a619d96 Make format work with C++17 std::string_view (#571)
e051de37 Use less version 2.6.1 and sudo to fix npm install issues on travis
5de459bf Suppress Clang's warning on zero as a null pointer
16589534 Make ArgMap::init not explicitly instantiated (#563)
3e75d3e0 Fix handling of types convertible to int
89654cd1 to_wstring added
37eb419a Fix noreturn attribute detection (#555)
14d85349 Explicitly cast range length to std::size_t to prevent conversion warnings
c2201ce0 Accept wide chars as integers to prevent conversion warning
6efbccb3 Add one more CMake warning fix
032c8380 Fix a segfault in test on glibc 2.26 #551, take 2
6655e804 Fix a segfault in test on glibc 2.26 #551
d16c4d20 Suppress warning about missing noreturn attribute (#549)
9c56a8ce Make format_arg() accept class hierarchies
ca0e3830 Update README.rst
81790d72 Update format.h to remove C4574 error on MSVC 14.2
30283443 Fix undefined behavior in UDL macro
4045d7fe Fix warning about missing ' character
89c3bc58 Remove warning C4668 in MSVC for FMT_GCC_VERSION and FMT_HAS_GXX_CXX11
4af9421f Adding OpenSpace to the list of projects
1a398b54 Fixed CMake CMP0048 warning.
589ccc16 Bump version
c3817046 Add an error on broken includes
16bdd842 Update scripts
b492316d Update version list
91f4ce02 Automatically update version in release script (#431)

git-subtree-dir: externals/fmt
git-subtree-split: 135ab5cf71ed731fc9fa0653051e7d4884a3652f
2020-04-22 20:41:46 +01:00

119 lines
4.8 KiB
Python
Executable file

#!/usr/bin/env python
# Build the documentation.
from __future__ import print_function
import errno, os, shutil, sys, tempfile
from subprocess import check_call, check_output, CalledProcessError, Popen, PIPE
from distutils.version import LooseVersion
versions = ['1.0.0', '1.1.0', '2.0.0', '3.0.2', '4.0.0', '4.1.0']
def pip_install(package, commit=None, **kwargs):
"Install package using pip."
min_version = kwargs.get('min_version')
if min_version:
from pkg_resources import get_distribution, DistributionNotFound
try:
installed_version = get_distribution(os.path.basename(package)).version
if LooseVersion(installed_version) >= min_version:
print('{} {} already installed'.format(package, min_version))
return
except DistributionNotFound:
pass
if commit:
package = 'git+https://github.com/{0}.git@{1}'.format(package, commit)
print('Installing {0}'.format(package))
check_call(['pip', 'install', package])
def create_build_env(dirname='virtualenv'):
# Create virtualenv.
if not os.path.exists(dirname):
check_call(['virtualenv', dirname])
import sysconfig
scripts_dir = os.path.basename(sysconfig.get_path('scripts'))
activate_this_file = os.path.join(dirname, scripts_dir, 'activate_this.py')
with open(activate_this_file) as f:
exec(f.read(), dict(__file__=activate_this_file))
# Import get_distribution after activating virtualenv to get info about
# the correct packages.
from pkg_resources import get_distribution, DistributionNotFound
# Upgrade pip because installation of sphinx with pip 1.1 available on Travis
# is broken (see #207) and it doesn't support the show command.
pip_version = get_distribution('pip').version
if LooseVersion(pip_version) < LooseVersion('1.5.4'):
print("Updating pip")
check_call(['pip', 'install', '--upgrade', 'pip'])
# Upgrade distribute because installation of sphinx with distribute 0.6.24
# available on Travis is broken (see #207).
try:
distribute_version = get_distribution('distribute').version
if LooseVersion(distribute_version) <= LooseVersion('0.6.24'):
print("Updating distribute")
check_call(['pip', 'install', '--upgrade', 'distribute'])
except DistributionNotFound:
pass
# Install Sphinx and Breathe.
pip_install('sphinx-doc/sphinx', '12b83372ac9316e8cbe86e7fed889296a4cc29ee',
min_version='1.4.1.dev20160531')
pip_install('michaeljones/breathe',
'6b1c5bb7a1866f15fc328b8716258354b10c1daa',
min_version='4.2.0')
def build_docs(version='dev', **kwargs):
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',
os.path.join(os.path.dirname(doc_dir), 'fmt'))
# Build docs.
cmd = ['doxygen', '-']
p = Popen(cmd, stdin=PIPE)
doxyxml_dir = os.path.join(work_dir, 'doxyxml')
p.communicate(input=r'''
PROJECT_NAME = fmt
GENERATE_LATEX = NO
GENERATE_MAN = NO
GENERATE_RTF = NO
CASE_SENSE_NAMES = NO
INPUT = {0}/container.h {0}/format.h {0}/ostream.h \
{0}/printf.h {0}/string.h
QUIET = YES
JAVADOC_AUTOBRIEF = YES
AUTOLINK_SUPPORT = NO
GENERATE_HTML = NO
GENERATE_XML = YES
XML_OUTPUT = {1}
ALIASES = "rst=\verbatim embed:rst"
ALIASES += "endrst=\endverbatim"
MACRO_EXPANSION = YES
PREDEFINED = _WIN32=1 \
FMT_USE_VARIADIC_TEMPLATES=1 \
FMT_USE_RVALUE_REFERENCES=1 \
FMT_USE_USER_DEFINED_LITERALS=1 \
FMT_API=
EXCLUDE_SYMBOLS = fmt::internal::* StringValue write_str
'''.format(include_dir, doxyxml_dir).encode('UTF-8'))
if p.returncode != 0:
raise CalledProcessError(p.returncode, cmd)
html_dir = os.path.join(work_dir, 'html')
main_versions = reversed(versions[-3:])
check_call(['sphinx-build',
'-Dbreathe_projects.format=' + os.path.abspath(doxyxml_dir),
'-Dversion=' + version, '-Drelease=' + version,
'-Aversion=' + version, '-Aversions=' + ','.join(main_versions),
'-b', 'html', doc_dir, html_dir])
try:
check_call(['lessc', '--clean-css',
'--include-path=' + os.path.join(doc_dir, 'bootstrap'),
os.path.join(doc_dir, 'fmt.less'),
os.path.join(html_dir, '_static', 'fmt.css')])
except OSError as e:
if e.errno != errno.ENOENT:
raise
print('lessc not found; make sure that Less (http://lesscss.org/) ' +
'is installed')
sys.exit(1)
return html_dir
if __name__ == '__main__':
create_build_env()
build_docs(sys.argv[1])