1
0
Fork 0
forked from lthn/blockchain

Improve SDK build process and Go client config

Added linguist-generated attribute for SDK clients in .gitattributes to hide them in GitHub diffs. Enhanced utils/sdk/Makefile with target-specific hooks, improved ignore file handling, and refined Go client build steps. Updated Go SDK config to use 'lthn' as package name and set isGoSubmodule property.
This commit is contained in:
Snider 2025-10-19 14:48:58 +01:00
parent ef59026e39
commit a3faa95400
4 changed files with 45 additions and 11 deletions

5
.gitattributes vendored
View file

@ -1,2 +1,5 @@
.git* export-ignore
/CMakeLists.txt export-subst
/CMakeLists.txt export-subst
# Mark auto-generated SDK clients as "generated" to hide them in GitHub diffs
utils/sdk/client/** linguist-generated=true

View file

@ -190,3 +190,4 @@ tags:
ctags -R --sort=1 --c++-kinds=+p --fields=+iaS --extra=+q --language-force=C++ src contrib tests/gtest
.PHONY: all release upload-conan-cache docs docs-dev configure static static-release test test-release test-debug clean tags conan-profile-detect get-conan $(PROFILES) sdk $(SDK_TARGETS)
.PHONY: go-client

View file

@ -1,9 +1,29 @@
PACKAGE_VERSION?=6.0.1
BASE_DIR:=$(CURDIR)
BUILD_DIR:=$(BASE_DIR)/../../build/packages
# Default build directory. Can be overridden from the parent Makefile.
# e.g., `make sdk BUILD_DIR=client` will output to the `client/` directory.
BUILD_DIR?=$(BASE_DIR)/../../build/packages
SDK_TARGETS := $(patsubst packages/%.json,%,$(wildcard packages/*.json))
# Default target to build all SDKs. This is the main entry point.
# --- Target-Specific Hooks ---
# Define pre- and post-build steps for specific languages.
# By default, these hooks are empty.
PRE_BUILD_HOOK = @true
POST_BUILD_HOOK = @true
# For the 'go' target, create an ignore file to prevent unwanted files from being generated.
go: PRE_BUILD_HOOK = @echo "--> Creating .openapi-generator-ignore file for Go client"; \
echo "go.sum" >> $(BUILD_DIR)/go/.openapi-generator-ignore
# For the 'go' target, define specific post-build steps.
go: POST_BUILD_HOOK = (cd $(BUILD_DIR)/go && go mod edit -module github.com/letheanVPN/blockchain/utils/sdk/client/go && go mod tidy)
# For the 'go' target, set the generator name correctly.
go: GENERATOR_NAME = go
# --- Main Targets ---
all: build
build: $(SDK_TARGETS)
@ -12,19 +32,28 @@ build: $(SDK_TARGETS)
# Rule to build each SDK package using OpenAPI Generator.
# It reads the corresponding JSON config file and generates the SDK in the build directory.
$(SDK_TARGETS): %: packages/%.json
# Default generator name is the target name itself.
$(eval GENERATOR_NAME = $@)
@echo "--> Creating .openapi-generator-ignore file"
@echo "git_push.sh" > "$(BUILD_DIR)/$@/.openapi-generator-ignore"
@echo ".travis.yml" >> "$(BUILD_DIR)/$@/.openapi-generator-ignore"
@echo "README.md" >> "$(BUILD_DIR)/$@/.openapi-generator-ignore"
@echo "--- Building package $@ with version $(PACKAGE_VERSION) ---"
# Run pre-build hook
$(PRE_BUILD_HOOK)
rm -rf "$(BUILD_DIR)/$@/*"
export TS_POST_PROCESS_FILE="/usr/local/bin/prettier --write" && \
openapi-generator generate --skip-validate-spec \
openapi-generator generate --minimal-update --git-host "github.com" --git-repo-id "blockchain" --git-user-id "letheanVPN" \
-i "$(BASE_DIR)/spec/oas-3.0.0.json" \
-g "$@" \
-g "$(GENERATOR_NAME)" \
-o "$(BUILD_DIR)/$@" \
-c "$<" \
--artifact-version "$(PACKAGE_VERSION)" \
--group-id "lethean" \
-p packageVersion="$(PACKAGE_VERSION)" \
--global-property "apiTests=true" \
--additional-properties=npmVersion="$(PACKAGE_VERSION)",artifactVersion="$(PACKAGE_VERSION)"
--package-name "lthn"
# Run post-build hook
@echo "--> Running Post Build..."
$(POST_BUILD_HOOK)
# Phony targets to avoid conflicts with file names and to ensure they always run.
.PHONY: all build $(SDK_TARGETS)

View file

@ -1,6 +1,7 @@
{
"additionalProperties": {
"packageName": "lethean-chain-sdk-go",
"generateInterfaces": true
"packageName": "lthn",
"generateInterfaces": true,
"isGoSubmodule": true
}
}