Skip to content

Commit 386ec3f

Browse files
authored
Add MSRV to generated SDK Cargo.toml files (#3601)
This PR sets the `rust-version` property on generated Cargo.toml files for the AWS SDK crates. It doesn't attempt to place the property on the runtime crates for now since that will either require manual updating, or more machinery to automate. ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._
1 parent cfb97ed commit 386ec3f

File tree

10 files changed

+41
-12
lines changed

10 files changed

+41
-12
lines changed

.github/workflows/ci-tls.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,13 @@ jobs:
2525
shell: bash
2626
run: |
2727
sudo apt-get update
28-
sudo apt-get -y install gcc make python3-pip nginx git ruby openjdk-17-jre pkg-config libssl-dev faketime
28+
sudo apt-get -y install gcc make python3-pip nginx git ruby pkg-config libssl-dev faketime
2929
pip3 install certbuilder crlbuilder
30+
- name: Configure JDK
31+
uses: actions/setup-java@v4
32+
with:
33+
distribution: corretto
34+
java-version: 17
3035
- name: Stop nginx
3136
run: sudo systemctl stop nginx
3237
- name: Checkout smithy-rs

CHANGELOG.next.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,9 @@ let result = client.wait_until_thing()
5252
references = ["smithy-rs#119", "smithy-rs#3595", "smithy-rs#3593", "smithy-rs#3585", "smithy-rs#3571", "smithy-rs#3569"]
5353
meta = { "breaking" = false, "tada" = true, "bug" = false, "target" = "client" }
5454
author = "jdisanti"
55+
56+
[[aws-sdk-rust]]
57+
message = "SDK crates now set the `rust-version` property in their Cargo.toml files to indicate the minimum supported Rust version."
58+
references = ["smithy-rs#3601"]
59+
meta = { "breaking" = false, "tada" = true, "bug" = false }
60+
author = "jdisanti"

aws/sdk/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ fun generateSmithyBuild(services: AwsServices): String {
116116
${service.examplesUri(project)?.let { """"examples": "$it",""" } ?: ""}
117117
"moduleRepository": "https://github.com/awslabs/aws-sdk-rust",
118118
"license": "Apache-2.0",
119+
"minimumSupportedRustVersion": "${getRustMSRV()}",
119120
"customizationConfig": {
120121
"awsSdk": {
121122
"awsSdkBuild": true,

codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/ClientRustSettings.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ data class ClientRustSettings(
3737
override val codegenConfig: ClientCodegenConfig,
3838
override val license: String?,
3939
override val examplesUri: String?,
40+
override val minimumSupportedRustVersion: String? = null,
4041
override val customizationConfig: ObjectNode?,
4142
) : CoreRustSettings(
4243
service,
@@ -49,6 +50,7 @@ data class ClientRustSettings(
4950
codegenConfig,
5051
license,
5152
examplesUri,
53+
minimumSupportedRustVersion,
5254
customizationConfig,
5355
) {
5456
companion object {
@@ -70,6 +72,7 @@ data class ClientRustSettings(
7072
codegenConfig = ClientCodegenConfig.fromCodegenConfigAndNode(coreCodegenConfig, codegenSettingsNode),
7173
license = coreRustSettings.license,
7274
examplesUri = coreRustSettings.examplesUri,
75+
minimumSupportedRustVersion = coreRustSettings.minimumSupportedRustVersion,
7376
customizationConfig = coreRustSettings.customizationConfig,
7477
)
7578
}

codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/testutil/TestHelpers.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ fun testClientRustSettings(
3636
codegenConfig: ClientCodegenConfig = ClientCodegenConfig(),
3737
license: String? = null,
3838
examplesUri: String? = null,
39+
minimumSupportedRustVersion: String? = null,
3940
customizationConfig: ObjectNode? = null,
4041
) = ClientRustSettings(
4142
service,
@@ -48,6 +49,7 @@ fun testClientRustSettings(
4849
codegenConfig,
4950
license,
5051
examplesUri,
52+
minimumSupportedRustVersion,
5153
customizationConfig,
5254
)
5355

codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/CoreRustSettings.kt

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@ import software.amazon.smithy.model.shapes.ShapeId
1515
import software.amazon.smithy.rust.codegen.core.util.orNull
1616
import java.util.Optional
1717
import java.util.logging.Logger
18-
import kotlin.streams.toList
1918

20-
const val SERVICE = "service"
21-
const val MODULE_NAME = "module"
22-
const val MODULE_DESCRIPTION = "moduleDescription"
23-
const val MODULE_VERSION = "moduleVersion"
24-
const val MODULE_AUTHORS = "moduleAuthors"
25-
const val MODULE_REPOSITORY = "moduleRepository"
26-
const val RUNTIME_CONFIG = "runtimeConfig"
27-
const val LICENSE = "license"
28-
const val EXAMPLES = "examples"
29-
const val CUSTOMIZATION_CONFIG = "customizationConfig"
19+
private const val SERVICE = "service"
20+
private const val MODULE_NAME = "module"
21+
private const val MODULE_DESCRIPTION = "moduleDescription"
22+
private const val MODULE_VERSION = "moduleVersion"
23+
private const val MODULE_AUTHORS = "moduleAuthors"
24+
private const val MODULE_REPOSITORY = "moduleRepository"
25+
private const val RUNTIME_CONFIG = "runtimeConfig"
26+
private const val LICENSE = "license"
27+
private const val EXAMPLES = "examples"
28+
private const val MINIMUM_SUPPORTED_RUST_VERSION = "minimumSupportedRustVersion"
29+
private const val CUSTOMIZATION_CONFIG = "customizationConfig"
3030
const val CODEGEN_SETTINGS = "codegen"
3131

3232
/**
@@ -88,6 +88,7 @@ open class CoreRustSettings(
8888
open val codegenConfig: CoreCodegenConfig,
8989
open val license: String?,
9090
open val examplesUri: String? = null,
91+
open val minimumSupportedRustVersion: String? = null,
9192
open val customizationConfig: ObjectNode? = null,
9293
) {
9394
/**
@@ -177,6 +178,7 @@ open class CoreRustSettings(
177178
CODEGEN_SETTINGS,
178179
EXAMPLES,
179180
LICENSE,
181+
MINIMUM_SUPPORTED_RUST_VERSION,
180182
CUSTOMIZATION_CONFIG,
181183
),
182184
)
@@ -198,6 +200,7 @@ open class CoreRustSettings(
198200
codegenConfig = coreCodegenConfig,
199201
license = config.getStringMember(LICENSE).orNull()?.value,
200202
examplesUri = config.getStringMember(EXAMPLES).orNull()?.value,
203+
minimumSupportedRustVersion = config.getStringMember(MINIMUM_SUPPORTED_RUST_VERSION).orNull()?.value,
201204
customizationConfig = config.getObjectMember(CUSTOMIZATION_CONFIG).orNull(),
202205
)
203206
}

codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/CargoTomlGenerator.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class CargoTomlGenerator(
4949
private val moduleDescription: String?,
5050
private val moduleLicense: String?,
5151
private val moduleRepository: String?,
52+
private val minimumSupportedRustVersion: String?,
5253
private val writer: RustWriter,
5354
private val manifestCustomizations: ManifestCustomizations = emptyMap(),
5455
private val dependencies: List<CargoDependency> = emptyList(),
@@ -67,6 +68,7 @@ class CargoTomlGenerator(
6768
settings.moduleDescription,
6869
settings.license,
6970
settings.moduleRepository,
71+
settings.minimumSupportedRustVersion,
7072
writer,
7173
manifestCustomizations,
7274
dependencies,
@@ -90,6 +92,7 @@ class CargoTomlGenerator(
9092
"edition" to "2021",
9193
"license" to moduleLicense,
9294
"repository" to moduleRepository,
95+
minimumSupportedRustVersion?.let { "rust-version" to it },
9396
"metadata" to
9497
listOfNotNull(
9598
"smithy" to

codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/testutil/Rust.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,7 @@ private fun String.intoCrate(
466466
moduleDescription = null,
467467
moduleLicense = null,
468468
moduleRepository = null,
469+
minimumSupportedRustVersion = null,
469470
writer = this,
470471
dependencies = deps,
471472
).render()

codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/ServerRustSettings.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ data class ServerRustSettings(
3838
override val codegenConfig: ServerCodegenConfig,
3939
override val license: String?,
4040
override val examplesUri: String?,
41+
override val minimumSupportedRustVersion: String? = null,
4142
override val customizationConfig: ObjectNode?,
4243
) : CoreRustSettings(
4344
service,
@@ -50,6 +51,7 @@ data class ServerRustSettings(
5051
codegenConfig,
5152
license,
5253
examplesUri,
54+
minimumSupportedRustVersion,
5355
customizationConfig,
5456
) {
5557
companion object {
@@ -71,6 +73,7 @@ data class ServerRustSettings(
7173
codegenConfig = ServerCodegenConfig.fromCodegenConfigAndNode(coreCodegenConfig, codegenSettingsNode),
7274
license = coreRustSettings.license,
7375
examplesUri = coreRustSettings.examplesUri,
76+
minimumSupportedRustVersion = coreRustSettings.minimumSupportedRustVersion,
7477
customizationConfig = coreRustSettings.customizationConfig,
7578
)
7679
}

codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/testutil/ServerTestHelpers.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ fun serverTestRustSettings(
8181
codegenConfig: ServerCodegenConfig = ServerCodegenConfig(),
8282
license: String? = null,
8383
examplesUri: String? = null,
84+
minimumSupportedRustVersion: String? = null,
8485
customizationConfig: ObjectNode? = null,
8586
) = ServerRustSettings(
8687
service,
@@ -93,6 +94,7 @@ fun serverTestRustSettings(
9394
codegenConfig,
9495
license,
9596
examplesUri,
97+
minimumSupportedRustVersion,
9698
customizationConfig,
9799
)
98100

0 commit comments

Comments
 (0)