Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Korman Buildsystem for CI. #272

Merged
merged 4 commits into from
Aug 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 96 additions & 0 deletions .github/workflows/ci_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: CI Build
on: [push, pull_request]

jobs:
windows-build:
strategy:
matrix:
cfg:
- {
os: windows-2019,
generator: Visual Studio 16 2019,
arch: Win32,
str: windows-x86,
blender-url: "https://github.com/Hoikas/blender2.7/releases/download/blender2.79_20210808/blender-2.79.0-git20210808.d2e1ea3f63e3-windows32.zip",
}
- {
os: windows-2019,
generator: Visual Studio 16 2019,
arch: x64,
str: windows-x64,
blender-url: "https://github.com/Hoikas/blender2.7/releases/download/blender2.79_20210808/blender-2.79.0-git20210808.d2e1ea3f63e3-windows64.zip",
}

env:
CMAKE_GENERATOR: ${{ matrix.cfg.generator }}
CMAKE_GENERATOR_PLATFORM: ${{ matrix.cfg.arch }}

runs-on: ${{ matrix.cfg.os }}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
path: korman

- name: Download Blender
run: |
curl --location "${{ matrix.cfg.blender-url }}" --output blender.zip
mkdir blender
7z x blender.zip -oblender -bsp1

- name: Build Standalone Korman
run: |
$BlenderSubDir = Split-Path -LeafBase $([System.URI]"${{ matrix.cfg.blender-url }}").Segments[-1]
korman/build.ps1 `
-Modern `
-BlenderDir "${{ github.workspace }}/blender/$BlenderSubDir" `
-NoInstaller -NoBlender

- name: Upload Standalone Korman
uses: actions/upload-artifact@v2
with:
name: korman-standalone-${{ matrix.cfg.str }}
path: build/package

- name: Build Korman+Blender Bundle
if: startsWith(github.ref, 'refs/tags')
run: |
Remove-Item -Recurse -Force build/package
korman/build.ps1 -Modern

- name: Upload Korman+Blender Bundle
if: startsWith(github.ref, 'refs/tags')
uses: actions/upload-artifact@v2
with:
name: korman-blender-${{ matrix.cfg.str }}
path: build/package

publish:
if: startsWith(github.ref, 'refs/tags')
needs: [windows-build]
runs-on: windows-2019

steps:
- name: Checkout Korman
uses: actions/checkout@v2
with:
path: korman

- name: Download Artifacts
id: download
uses: actions/download-artifact@v2
with:
path: artifacts

- name: Publish Release
run: |
korman/release.ps1 `
-Repository "${{ github.repository }}" `
-Token "${{ secrets.GITHUB_TOKEN }}" `
-UploadDir "${{ steps.download.outputs.download-path }}" `
-SubDirs @{
"korman-standalone-windows-x86" = "standalone"
"korman-standalone-windows-x64" = "standalone"
"korman-blender-windows-x86" = "bundled"
"korman-blender-windows-x64" = "bundled"
}
93 changes: 93 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# This file is part of Korman.
#
# Korman is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Korman is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Korman. If not, see <http://www.gnu.org/licenses/>.

cmake_minimum_required(VERSION 3.12)

set(_PROJECT_INFO
korman
VERSION 0.11
DESCRIPTION "Blender plugin for creating ages for Cyan Worlds' proprietary Plasma engine and its open source variant, CyanWorlds.com Engine."
LANGUAGES CXX # This should probably be NONE, but we need the compiler for string_theory tests
)
project(${_PROJECT_INFO})

include(CMakeDependentOption)

set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
set(CMAKE_INSTALL_PREFIX "${PROJECT_BINARY_DIR}/install" CACHE PATH "")

# TODO: Maybe use cmake_path (requires CMake 3.21) to ensure Blender_EXECUTABLE is not in the CMAKE_INSTALL_PREFIX?
# That would indicate that we are installing Korman into the blender we found, so no need to install blender.
option(korman_INSTALL_BLENDER "Copy Blender as part of the INSTALL target" ON)
option(korman_INSTALL_SCRIPTS "Copy Korman python scripts as part of the INSTALL target" ON)

# While, yes, we could tie our build process into Blender's, Blender pulls in
# tons of dependencies and can be quite slow if you start trying to build
# errthang from source. So, we'll jst let you handle that. Good luck!
if(NOT "${Blender_PYTHON_VERSION}" OR korman_INSTALL_BLENDER)
set(_Blender_REQUIRED "REQUIRED")
elseif("${Blender_PYTHON_VERSION}" AND NOT "${Blender_PYTHON_VERSION}" MATCHES "^[0-9]+\\.[0-9]+$")
message(FATAL_ERROR "Your manually defined Blender python version ($CACHE{Blender_PYTHON_VERSION}) doesn't pass muster.")
endif()
find_package(Blender 2.79 EXACT ${_Blender_REQUIRED})

# Gotta do this because libHSPlasma is still using the old broke-ass pre-3.12 find modules.
set(Python3_FIND_STRATEGY VERSION)
find_package(Python3 ${Blender_PYTHON_VERSION} EXACT COMPONENTS Development REQUIRED)

include(Dependencies)
include(Packaging)

if(korman_INSTALL_SCRIPTS)
set(korman_INSTALL_SCRIPTS_PATH "${Blender_VERSION}/scripts/addons" CACHE STRING "")
install(DIRECTORY
"${CMAKE_SOURCE_DIR}/korman"
DESTINATION "${korman_INSTALL_SCRIPTS_PATH}"
COMPONENT "Korman"
FILES_MATCHING
PATTERN "*.py"
)
endif()

# When we update to CMake 3.21, it might be worth separating the dependency build
# and Korman build a little more and using install(TARGETS RUNTIME_DEPENDENCIES). For now,
# this causes no observable problems and gives a good result, so meh.
set(korman_INSTALL_BINARY_DIR "${Blender_VERSION}/python/lib/site-packages" CACHE STRING "")
install(DIRECTORY
"${korman_HARVEST_DIR}/bin/"
DESTINATION "${korman_INSTALL_BINARY_DIR}"
COMPONENT "Korman"
FILES_MATCHING
PATTERN "*.dll"
PATTERN "*.pyd"
PATTERN "*.so"
)

if(korman_INSTALL_BLENDER)
get_filename_component(_Blender_PATH "${Blender_EXECUTABLE}" DIRECTORY)
install(DIRECTORY
"${_Blender_PATH}/"
DESTINATION "."
COMPONENT "Blender"
)
endif()

if(korman_HARVEST_PYTHON22)
install(PROGRAMS
"${korman_HARVEST_DIR}/bin/Python-2.2.3.exe"
DESTINATION "."
COMPONENT "Python22"
)
endif()
Loading