Skip to content

Commit 7558ed2

Browse files
committed
build: update sphinx tool
Use the improved version from the ndn-cxx repository Refs: #5298 Change-Id: I41714a3f4bfa65fee0baa521fa21e1a76071b405
1 parent 2620684 commit 7558ed2

8 files changed

Lines changed: 92 additions & 102 deletions

File tree

.waf-tools/boost.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
#!/usr/bin/env python
2-
# encoding: utf-8
3-
#
41
# partially based on boost.py written by Gernot Vormayr
52
# written by Ruediger Sonderfeld <ruediger@c-plusplus.de>, 2008
63
# modified by Bjoern Michaelsen, 2008

.waf-tools/coverage.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
2-
31
from waflib import TaskGen
42

53
def options(opt):

.waf-tools/default-compiler-flags.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
2-
31
import platform
42
from waflib import Configure, Logs, Utils
53

@@ -128,16 +126,16 @@ def getCompilerVersion(self, conf):
128126

129127
def getGeneralFlags(self, conf):
130128
"""Get dict of CXXFLAGS, LINKFLAGS, and DEFINES that are always needed"""
129+
return {'CXXFLAGS': [], 'LINKFLAGS': [], 'DEFINES': []}
130+
131+
def getDebugFlags(self, conf):
132+
"""Get dict of CXXFLAGS, LINKFLAGS, and DEFINES that are needed only in debug mode"""
131133
return {
132134
'CXXFLAGS': [],
133135
'LINKFLAGS': [],
134136
'DEFINES': ['BOOST_ASIO_NO_DEPRECATED', 'BOOST_FILESYSTEM_NO_DEPRECATED'],
135137
}
136138

137-
def getDebugFlags(self, conf):
138-
"""Get dict of CXXFLAGS, LINKFLAGS, and DEFINES that are needed only in debug mode"""
139-
return {'CXXFLAGS': [], 'LINKFLAGS': [], 'DEFINES': []}
140-
141139
def getOptimizedFlags(self, conf):
142140
"""Get dict of CXXFLAGS, LINKFLAGS, and DEFINES that are needed only in optimized mode"""
143141
return {'CXXFLAGS': [], 'LINKFLAGS': [], 'DEFINES': ['NDEBUG']}
@@ -246,6 +244,9 @@ def getDebugFlags(self, conf):
246244
elif self.getCompilerVersion(conf) >= (15, 0, 0):
247245
# https://releases.llvm.org/15.0.0/projects/libcxx/docs/UsingLibcxx.html#enabling-the-safe-libc-mode
248246
flags['DEFINES'] += ['_LIBCPP_ENABLE_ASSERTIONS=1']
247+
# Tell libc++ to avoid including transitive headers
248+
# https://libcxx.llvm.org/DesignDocs/HeaderRemovalPolicy.html
249+
flags['DEFINES'] += ['_LIBCPP_REMOVE_TRANSITIVE_INCLUDES=1']
249250
return flags
250251

251252
def getOptimizedFlags(self, conf):

.waf-tools/doxygen.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
#! /usr/bin/env python
2-
# encoding: UTF-8
31
# Thomas Nagy 2008-2010 (ita)
42

53
"""
6-
74
Doxygen support
85
96
Variables passed to bld():
@@ -27,9 +24,8 @@ def doxygen(bld):
2724
bld(features="doxygen", doxyfile='Doxyfile', ...)
2825
"""
2926

30-
from fnmatch import fnmatchcase
31-
import os, os.path, re, stat
32-
from waflib import Task, Utils, Node, Logs, Errors, Build
27+
import os, os.path, re
28+
from waflib import Task, Utils, Node
3329
from waflib.TaskGen import feature
3430

3531
DOXY_STR = '"${DOXYGEN}" - '
@@ -207,8 +203,8 @@ def configure(conf):
207203
conf.find_program('doxygen', var='DOXYGEN', mandatory=False)
208204
conf.find_program('tar', var='TAR', mandatory=False)
209205

210-
# doxygen docs
206+
# doxygen command
211207
from waflib.Build import BuildContext
212208
class doxy(BuildContext):
213-
cmd = "doxygen"
214-
fun = "doxygen"
209+
cmd = 'doxygen'
210+
fun = 'doxygen'

.waf-tools/sanitizers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
1+
# Davide Pesavento (LIP6), 2016
22

