-
Notifications
You must be signed in to change notification settings - Fork 638
/
Copy pathgenerate-python.sh
executable file
·98 lines (84 loc) · 3.83 KB
/
generate-python.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/bash
# Usage: ./generate-python.sh
#
# Based on https://github.com/RosettaCommons/binder
#
# binder config: llvm-14
#
PYBIND11_VERSION=$(dpkg -s pybind11-dev | grep '^Version:' | cut -d " " -f2)
SYSTEM_PYBIND11_MM_VERSION=$(echo $PYBIND11_VERSION | cut -d. -f1).$(echo $PYBIND11_VERSION | cut -d. -f2)
PYBIND11_MM_VERSION=${PYBIND11_MM_VERSION:-$SYSTEM_PYBIND11_MM_VERSION}
echo "System PYBIND11_VERSION: $PYBIND11_VERSION (Used for wrapper: $PYBIND11_MM_VERSION)"
MODULE_NAME=mrpt
WRAP_OUT_DIR=src
mkdir -p $WRAP_OUT_DIR
$HOME/code/binder/build/source/binder \
--root-module=pymrpt \
--prefix $WRAP_OUT_DIR/ \
--bind pymrpt \
-config ./python.conf \
./all_wrapped_mrpt_headers.hpp \
-- \
-iwithsysroot/usr/include/c++/11/ \
-iwithsysroot/usr/include/x86_64-linux-gnu/c++/11/ \
-std=c++17 -DNDEBUG \
-DMRPT_BUILDING_PYTHON_WRAPPER \
-I$HOME/code/mrpt/build-Release/include/mrpt-configuration/ \
-I$HOME/code/mrpt/build-Release/3rdparty/nanogui/ \
-I/usr/include/eigen3 \
-I$HOME/code/mrpt/3rdparty/nanoflann/include/ \
-I$HOME/code/mrpt/3rdparty/nanogui/ext/nanovg/src/ \
-I$HOME/code/mrpt/3rdparty/nanogui/include/ \
-I$HOME/code/mrpt/libs/apps/include/ \
-I$HOME/code/mrpt/libs/bayes/include/ \
-I$HOME/code/mrpt/libs/comms/include/ \
-I$HOME/code/mrpt/libs/config/include/ \
-I$HOME/code/mrpt/libs/containers/include/ \
-I$HOME/code/mrpt/libs/core/include/ \
-I$HOME/code/mrpt/libs/expr/include/ \
-I$HOME/code/mrpt/libs/gui/include/ \
-I$HOME/code/mrpt/libs/hwdrivers/include/ \
-I$HOME/code/mrpt/libs/img/include/ \
-I$HOME/code/mrpt/libs/io/include/ \
-I$HOME/code/mrpt/libs/kinematics/include/ \
-I$HOME/code/mrpt/libs/maps/include/ \
-I$HOME/code/mrpt/libs/math/include/ \
-I$HOME/code/mrpt/libs/nav/include/ \
-I$HOME/code/mrpt/libs/obs/include/ \
-I$HOME/code/mrpt/libs/opengl/include/ \
-I$HOME/code/mrpt/libs/poses/include/ \
-I$HOME/code/mrpt/libs/random/include/ \
-I$HOME/code/mrpt/libs/rtti/include/ \
-I$HOME/code/mrpt/libs/serialization/include/ \
-I$HOME/code/mrpt/libs/serialization/include/ \
-I$HOME/code/mrpt/libs/slam/include/ \
-I$HOME/code/mrpt/libs/graphs/include/ \
-I$HOME/code/mrpt/libs/system/include/ \
-I$HOME/code/mrpt/libs/tfest/include \
-I$HOME/code/mrpt/libs/topography/include \
-I$HOME/code/mrpt/libs/typemeta/include \
-I$HOME/code/mrpt/libs/vision/include/ \
# Workarounds to binder limitations:
# These are to ensure multiplatform portatbility of generated code
# (e.g. avoid build errors in armhf)
# -----------------------------------------------------------------------------
# Replace:
# struct std::chrono::time_point<class mrpt::Clock, struct std::chrono::duration<long, struct std::ratio<1, 10000000> > >
# mrpt::Clock::time_point
find $WRAP_OUT_DIR -name "*.cpp" | xargs -I FIL \
sed -i -e 's/struct std::chrono::time_point<class mrpt::Clock, struct std::chrono::duration<long, struct std::ratio<1, 10000000> > >/mrpt::Clock::time_point/g' FIL
find $WRAP_OUT_DIR -name "*.cpp" | xargs -I FIL \
sed -i -e 's/std::chrono::time_point<mrpt::Clock,std::chrono::duration<long, std::ratio<1, 10000000> >>/mrpt::Clock::time_point/g' FIL
find $WRAP_OUT_DIR -name "*.cpp" | xargs -I FIL \
sed -i -e 's/std::chrono::duration<long, struct std::ratio<1, 10000000> >/std::chrono::duration<int64_t,struct std::ratio<1,10000000>>/g' FIL
find $WRAP_OUT_DIR -name "*.cpp" | xargs -I FIL \
sed -i -e 's/std::chrono::duration<long,/std::chrono::duration<int64_t,/g' FIL
sed -i -e 's/unsigned long/size_t/g' $WRAP_OUT_DIR/std/array.cpp
sed -i -e 's/unsigned long/size_t/g' $WRAP_OUT_DIR/std/stl_multimap.cpp
# (long)
# (int64_t)
find $WRAP_OUT_DIR -name "*.cpp" | xargs -I FIL \
sed -i -e 's/(long)/(int64_t)/g' FIL
# applying manual patches:
echo "Applying manual patches to pybind11 code..."
find . -name "patch-0*.diff" | sort | xargs -I FIL bash -c "echo \"Applying patch: FIL\" && git apply FIL --ignore-whitespace"