geometry/doc/index/make_qbk.py
Andrey Semashev e922b89e36 Fix doxygen_xml2qbk execution from make_qbk.py.
When b2 invokes doc/make_qbk.py, it passes a relative path to the compiled
doxygen_xml2qbk executable. This path becomes invalid if used from a directory
different from doc, which may happen as make_qbk.py changes the current
directory during its execution. Additionally, doc/index/make_qbk.py invokes
doxygen_xml2qbk unqualified, which requires the executable to be in PATH and
is never the case unless the user has pre-compiled and placed it accordingly.

To fix this, first resolve the paths to doxygen and doxygen_xml2qbk to absolute
paths before changing the current directory. Additionally, pass the resolved
path to doxygen_xml2qbk to doc/index/make_qbk.py via the DOXYGEN_XML2QBK
environment variable.

Fixes https://github.com/boostorg/geometry/issues/1311.
2024-09-25 02:37:00 +03:00

79 lines
3.3 KiB
Python
Executable File

#! /usr/bin/env python
# -*- coding: utf-8 -*-
# ===========================================================================
# Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands.
# Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
#
# This file was modified by Oracle on 2020.
# Modifications copyright (c) 2020, Oracle and/or its affiliates.
# Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
#
# Use, modification and distribution is subject to the Boost Software License,
# Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)9
# ============================================================================
import os, sys, shutil
# Resolves the path to an executable and returns an absolute path to it
def resolve_executable(orig_path):
resolved_path = shutil.which(orig_path)
if resolved_path is None:
raise Exception("%s is not found or not executable" % orig_path)
return os.path.abspath(resolved_path)
if 'DOXYGEN_XML2QBK' in os.environ:
doxygen_xml2qbk_cmd = os.environ['DOXYGEN_XML2QBK']
elif '--doxygen-xml2qbk' in sys.argv:
doxygen_xml2qbk_cmd = sys.argv[sys.argv.index('--doxygen-xml2qbk')+1]
else:
doxygen_xml2qbk_cmd = 'doxygen_xml2qbk'
doxygen_xml2qbk_cmd = resolve_executable(doxygen_xml2qbk_cmd)
os.environ['DOXYGEN_XML2QBK'] = doxygen_xml2qbk_cmd
doxygen_xml2qbk_cmd = '"' + doxygen_xml2qbk_cmd + '"'
cmd = doxygen_xml2qbk_cmd
cmd = cmd + " --xml xml/%s.xml"
cmd = cmd + " --start_include boost/"
cmd = cmd + " --output_style alt"
cmd = cmd + " --alt_max_synopsis_length 59"
cmd = cmd + " > generated/%s.qbk"
def run_command(command):
if os.system(command) != 0:
raise Exception("Error running %s" % command)
def remove_all_files(dir_relpath):
if os.path.exists(dir_relpath):
dir_abspath = os.path.join(os.getcwd(), dir_relpath)
print("Boost.Geometry is cleaning Doxygen files in %s" % dir_abspath)
shutil.rmtree(dir_abspath, ignore_errors=True)
remove_all_files("xml/")
run_command("doxygen Doxyfile")
run_command(cmd % ("classboost_1_1geometry_1_1index_1_1rtree", "rtree"))
run_command(cmd % ("group__rtree__functions", "rtree_functions"))
run_command(cmd % ("structboost_1_1geometry_1_1index_1_1linear", "rtree_linear"))
run_command(cmd % ("structboost_1_1geometry_1_1index_1_1quadratic", "rtree_quadratic"))
run_command(cmd % ("structboost_1_1geometry_1_1index_1_1rstar", "rtree_rstar"))
run_command(cmd % ("classboost_1_1geometry_1_1index_1_1dynamic__linear", "rtree_dynamic_linear"))
run_command(cmd % ("classboost_1_1geometry_1_1index_1_1dynamic__quadratic", "rtree_dynamic_quadratic"))
run_command(cmd % ("classboost_1_1geometry_1_1index_1_1dynamic__rstar", "rtree_dynamic_rstar"))
run_command(cmd % ("structboost_1_1geometry_1_1index_1_1indexable", "indexable"))
run_command(cmd % ("structboost_1_1geometry_1_1index_1_1equal__to", "equal_to"))
run_command(cmd % ("group__predicates", "predicates"))
#run_command(cmd % ("group__nearest__relations", "nearest_relations"))
run_command(cmd % ("group__adaptors", "adaptors"))
run_command(cmd % ("group__inserters", "inserters"))
# Clean up generated intermediate files
if "--release-build" in sys.argv:
remove_all_files("xml/")
remove_all_files("html_by_doxygen/")
#run_command("b2")