File tree Expand file tree Collapse file tree 3 files changed +53
-9
lines changed Expand file tree Collapse file tree 3 files changed +53
-9
lines changed Original file line number Diff line number Diff line change @@ -97,14 +97,26 @@ jobs:
97
97
LDK_C_BINDINGS_BASE : /home/runner/work/ldk-swift/ldk-swift/ldk-c-bindings
98
98
LLVM_CLANG_ASAN_PATH : /usr/lib/llvm-11/lib/clang/11.0.0/lib/linux/libclang_rt.asan-x86_64.a
99
99
RUST_BACKTRACE : 1
100
- - name : Test Swift bindings package
100
+ - name : Test Swift bindings package without address sanitizer
101
101
run : |
102
+ python ci/toggle_address_sanitation_library.py off
102
103
cd ci/LDKSwift
103
104
../../swift-5.6-RELEASE-ubuntu20.04/usr/bin/swift test -v
105
+ cd ../../
104
106
env :
105
107
LDK_C_BINDINGS_BASE : /home/runner/work/ldk-swift/ldk-swift/ldk-c-bindings
106
108
LLVM_CLANG_ASAN_PATH : /usr/lib/llvm-11/lib/clang/11.0.0/lib/linux/libclang_rt.asan-x86_64.a
107
109
RUST_BACKTRACE : 1
110
+ - name : Test Swift bindings package with address sanitizer
111
+ run : |
112
+ python ci/toggle_address_sanitation_library.py on
113
+ cd ci/LDKSwift
114
+ ../../swift-5.6-RELEASE-ubuntu20.04/usr/bin/swift test -v
115
+ env :
116
+ LDK_C_BINDINGS_BASE : /home/runner/work/ldk-swift/ldk-swift/ldk-c-bindings
117
+ LLVM_CLANG_ASAN_PATH : /usr/lib/llvm-11/lib/clang/11.0.0/lib/linux/libclang_rt.asan-x86_64.a
118
+ RUST_BACKTRACE : 1
119
+
108
120
- name : Check that the latest headers are in the swift repo
109
121
run : |
110
122
git diff --exit-code
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ let package = Package(
13
13
// .library(name: "LDKSwift", type: .dynamic, targets: ["LDKSwift"])
14
14
] ,
15
15
dependencies: [
16
- . package ( url: " https://github.com/apple/swift-crypto.git " , " 1.0.0 " ..< " 3.0.0 " )
16
+ . package ( url: " https://github.com/apple/swift-crypto.git " , " 1.0.0 " ..< " 3.0.0 " )
17
17
] ,
18
18
targets: [
19
19
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
@@ -46,17 +46,15 @@ let package = Package(
46
46
swiftSettings: nil ,
47
47
linkerSettings: [
48
48
. linkedLibrary( String ( utf8String: getenv ( " LDK_C_BINDINGS_BASE " ) !) ! + " /lightning-c-bindings/target/debug/libldk.a " ) ,
49
- // .linkedLibrary(String(utf8String: getenv("LDK_C_BINDINGS_BASE") ?? "~/Developer/ldk-c-bindings")! + "/lightning-c-bindings/target/debug/libldk.a"),
50
- // .linkedLibrary("/usr/lib/llvm-11/lib/clang/11.0.0/lib/linux/libclang_rt.asan-x86_64.a")
51
- . linkedLibrary( String ( utf8String: getenv ( " LLVM_CLANG_ASAN_PATH " ) !) !)
49
+ . linkedLibrary( String ( utf8String: getenv ( " LLVM_CLANG_ASAN_PATH " ) !) !) ,
52
50
] ) ,
53
51
. testTarget(
54
52
name: " LDKSwiftTests " ,
55
53
dependencies: [
56
- " LDKSwift " ,
57
- " LDKHeaders " ,
58
- . product( name: " Crypto " , package : " swift-crypto " )
59
- ] ,
54
+ " LDKSwift " ,
55
+ " LDKHeaders " ,
56
+ . product( name: " Crypto " , package : " swift-crypto " )
57
+ ] ,
60
58
path: nil ,
61
59
exclude: [ ] ,
62
60
// exclude: ["SampleTest.swift"],
Original file line number Diff line number Diff line change
1
+ import re
2
+ import os
3
+ import sys
4
+
5
+ directory_path = os .path .dirname (os .path .realpath (__file__ ))
6
+ file_path = f'{ directory_path } /LDKSwift/Package.swift'
7
+ if len (sys .argv ) != 2 :
8
+ sys .exit ('Usage: python3 toggle_address_sanitation_library.py [on/off]' )
9
+
10
+ if not os .path .isfile (file_path ):
11
+ sys .exit (f'Package.swift file is missing' )
12
+
13
+ should_enable_string = sys .argv [1 ]
14
+ if not should_enable_string .lower () in ['on' , 'off' ]:
15
+ sys .exit (f'{ should_enable_string } is not a valid on/off value' )
16
+
17
+ should_enable = True if should_enable_string .lower () == 'on' else False
18
+
19
+ file_in = open (file_path , 'rt' , encoding = 'utf-8' )
20
+ original_contents = file_in .read ()
21
+ file_in .close ()
22
+
23
+ regex = re .compile ("(\/\/)?([^\S\r \n ]*)(\.linkedLibrary\(String\(utf8String: getenv\(\" LLVM_CLANG_ASAN_PATH\" \)!\)!\))" , re .MULTILINE )
24
+ matches = regex .search (original_contents )
25
+
26
+ comment_prefix = ''
27
+ if not should_enable :
28
+ comment_prefix = '//'
29
+
30
+ toggle_result = regex .sub (f'\g<2>{ comment_prefix } \g<3>' , original_contents )
31
+
32
+ file_out = open (file_path , 'wt' , encoding = 'utf-8' )
33
+ file_out .write (toggle_result )
34
+ file_out .close ()
You can’t perform that action at this time.
0 commit comments