File tree Expand file tree Collapse file tree 2 files changed +38
-6
lines changed Expand file tree Collapse file tree 2 files changed +38
-6
lines changed Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env python
2
+ # sourcekitd_path_sanitize.py - Cleans up paths from sourcekitd-test output
3
+ #
4
+ # This source file is part of the Swift.org open source project
5
+ #
6
+ # Copyright (c) 2014 - 2019 Apple Inc. and the Swift project authors
7
+ # Licensed under Apache License v2.0 with Runtime Library Exception
8
+ #
9
+ # See https://swift.org/LICENSE.txt for license information
10
+ # See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
11
+
12
+ import re
13
+ import sys
14
+
15
+ SWIFTMODULE_BUNDLE_RE = re .compile (
16
+ r'key.filepath: ".*[/\\](.*)\.swiftmodule[/\\].*\.swiftmodule"' )
17
+ SWIFTMODULE_RE = re .compile (r'key.filepath: ".*[/\\](.*)\.swiftmodule"' )
18
+ SWIFT_RE = re .compile (r'key.filepath: ".*[/\\](.*)\.swift"' )
19
+ PCM_RE = re .compile (r'key.filepath: ".*[/\\](.*)-[0-9A-Z]*\.pcm"' )
20
+ HEADER_RE = re .compile (r' file=\\".*[/\\](.*)\.h\\"' )
21
+
22
+ try :
23
+ for line in sys .stdin .readlines ():
24
+ line = re .sub (SWIFTMODULE_BUNDLE_RE ,
25
+ r'key.filepath: \1.swiftmodule' , line )
26
+ line = re .sub (SWIFTMODULE_RE , r'key.filepath: \1.swiftmodule' , line )
27
+ line = re .sub (SWIFT_RE , r'key.filepath: \1.swift' , line )
28
+ line = re .sub (PCM_RE , r'key.filepath: \1.pcm' , line )
29
+ line = re .sub (HEADER_RE , r' file=\1.h' , line )
30
+ sys .stdout .write (line )
31
+ except KeyboardInterrupt :
32
+ sys .stdout .flush ()
Original file line number Diff line number Diff line change
1
+ import os
2
+
3
+
1
4
if ' sourcekit' not in config.available_features:
2
5
config.unsupported = True
3
6
@@ -9,13 +12,10 @@ elif 'swift_evolve' in config.available_features:
9
12
config.unsupported = True
10
13
11
14
else:
12
- sed_clean = r" sed -e 's/key.filepath: \" .*[/\\\\]\\(.*\\)\\.swiftmodule[/\\\\].*\\.swiftmodule\" /key.filepath: \\1.swiftmodule/g'"
13
- sed_clean += r" | sed -e 's/key.filepath: \" .*[/\\\\]\\(.*\\)\\.swiftmodule\" /key.filepath: \\1.swiftmodule/g'"
14
- sed_clean += r" | sed -e 's/key.filepath: \" .*[/\\\\]\\(.*\\)\\.swift\" /key.filepath: \\1.swift/g'"
15
- sed_clean += r" | sed -e 's/key.filepath: \" .*[/\\\\]\\(.*\\)-[0-9A-Z]*\\.pcm\" /key.filepath: \\1.pcm/g'"
16
- sed_clean += r" | sed -e 's/ file=\\\\\" .*[/\\\\]\\(.*\\)\\.h\\\\\" / file=\\1.h/g'"
15
+ sk_path_sanitize = os.path.join(os.path.dirname(__file__), ' Inputs' , ' sourcekitd_path_sanitize.py' )
17
16
18
17
config.substitutions.append( (' %sourcekitd-test' , config.sourcekitd_test) )
19
18
config.substitutions.append( (' %complete-test' , config.complete_test) )
20
19
config.substitutions.append( (' %swiftlib_dir' , config.swiftlib_dir) )
21
- config.substitutions.append( (' %sed_clean' , sed_clean) )
20
+ config.substitutions.append( (' %sed_clean' , ' %s %s' % (sys.executable, sk_path_sanitize) )
21
+ )
You can’t perform that action at this time.
0 commit comments