Skip to content

Commit d0a8c4e

Browse files
authored
Merge pull request swiftlang#68318 from compnerd/plugin-helper-helper-helper
test: introduce a helper for building mock plugins
2 parents 6c4ae5d + af79bc2 commit d0a8c4e

5 files changed

+28
-28
lines changed

test/Macros/lit.local.cfg

+24
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
11
# '-enable-experimental-feature Macros' requires an asserts build.
22
if 'asserts' not in config.available_features:
33
config.unsupported = True
4+
5+
config.subsitutions = list(config.substitutions)
6+
7+
def get_target_os():
8+
import re
9+
(run_cpu, run_vendor, run_os, run_version) = re.match('([^-]+)-([^-]+)-([^0-9]+)(.*)', config.variant_triple).groups()
10+
return run_os
11+
12+
if get_target_os() in ['windows-msvc']:
13+
config.substitutions.insert(
14+
0,
15+
(
16+
'%swift-build-cxx-plugin',
17+
'%clang -isysroot %host_sdk -I %swift_src_root/include -L %swift-lib-dir -l_swiftMockPlugin'
18+
)
19+
)
20+
else:
21+
config.substitutions.insert(
22+
0,
23+
(
24+
'%swift-build-cxx-plugin',
25+
'%clang -isysroot %host_sdk -I %swift_src_root/include -L %swift-lib-dir -l_swiftMockPlugin -Xlinker -rpath -Xlinker %swift-lib-dir'
26+
)
27+
)

test/Macros/macro_plugin_basic.swift

+1-7
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,7 @@
33
// RUN: %empty-directory(%t)
44
// RUN: split-file %s %t
55

6-
// RUN: %clang \
7-
// RUN: -isysroot %host_sdk \
8-
// RUN: -I %swift_src_root/include \
9-
// RUN: -L %swift-lib-dir -l_swiftMockPlugin \
10-
// RUN: -Wl,-rpath,%swift-lib-dir \
11-
// RUN: -o %t/mock-plugin \
12-
// RUN: %t/plugin.c
6+
// RUN: %swift-build-cxx-plugin -o %t/mock-plugin %t/plugin.c
137

148
// RUN: env SWIFT_DUMP_PLUGIN_MESSAGING=1 %swift-target-frontend \
159
// RUN: -typecheck -verify \

test/Macros/macro_plugin_error.swift

+1-7
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,7 @@
33
// RUN: %empty-directory(%t)
44
// RUN: split-file %s %t
55

6-
// RUN: %clang \
7-
// RUN: -isysroot %host_sdk \
8-
// RUN: -I %swift_src_root/include \
9-
// RUN: -L %swift-lib-dir -l_swiftMockPlugin \
10-
// RUN: -Wl,-rpath,%swift-lib-dir \
11-
// RUN: -o %t/mock-plugin \
12-
// RUN: %t/plugin.c
6+
// RUN: %swift-build-cxx-plugin -o %t/mock-plugin %t/plugin.c
137

148
// RUN: env SWIFT_DUMP_PLUGIN_MESSAGING=1 %swift-target-frontend \
159
// RUN: -typecheck -verify \

test/Macros/macro_plugin_searchorder.swift

+1-7
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,7 @@
3737
// RUN: %t/src/MacroDefinition.swift
3838

3939
//#-- For -load-plugin-executable
40-
// RUN: %clang \
41-
// RUN: -isysroot %host_sdk \
42-
// RUN: -I %swift_src_root/include \
43-
// RUN: -L %swift-lib-dir -l_swiftMockPlugin \
44-
// RUN: -Wl,-rpath,%swift-lib-dir \
45-
// RUN: -o %t/libexec/MacroDefinitionPlugin \
46-
// RUN: %t/src/MacroDefinition.c
40+
// RUN: %swift-build-cxx-plugin -o %t/libexec/MacroDefinitionPlugin %t/src/MacroDefinition.c
4741

4842
//#-- Expect -load-plugin-library
4943
// RUN: %target-build-swift %t/src/test.swift \

test/Macros/macro_swiftdeps.swift

+1-7
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,7 @@
1515
// RUN: %S/Inputs/syntax_macro_definitions.swift
1616

1717
//#-- Prepare the macro executable plugin.
18-
// RUN: %clang \
19-
// RUN: -isysroot %host_sdk \
20-
// RUN: -I %swift_src_root/include \
21-
// RUN: -L %swift-lib-dir -l_swiftMockPlugin \
22-
// RUN: -Wl,-rpath,%swift-lib-dir \
23-
// RUN: -o %t/mock-plugin \
24-
// RUN: %t/src/plugin.c
18+
// RUN: %swift-build-cxx-plugin -o %t/mock-plugin %t/src/plugin.c
2519

2620
//#-- Prepare the macro library.
2721
// RUN: %target-swift-frontend \

0 commit comments

Comments
 (0)