Skip to content

Commit 2735971

Browse files
Fix file parsing.
1 parent d8831cd commit 2735971

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

.github/workflows/py_binding.yml

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -143,20 +143,14 @@ jobs:
143143
run: |
144144
echo "Detecting STL version using $CXX"
145145
146-
STL_VER_RAW=$($CXX -dM -E -x c++ - <<<'#include <vector>' 2>/dev/null | grep -E '__GLIBCXX__|_LIBCPP_VERSION')
146+
STL_DEFINE=$($CXX -dM -E -x c++ - <<<'#include <vector>' 2>/dev/null | grep -E '^#define (__GLIBCXX__|_LIBCPP_VERSION) ' || true)
147147
148-
if echo "$STL_VER_RAW" | grep -q '__GLIBCXX__'; then
149-
val=$(echo "$STL_VER_RAW" | grep '__GLIBCXX__' | awk '{print $3}')
150-
major=${val:0:4}
151-
minor=${val:4:2}
152-
patch=${val:6:2}
153-
STL_VERSION="libstdcxx${major}.${minor}.${patch}"
154-
elif echo "$STL_VER_RAW" | grep -q '_LIBCPP_VERSION'; then
155-
val=$(echo "$STL_VER_RAW" | grep '_LIBCPP_VERSION' | awk '{print $3}')
156-
major=$((10#${val:0:2}))
157-
minor=$((10#${val:2:2}))
158-
patch=$((10#${val:4:2}))
159-
STL_VERSION="libcxx${major}.${minor}.${patch}"
148+
if echo "$STL_DEFINE" | grep -q '__GLIBCXX__'; then
149+
val=$(echo "$STL_DEFINE" | grep '__GLIBCXX__' | awk '{print $3}')
150+
STL_VERSION="libstdcxx${val}"
151+
elif echo "$STL_DEFINE" | grep -q '_LIBCPP_VERSION'; then
152+
val=$(echo "$STL_DEFINE" | grep '_LIBCPP_VERSION' | awk '{print $3}')
153+
STL_VERSION="libcxx${val}"
160154
else
161155
STL_VERSION="unknown"
162156
fi

0 commit comments

Comments
 (0)