Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# macOS system files
.DS_Store

# IDE
.idea/

# Docs build artifacts
site/
docs/clients/
Expand Down
13 changes: 11 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ PYTHON_VERSION := 3.12
# Colocated smithy-python checkout that provides the codegen jars.
SMITHY_PYTHON ?= ../smithy-python

.PHONY: docs docs-serve docs-clean docs-install docs-lock venv gen publish-codegen aio-check
# Clients per gradle build in `make clients`; lower it if the build runs out of heap.
BATCH_SIZE ?= 25

.PHONY: docs docs-serve docs-clean docs-install docs-lock venv gen clients publish-codegen aio-check

# Publishes the smithy-python codegen jars to the local Maven cache so `gen`
# can resolve them. Run once, and again whenever the generator changes.
Expand All @@ -14,7 +17,13 @@ publish-codegen:
# Regenerate one client from its service model: `make gen dynamodb`.
# Accepts dynamodb, aws_sdk_dynamodb, aws-sdk-dynamodb, or a hyphenated model name.
gen:
SMITHY_PYTHON=$(SMITHY_PYTHON) uv run python codegen/gen_client.py $(filter-out gen,$(MAKECMDGOALS))
SMITHY_PYTHON=$(abspath $(SMITHY_PYTHON)) uv run python codegen/gen_client.py $(filter-out gen,$(MAKECMDGOALS))

# Regenerate every client from codegen/aws-models with codegen built from the
# smithy-python commit in codegen/smithy-python.toml. Each client is cleared first,
# keeping only the paths in gen_client.py's KEEP, then scripts/client-overlays is applied.
clients:
SMITHY_PYTHON=$(abspath $(SMITHY_PYTHON)) uv run python codegen/gen_client.py --all --pinned --batch-size $(BATCH_SIZE)

# Swallow the client-name argument so make does not treat it as a target.
# Scoped to `gen` so it does not mask typos in unrelated commands.
Expand Down
1 change: 1 addition & 0 deletions codegen/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
build/
smithy-build.json
__pycache__/
.smithy-python/
21 changes: 8 additions & 13 deletions codegen/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,23 @@ repositories {
mavenCentral()
}

// Read the codegen and smithy versions from the colocated smithy-python
// checkout so this harness tracks whatever generator you build against,
// rather than a literal that silently rots when smithy-python bumps.
// Falls back to the last-known values if the checkout can't be read.
val smithyPython = file(System.getenv("SMITHY_PYTHON") ?: "../smithy-python")
// Read the codegen and smithy versions from the smithy-python checkout being built
// against, so this harness tracks that generator instead of a literal that rots.
val smithyPython = file(System.getenv("SMITHY_PYTHON") ?: "../../smithy-python")

fun readVersion(file: File, regex: Regex, fallback: String): String =
if (file.exists()) {
file.readLines().firstNotNullOfOrNull { regex.find(it)?.groupValues?.get(1) } ?: fallback
} else {
fallback
}
fun readVersion(file: File, regex: Regex): String =
file.takeIf { it.exists() }
?.readLines()
?.firstNotNullOfOrNull { regex.find(it)?.groupValues?.get(1) }
?: error("cannot read ${regex.pattern} from $file; set SMITHY_PYTHON to a smithy-python checkout")

val codegenVersion = readVersion(
smithyPython.resolve("codegen/build.gradle.kts"),
Regex("""version\s*=\s*"([^"]+)""""),
"0.5.1",
)
val smithyVersion = readVersion(
smithyPython.resolve("codegen/gradle/libs.versions.toml"),
Regex("""^smithy\s*=\s*"([^"]+)""""),
"1.73.0",
)

dependencies {
Expand Down
Loading
Loading