forked from lthn/blockchain
Add configuration files for SDK generation and OpenAPI specifications
This commit is contained in:
parent
e5c5d1e279
commit
c03c4dac86
6 changed files with 82 additions and 14 deletions
43
Makefile
43
Makefile
|
|
@ -58,16 +58,17 @@ CPU_CORES := $(or $(CPU_CORES),1)
|
|||
CPU_CORES := $(shell expr $(CPU_CORES) + 0 2>/dev/null || echo 1)
|
||||
CONAN_CPU_COUNT=$(CPU_CORES)
|
||||
|
||||
|
||||
PROFILES := $(patsubst cmake/profiles/%,%,$(wildcard cmake/profiles/*))
|
||||
SORTED_PROFILES := $(sort $(PROFILES))
|
||||
CONAN_CACHE := $(CURDIR)/build/sdk
|
||||
CONAN_URL:=https://artifacts.host.uk.com/artifactory/api/conan/conan-build
|
||||
CONAN_USER:=public
|
||||
CONAN_PASSWORD:=Lethean1234
|
||||
DEFAULT_CONAN_PROFILE := $(CONAN_CACHE)/profiles/default
|
||||
CONAN_EXECUTABLE := $(CURDIR)/build/bin/conan
|
||||
CC_DOCKER_FILE?=utils/docker/images/lthn-chain/Dockerfile
|
||||
PROFILES :=$(patsubst cmake/profiles/%,%,$(wildcard cmake/profiles/*))
|
||||
SORTED_PROFILES :=$(sort $(PROFILES))
|
||||
CONAN_CACHE :=$(CURDIR)/build/sdk
|
||||
CONAN_URL :=https://artifacts.host.uk.com/artifactory/api/conan/conan-build
|
||||
CONAN_USER :=public
|
||||
CONAN_PASSWORD :=Lethean1234
|
||||
CONAN_EXECUTABLE :=$(CURDIR)/build/bin/conan
|
||||
CC_DOCKER_FILE ?=utils/docker/images/lthn-chain/Dockerfile
|
||||
SDK_PACKAGES_JSON :=$(wildcard utils/sdk/packages/*.json)
|
||||
SDK_TARGETS :=$(patsubst utils/sdk/packages/%.json,%,$(SDK_PACKAGES_JSON))
|
||||
SORTED_SDK_TARGETS :=$(sort $(SDK_TARGETS))
|
||||
|
||||
all: help
|
||||
|
||||
|
|
@ -98,6 +99,9 @@ docs: configure
|
|||
@echo "Building Documentation"
|
||||
cmake --build build/release --target=docs --config=Release --parallel=$(CPU_CORES)
|
||||
|
||||
sdk:
|
||||
$(MAKE) -C utils/sdk $(filter-out $@,$(MAKECMDGOALS)) PACKAGE_VERSION=$(BUILD_VERSION)
|
||||
|
||||
# Rule for each profile
|
||||
$(PROFILES): conan-profile-detect
|
||||
@echo "Building profile: $@"
|
||||
|
|
@ -107,6 +111,12 @@ $(PROFILES): conan-profile-detect
|
|||
(cd $(BUILD_FOLDER) && cpack)
|
||||
|
||||
help:
|
||||
@echo "Lethean VPN Blockchain"
|
||||
@echo "======================"
|
||||
@echo "Website: https://lt.hn"
|
||||
@echo "GitHub: https://github.com/letheanVPN/blockchain/"
|
||||
@echo "Discord: https://discord.lt.hn"
|
||||
@echo ""
|
||||
@echo "Available targets:"
|
||||
@printf " %-42s %s\n" "make clean" "Clean all build directories"
|
||||
@printf " %-42s %s\n" "make get-conan" "Download and install conan locally"
|
||||
|
|
@ -118,12 +128,14 @@ help:
|
|||
@printf " %-42s %s\n" "make docs-dev" "Runs local doc server, for editing/adding docs"
|
||||
@printf " %-42s %s\n" "make conan-profile-detect" "Creates host config"
|
||||
@printf " %-42s %s\n" "make configure" "Runs a cmake configure within conan build flow"
|
||||
@printf "\n --- Conan Cross-Compilation Profiles ---\n"
|
||||
@$(foreach profile,$(SORTED_PROFILES),printf " %-42s %s\n" "make $(profile)" "Build the $(profile) profile";)
|
||||
@printf "\n --- SDK Generation ---\n"
|
||||
@printf " %-42s %s\n" "make sdk" "Build all SDK packages"
|
||||
@$(foreach sdk,$(SORTED_SDK_TARGETS),printf " %-42s %s\n" "make sdk $(sdk)" "Build the $(sdk) SDK package";)
|
||||
@printf "\n"
|
||||
@printf " %-42s %s\n" "make help" "Show this help message"
|
||||
|
||||
#
|
||||
# Tests
|
||||
#
|
||||
|
||||
test: test-release
|
||||
test-release:
|
||||
|
|
@ -156,6 +168,9 @@ docs-dev: configure
|
|||
@echo "Building Documentation"
|
||||
cmake --build build/release --target=serve_docs --config=Release
|
||||
|
||||
$(SDK_TARGETS):
|
||||
@# This is a proxy target. Handled by the 'sdk' rule.
|
||||
|
||||
clean:
|
||||
@cmake -P cmake/CleanBuild.cmake
|
||||
|
||||
|
|
@ -165,4 +180,4 @@ clean-build: clean
|
|||
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)
|
||||
.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)
|
||||
|
|
|
|||
30
utils/sdk/Makefile
Normal file
30
utils/sdk/Makefile
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
PACKAGE_VERSION?=6.0.1
|
||||
BASE_DIR:=$(CURDIR)
|
||||
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.
|
||||
all: build
|
||||
|
||||
build: $(SDK_TARGETS)
|
||||
@echo "All SDKs have been processed."
|
||||
|
||||
# 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
|
||||
@echo "--- Building package $@ with version $(PACKAGE_VERSION) ---"
|
||||
rm -rf "$(BUILD_DIR)/$@/*"
|
||||
export TS_POST_PROCESS_FILE="/usr/local/bin/prettier --write" && \
|
||||
openapi-generator generate --skip-validate-spec \
|
||||
-i "$(BASE_DIR)/spec/oas-3.0.0.json" \
|
||||
-g "$@" \
|
||||
-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)"
|
||||
|
||||
# Phony targets to avoid conflicts with file names and to ensure they always run.
|
||||
.PHONY: all build $(SDK_TARGETS)
|
||||
7
utils/sdk/openapitools.json
Normal file
7
utils/sdk/openapitools.json
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"$schema": "./node_modules/@openapitools/openapi-generator-cli/config.schema.json",
|
||||
"spaces": 2,
|
||||
"generator-cli": {
|
||||
"version": "7.14.0"
|
||||
}
|
||||
}
|
||||
9
utils/sdk/packages/bash.json
Normal file
9
utils/sdk/packages/bash.json
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"additionalProperties": {
|
||||
"apiPackage": "lethean-chain-sdk-bash",
|
||||
"generateBashCompletion": true,
|
||||
"generateZshCompletion": true,
|
||||
"processMarkdown": true,
|
||||
"scriptName":"lthn-cli"
|
||||
}
|
||||
}
|
||||
6
utils/sdk/packages/go.json
Normal file
6
utils/sdk/packages/go.json
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"additionalProperties": {
|
||||
"packageName": "lethean-chain-sdk-go",
|
||||
"generateInterfaces": true
|
||||
}
|
||||
}
|
||||
1
utils/sdk/spec/oas-3.0.0.json
Normal file
1
utils/sdk/spec/oas-3.0.0.json
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"openapi":"3.0.0","info":{"title":"Lethean Blockchain API","description":"New API layer for Lethean","contact":{"name":"Lethean","url":"https:\/\/lt.hn\/"},"license":{"name":"EUPL-1.2","url":"https:\/\/joinup.ec.europa.eu\/software\/page\/eupl\/licence-eupl"},"version":"6.0.1"},"servers":[{"url":"http:\/\/localhost:8000","description":"server on localhost"}],"paths":{"\/info\/version":{"get":{"description":"Returns the current version of the API.","summary":"Get API version","operationId":"version","tags":["Info"],"responses":{"200":{"description":"OK","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/VersionDto"}}}}},"parameters":[]}},"\/block\/{hash}":{"get":{"summary":"Get a block by its hash","operationId":"getBlockByHash","tags":["Block"],"responses":{"200":{"description":"OK","content":{"application\/json":{"schema":{"$ref":"#\/components\/schemas\/BlockDetailsDto"}}}}},"parameters":[{"name":"hash","description":"The hash of the block to retrieve","in":"path","required":true,"deprecated":false,"schema":{"type":"string"}}]}}},"components":{"schemas":{"VersionDto":{"type":"object","properties":{"version":{"type":"string"},"version_long":{"type":"string"},"major":{"type":"string"},"minor":{"type":"string"},"revision":{"type":"string"}},"required":[]},"TransactionOutputDto":{"type":"object","properties":{"amount":{"type":"integer"},"global_index":{"type":"integer"},"is_spent":{"type":"boolean"},"minimum_sigs":{"type":"integer","minimum":0,"maximum":4294967295},"pub_keys":{"type":"array","items":{"type":"string"}}},"required":[]},"TransactionInputDto":{"type":"object","properties":{"amount":{"type":"integer"},"global_indexes":{"type":"array","items":{"type":"integer"}},"htlc_origin":{"type":"string"},"kimage_or_ms_id":{"type":"string"},"multisig_count":{"type":"integer","minimum":0,"maximum":4294967295}},"required":[]},"TransactionExtraDto":{"type":"object","properties":{"type":{"type":"string"},"short_view":{"type":"string"},"details_view":{"type":"string"}},"required":[]},"TransactionAttachmentDto":{"type":"object","properties":{"type":{"type":"string"},"short_view":{"type":"string"},"details_view":{"type":"string"}},"required":[]},"TransactionDetailsDto":{"type":"object","properties":{"amount":{"type":"integer"},"attachments":{"type":"array","items":{"$ref":"#\/components\/schemas\/TransactionAttachmentDto"}},"blob":{"type":"string"},"blob_size":{"type":"integer"},"extra":{"type":"array","items":{"$ref":"#\/components\/schemas\/TransactionExtraDto"}},"fee":{"type":"integer"},"id":{"type":"string"},"ins":{"type":"array","items":{"$ref":"#\/components\/schemas\/TransactionInputDto"}},"keeper_block":{"type":"integer","format":"int64"},"object_in_json":{"type":"string"},"outs":{"type":"array","items":{"$ref":"#\/components\/schemas\/TransactionOutputDto"}},"pub_key":{"type":"string"},"timestamp":{"type":"integer"}},"required":[]},"BlockDetailsDto":{"type":"object","properties":{"actual_timestamp":{"type":"integer"},"already_generated_coins":{"type":"string"},"base_reward":{"type":"integer"},"blob":{"type":"string"},"block_cumulative_size":{"type":"integer"},"block_tself_size":{"type":"integer"},"cumulative_diff_adjusted":{"type":"string"},"cumulative_diff_precise":{"type":"string"},"difficulty":{"type":"string"},"effective_fee_median":{"type":"integer"},"height":{"type":"integer"},"id":{"type":"string"},"is_orphan":{"type":"boolean"},"miner_text_info":{"type":"string"},"object_in_json":{"type":"string"},"penalty":{"type":"integer"},"pow_seed":{"type":"string"},"prev_id":{"type":"string"},"summary_reward":{"type":"integer"},"this_block_fee_median":{"type":"integer"},"timestamp":{"type":"integer"},"total_fee":{"type":"integer"},"total_txs_size":{"type":"integer"},"transactions_details":{"type":"array","items":{"$ref":"#\/components\/schemas\/TransactionDetailsDto"}},"type":{"type":"integer","minimum":0,"maximum":4294967295}},"required":[]}}}}
|
||||
Loading…
Add table
Reference in a new issue