Skip to content

Commit 9efbdc5

Browse files
authored
Merge pull request #112 from G8XSU/main
Use Gnu-sed on macosx if available
2 parents 2a8f98f + 0a60abb commit 9efbdc5

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

genbindings.sh

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ usage() {
1616
set -e
1717
set -x
1818

19+
function is_gnu_sed(){
20+
sed --version >/dev/null 2>&1
21+
}
22+
1923
if [ "$CC" != "" ]; then
2024
COMMON_COMPILE="$CC -std=c11 -Wall -Wextra -Wno-unused-parameter -Wno-ignored-qualifiers -Wno-unused-function -Wno-nullability-completeness -Wno-pointer-sign -Wdate-time -ffile-prefix-map=$(pwd)="
2125
else
@@ -29,11 +33,11 @@ if [ "$3" = "leaks" ]; then
2933
fi
3034

3135
cp "$1/lightning-c-bindings/include/lightning.h" ./
32-
if [ "$(rustc --version --verbose | grep "host:")" = "host: x86_64-apple-darwin" ] || [ "$(rustc --version --verbose | grep "host:")" = "host: aarch64-apple-darwin" ]; then
33-
# OSX sed is for some reason not compatible with GNU sed
34-
sed -i '' "s/TransactionOutputs/C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ/g" ./lightning.h
35-
else
36+
if is_gnu_sed; then
3637
sed -i "s/TransactionOutputs/C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ/g" ./lightning.h
38+
else
39+
# OSX sed is for some reason not compatible with GNU sed
40+
sed -i '' "s/TransactionOutputs/C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ/g" ./lightning.h
3741
fi
3842

3943
if [ "$LDK_GARBAGECOLLECTED_GIT_OVERRIDE" = "" ]; then
@@ -71,11 +75,11 @@ if [ "$2" != "wasm" ]; then
7175
LDK_TARGET_CPU="sandybridge"
7276
fi
7377

74-
if [ "$(rustc --version --verbose | grep "host:")" = "host: x86_64-apple-darwin" ] || [ "$(rustc --version --verbose | grep "host:")" = "host: aarch64-apple-darwin" ]; then
75-
# OSX sed is for some reason not compatible with GNU sed
76-
sed -i '' "s/^ <version>.*<\/version>/ <version>${LDK_GARBAGECOLLECTED_GIT_OVERRIDE:1:100}<\/version>/g" pom.xml
77-
else
78+
if is_gnu_sed; then
7879
sed -i "s/^ <version>.*<\/version>/ <version>${LDK_GARBAGECOLLECTED_GIT_OVERRIDE:1:100}<\/version>/g" pom.xml
80+
else
81+
# OSX sed is for some reason not compatible with GNU sed
82+
sed -i '' "s/^ <version>.*<\/version>/ <version>${LDK_GARBAGECOLLECTED_GIT_OVERRIDE:1:100}<\/version>/g" pom.xml
7983
fi
8084

8185
echo "Creating Java bindings..."

0 commit comments

Comments
 (0)