Skip to content

Commit 51a5730

Browse files
Idea: recommend using --target-arch in README.md, with option to use --target for different platforms + environments
1 parent 302fa10 commit 51a5730

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,15 @@ to the `--experimental-swift-sdk` option.
120120

121121
By default, on macOS hosts running on Apple Silicon, the Swift SDK Generator will create Swift SDKs
122122
for Ubuntu Jammy on aarch64, which matches the arch of the host. However, it is possible to change
123-
the default target architecture by passing the `--target` flag:
123+
the default target architecture by passing the `--target-arch` flag:
124124

125125
```bash
126-
swift run swift-sdk-generator make-linux-sdk --target x86_64-unknown-linux-gnu
126+
swift run swift-sdk-generator make-linux-sdk --target-arch x86_64
127127
```
128128

129+
This will default to building the Swift SDK for `x86_64-unknown-linux-gnu`. To build for other
130+
platforms and environments, supply the `--target` flag with the full target triple instead.
131+
129132
The Linux distribution name and version can also be passed to change from the default of Ubuntu Jammy:
130133

131134
```bash
@@ -141,13 +144,13 @@ and are likely not using the Swift OSS toolchain to build and run Swift projects
141144
is included by *default*. This default behavior can be changed by passing `--no-host-toolchain`:
142145

143146
```bash
144-
swift run swift-sdk-generator make-linux-sdk --no-host-toolchain --target x86_64-unknown-linux-gnu
147+
swift run swift-sdk-generator make-linux-sdk --no-host-toolchain --target x86_64
145148
```
146149

147150
Or, if on Linux, and desiring to generate the Swift SDK with the host toolchain included, add `--host-toolchain`:
148151

149152
```bash
150-
swift run swift-sdk-generator make-linux-sdk --host-toolchain --target aarch64-unknown-linux-gnu
153+
swift run swift-sdk-generator make-linux-sdk --host-toolchain --target aarch64
151154
```
152155

153156
## Building an SDK from a container image

Sources/GeneratorCLI/GeneratorCLI.swift

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,15 +148,19 @@ extension GeneratorCLI {
148148
var host: Triple? = nil
149149

150150
@Option(
151-
help: """
152-
The target triple of the bundle. The default depends on a recipe used for SDK generation. Pass `--help` to a specific recipe subcommand for more details.
153-
"""
154-
)
151+
help:
152+
"The target triple of the bundle. The default depends on a recipe used for SDK generation.")
155153
var target: Triple? = nil
156154

157155
@Option(help: "Deprecated. Use `--host` instead")
158156
var hostArch: Triple.Arch? = nil
159-
@Option(help: "Deprecated. Use `--target` instead")
157+
@Option(
158+
help: """
159+
The target arch of the bundle. The default depends on a recipe used for SDK generation.
160+
If this is passed, the target triple will default to `<target-arch>-unknown-linux-gnu`.
161+
Use the `--target` param to pass the full target triple if needed.
162+
"""
163+
)
160164
var targetArch: Triple.Arch? = nil
161165

162166
/// Default to adding host toolchain when building on macOS
@@ -228,7 +232,8 @@ extension GeneratorCLI {
228232
if let arch = generatorOptions.targetArch {
229233
let target = Triple(arch: arch, vendor: nil, os: .linux, environment: .gnu)
230234
appLogger.warning(
231-
"deprecated: Please use `--target \(target.triple)` instead of `--target-arch \(arch)`")
235+
"Using `--target-arch \(arch)` defaults to `\(target.triple)`. Use `--target` if you want to pass the full target triple."
236+
)
232237
return target
233238
}
234239
return Triple(arch: hostTriple.arch!, vendor: nil, os: .linux, environment: .gnu)

0 commit comments

Comments
 (0)