1
0
Fork 0
forked from lthn/blockchain

Refactor build presets and folder layout for Windows

Updated Makefile and GitHub workflow to use configurable build and configure presets, improving flexibility for different environments. Adjusted CMakePresets.json to fix preset naming and version, and refactored conanfile.py to set build folders based on compiler type, ensuring correct folder structure for MSVC and other compilers.
This commit is contained in:
Snider 2025-10-08 23:04:54 +01:00
parent cea280777e
commit 5d9d6f9282
4 changed files with 21 additions and 24 deletions

View file

@ -70,7 +70,7 @@ jobs:
- run: pip install mkdocs-material mkdocs-git-revision-date-localized-plugin mkdocs-git-committers-plugin-2 mkdocs-git-authors-plugin "mkdocs-material[imaging]"
- name: Compile Release
run: make release CPU_CORES=4 TESTNET=${{ inputs.chain-network == 'testnet' && '1' || '0' }}
run: make release PRESET_CONFIGURE=conan-default CPU_CORES=4 TESTNET=${{ inputs.chain-network == 'testnet' && '1' || '0' }}
- name: CLI Artifacts
uses: ./.github/actions/upload-artifacts

View file

@ -1,11 +1,10 @@
{
"version": 10,
"version": 8,
"cmakeMinimumRequired": {
"major": 3,
"minor": 23,
"patch": 0
},
"$comment": "Lethean presets",
"include": [
"ConanPresets.json"
@ -22,7 +21,7 @@
}
},
{
"name": "windows-default",
"name": "windows-defaultss",
"displayName": "Windows x64 Debug",
"description": "Sets Ninja generator, compilers, x64 architecture, build and install directory, debug build type",
"generator": "Ninja",

View file

@ -16,6 +16,8 @@ STATIC:= 0
BUILD_TYPE ?=Release
BUILD_VERSION:=6.0.1
BUILD_FOLDER:=build/release
PRESET_BUILD:=conan-release
PRESET_CONFIGURE:=conan-release
# -----------------------------------------------------------------
# Unixlike systems (Linux, macOS, *BSD, etc.)
@ -77,14 +79,7 @@ release: docs build
@rm -rf $(CURDIR)/build/packages/_CPack_Packages
build: configure
cmake --build --preset conan-release --parallel=$(CPU_CORES)
debug: conan-profile-detect
@echo "Building profile: debug"
CONAN_HOME=$(CONAN_CACHE) $(CONAN_EXECUTABLE) install . --build=missing -s build_type=Debug
cmake -S . -B $(CURDIR)/build/debug -DCMAKE_TOOLCHAIN_FILE=$(CURDIR)/build/debug/generators/conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Debug -DTESTNET=$(TESTNET)
cmake --build $(CURDIR)/build/debug --config=Debug --parallel=$(CPU_CORES)
cmake --build --preset $(PRESET_BUILD) --parallel=$(CPU_CORES)
build-deps: conan-profile-detect
@echo "Build Dependencies: $(BUILD_TYPE) testnet=$(TESTNET)"
@ -92,7 +87,7 @@ build-deps: conan-profile-detect
configure: build-deps
@echo "Running Configure: $(BUILD_TYPE) testnet=$(TESTNET)"
cmake --preset conan-release -DSTATIC=$(STATIC) -DTESTNET=$(TESTNET) -DBUILD_VERSION=$(BUILD_VERSION)
cmake --preset $(PRESET_CONFIGURE) -DSTATIC=$(STATIC) -DTESTNET=$(TESTNET) -DBUILD_VERSION=$(BUILD_VERSION)
docs: configure
@echo "Building Documentation"
@ -165,4 +160,4 @@ clean-build:
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 docker-chain-node debug 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)

View file

@ -32,12 +32,10 @@ class BlockchainConan(ConanFile):
def generate(self):
tc = CMakeToolchain(self)
# When conan-default / conan-release becomes an issue the blow adds OS, ARCH and Compiler to the preset name
# if self.options.__contains__("CI"):
# os_val = str(self.settings.os).lower()
# arch_val = str(self.settings.arch).lower()
# compiler_val = str(self.settings.compiler).lower()
# tc.presets_prefix = f"{os_val}-{arch_val}-{compiler_val}"
os_val = str(self.settings.os).lower()
# arch_val = str(self.settings.arch).lower()
# compiler_val = str(self.settings.compiler).lower()
# tc.presets_prefix = f"{os_val}"
tc.user_presets_path = "ConanPresets.json"
tc.variables["STATIC"] = self.options.static
@ -50,10 +48,15 @@ class BlockchainConan(ConanFile):
deps.generate()
def layout(self):
self.folders.generators = os.path.join("build", str(self.settings.build_type).lower(), "generators")
self.folders.build = os.path.join("build", str(self.settings.build_type).lower())
# self.folders.build_folder_vars = ["settings.os", "settings.arch", "settings.compiler", "settings.build_type"]
if self.settings.compiler == "msvc":
# For multi-config, all configurations go into the same "build" folder.
self.folders.build = "build/release"
self.folders.generators = "build/release/generators"
else:
# For single-config, we create a subfolder for each build type.
build_type_str = str(self.settings.build_type).lower()
self.folders.build = os.path.join("build", build_type_str)
self.folders.generators = os.path.join(self.folders.build, "generators")
def build(self):
cmake = CMake(self)