Skip to content

Main merge, more ideas for experimental README changes #215

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
b9d611f
Fix support for building with `--static-swift-stdlib` for armv7 (#194)
xtremekforever Mar 3, 2025
df46d2f
Fix missing `lib/` directory for Ubuntu Noble, remove unused componen…
xtremekforever Mar 3, 2025
5fee508
CI: Add support for GitHub Actions (#199)
shahmishal Mar 10, 2025
4de34ce
workflows: Run unit tests using GitHub Actions (#200)
euanh Mar 10, 2025
330c3f2
Fix support for Amazon Linux 2 x86_64, add EndToEndTests for all RHEL…
xtremekforever Mar 12, 2025
685190d
Fix typo in `README.md` (#202)
xavgru12 Mar 21, 2025
0158a41
Set `lineBreakBeforeEachArgument` to `true` in `.swift-format` (#205)
MaxDesiatov Apr 3, 2025
a3e3c73
Update defaults for Swift `6.1-RELEASE` tag (#204)
xtremekforever Apr 4, 2025
9fe010c
docs: Delete instructions to run non-existent soundness.sh (#206)
euanh Apr 16, 2025
ed6a85b
Support Debian 11 and Debian 12 distributions in the generator (#203)
xtremekforever Apr 16, 2025
44ea35b
Bump `// swift-tools-version` to 5.9 (#207)
MaxDesiatov May 14, 2025
19deeb1
Bump `lineLength` to 120 in `.swift-format` (#211)
MaxDesiatov May 15, 2025
fc7da52
Generate Embedded Swift SDK for WASI (#208)
MaxDesiatov May 15, 2025
d45075e
Fix use of absolute paths to Swift SDK metatadata (#212)
MaxDesiatov May 16, 2025
d7264b7
Symlink `libclang_rt.builtins.a` for Embedded Swift for WASI (#213)
MaxDesiatov May 16, 2025
6339e11
Merge branch 'main' into revision/experimental-readme
xtremekforever May 17, 2025
8131942
Add conditional experimental- prefix to completion message with anyth…
xtremekforever May 17, 2025
16fea50
Add more info to distribution section on how to generate checksums fo…
xtremekforever May 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Pull request

on:
pull_request:
types: [opened, reopened, synchronize]

jobs:
tests:
name: Test
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main
with:
linux_pre_build_command: apt-get update && apt-get install -y locales locales-all libsqlite3-dev
enable_windows_checks: false
soundness:
name: Soundness
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main
with:
api_breakage_check_enabled: false
12 changes: 12 additions & 0 deletions .license_header_template
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@@===----------------------------------------------------------------------===@@
@@
@@ This source file is part of the Swift open source project
@@
@@ Copyright (c) YEARS Apple Inc. and the Swift project authors
@@ Licensed under Apache License v2.0 with Runtime Library Exception
@@
@@ See https://swift.org/LICENSE.txt for license information
@@ See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
@@
@@===----------------------------------------------------------------------===@@

22 changes: 22 additions & 0 deletions .licenseignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.gitignore
.swiftformat
.swiftformatignore
.editorconfig
.unacceptablelanguageignore
Brewfile
Package.swift
Package.resolved
*.md
*.txt
*.yml
**/.editorconfig
**/*.docc/**
**/*.entitlements
**/*.input
**/*.modulemap
**/*.plist
**/*.xcodeproj/**
**/CODEOWNERS
**/Dockerfile
**/Package.swift
Utilities/git.commit.template
70 changes: 70 additions & 0 deletions .swift-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"fileScopedDeclarationPrivacy" : {
"accessLevel" : "private"
},
"indentConditionalCompilationBlocks" : true,
"indentSwitchCaseLabels" : false,
"indentation" : {
"spaces" : 2
},
"lineBreakAroundMultilineExpressionChainComponents" : false,
"lineBreakBeforeControlFlowKeywords" : false,
"lineBreakBeforeEachArgument" : true,
"lineBreakBeforeEachGenericRequirement" : false,
"lineLength" : 120,
"maximumBlankLines" : 1,
"multiElementCollectionTrailingCommas" : true,
"noAssignmentInExpressions" : {
"allowedFunctions" : [
"XCTAssertNoThrow"
]
},
"prioritizeKeepingFunctionOutputTogether" : false,
"respectsExistingLineBreaks" : true,
"rules" : {
"AllPublicDeclarationsHaveDocumentation" : false,
"AlwaysUseLiteralForEmptyCollectionInit" : false,
"AlwaysUseLowerCamelCase" : false,
"AmbiguousTrailingClosureOverload" : true,
"BeginDocumentationCommentWithOneLineSummary" : false,
"DoNotUseSemicolons" : true,
"DontRepeatTypeInStaticProperties" : true,
"FileScopedDeclarationPrivacy" : true,
"FullyIndirectEnum" : true,
"GroupNumericLiterals" : true,
"IdentifiersMustBeASCII" : true,
"NeverForceUnwrap" : false,
"NeverUseForceTry" : false,
"NeverUseImplicitlyUnwrappedOptionals" : false,
"NoAccessLevelOnExtensionDeclaration" : true,
"NoAssignmentInExpressions" : true,
"NoBlockComments" : true,
"NoCasesWithOnlyFallthrough" : true,
"NoEmptyTrailingClosureParentheses" : true,
"NoLabelsInCasePatterns" : true,
"NoLeadingUnderscores" : false,
"NoParensAroundConditions" : true,
"NoPlaygroundLiterals" : true,
"NoVoidReturnOnFunctionSignature" : true,
"OmitExplicitReturns" : false,
"OneCasePerLine" : true,
"OneVariableDeclarationPerLine" : true,
"OnlyOneTrailingClosureArgument" : true,
"OrderedImports" : true,
"ReplaceForEachWithForLoop" : true,
"ReturnVoidInsteadOfEmptyTuple" : true,
"TypeNamesShouldBeCapitalized" : true,
"UseEarlyExits" : false,
"UseExplicitNilCheckInConditions" : true,
"UseLetInEveryBoundCaseVariable" : false,
"UseShorthandTypeNames" : true,
"UseSingleLinePropertyGetter" : true,
"UseSynthesizedInitializer" : true,
"UseTripleSlashForDocumentationComments" : true,
"UseWhereClausesInForLoops" : false,
"ValidateDocumentationComments" : false
},
"spacesAroundRangeFormationOperators" : false,
"tabWidth" : 8,
"version" : 1
}
2 changes: 2 additions & 0 deletions .swiftformatignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Sources/Helpers/Vendor/*
Sources/AsyncProcess/ProcessExecutor.swift
2 changes: 2 additions & 0 deletions .unacceptablelanguageignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Sources/AsyncProcess/ProcessExecutor.swift
Tests/AsyncProcessTests/IntegrationTests.swift
25 changes: 1 addition & 24 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,29 +58,6 @@ We require that your commit messages match our template. The easiest way to do t

git config commit.template Utilities/git.commit.template

### Run `./Utilities/soundness.sh`

The scripts directory contains a [`soundness.sh` script](https://github.com/apple/swift-sdk-generator/blob/main/Utilities/soundness.sh)
that enforces additional checks, like license headers and formatting style.

Please make sure to run `./Utilities/soundness.sh` before pushing a change upstream, otherwise it is likely the PR validation will fail
on minor changes such as formatting issues.

For frequent contributors, we recommend adding the script as a [git pre-push hook](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks), which you can do via executing the following command in the project root directory:

```bash
cat << EOF > .git/hooks/pre-push

if [[ -f "Utilities/soundness.sh" ]]; then
Utilities/soundness.sh
fi
EOF
```

Which makes the script execute, and only allow the `git push` to complete if the check has passed.

In the case of formatting issues, you can then `git add` the formatting changes, and attempt the push again.

## How to contribute your work

Please open a pull request at https://github.com/apple/swift-sdk-generator. Make sure the CI passes, and then wait for code review.
Please open a pull request at https://github.com/apple/swift-sdk-generator. Make sure the CI passes, and then wait for code review.
4 changes: 0 additions & 4 deletions Docker/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ services:
- ..:/code:z
working_dir: /code

soundness:
<<: *common
command: /bin/bash -xcl "swift -version && uname -a && ./Utilities/soundness.sh"

test:
<<: *common
environment:
Expand Down
18 changes: 9 additions & 9 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version: 5.8
// swift-tools-version: 5.9
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription
Expand All @@ -11,7 +11,7 @@ let package = Package(
.executable(
name: "swift-sdk-generator",
targets: ["GeneratorCLI"]
),
)
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
Expand All @@ -23,7 +23,7 @@ let package = Package(
.product(name: "ArgumentParser", package: "swift-argument-parser"),
],
swiftSettings: [
.enableExperimentalFeature("StrictConcurrency=complete"),
.enableExperimentalFeature("StrictConcurrency=complete")
]
),
.target(
Expand All @@ -38,22 +38,22 @@ let package = Package(
],
exclude: ["Dockerfiles"],
swiftSettings: [
.enableExperimentalFeature("StrictConcurrency=complete"),
.enableExperimentalFeature("StrictConcurrency=complete")
]
),
.testTarget(
name: "SwiftSDKGeneratorTests",
dependencies: [
"SwiftSDKGenerator",
"SwiftSDKGenerator"
],
swiftSettings: [
.enableExperimentalFeature("StrictConcurrency=complete"),
.enableExperimentalFeature("StrictConcurrency=complete")
]
),
.testTarget(
name: "GeneratorEngineTests",
dependencies: [
"Helpers",
"Helpers"
]
),
.target(
Expand All @@ -66,13 +66,13 @@ let package = Package(
],
exclude: ["Vendor/README.md"],
swiftSettings: [
.enableExperimentalFeature("StrictConcurrency=complete"),
.enableExperimentalFeature("StrictConcurrency=complete")
]
),
.testTarget(
name: "HelpersTests",
dependencies: [
"Helpers",
"Helpers"
]
),
.systemLibrary(name: "SystemSQLite", pkgConfig: "sqlite3"),
Expand Down
21 changes: 17 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ The generator also allows cross-compiling between any Linux distributions offici
| macOS (arm64) | ✅ macOS 13.0+ | ❌ |
| macOS (x86_64) | ✅ macOS 13.0+[^1] | ❌ |
| Ubuntu | ✅ 20.04+ | ✅ 20.04+ |
| RHEL | ✅ Fedora 39[^2], UBI 9 | ✅ UBI 9 |
| Debian | ✅ 11, 12[^2] | ✅ 11, 12[^2] |
| RHEL | ✅ Fedora 39, UBI 9 | ✅ Fedora 39, UBI 9[^3] |
| Amazon Linux 2 | ✅ Supported | ✅ Supported[^3] |
| Debian 12 | ✅ Supported[^2] | ✅ Supported[^2][^3] |

[^1]: Since LLVM project doesn't provide pre-built binaries of `lld` for macOS on x86_64, it will be automatically built
from sources by the generator, which will increase its run by at least 15 minutes on recent hardware. You will also
need CMake and Ninja preinstalled (e.g. via `brew install cmake ninja`).
[^2]: These distributions are only supported by Swift 5.10.1 and later as both host and target platforms.
[^2]: Swift does not officially support Debian 11 or Debian 12 with Swift versions before 5.10.1. However, the Ubuntu 20.04/22.04 toolchains can be used with Debian 11 and 12 (respectively) since they are binary compatible.
[^3]: These versions are technically supported but require custom commands and a Docker container to build the Swift SDK, as the generator will not download dependencies for these distributions automatically. See [issue #138](https://github.com/swiftlang/swift-sdk-generator/issues/138).

## How to use it
Expand Down Expand Up @@ -94,7 +94,7 @@ subsequently as `<generated_sdk_id>`.
Create a new project to verify that the SDK works:

```
mkdir cross-compilation test
mkdir cross-compilation-test
cd cross-compilation-test
swift package init --type executable
```
Expand Down Expand Up @@ -185,6 +185,19 @@ The `.artifactbundle` directory produced in the previous section can be packaged
in this form. Users of such Swift SDK bundle archive can easily install it with `swift sdk install`
command, which supports both local file system paths and public `http://` and `https://` URLs as an argument.

To make an `.artifactbundle.tar.gz` archive installable directly from `http://` and `https://` URLs, a checksum must be
generated. This can be done using the `swift package compute-checksum` command, like this:

```console
swift package compute-checksum ./Bundles/6.1-RELEASE_ubuntu_jammy_x86_64.artifactbundle.tar.gz
<checksum>
```

This checksum should be provided along with the artifact bundles to be included with the sdk install invocation:

```console
swift sdk install https://my-public-site/sdks/6.1-RELEASE_ubuntu_jammy_x86_64.artifactbundle.tar.gz --checksum <checksum>
```

## Contributing

Expand Down
10 changes: 5 additions & 5 deletions Sources/AsyncProcess/ChunkSequence.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
import NIO

#if os(Linux) || os(Android) || os(Windows)
@preconcurrency import Foundation
@preconcurrency import Foundation
#else
import Foundation
import Foundation
#endif

public struct IllegalStreamConsumptionError: Error {
Expand Down Expand Up @@ -53,9 +53,9 @@ public struct ChunkSequence: AsyncSequence & Sendable {
} else {
throw IllegalStreamConsumptionError(
description: """
Either `.discard`ed, `.inherit`ed or redirected this stream to a `.fileHandle`,
cannot also consume it. To consume, please `.stream` it.
"""
Either `.discard`ed, `.inherit`ed or redirected this stream to a `.fileHandle`,
cannot also consume it. To consume, please `.stream` it.
"""
)
}
}
Expand Down
21 changes: 13 additions & 8 deletions Sources/AsyncProcess/FileContentStream.swift
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,10 @@ private final class ReadIntoAsyncChannelHandler: ChannelDuplexHandler {

extension FileHandle {
func fileContentStream(eventLoop: EventLoop) throws -> FileContentStream {
let asyncBytes = try FileContentStream(fileDescriptor: self.fileDescriptor, eventLoop: eventLoop)
let asyncBytes = try FileContentStream(
fileDescriptor: self.fileDescriptor,
eventLoop: eventLoop
)
try self.close()
return asyncBytes
}
Expand All @@ -272,8 +275,8 @@ extension FileContentStream {
}
}

public extension AsyncSequence where Element == ByteBuffer, Self: Sendable {
func splitIntoLines(
extension AsyncSequence where Element == ByteBuffer, Self: Sendable {
public func splitIntoLines(
dropTerminator: Bool = true,
maximumAllowableBufferSize: Int = 1024 * 1024,
dropLastChunkIfNoNewline: Bool = false
Expand All @@ -286,14 +289,13 @@ public extension AsyncSequence where Element == ByteBuffer, Self: Sendable {
)
}

var strings: AsyncMapSequence<Self, String> {
public var strings: AsyncMapSequence<Self, String> {
self.map { String(buffer: $0) }
}
}

public struct AsyncByteBufferLineSequence<Base: Sendable>: AsyncSequence & Sendable
where Base: AsyncSequence, Base.Element == ByteBuffer
{
where Base: AsyncSequence, Base.Element == ByteBuffer {
public typealias Element = ByteBuffer
private let underlying: Base
private let dropTerminator: Bool
Expand Down Expand Up @@ -329,7 +331,9 @@ public struct AsyncByteBufferLineSequence<Base: Sendable>: AsyncSequence & Senda
self.buffer.last?.readableBytesView
}

mutating func concatenateEverything(upToLastChunkLengthToConsume lastLength: Int) -> ByteBuffer {
mutating func concatenateEverything(upToLastChunkLengthToConsume lastLength: Int)
-> ByteBuffer
{
var output = ByteBuffer()
output.reserveCapacity(lastLength + self.byteCountButLast)

Expand Down Expand Up @@ -430,7 +434,8 @@ public struct AsyncByteBufferLineSequence<Base: Sendable>: AsyncSequence & Senda
}

public init(
_ underlying: Base, dropTerminator: Bool,
_ underlying: Base,
dropTerminator: Bool,
maximumAllowableBufferSize: Int,
dropLastChunkIfNoNewline: Bool
) {
Expand Down
Loading