mirror of
https://github.com/drewcassidy/KSP-DepthMask
synced 2024-09-01 14:54:35 +00:00
Rework build system to be automated
This commit is contained in:
3
Tools/requirements.txt
Normal file
3
Tools/requirements.txt
Normal file
@ -0,0 +1,3 @@
|
||||
GitPython ~= 3.1.27
|
||||
yaclog ~= 1.0.4
|
||||
jinja2 ~= 3.1.0
|
55
Tools/version.py
Normal file
55
Tools/version.py
Normal file
@ -0,0 +1,55 @@
|
||||
# This file generates versioned files for deploying DepthMask
|
||||
|
||||
import yaclog
|
||||
import yaclog.version
|
||||
import git as gp
|
||||
import os
|
||||
from pathlib import Path
|
||||
from jinja2 import Environment, FileSystemLoader, select_autoescape
|
||||
|
||||
|
||||
def run():
|
||||
basedir = Path(__file__).parent.parent
|
||||
|
||||
g = gp.Git(basedir)
|
||||
|
||||
release = True
|
||||
tag, distance, sha = g.execute(["git", "describe"]).split("-")
|
||||
|
||||
if int(distance) > 0:
|
||||
release = False
|
||||
tag = yaclog.version.increment_version(tag, 2)
|
||||
|
||||
segments = tag.split('.')
|
||||
ver_major, ver_minor, ver_patch = segments[0:3]
|
||||
if len(segments) >= 4:
|
||||
ver_build = segments[3]
|
||||
elif release:
|
||||
ver_build = int(distance)
|
||||
else:
|
||||
ver_build = int("0x" + sha[1:5], 16)
|
||||
|
||||
print(f'Configuring version {ver_major}.{ver_minor}.{ver_patch} build {ver_build}')
|
||||
|
||||
env = Environment(
|
||||
loader=FileSystemLoader(basedir / "Templates"),
|
||||
autoescape=select_autoescape()
|
||||
)
|
||||
|
||||
for template_name in ["GameData/DepthMask/DepthMask.version", "DepthMask/Properties/AssemblyInfo.cs"]:
|
||||
print("Generating " + template_name)
|
||||
template = env.get_template(template_name)
|
||||
with open(basedir / template_name, "w") as fh:
|
||||
fh.write(template.render(
|
||||
ver_major=ver_major,
|
||||
ver_minor=ver_minor,
|
||||
ver_patch=ver_patch,
|
||||
ver_build=ver_build,
|
||||
tag=tag
|
||||
))
|
||||
|
||||
print('Done!')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
run()
|
Reference in New Issue
Block a user