Skip to content

Commit ebe2144

Browse files
committed
Pass through SwiftUI Preview thunk compilation
1 parent b57b679 commit ebe2144

File tree

14 files changed

+147
-7
lines changed

14 files changed

+147
-7
lines changed

examples/ios_app/test/fixtures/bwb.xcodeproj/rules_xcodeproj/bazel/ld.sh

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
set -euo pipefail
44

5+
passthrough_args=("${@:1}")
6+
57
while test $# -gt 0
68
do
79
case $1 in
@@ -10,7 +12,19 @@ do
1012
printf "\0%s\0" "$ld_version" > "$1"
1113
break
1214
;;
13-
esac
1415

16+
-isysroot)
17+
shift
18+
# PATH/DEVELOPER_DIR isn't set when this is called, so we need to calculate
19+
# the developer dir from the sysroot to invoke clang (used below)
20+
developer_dir="${1/\/Platforms\/*/}"
21+
;;
22+
23+
*.preview-thunk.dylib)
24+
# Pass through for SwiftUI Preview thunk compilation
25+
shift
26+
exec "$developer_dir/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" "${passthrough_args[@]}"
27+
;;
28+
esac
1529
shift
1630
done

examples/ios_app/test/fixtures/bwb.xcodeproj/rules_xcodeproj/bazel/swiftc.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import json
44
import os
5+
import subprocess
56
import sys
67
from typing import List
78

@@ -10,6 +11,11 @@ def _main() -> None:
1011
os.system("swiftc -v")
1112
return
1213

14+
# Pass through for SwiftUI Preview thunk compilation
15+
if (any(arg.endswith(".preview-thunk.swift") for arg in sys.argv) and
16+
"-output-file-map" not in sys.argv):
17+
exit(subprocess.run(["swiftc"] + sys.argv[1:], check=False).returncode)
18+
1319
_touch_deps_files(sys.argv)
1420

1521

test/fixtures/cc/bwb.xcodeproj/rules_xcodeproj/bazel/ld.sh

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
set -euo pipefail
44

5+
passthrough_args=("${@:1}")
6+
57
while test $# -gt 0
68
do
79
case $1 in
@@ -10,7 +12,19 @@ do
1012
printf "\0%s\0" "$ld_version" > "$1"
1113
break
1214
;;
13-
esac
1415

16+
-isysroot)
17+
shift
18+
# PATH/DEVELOPER_DIR isn't set when this is called, so we need to calculate
19+
# the developer dir from the sysroot to invoke clang (used below)
20+
developer_dir="${1/\/Platforms\/*/}"
21+
;;
22+
23+
*.preview-thunk.dylib)
24+
# Pass through for SwiftUI Preview thunk compilation
25+
shift
26+
exec "$developer_dir/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" "${passthrough_args[@]}"
27+
;;
28+
esac
1529
shift
1630
done

test/fixtures/cc/bwb.xcodeproj/rules_xcodeproj/bazel/swiftc.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import json
44
import os
5+
import subprocess
56
import sys
67
from typing import List
78

@@ -10,6 +11,11 @@ def _main() -> None:
1011
os.system("swiftc -v")
1112
return
1213

14+
# Pass through for SwiftUI Preview thunk compilation
15+
if (any(arg.endswith(".preview-thunk.swift") for arg in sys.argv) and
16+
"-output-file-map" not in sys.argv):
17+
exit(subprocess.run(["swiftc"] + sys.argv[1:], check=False).returncode)
18+
1319
_touch_deps_files(sys.argv)
1420

1521

test/fixtures/command_line/bwb.xcodeproj/rules_xcodeproj/bazel/ld.sh

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
set -euo pipefail
44

5+
passthrough_args=("${@:1}")
6+
57
while test $# -gt 0
68
do
79
case $1 in
@@ -10,7 +12,19 @@ do
1012
printf "\0%s\0" "$ld_version" > "$1"
1113
break
1214
;;
13-
esac
1415

16+
-isysroot)
17+
shift
18+
# PATH/DEVELOPER_DIR isn't set when this is called, so we need to calculate
19+
# the developer dir from the sysroot to invoke clang (used below)
20+
developer_dir="${1/\/Platforms\/*/}"
21+
;;
22+
23+
*.preview-thunk.dylib)
24+
# Pass through for SwiftUI Preview thunk compilation
25+
shift
26+
exec "$developer_dir/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" "${passthrough_args[@]}"
27+
;;
28+
esac
1529
shift
1630
done

