added auto incremental version system

This commit is contained in:
NotImplementedLife 2022-05-10 09:57:13 +03:00
parent d1e5ecd0c2
commit 91cd4e334b
6 changed files with 62 additions and 1 deletions

3
.gitignore vendored
View File

@ -1,3 +1,4 @@
__pycache__/
.git/
arm7/build/
arm9/build/
@ -5,5 +6,5 @@ build/
flipnotes-example/
FSPDS.layout
*.elf
FSPDS.nds
*.nds
run.bat

View File

@ -10,6 +10,7 @@ include $(DEVKITARM)/ds_rules
export GAME_TITLE := FSPDS
export GAME_ICON := $(CURDIR)/icon.bmp
export TARGET := FSPDS
export NDS_FILE := $(TARGET)
.PHONY: arm7/$(TARGET).elf arm9/$(TARGET).elf
@ -23,6 +24,7 @@ all: $(TARGET).nds
$(TARGET).nds : arm7/$(TARGET).elf arm9/$(TARGET).elf
@ndstool -7 arm7/$(TARGET).elf -9 arm9/$(TARGET).elf -b $(GAME_ICON) "$(GAME_TITLE)" -c $(TARGET).nds
@echo built ... $(notdir $@)
mv $(TARGET).nds $(TARGET)-V${shell python build_counter.py}.nds
#---------------------------------------------------------------------------------
arm7/$(TARGET).elf:

6
arm9/include/version.h Normal file
View File

@ -0,0 +1,6 @@
#pragma once
extern const char BUILD_TYPE; //! 'D' = Debug, 'R' = Release
extern const u8 MAJOR;
extern const u8 MINOR;
extern const u32 BUILD;

View File

@ -0,0 +1,6 @@
// This file was generated automatically. Do not modify it
#include "version.h"
const char BUILD_TYPE = 'D';
const u8 MAJOR = 0;
const u8 MINOR = 3;
const u32 BUILD = 40471012;

43
build_counter.py Normal file
View File

@ -0,0 +1,43 @@
#!/usr/bin/env python
from datetime import datetime
import sys
origin = datetime(2021, 1, 27)
now = datetime.now()
build_number = int((now - origin).total_seconds())
bc_src_string ='// This file was generated automatically. Do not modify it\n#include "version.h"\n'
from importlib.util import spec_from_loader, module_from_spec
from importlib.machinery import SourceFileLoader
spec = spec_from_loader("version", SourceFileLoader("version", "version.ini"))
version = module_from_spec(spec)
spec.loader.exec_module(version)
def get_book_variable_module_name(module_name):
module = globals().get(module_name, None)
book = {}
if module:
book = {key: value for key, value in module.__dict__.items() if not (key.startswith('__') or key.startswith('_'))}
return book
book = get_book_variable_module_name('version')
book['BUILD'] = build_number;
for key, value in book.items():
if isinstance(value, int):
if(value<256):
bc_src_string += "const u8 {:<10} = {:>12};\n".format(key,value)
else:
bc_src_string += "const u32 {:<10} = {:>12};\n".format(key, value)
elif isinstance(value, str):
if(len(value)==1):
bc_src_string += "const char {:<10} = {:>12};\n".format(key, f"'{value}'")
print(f"{book['MAJOR']}.{book['MINOR']}.{build_number}{book['BUILD_TYPE']}")
bc_src = open("arm9/source/build_counter.c", "w")
bc_src.write(bc_src_string)
bc_src.close()

3
version.ini Normal file
View File

@ -0,0 +1,3 @@
BUILD_TYPE = 'D'
MAJOR = 0
MINOR = 3