Add recipe support.

This commit is contained in:
2023-06-25 12:44:11 +02:00
parent feb87f3cf2
commit 0071b4942e
10 changed files with 253 additions and 10 deletions

Binary file not shown.

View File

@@ -0,0 +1,26 @@
from git import Repo
from git.exc import GitError
import hashlib
import os
from SCons.Script import *
def cook(env: Environment, repo_name: str, remote_url: str, git_ref: str = "main") -> dict:
repo_dir = os.path.join(env['CLONE_DIR'], 'git', repo_name, '_bare')
try:
repo = Repo(repo_dir)
origin = repo.remotes['origin']
except GitError:
print(f'Initializing git repository for SDL at {repo_dir}.')
repo = Repo.init(repo_dir, bare=True)
origin = repo.create_remote('origin', remote_url)
worktree_dir = os.path.join(env['CLONE_DIR'], 'git', repo_name, hashlib.shake_128(git_ref.encode('utf-8')).hexdigest(6)) # TODO: commit hash would be better, right?
if not os.path.exists(worktree_dir):
print(f'Checking out into {worktree_dir}.')
origin.fetch()
os.makedirs(worktree_dir)
repo.git.worktree('add', worktree_dir, git_ref)
return {
'checkout_root': worktree_dir
}

Binary file not shown.

40
recipes/SDL/recipe.py Normal file
View File

@@ -0,0 +1,40 @@
import os
import subprocess
import sys
from SCons.Script import *
def cook(env: Environment, git_ref: str = "main") -> dict:
repo = env.Cook('GitBranch', repo_name = 'SDL', remote_url = 'https://github.com/libsdl-org/SDL.git', git_ref = git_ref)
checkout_root = repo['checkout_root']
config = env['BUILD_TYPE']
build_dir = os.path.join(checkout_root, f'build_{config}')
install_dir = os.path.join(checkout_root, f'install_{config}')
lib_fname = {
'debug': 'libSDL2d.a'
}.get(env['BUILD_TYPE'], 'libSDL2.a') # TODO: who cares about windows?
is_built = os.path.exists(os.path.join(build_dir, lib_fname)) # TODO!
if not is_built:
print(f'Building SDL, config {config}')
os.makedirs(build_dir, exist_ok=True)
build_type = {
'debug': 'Debug',
'release_debug': 'RelWithDebInfo',
'release': 'Release',
'profile': 'RelWithDebInfo'
}.get(env['BUILD_TYPE'], 'RelWithDebInfo')
subprocess.run(('cmake', '-G', 'Ninja', '-B', build_dir, f'-DCMAKE_BUILD_TYPE={build_type}', '-DSDL_STATIC=ON', '-DSDL_SHARED=OFF', f'-DCMAKE_INSTALL_PREFIX={install_dir}', checkout_root), stdout=sys.stdout, stderr=sys.stderr, check=True)
subprocess.run(('cmake', '--build', build_dir), stdout=sys.stdout, stderr=sys.stderr, check=True)
subprocess.run(('cmake', '--install', build_dir), stdout=sys.stdout, stderr=sys.stderr, check=True)
lib_name = {
'debug': 'SDL2d'
}.get(env['BUILD_TYPE'], 'SDL2')
return {
'LIBPATH': [os.path.join(install_dir, 'lib')],
'CPPPATH': [os.path.join(install_dir, 'include')],
'LIBS': [lib_name, 'm']
}

View File

@@ -0,0 +1,9 @@
import os
from SCons.Script import *
def cook(env: Environment, git_ref: str = "main") -> dict:
repo = env.Cook('GitBranch', repo_name = 'VulkanHeaders', remote_url = 'https://github.com/KhronosGroup/Vulkan-Headers.git', git_ref = git_ref)
checkout_root = repo['checkout_root']
env.Append(CPPPATH = [os.path.join(checkout_root, 'include')])
return {}

Binary file not shown.

8
recipes/mijin/recipe.py Normal file
View File

@@ -0,0 +1,8 @@
import os
from SCons.Script import *
def cook(env: Environment, git_ref: str = "master") -> dict:
repo = env.Cook('GitBranch', repo_name = 'mijin', remote_url = 'ssh://git@git.mewin.de:10022/mewin/mijin2.git', git_ref = git_ref)
checkout_root = repo['checkout_root']
return SConscript(os.path.join(checkout_root, 'LibConf'), exports = ['env'])