Skip to content
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

fix: Delete the Package.swift in AWSClientRuntime/ #621

Merged
merged 10 commits into from
Sep 27, 2022
52 changes: 0 additions & 52 deletions AWSClientRuntime/Package.swift

This file was deleted.

24 changes: 18 additions & 6 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

import PackageDescription
import class Foundation.FileManager
import class Foundation.ProcessInfo
import struct Foundation.URL

/*
This Package.swift file is used to compile against locally
Expand Down Expand Up @@ -61,14 +63,23 @@ let LOCAL_BASE_DIR = "Projects/Amplify/SwiftSDK"
let AWS_SDK_SWIFT_DIR = "\(LOCAL_BASE_DIR)/aws-sdk-swift"
let AWS_CRT_SWIFT_DIR = "\(LOCAL_BASE_DIR)/aws-crt-swift"
let SMITHY_SWIFT_DIR = "\(LOCAL_BASE_DIR)/smithy-swift"
let LOCAL_RELEASE_SWIFT_DIR = "\(AWS_SDK_SWIFT_DIR)/\(RELEASE)"

let fileManager = FileManager.default
let awsSDKSwiftDir = fileManager.homeDirectoryForCurrentUser.appendingPathComponent(AWS_SDK_SWIFT_DIR)
let awsCRTSwiftDir = fileManager.homeDirectoryForCurrentUser.appendingPathComponent(AWS_CRT_SWIFT_DIR)
let smithySwiftDir = fileManager.homeDirectoryForCurrentUser.appendingPathComponent(SMITHY_SWIFT_DIR)
let homePath = FileManager.default.homeDirectoryForCurrentUser
let env = ProcessInfo.processInfo.environment

let awsSDKSwiftDir, awsCRTSwiftDir, smithySwiftDir: URL
if let awsSDKSwiftCIPath = env["AWS_SDK_SWIFT_CI_DIR"], let awsCRTSwiftCIPath = env["AWS_CRT_SWIFT_CI_DIR"],
let smithySwiftCIPath = env["SMITHY_SWIFT_CI_DIR"] {
awsSDKSwiftDir = URL(fileURLWithPath: awsSDKSwiftCIPath)
awsCRTSwiftDir = URL(fileURLWithPath: awsCRTSwiftCIPath)
smithySwiftDir = URL(fileURLWithPath: smithySwiftCIPath)
} else {
awsSDKSwiftDir = homePath.appendingPathComponent(AWS_SDK_SWIFT_DIR)
awsCRTSwiftDir = homePath.appendingPathComponent(AWS_CRT_SWIFT_DIR)
smithySwiftDir = homePath.appendingPathComponent(SMITHY_SWIFT_DIR)
}

let localReleaseSwiftSDKDir = fileManager.homeDirectoryForCurrentUser.appendingPathComponent(LOCAL_RELEASE_SWIFT_DIR)
let localReleaseSwiftSDKDir = awsSDKSwiftDir.appendingPathComponent(RELEASE)

private extension Package {

Expand All @@ -77,6 +88,7 @@ private extension Package {
.package(name: "AwsCrt", path: awsCRTSwiftDir.path),
.package(name: "ClientRuntime", path: smithySwiftDir.path)
]

let sdksToIncludeInTargets = try! FileManager.default.contentsOfDirectory(atPath: localReleaseSwiftSDKDir.path)
includeTargets(package: self, releasedSDKs: sdksToIncludeInTargets)
return self
Expand Down
5 changes: 3 additions & 2 deletions builder.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
"{gradlew} -p {source_dir}/codegen/smithy-aws-swift-codegen build",
"{gradlew} -p {source_dir}/codegen/protocol-test-codegen build",
"{gradlew} -p {source_dir}/codegen/protocol-test-codegen-local build",
"cd {source_dir}/AWSClientRuntime && swift build --build-tests"
"mkdir -p {source_dir}/release",
"cd {source_dir} && swift build --build-tests"
],
"test_steps": [
"cd {source_dir}/AWSClientRuntime && swift test --skip-build",
"cd {source_dir} && swift test --skip-build",
"cd {source_dir} && ./scripts/mergeModels.sh {source_dir}/codegen/protocol-test-codegen/build/smithyprojections/protocol-test-codegen/aws-restjson/swift-codegen/AWSRestJsonTestSDK/models",
"cd {source_dir}/codegen && swift test"
],
Expand Down
6 changes: 3 additions & 3 deletions codegen/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func appendLibTarget(name: String, path: String) {
),
.product(
name: "AWSClientRuntime",
package: "AWSClientRuntime"
package: "AWSSwiftSDK"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems incorrect. Why AWSSwiftSDK is not defined as package.

Copy link
Contributor Author

@jbelkins jbelkins Sep 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is indeed correct.

Instead of being a product published from its own package, i.e. package=AWSClientRuntime & product=AWSClientRuntime, AWSClientRuntime is now a product published from the AWSSwiftSDK package, i.e. package=AWSSwiftSDK and product=AWSClientRuntime.

This is similar to how the service clients are products published by the AWSSwiftSDK package. The only difference here is that AWSClientRuntime is not auto-generated.

As proof that this configuration is correct, if you generate files and run swift test from within the codegen/ directory, it resolves dependencies & runs tests successfully.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome, thanks for verifying it.

),
],
path: "\(path)/swift-codegen/\(name)")
Expand Down Expand Up @@ -99,11 +99,11 @@ if let smithySwiftDir = ProcessInfo.processInfo.environment["SMITHY_SWIFT_CI_DIR
let sdkDir = ProcessInfo.processInfo.environment["AWS_SDK_SWIFT_CI_DIR"] {
package.dependencies += [
.package(name: "ClientRuntime", path: smithySwiftDir),
.package(name: "AWSClientRuntime", path: "\(sdkDir)/AWSClientRuntime"),
.package(name: "AWSSwiftSDK", path: sdkDir),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my comment above, this package dependency is correct.

]
} else {
package.dependencies += [
.package(name: "ClientRuntime", path: "~/Projects/Amplify/SwiftSDK/smithy-swift"),
.package(name: "AWSClientRuntime", path: "~/Projects/Amplify/SwiftSDK/aws-sdk-swift/AWSClientRuntime"),
.package(name: "AWSSwiftSDK", path: "~/Projects/Amplify/SwiftSDK/aws-sdk-swift"),
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ enum class AWSSwiftDependency(
"main",
"0.1.0",
"https://github.com/awslabs/aws-sdk-swift",
Resources.computeAbsolutePath("aws-sdk-swift/AWSClientRuntime", "AWSClientRuntime", "AWS_SDK_SWIFT_CI_DIR") + "/AWSClientRuntime",
Resources.computeAbsolutePath("aws-sdk-swift", "", "AWS_SDK_SWIFT_CI_DIR"),
"AWSClientRuntime"
);

Expand Down