diff --git a/.github/workflows/bundles.yml b/.github/workflows/bundles.yml index 6733395c..227148b0 100644 --- a/.github/workflows/bundles.yml +++ b/.github/workflows/bundles.yml @@ -38,11 +38,6 @@ jobs: python-version: '3.11' cache: 'pip' - - name: Fetch build dependencies - run: | - pip install --upgrade pip - pip install tomlkit - - uses: moguri/setup-blender@v1 with: blender-version: '4.2.4' diff --git a/.gitignore b/.gitignore index c93658d8..7dc5f6c9 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,10 @@ release/* # For ignored files in bin/ subdirectory, see the .gitignore file in bin/ wheels/ + +# CMake various files +build/ +CMakeCache.txt +CMakeFiles/ +Makefile +cmake_install.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..a6e1112e --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,46 @@ +cmake_minimum_required(VERSION 3.25) +project(BlendLuxCore LANGUAGES NONE) + +file(MAKE_DIRECTORY build) + +function(validate_blender_version result blender) + execute_process( + COMMAND ${blender} --version + OUTPUT_VARIABLE blender_output + ) + if (blender_output MATCHES "Blender ([0-9]+\.[0-9]+\.[0-9]+).*") + set(version ${CMAKE_MATCH_1}) + message(STATUS "Blender version: ${version}") + if (${version} VERSION_LESS "4.2.0") + message(FATAL_ERROR "Bad Blender version - expected 4.2.0 or higher") + set(${result} FALSE PARENT_SCOPE) + else() + message(STATUS "Blender version OK") + set(${result} TRUE PARENT_SCOPE) + endif() + else() + message(FATAL_ERROR "Blender version: Not found") + set(${result} FALSE PARENT_SCOPE) + endif() +endfunction() + + +# Get BlendLuxCore version +execute_process( + COMMAND python + ${CMAKE_CURRENT_SOURCE_DIR}/cmake/blendluxcore_version.py + ${CMAKE_CURRENT_SOURCE_DIR}/blender_manifest.toml + OUTPUT_VARIABLE BLC_VERSION +) + +find_program(BLENDER blender NAMES blender.exe VALIDATOR validate_blender_version NO_CACHE) + +# Add BlendLuxCore target +add_custom_target( + extension ALL + COMMAND ${BLENDER} + --command extension build + --source-dir ${CMAKE_CURRENT_SOURCE_DIR} + --output-filepath ${CMAKE_CURRENT_BINARY_DIR}/build/BlendLuxCore-${BLC_VERSION}.zip + VERBATIM +) diff --git a/cmake/blendluxcore_version.py b/cmake/blendluxcore_version.py new file mode 100644 index 00000000..06646040 --- /dev/null +++ b/cmake/blendluxcore_version.py @@ -0,0 +1,15 @@ +"""Retrieve BlendLuxCore version from blender_manifest.toml""" +import tomllib +import os +from pathlib import Path +import argparse + + +parser = argparse.ArgumentParser() +parser.add_argument("filepath", type=Path) +args = parser.parse_args() + +with open(args.filepath, 'rb') as fp: + manifest = tomllib.load(fp) +version = manifest['version'] +print(version, end='')