Page MenuHomec4science

SConscript
No OneTemporary

File Metadata

Created
Thu, Mar 28, 16:37

SConscript

# -*- mode:python; coding: utf-8 -*-
# vim: set ft=python:
#
# Copyright (©) 2016-2024 EPFL (École Polytechnique Fédérale de Lausanne),
# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
# Copyright (©) 2020-2024 Lucas Frérot
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
from __future__ import print_function
from SCons.Script import Import, Glob, Dir, File
def add_sources(source_list, dirname, fnames):
source_list += Dir(dirname).glob('*.hh')
source_list += Dir(dirname).glob('*.cpp')
Import('main_env')
Import('libTamaas')
doc_env = main_env.Clone()
doc_env['man_section'] = 7
doc_targets = []
# Generate Doxygen API documentation
doc_env.Tool('doxygen')
if doc_env['has_doxygen']:
# Generating Doxyfile
doxygen_verbose = {True: "NO", False: "YES"}
doxyfile_target = doc_env.Substfile('doxygen/Doxyfile',
'doxygen/Doxyfile.in',
SUBST_DICT={
'@version@': '$version',
'@build_dir@': Dir('doxygen').path,
'@logo@': File('icon.svg').path,
'@src_dir@': Dir('#src').abspath,
'@verbose@':
doxygen_verbose[doc_env["verbose"]],
})
doxygen_target = doc_env.Doxygen('doxygen/xml/index.xml',
[doxyfile_target, 'icon.svg', 'icon.ico'])
# Adding all source files as dependencies
sources = []
Dir('#src').walk(add_sources, sources)
doc_env.Depends(doxygen_target, sources)
doc_targets.append(doxygen_target)
# Generate Sphinx User documentation
sphinx_targets_map = {
"html": "sphinx/html/index.html",
"man": "sphinx/tamaas.${man_section}",
"latex": "sphinx/latex/Tamaas.tex"
}
doc_env.Tool('sphinx')
sphinx_targets = None
if doc_env['has_sphinx'] and len(doc_targets) != 0:
doc_env['IMPLICIT_COMMAND_DEPENDENCIES'] = 0
sphinx_sources = [Glob('sphinx/source/*'), Glob('sphinx/source/figures/*')]
sphinx_targets = {
builder: doc_env.Sphinx(sphinx_targets_map[builder], sphinx_sources)
for builder in doc_env['doc_builders']
}
for target in sphinx_targets.values():
doc_env.Depends(target, doxygen_target)
if main_env['build_python']:
doc_env.Depends(target, 'build-python')
doc_targets += list(sphinx_targets.values())
# Alias for both docs
main_env.Alias('build-doc', doc_targets)
# Install target for documentation
share = Dir('share', doc_env['prefix'])
doc_install = []
sphinx_prefix_map = {}
if sphinx_targets is not None:
if "html" in doc_env['doc_builders']:
doc_install.append(doc_env.Install(
target=share.Dir('doc').Dir('tamaas'),
source=sphinx_targets['html'][0].dir))
if "man" in doc_env['doc_builders']:
doc_install.append(doc_env.Install(
target=share.Dir('man') .Dir(doc_env.subst('man${man_section}')),
source=sphinx_targets['man']))
main_env.Alias('install-doc', doc_install)

Event Timeline