Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ad_map_access/generated/include/ad/map/point/GeoPoint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#pragma once

#include <iomanip>
#include <iostream>
#include <limits>
#include <memory>
Expand Down Expand Up @@ -171,6 +172,7 @@ inline std::ostream &operator<<(std::ostream &os, GeoPoint const &_value)
{
os << "GeoPoint(";
os << "longitude:";
os << std::setprecision(9);
os << _value.longitude;
os << ",";
os << "latitude:";
Expand Down
3 changes: 3 additions & 0 deletions ad_map_access/python/generate_python_lib.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ def main():
additional_replacements_component.append(
("bp::class_< std::vector<boost::geometry::model::polygon<boost::geometry::model::d2::point_xy<double>, false, true>>, boost::noncopyable >( \"PolygonVector\" )", "// generate_python_lib.py: PolygonVector manually removed here")
)
additional_replacements_component.append(
("bp::class_<std::vector<boost::geometry::model::polygon<boost::geometry::model::d2::point_xy<double>, false, true>>, boost::noncopyable>( \"PolygonVector\" )", "// generate_python_lib.py: PolygonVector manually removed here")
)
additional_replacements_component.append(
(".def( bp::indexing::vector_suite< std::vector< boost::geometry::model::polygon<boost::geometry::model::d2::point_xy<double, boost::geometry::cs::cartesian>, false, true, std::vector, std::vector, std::allocator, std::allocator> > >() );", "// generate_python_lib.py: PolygonVector manually removed here")
)
Expand Down
2 changes: 2 additions & 0 deletions ad_physics/python/generate_python_lib.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ def main():
("polygon_less__boost_scope_geometry_scope_model_scope_d2_scope_point_xy_less__double__greater__comma__false_comma__true__greater_", "Polygon"),
("polygon_less__boost_scope_geometry_scope_model_scope_d2_scope_point_xy_less__double__greater__comma__false__greater_", "Polygon"),
("polygon_less_boost_scope_geometry_scope_model_scope_d2_scope_point_xy_less_double_greater__comma__false_greater_", "Polygon"),
("polygon_less_boost_scope_geometry_scope_model_scope_d2_scope_point_xy_less_double_greater__comma__false_comma__true_greater_", "Polygon"),

("polygon_less__boost_scope_geometry_scope_model_scope_d2_scope_Point_comma__false_comma__true_comma__std_scope_vector_comma__std_scope_vector_comma__std_scope_allocator_comma__std_scope_allocator__greater_", "Polygon"),
("polygon_less__boost_scope_geometry_scope_model_scope_d2_scope_Point_comma__false_comma__true__greater_", "Polygon"),
("polygon_less_boost_scope_geometry_scope_model_scope_d2_scope_Point_comma__false_comma__true_greater_", "Polygon"),
("polygon_less__boost_scope_geometry_scope_model_scope_d2_scope_Point_comma__false__greater_", "Polygon"),
("polygon_less_boost_scope_geometry_scope_model_scope_d2_scope_Point_comma__false_greater_", "Polygon"),

Expand Down
49 changes: 46 additions & 3 deletions cmake/python/python_wrapper_helper.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@

import os
import re
import sys

from pygccxml import parser
from pygccxml import utils
from pyplusplus import module_builder, decl_wrappers

import fileinput

import subprocess
import warnings


Expand All @@ -40,6 +39,46 @@ def get_list_of_files(directory, ignore_files):

return all_files

def get_safe_compiler_include_dirs(compiler_path, language="c++"):
"""
Gets system includes to fix <cmath> errors, but filters out
internal compiler intrinsics to prevent CastXML __builtin errors.
"""
cmd = [compiler_path, "-E", "-x", language, "-", "-v"]
try:
result = subprocess.run(cmd, input=b'', capture_output=True, check=True)
except subprocess.CalledProcessError:
print(f"\n[!] ERROR extracting paths: {e.stderr.decode('utf-8', errors='ignore')}\n")
return []

stderr_output = result.stderr.decode('utf-8', errors='ignore')
include_dirs = []
in_search_list = False

for line in stderr_output.splitlines():
if line.startswith("#include <...> search starts here:"):
in_search_list = True
continue
elif line.startswith("End of search list."):
break

if in_search_list:
raw_path = line.strip().replace(" (framework directory)", "")
normalized_path = os.path.normpath(raw_path)

# --- THE CRITICAL FILTER ---
# Exclude compiler-internal intrinsic headers
if "include-fixed" in normalized_path:
continue
if "/usr/lib/gcc" in normalized_path and "include" in normalized_path:
continue
if "/lib/clang/" in normalized_path:
continue

if os.path.isdir(normalized_path):
include_dirs.append(normalized_path)
print(f"Detected safe compiler include directories: {include_dirs}")
return include_dirs

def generate_python_wrapper(header_directories, include_paths, library_name, cpp_filename, declarations, main_namespace="", ignore_declarations={}, ignore_files={}, add_declarations={}):
"""
Expand Down Expand Up @@ -71,13 +110,17 @@ def generate_python_wrapper(header_directories, include_paths, library_name, cpp

# Find out the xml generator (gccxml or castxml)
generator_path, generator_name = utils.find_xml_generator()
compiler = "@CXX@"
compiler = "@CMAKE_CXX_COMPILER@"

# Fetch the safe system include directories
safe_includes = get_safe_compiler_include_dirs(compiler)

# Create configuration for CastXML
xml_generator_config = parser.xml_generator_configuration_t(
xml_generator_path=generator_path,
xml_generator=generator_name,
compiler=compiler,
include_paths=safe_includes,
start_with_declarations=declarations)

# Set include dirs and cflags to avoid warnings and errors
Expand Down
3 changes: 3 additions & 0 deletions colcon.meta
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@
"ad_map_access": {
"dependencies": ["ad_map_opendrive_reader"]
},
"ad_map_access_qgis": {
"dependencies": ["ad_map_access"]
},
}
}
Loading