mirror of
https://github.com/hanzo-cpp/sdk.git
synced 2026-11-20 19:55:32 +00:00
This repo owned its whole generator invocation and gave two reasons. Both are gone, so it now owns none of it: `scripts/generate.sh` says "cpp, into this checkout" and every other fact about how this client is produced is one row in hanzoai/openapi's sdks.yaml. TEMPLATES were the first reason — four cpp-restsdk mustache overrides, without which the library does not compile at all (measured: 8 errors, all in ModelBase.h). The argument was that a template is a FILE and has to sit beside the call. That was right about the risk and wrong about which call: the call is generate.py's emit(), so the overrides move to templates/cpp-restsdk/ in the driver repo, one directory from the flags they go with. A template in the client and its flags upstream would have been the two that drift. THE GENERATOR VERSION was the second, and it was never a fact about cpp-restsdk. The floor said 7.24.0 because on 7.14.0 ten translation units would not compile through two defects no template reaches. Both defects were real and both lived in schemas the document no longer carries — vector_NamedVectors/ vector_DenseVector under additionalProperties, and framework_Document.docstatus. Re-measured at the locked commit: ignoring blank lines and the generator string in each header, exactly one of 5327 files differs between 7.14.0 and 7.24.0, and the difference is a doc comment on ConsoleSettings::getOidcConfig. So this client is on the fleet's one pin and needs no exception. The row reproduces the departed script exactly: `generate.py cpp --check` reports clean against the tree that script produced, byte for byte, 5327 files. `.generated` is committed because it is what makes that check able to see a deletion on a fresh clone.
45 lines
2.4 KiB
Bash
Executable File
45 lines
2.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# The call site. Nothing about HOW this SDK is generated lives here.
|
|
#
|
|
# The invocation is logic and lives once, in hanzoai/openapi's `generate.py`;
|
|
# every per-language knob is data in `sdks.yaml` beside it, including the four
|
|
# `cpp-restsdk` mustache overrides this client needs — those now sit at
|
|
# `templates/cpp-restsdk/` in the driver repo, next to the flags they go with.
|
|
# This file says "cpp, into this checkout" and nothing else.
|
|
#
|
|
# ./scripts/generate.sh # regenerate include/ and src/
|
|
# ./scripts/generate.sh --check # fail if the committed client drifted
|
|
#
|
|
# WHAT THIS REPLACED, because the reason is the whole point. This script used to
|
|
# carry the entire invocation: it fetched the generator jar, converted YAML to
|
|
# JSON, passed --skip-validate-spec, ran the diff check, and named the document
|
|
# itself. Four of those are copies of logic the driver already owns once, and
|
|
# the fifth is what went wrong — it defaulted to SPEC_REPO=hanzoai/openapi,
|
|
# `hanzo.yaml`, at the branch `main`, while this repo's own hanzo.yml already
|
|
# declared hanzoai/cloud's `openapi.yaml`. One repo, two answers to "which
|
|
# document is this client a projection of", and no `.spec-lock` to settle it.
|
|
#
|
|
# It also pinned generator 7.24.0 against the fleet's 7.14.0. That floor was
|
|
# real when written and expired with the document that caused it: both defects
|
|
# it named live in schemas the document no longer carries, and at the locked ref
|
|
# the two versions emit the same library. There is one pin now, in sdks.yaml.
|
|
#
|
|
# BOTH INPUTS ARRIVE AS VALUES. $SPEC is the document, already fetched at a
|
|
# pinned ref and digest-checked; $OPENAPI is the checkout holding the driver.
|
|
# hanzoai/ci's client lane sets both, because it holds the one credential that
|
|
# reads this forge. Without $SPEC the driver reads `.spec-lock` and fetches the
|
|
# ref it names, which is what a maintainer regenerating by hand gets.
|
|
#
|
|
# uv rather than a bare python3: the driver needs PyYAML and the runner image
|
|
# promises no interpreter at all, let alone one with it installed.
|
|
#
|
|
# Requires: java 17+, uv.
|
|
set -euo pipefail
|
|
cd "$(dirname "$0")/.."
|
|
|
|
: "${OPENAPI:?the generator lives in hanzoai/openapi; the ci client lane sets OPENAPI, or point it at a checkout}"
|
|
|
|
if [ -n "${SPEC:-}" ]; then set -- --spec "$SPEC" "$@"; fi
|
|
|
|
exec uv run --with pyyaml python3 "$OPENAPI/generate.py" cpp --repo "$PWD" "$@"
|