33
def options(opt):
44
opt.add_option('--with-sanitizer', action='store', default='', dest='sanitizers',

.waf-tools/sphinx.py

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# inspired by code by Hans-Martin von Gaudecker, 2012
2+
3+
"""Support for Sphinx documentation"""
4+
5+
import os
6+
from waflib import Task, TaskGen
7+
8+
9+
class sphinx_build(Task.Task):
10+
color = 'BLUE'
11+
run_str = '${SPHINX_BUILD} -q -b ${BUILDERNAME} -D ${VERSION} -D ${RELEASE} -d ${DOCTREEDIR} ${SRCDIR} ${OUTDIR}'
12+
13+
def keyword(self):
14+
return f'Processing ({self.env.BUILDERNAME})'
15+
16+
17+
# from https://docs.python.org/3.12/whatsnew/3.12.html#imp
18+
def load_source(modname, filename):
19+
import importlib.util
20+
from importlib.machinery import SourceFileLoader
21+
loader = SourceFileLoader(modname, filename)
22+
spec = importlib.util.spec_from_file_location(modname, filename, loader=loader)
23+
module = importlib.util.module_from_spec(spec)
24+
loader.exec_module(module)
25+
return module
26+
27+
28+
@TaskGen.feature('sphinx')
29+
@TaskGen.before_method('process_source')
30+
def process_sphinx(self):
31+
"""Set up the task generator with a Sphinx instance and create a task."""
32+
33+
conf = self.path.find_node(self.config)
34+
if not conf:
35+
self.bld.fatal(f'Sphinx configuration file {repr(self.config)} not found')
36+
37+
inputs = [conf] + self.to_nodes(self.source)
38+
task = self.create_task('sphinx_build', inputs, always_run=getattr(self, 'always', False))
39+
40+
confdir = conf.parent.abspath()
41+
buildername = getattr(self, 'builder', 'html')
42+
srcdir = getattr(self, 'srcdir', confdir)
43+
outdir = self.path.find_or_declare(getattr(self, 'outdir', buildername)).get_bld()
44+
doctreedir = getattr(self, 'doctreedir', os.path.join(outdir.abspath(), '.doctrees'))
45+
release = getattr(self, 'release', self.version)
46+
47+
task.env['BUILDERNAME'] = buildername
48+
task.env['SRCDIR'] = srcdir
49+
task.env['OUTDIR'] = outdir.abspath()
50+
task.env['DOCTREEDIR'] = doctreedir
51+
task.env['VERSION'] = f'version={self.version}'
52+
task.env['RELEASE'] = f'release={release}'
53+
54+
if buildername == 'man':
55+
confdata = load_source('sphinx_conf', conf.abspath())
56+
for i in confdata.man_pages:
57+
target = outdir.find_or_declare(f'{i[1]}.{i[4]}')
58+
task.outputs.append(target)
59+
if self.install_path:
60+
self.bld.install_files(f'{self.install_path}/man{i[4]}/', target)
61+
else:
62+
task.outputs.append(outdir)
63+
64+
# prevent process_source from complaining that there is no extension mapping for .rst files
65+
self.source = []
66+
67+
68+
def configure(conf):
69+
"""Check if sphinx-build program is available."""
70+
conf.find_program('sphinx-build', var='SPHINX_BUILD', mandatory=False)
71+
72+
73+
# sphinx command
74+
from waflib.Build import BuildContext
75+
class sphinx(BuildContext):
76+
cmd = 'sphinx'
77+
fun = 'sphinx'

.waf-tools/sphinx_build.py

Lines changed: 0 additions & 79 deletions
This file was deleted.

wscript

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def options(opt):
1212
opt.load(['compiler_cxx', 'gnu_dirs'])
1313
opt.load(['default-compiler-flags',
1414
'coverage', 'sanitizers', 'boost',
15-
'doxygen', 'sphinx_build'],
15+
'doxygen', 'sphinx'],
1616
tooldir=['.waf-tools'])
1717

1818
optgrp = opt.add_option_group('ChronoSync Options')
@@ -22,7 +22,7 @@ def options(opt):
2222
def configure(conf):
2323
conf.load(['compiler_cxx', 'gnu_dirs',
2424
'default-compiler-flags', 'boost',
25-
'doxygen', 'sphinx_build'])
25+
'doxygen', 'sphinx'])
2626

2727
conf.env.WITH_TESTS = conf.options.with_tests
2828

0 commit comments

Comments
 (0)