test/fixtures/command_line/bwb.xcodeproj/rules_xcodeproj/bazel/swiftc.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import json
44
import os
5+
import subprocess
56
import sys
67
from typing import List
78

@@ -10,6 +11,11 @@ def _main() -> None:
1011
os.system("swiftc -v")
1112
return
1213

14+
# Pass through for SwiftUI Preview thunk compilation
15+
if (any(arg.endswith(".preview-thunk.swift") for arg in sys.argv) and
16+
"-output-file-map" not in sys.argv):
17+
exit(subprocess.run(["swiftc"] + sys.argv[1:], check=False).returncode)
18+
1319
_touch_deps_files(sys.argv)
1420

1521

test/fixtures/generator/bwb.xcodeproj/rules_xcodeproj/bazel/ld.sh

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
set -euo pipefail
44

5+
passthrough_args=("${@:1}")
6+
57
while test $# -gt 0
68
do
79
case $1 in
@@ -10,7 +12,19 @@ do
1012
printf "\0%s\0" "$ld_version" > "$1"
1113
break
1214
;;
13-
esac
1415

16+
-isysroot)
17+
shift
18+
# PATH/DEVELOPER_DIR isn't set when this is called, so we need to calculate
19+
# the developer dir from the sysroot to invoke clang (used below)
20+
developer_dir="${1/\/Platforms\/*/}"
21+
;;
22+
23+
*.preview-thunk.dylib)
24+
# Pass through for SwiftUI Preview thunk compilation
25+
shift
26+
exec "$developer_dir/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" "${passthrough_args[@]}"
27+
;;
28+
esac
1529
shift
1630
done

test/fixtures/generator/bwb.xcodeproj/rules_xcodeproj/bazel/swiftc.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import json
44
import os
5+
import subprocess
56
import sys
67
from typing import List
78

@@ -10,6 +11,11 @@ def _main() -> None:
1011
os.system("swiftc -v")
1112
return
1213

14+
# Pass through for SwiftUI Preview thunk compilation
15+
if (any(arg.endswith(".preview-thunk.swift") for arg in sys.argv) and
16+
"-output-file-map" not in sys.argv):
17+
exit(subprocess.run(["swiftc"] + sys.argv[1:], check=False).returncode)
18+
1319
_touch_deps_files(sys.argv)
1420

1521

test/fixtures/multiplatform/bwb.xcodeproj/rules_xcodeproj/bazel/ld.sh

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
set -euo pipefail
44

5+
passthrough_args=("${@:1}")
6+
57
while test $# -gt 0
68
do
79
case $1 in
@@ -10,7 +12,19 @@ do
1012
printf "\0%s\0" "$ld_version" > "$1"
1113
break
1214
;;
13-
esac
1415

16+
-isysroot)
17+
shift
18+
# PATH/DEVELOPER_DIR isn't set when this is called, so we need to calculate
19+
# the developer dir from the sysroot to invoke clang (used below)
20+
developer_dir="${1/\/Platforms\/*/}"
21+
;;
22+
23+
*.preview-thunk.dylib)
24+
# Pass through for SwiftUI Preview thunk compilation
25+
shift
26+
exec "$developer_dir/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" "${passthrough_args[@]}"
27+
;;
28+
esac
1529
shift
1630
done

test/fixtures/multiplatform/bwb.xcodeproj/rules_xcodeproj/bazel/swiftc.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import json
44
import os
5+
import subprocess
56
import sys
67
from typing import List
78

@@ -10,6 +11,11 @@ def _main() -> None:
1011
os.system("swiftc -v")
1112
return
1213

14+
# Pass through for SwiftUI Preview thunk compilation
15+
if (any(arg.endswith(".preview-thunk.swift") for arg in sys.argv) and
16+
"-output-file-map" not in sys.argv):
17+
exit(subprocess.run(["swiftc"] + sys.argv[1:], check=False).returncode)
18+
1319
_touch_deps_files(sys.argv)
1420

1521

0 commit comments

Comments
 (0)