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

feat: Support multiple models/dependencies in Rust, within a single crate #583

Merged
merged 111 commits into from
Oct 10, 2024

Conversation

robin-aws
Copy link
Contributor

@robin-aws robin-aws commented Sep 13, 2024

Issue #, if available:
Resolves #576. Resolves #591. Resolves #590.

Description of changes:

Modifies the polymorph code generation process for Rust to apply to all services in scope at once, to get around the fact that Dafny's Rust code generation (and hence smithy-dafny's as well) only supports a single crate at a time. The polymorph CLI now supports multiple --namespace options, and the makefile now requires a MAIN_SERVICE_FOR_RUST service name in order to still select a single primary service to generate at the top level of the crate. All other services are qualified under deps::<service_name>. This layout may be changed before GA but I assert it is better to merge this first in order to lock down progress in the CI.

To implement this change, introduced a MergedServicesGenerator which instantiates a separate generator for each service. The individual generators were changed throughout to use the root path/module name for the given service.

Also made several other improvements to support building the complete DB ESDK dependency graph:

  • Fixed several bugs in the handling of @positional (testing followup tracked in More cases on Positional TestModel #599)
  • Handled the Smithy Unit type properly (testing followup tracked in SimpleUnit test model #602)
  • Properly handled introducing a single top-level error type for SDK wrappers, and wrapping errors from dependent services.
  • Miscellaneous bug fixes exposed by the DB ESDK source.
  • Deleted generated source for several test models to avoid review noise (and CI sensitivity to non-deterministic code generation)

Reviewer: I recommend skipping all TestModel changes except their makefiles. I also apologize for the size of this PR, but would also recommend biasing for merging this in order to lock down the progress - feel free to leave comments for cleanup to follow up with. Please do at least review the overall structure change for the sake of understanding.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

robin-aws and others added 17 commits September 26, 2024 15:35
…obin-aws/support-dependencies-on-rust

# Conflicts:
#	TestModels/Positional/runtimes/rust/src/operation/get_name.rs
#	TestModels/Positional/runtimes/rust/src/operation/get_resource.rs
#	TestModels/Positional/runtimes/rust/src/operation/get_resource_positional.rs
#	codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/smithyrust/generator/AbstractRustShimGenerator.java
#	codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/smithyrust/generator/RustLibraryShimGenerator.java
…obin-aws/support-dependencies-on-rust

# Conflicts:
#	SmithyDafnyMakefile.mk
#	TestModels/aws-sdks/ddb-lite/runtimes/rust/src/conversions/attribute_value.rs
#	TestModels/aws-sdks/ddb/Makefile
#	TestModels/aws-sdks/kms/Makefile
#	TestModels/aws-sdks/kms/Model/model.json
#	codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/CodegenEngine.java
#	codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/smithyrust/generator/AbstractRustShimGenerator.java
#	codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/smithyrust/generator/RustAwsSdkShimGenerator.java
#	codegen/smithy-dafny-codegen/src/main/java/software/amazon/polymorph/smithyrust/generator/RustLibraryShimGenerator.java
…mithy-lang/smithy-dafny into robin-aws/support-dependencies-on-rust
@robin-aws robin-aws changed the title Robin aws/support dependencies on rust feat: Support multiple models/dependencies in Rust, within a single crate Oct 10, 2024
@robin-aws robin-aws marked this pull request as ready for review October 10, 2024 04:21
@robin-aws robin-aws requested a review from a team as a code owner October 10, 2024 04:21
ajewellamz
ajewellamz previously approved these changes Oct 10, 2024
@ajewellamz ajewellamz dismissed their stale review October 10, 2024 14:11

I missed some stuff

@robin-aws robin-aws merged commit 768041d into main-1.x Oct 10, 2024
80 checks passed
@robin-aws robin-aws deleted the robin-aws/support-dependencies-on-rust branch October 10, 2024 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants