summaryrefslogtreecommitdiffstats
path: root/source-builder
diff options
context:
space:
mode:
authorChris Johns <chris@contemporary.net.au>2023-03-27 13:49:38 +1100
committerChris Johns <chris@contemporary.net.au>2023-04-05 10:09:21 +1000
commit9919f1217c66dad5e721802a265cdbdcf6070069 (patch)
tree43c9a31e661d2ac886ff2e906ed8c3bb59631670 /source-builder
parentdtc: Disable warnings (diff)
downloadrtems-source-builder-9919f1217c66dad5e721802a265cdbdcf6070069.tar.bz2
gdb: Use a virtual environment if present
- Detect and use a virtual environment if present - Supports MacOS with python.org in a venv Updates #4892
Diffstat (limited to 'source-builder')
-rw-r--r--source-builder/config/gdb-common-1.cfg58
1 files changed, 35 insertions, 23 deletions
diff --git a/source-builder/config/gdb-common-1.cfg b/source-builder/config/gdb-common-1.cfg
index 9d67da0..a52e64d 100644
--- a/source-builder/config/gdb-common-1.cfg
+++ b/source-builder/config/gdb-common-1.cfg
@@ -58,7 +58,7 @@
%define gdb-enable-python %(command -v python2 || true)
%endif
%if %{gdb-enable-python} == %{nil}
- %define gdb-enable-python %(command -v python || true})
+ %define gdb-enable-python %(command -v python || true})
%endif
%endif
%if %{gdb-enable-python} == %{nil}
@@ -79,6 +79,9 @@
%endif
%if %{gdb-python-config} == %{nil}
%define gdb-python-config %(command -v %{gdb-enable-python}-config || true)
+ %if %{gdb-python-config} == %{nil}
+ %define gdb-python-config %(command -v %(basename %{gdb-enable-python})-config || true)
+ %endif
%endif
%define gdb-python-ver-mm %(%{gdb-enable-python} --version 2>&1 | sed -e 's/.* //g' | rev | cut -d'.' -f2- | rev)
%define gdb-python-ver-major %(echo "%{gdb-python-ver-mm}" | sed -e 's/\..*//')
@@ -100,30 +103,39 @@
%if %{gdb-python-header-check} == not-found && !%{_rsb_getting_source}
%error "gdb: python: header file not found: %{gdb-python-ver-header}, please install"
%endif
-#
-# Too hard to find on MacOS (darwin), the header is good enough.
-#
-%ifnos darwin
- %if %{host_ldflags} == %{nil}
- %define gdb-host-libs %{nil}
- %else
- %define gdb-host-libs -L '%{host_ldflags}'
- %endif
- %if %{gdb-python-config} != %{nil}
- %define gdb-python-lib-filter awk 'BEGIN{FS=" "}/python/{for(i=1;i<NF;++i)if(match($i,".*lpython.*")) print "lib"substr($i,3)"*";}'
- %if %{gdb-python-ver-major} < 3 || \
- %{gdb-python-ver-major} == 3 && %{gdb-python-ver-minor} < 8
- %define gdb-python-config-lib-check-flags --ldflags
- %else
- %define gdb-python-config-lib-check-flags --ldflags --embed
- %endif
- %define gdb-python-config-libs %(%{gdb-python-config} %{gdb-python-config-lib-check-flags} | %{gdb-python-lib-filter})
- %define gdb-python-lib-check %(%{_sbdir}/sb/rtems-build-dep -c %{__cc} %{gdb-host-libs} -l %{gdb-python-config-libs})
+%if %{host_ldflags} == %{nil}
+ %define gdb-host-libs %{nil}
+%else
+ %define gdb-host-libs -L '%{host_ldflags}'
+%endif
+%if %{gdb-python-config} != %{nil}
+ %define gdb-python-lib-filter awk 'BEGIN{FS=" "}/python/{for(i=1;i<NF;++i)if(match($i,".*lpython.*")) print "lib"substr($i,3)"\\*";}'
+ %define gdb-python-libpath-filter awk 'BEGIN{FS=" "}/python/{for(i=1;i<NF;++i)if(match($i,".*L.*")) print substr($i,3);}'
+ %if %{gdb-python-ver-major} < 3 || \
+ %{gdb-python-ver-major} == 3 && %{gdb-python-ver-minor} < 8
+ %define gdb-python-config-lib-check-flags --ldflags
%else
- %define gdb-python-lib-check %(%{_sbdir}/sb/rtems-build-dep -c %{__cc} %{gdb-host-libs} -l %{gdb-python-ver-lib})
+ %define gdb-python-config-lib-check-flags --ldflags --embed
%endif
- %if %{gdb-python-lib-check} == not-found && !%{_rsb_getting_source}
- %error "gdb: python: library file not found: %{gdb-python-ver-lib}, please install"
+ %define gdb-python-config-libs %(%{gdb-python-config} %{gdb-python-config-lib-check-flags} | %{gdb-python-lib-filter})
+ %define gdb-python-config-libpath %(%{gdb-python-config} %{gdb-python-config-lib-check-flags} | %{gdb-python-libpath-filter} | uniq)
+ %define gdb-python-lib-check %(%{_sbdir}/sb/rtems-build-dep -c %{__cc} %{gdb-host-libs} -L %{gdb-python-config-libpath} -l %{gdb-python-config-libs})
+%else
+ %define gdb-python-lib-check %(%{_sbdir}/sb/rtems-build-dep -c %{__cc} %{gdb-host-libs} -l %{gdb-python-ver-lib})
+%endif
+%if %{gdb-python-lib-check} == not-found && !%{_rsb_getting_source}
+ %error "gdb: python: library file not found: %{gdb-python-ver-lib}, please install"
+%endif
+
+#
+# If in a virtual environment use that as GDB will look 'bin/python' under it
+# Supportted in GDB 13 and later.
+#
+%define gdb_version_major %(echo "%{gdb_version}" | sed -e 's/\..*//')
+%if %{gdb_version_major} >= 13
+ %define python-venv %(echo $VIRTUAL_ENV)
+ %if %{python-venv} != %{nil}
+ %define gdb-enable-python %{python-venv}
%endif
%endif