Added options to version specs and allow specifying a git ref to build instead of a version.

This commit is contained in:
2024-09-11 09:00:03 +02:00
parent bdf063a16c
commit 1b8d6e175b
2 changed files with 56 additions and 13 deletions

View File

@@ -2,7 +2,6 @@
from git import Repo
from git.exc import GitError
import hashlib
import re
from SCons.Script import *
Import('env')
@@ -56,7 +55,9 @@ def _git_recipe(env: Environment, globals: dict, repo_name, repo_url, cook_fn, v
_tag_pattern = _make_callable(tag_pattern)
versions_cb = versions and _make_callable(versions)
def _versions(env: Environment, update: bool = False):
def _versions(env: Environment, update: bool = False, options: dict = {}):
if 'ref' in options:
return [(0, 0, 0)] # no versions if compiling from a branch
pattern = _tag_pattern(env)
if pattern:
tags = env.GitTags(repo_name = _repo_name(env), remote_url = _repo_url(env), force_fetch=update)
@@ -76,8 +77,10 @@ def _git_recipe(env: Environment, globals: dict, repo_name, repo_url, cook_fn, v
def _dependencies(env: Environment, version) -> 'dict':
return dependencies
def _cook(env: Environment, version) -> dict:
if tag_fn:
def _cook(env: Environment, version, options: dict = {}) -> dict:
if 'ref' in options:
git_ref = options['ref']
elif tag_fn:
git_ref = f'refs/tags/{tag_fn(version)}'
else:
assert ref_fn