@@ -47,6 +47,11 @@ logging.basicConfig(
47
47
REPO_ROOT_PATH = pathlib .Path (__file__ ).parent .parent .resolve ()
48
48
49
49
50
+ class UnsupportedArchitecture (Exception ):
51
+
52
+ pass
53
+
54
+
50
55
def get_arguments () -> argparse .Namespace :
51
56
parser = argparse .ArgumentParser (
52
57
formatter_class = argparse .ArgumentDefaultsHelpFormatter
@@ -89,7 +94,7 @@ def get_swiftpm_bin_dir(config: Configuration) -> pathlib.Path:
89
94
90
95
91
96
def is_on_darwin () -> bool :
92
- return platform .uname (). system == "Darwin"
97
+ return platform .system () == "Darwin"
93
98
94
99
95
100
def set_environment (* , swiftpm_bin_dir : pathlib .Path ,) -> None :
@@ -107,22 +112,30 @@ def set_environment(*, swiftpm_bin_dir: pathlib.Path,) -> None:
107
112
108
113
109
114
def run_bootstrap (swiftpm_bin_dir : pathlib .Path ) -> None :
110
- if is_on_darwin ():
111
- logging .info ("Current working directory is %s" , pathlib .Path .cwd ())
112
- logging .info ("Bootstrapping with the XCBuild codepath..." )
113
- call (
114
- [
115
- REPO_ROOT_PATH / "Utilities" / "bootstrap" ,
116
- "build" ,
117
- "--release" ,
118
- "--verbose" ,
119
- "--cross-compile-hosts" ,
120
- "macosx-arm64" ,
121
- "--skip-cmake-bootstrap" ,
122
- "--swift-build-path" ,
123
- (swiftpm_bin_dir / "swift-build" ).resolve (),
124
- ],
125
- )
115
+ logging .info ("Current working directory is %s" , pathlib .Path .cwd ())
116
+ logging .info ("Bootstrapping with the XCBuild codepath..." )
117
+ cross_compile_arch : str
118
+ arch = platform .machine ()
119
+ if arch == "arm64" :
120
+ cross_compile_arch = "x86_64"
121
+ elif arch == "x86_64" :
122
+ cross_compile_arch = "arm64"
123
+ else :
124
+ raise UnsupportedArchitecture (f"Architecture { arch } is not supported." )
125
+
126
+ call (
127
+ [
128
+ REPO_ROOT_PATH / "Utilities" / "bootstrap" ,
129
+ "build" ,
130
+ "--release" ,
131
+ "--verbose" ,
132
+ "--cross-compile-hosts" ,
133
+ f"macosx-{ cross_compile_arch } " ,
134
+ "--skip-cmake-bootstrap" ,
135
+ "--swift-build-path" ,
136
+ (swiftpm_bin_dir / "swift-build" ).resolve (),
137
+ ],
138
+ )
126
139
127
140
128
141
def main () -> None :
@@ -158,7 +171,8 @@ def main() -> None:
158
171
),
159
172
)
160
173
161
- run_bootstrap (swiftpm_bin_dir = swiftpm_bin_dir )
174
+ if is_on_darwin ():
175
+ run_bootstrap (swiftpm_bin_dir = swiftpm_bin_dir )
162
176
163
177
164
178
if __name__ == "__main__" :
0 commit comments