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

Do not set RUSTFLAGS environment variable when invoking Cargo commands via Gradle tasks #3678

Merged
merged 27 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
d0f7448
Do not set `RUSTFLAGS` environment variable when invoking Cargo comma…
david-perez Jun 3, 2024
631a955
Merge branch 'main' into davidpz/do-not-set-rustflags-environment-var…
david-perez Jun 4, 2024
c7b242c
Clear RUSTDOCFLAGS
david-perez Jun 4, 2024
0dfd571
Fix some Clippy warnings
david-perez Jun 4, 2024
ee343d5
Fix more Clippy warnings
david-perez Jun 5, 2024
e3ad6cc
Add EOF newline to gradle.properties
david-perez Jun 5, 2024
c1060ef
Remove unnecessary semicolon
david-perez Jun 5, 2024
f891ab6
Fix fluent client docs
david-perez Jun 5, 2024
ec93443
Escape brackets in HTML elements' text
david-perez Jun 5, 2024
9cf2f0c
Dont reference types module if not generated
david-perez Jun 5, 2024
4e98dda
Comment out clearing RUSTDOCFLAGS
david-perez Jun 5, 2024
b0af582
Merge remote-tracking branch 'upstream/main' into davidpz/do-not-set-…
david-perez Jun 5, 2024
e75a6e0
Use [ instead of < in Smithy docs for misc.smithy
david-perez Jun 5, 2024
741d9ef
Unions are generated in the types module
david-perez Jun 5, 2024
1d249c2
./gradlew ktlintFormat
david-perez Jun 5, 2024
738f241
Fix doc warning when generating unions with unit variants
david-perez Jun 5, 2024
a6ed02b
Fix doc warning when referring to client methods with Rust reserved n…
david-perez Jun 5, 2024
d700dd4
Docs adjustment
david-perez Jun 5, 2024
dc67bc3
Allow broken intra doc links in server codegen integration tests temp…
david-perez Jun 5, 2024
cfbcba8
Fix cargo doc invocation
david-perez Jun 5, 2024
7d99365
./gradlew ktlintFormat
david-perez Jun 5, 2024
c35dc14
allow broken intra doc links in server codegen integration tests
david-perez Jun 6, 2024
2603634
Formatting
david-perez Jun 6, 2024
0d57bba
Merge remote-tracking branch 'upstream/main' into davidpz/do-not-set-…
david-perez Jun 21, 2024
81df348
Remove escape hatch to tolerate broken intra doc links
david-perez Jun 21, 2024
2c9d9f9
Fix Python
david-perez Jun 21, 2024
99f73ec
Fix Python now for real
david-perez Jun 21, 2024
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
3 changes: 1 addition & 2 deletions aws/sdk-adhoc-test/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ java {
}

val smithyVersion: String by project
val defaultRustDocFlags: String by project
val properties = PropertyRetriever(rootProject, project)

val pluginName = "rust-client-codegen"
Expand Down Expand Up @@ -78,7 +77,7 @@ tasks["smithyBuild"].dependsOn("generateSmithyBuild")
tasks["assemble"].finalizedBy("generateCargoWorkspace")

project.registerModifyMtimeTask()
project.registerCargoCommandsTasks(layout.buildDirectory.dir(workingDirUnderBuildDir).get().asFile, defaultRustDocFlags)
project.registerCargoCommandsTasks(layout.buildDirectory.dir(workingDirUnderBuildDir).get().asFile)

tasks["test"].finalizedBy(cargoCommands(properties).map { it.toString })

Expand Down
3 changes: 1 addition & 2 deletions aws/sdk/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ configure<software.amazon.smithy.gradle.SmithyExtension> {
}

val smithyVersion: String by project
val defaultRustDocFlags: String by project
val properties = PropertyRetriever(rootProject, project)

val crateHasherToolPath = rootProject.projectDir.resolve("tools/ci-build/crate-hasher")
Expand Down Expand Up @@ -442,7 +441,7 @@ tasks["assemble"].apply {
outputs.upToDateWhen { false }
}

project.registerCargoCommandsTasks(outputDir.asFile, defaultRustDocFlags)
project.registerCargoCommandsTasks(outputDir.asFile)
project.registerGenerateCargoConfigTomlTask(outputDir.asFile)

//The task name "test" is already registered by one of our plugins
Expand Down
14 changes: 4 additions & 10 deletions buildSrc/src/main/kotlin/CodegenTestCommon.kt
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,15 @@ fun Project.registerGenerateCargoWorkspaceTask(
fun Project.registerGenerateCargoConfigTomlTask(outputDir: File) {
this.tasks.register("generateCargoConfigToml") {
description = "generate `.cargo/config.toml`"
// TODO(https://github.com/smithy-lang/smithy-rs/issues/1068): Once doc normalization
// is completed, warnings can be prohibited in rustdoc by setting `rustdocflags` to `-D warnings`.
doFirst {
outputDir.resolve(".cargo").mkdirs()
outputDir.resolve(".cargo/config.toml")
.writeText(
"""
[build]
rustflags = ["--deny", "warnings"]
rustflags = ["--deny", "warnings", "--cfg", "aws_sdk_unstable"]
""".trimIndent(),
)
}
Expand Down Expand Up @@ -255,10 +257,7 @@ fun Project.registerModifyMtimeTask() {
}
}

fun Project.registerCargoCommandsTasks(
outputDir: File,
defaultRustDocFlags: String,
) {
fun Project.registerCargoCommandsTasks(outputDir: File) {
val dependentTasks =
listOfNotNull(
"assemble",
Expand All @@ -269,29 +268,24 @@ fun Project.registerCargoCommandsTasks(
this.tasks.register<Exec>(Cargo.CHECK.toString) {
dependsOn(dependentTasks)
workingDir(outputDir)
environment("RUSTFLAGS", "--cfg aws_sdk_unstable")
commandLine("cargo", "check", "--lib", "--tests", "--benches", "--all-features")
}

this.tasks.register<Exec>(Cargo.TEST.toString) {
dependsOn(dependentTasks)
workingDir(outputDir)
environment("RUSTFLAGS", "--cfg aws_sdk_unstable")
commandLine("cargo", "test", "--all-features", "--no-fail-fast")
}

this.tasks.register<Exec>(Cargo.DOCS.toString) {
dependsOn(dependentTasks)
workingDir(outputDir)
environment("RUSTDOCFLAGS", defaultRustDocFlags)
environment("RUSTFLAGS", "--cfg aws_sdk_unstable")
commandLine("cargo", "doc", "--no-deps", "--document-private-items")
}

this.tasks.register<Exec>(Cargo.CLIPPY.toString) {
dependsOn(dependentTasks)
workingDir(outputDir)
environment("RUSTFLAGS", "--cfg aws_sdk_unstable")
commandLine("cargo", "clippy")
}
}
3 changes: 1 addition & 2 deletions codegen-client-test/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ plugins {
}

val smithyVersion: String by project
val defaultRustDocFlags: String by project
val properties = PropertyRetriever(rootProject, project)
fun getSmithyRuntimeMode(): String = properties.get("smithy.runtime.mode") ?: "orchestrator"

Expand Down Expand Up @@ -125,7 +124,7 @@ tasks["smithyBuild"].dependsOn("generateSmithyBuild")
tasks["assemble"].finalizedBy("generateCargoWorkspace")

project.registerModifyMtimeTask()
project.registerCargoCommandsTasks(layout.buildDirectory.dir(workingDirUnderBuildDir).get().asFile, defaultRustDocFlags)
project.registerCargoCommandsTasks(layout.buildDirectory.dir(workingDirUnderBuildDir).get().asFile)

tasks["test"].finalizedBy(cargoCommands(properties).map { it.toString })

Expand Down
3 changes: 1 addition & 2 deletions codegen-server-test/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ plugins {
}

val smithyVersion: String by project
val defaultRustDocFlags: String by project
val properties = PropertyRetriever(rootProject, project)

val pluginName = "rust-server-codegen"
Expand Down Expand Up @@ -103,7 +102,7 @@ tasks["smithyBuild"].dependsOn("generateSmithyBuild")
tasks["assemble"].finalizedBy("generateCargoWorkspace", "generateCargoConfigToml")

project.registerModifyMtimeTask()
project.registerCargoCommandsTasks(layout.buildDirectory.dir(workingDirUnderBuildDir).get().asFile, defaultRustDocFlags)
project.registerCargoCommandsTasks(layout.buildDirectory.dir(workingDirUnderBuildDir).get().asFile)

tasks["test"].finalizedBy(cargoCommands(properties).map { it.toString })

Expand Down
3 changes: 1 addition & 2 deletions codegen-server-test/python/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ plugins {
}

val smithyVersion: String by project
val defaultRustDocFlags: String by project
val properties = PropertyRetriever(rootProject, project)
val buildDir = layout.buildDirectory.get().asFile

Expand Down Expand Up @@ -120,7 +119,7 @@ tasks["smithyBuild"].dependsOn("generateSmithyBuild")
tasks["assemble"].finalizedBy("generateCargoWorkspace")

project.registerModifyMtimeTask()
project.registerCargoCommandsTasks(buildDir.resolve(workingDirUnderBuildDir), defaultRustDocFlags)
project.registerCargoCommandsTasks(buildDir.resolve(workingDirUnderBuildDir))

tasks["test"].finalizedBy(cargoCommands(properties).map { it.toString })

Expand Down
3 changes: 1 addition & 2 deletions codegen-server-test/typescript/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ plugins {
}

val smithyVersion: String by project
val defaultRustDocFlags: String by project
val properties = PropertyRetriever(rootProject, project)
val buildDir = layout.buildDirectory.get().asFile

Expand Down Expand Up @@ -49,7 +48,7 @@ tasks["smithyBuild"].dependsOn("generateSmithyBuild")
tasks["assemble"].finalizedBy("generateCargoWorkspace")

project.registerModifyMtimeTask()
project.registerCargoCommandsTasks(buildDir.resolve(workingDirUnderBuildDir), defaultRustDocFlags)
project.registerCargoCommandsTasks(buildDir.resolve(workingDirUnderBuildDir))

tasks["test"].finalizedBy(cargoCommands(properties).map { it.toString })

Expand Down
8 changes: 1 addition & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,4 @@ kotlinVersion=1.9.20
ktlintVersion=1.0.1
kotestVersion=5.8.0
# Avoid registering dependencies/plugins/tasks that are only used for testing purposes
isTestingEnabled=true

# TODO(https://github.com/smithy-lang/smithy-rs/issues/1068): Once doc normalization
# is completed, warnings can be prohibited in rustdoc.
#
# defaultRustDocFlags=-D warnings
defaultRustDocFlags=
isTestingEnabled=true
Loading