split up taskfiles

add azure builds
This commit is contained in:
onyx-and-iris 2026-03-09 10:27:47 +00:00
parent 5e5ae33e6a
commit b0f634f1e8
8 changed files with 178 additions and 80 deletions

40
Taskfile.azure.yml Normal file
View File

@ -0,0 +1,40 @@
version: '3'
tasks:
build:
desc: Build Azure artifacts
deps: [rewrite]
cmds:
- defer: { task: restore }
- for:
matrix:
KIND: [basic, banana, potato]
THEME: [azure-light, azure-dark]
cmd: poetry run pyinstaller --noconfirm --distpath dist/{{.ITEM.THEME}}-{{.ITEM.KIND}} spec/azure/{{.ITEM.THEME}}-{{.ITEM.KIND}}.spec
rewrite:
internal: true
desc: Run the source code rewriter
cmds:
- poetry run python tools/rewriter.py --rewrite --theme {{.THEME}}
restore:
internal: true
desc: Restore the backup files
cmds:
- poetry run python tools/rewriter.py --restore
compress:
desc: Compress Azure artifacts
cmds:
- for:
matrix:
KIND: [basic, banana, potato]
THEME: [azure-light, azure-dark]
cmd: '{{.SHELL}} -Command "Compress-Archive -Path dist/{{.ITEM.THEME}}-{{.ITEM.KIND}} -DestinationPath dist/{{.ITEM.THEME}}-{{.ITEM.KIND}}.zip -Force"'
clean:
desc: Clean build and dist directories
cmds:
- |
{{.SHELL}} -Command "Remove-Item -Path build/azure-*,dist/azure-* -Recurse -Force"

40
Taskfile.forest.yml Normal file
View File

@ -0,0 +1,40 @@
version: '3'
tasks:
build:
desc: Build Forest artifacts
deps: [rewrite]
cmds:
- defer: { task: restore }
- for:
matrix:
KIND: [basic, banana, potato]
THEME: [forest-light, forest-dark]
cmd: poetry run pyinstaller --noconfirm --distpath dist/{{.ITEM.THEME}}-{{.ITEM.KIND}} spec/forest/{{.ITEM.THEME}}-{{.ITEM.KIND}}.spec
rewrite:
internal: true
desc: Run the source code rewriter
cmds:
- poetry run python tools/rewriter.py --rewrite --theme {{.THEME}}
restore:
internal: true
desc: Restore the backup files
cmds:
- poetry run python tools/rewriter.py --restore
compress:
desc: Compress Forest artifacts
cmds:
- for:
matrix:
KIND: [basic, banana, potato]
THEME: [forest-light, forest-dark]
cmd: '{{.SHELL}} -Command "Compress-Archive -Path dist/{{.ITEM.THEME}}-{{.ITEM.KIND}} -DestinationPath dist/{{.ITEM.THEME}}-{{.ITEM.KIND}}.zip -Force"'
clean:
desc: Clean build and dist directories
cmds:
- |
{{.SHELL}} -Command "Remove-Item -Path build/forest-*,dist/forest-* -Recurse -Force"

24
Taskfile.sunvalley.yml Normal file
View File

@ -0,0 +1,24 @@
version: '3'
tasks:
build:
desc: Build Sunvalley artifacts
cmds:
- for:
matrix:
KIND: [basic, banana, potato]
cmd: poetry run pyinstaller --noconfirm --distpath dist/sunvalley-{{.ITEM.KIND}} spec/sunvalley/sunvalley-{{.ITEM.KIND}}.spec
compress:
desc: Compress Sunvalley artifacts
cmds:
- for:
matrix:
KIND: [basic, banana, potato]
cmd: '{{.SHELL}} -Command "Compress-Archive -Path dist/sunvalley-{{.ITEM.KIND}} -DestinationPath dist/sunvalley-{{.ITEM.KIND}}.zip -Force"'
clean:
desc: Clean build and dist directories
cmds:
- |
{{.SHELL}} -Command "Remove-Item -Path build/sunvalley-*,dist/sunvalley-* -Recurse -Force"

View File

@ -1,5 +1,19 @@
version: '3'
includes:
sunvalley:
taskfile: ./Taskfile.sunvalley.yml
vars:
THEME: sunvalley
forest:
taskfile: ./Taskfile.forest.yml
vars:
THEME: forest
azure:
taskfile: ./Taskfile.azure.yml
vars:
THEME: azure
vars:
SHELL: pwsh
@ -18,64 +32,24 @@ tasks:
build:
desc: Build all artifacts
cmds:
- task: build-sunvalley
- echo "Sunvalley build complete"
- task: build-forest
- echo "Forest build complete"
build-sunvalley:
desc: Build Sunvalley artifacts
cmds:
- for:
matrix:
KIND: [basic, banana, potato]
cmd: poetry run pyinstaller --noconfirm --distpath dist/sunvalley-{{.ITEM.KIND}} spec/sunvalley-{{.ITEM.KIND}}.spec
build-forest:
desc: Build Forest artifacts
deps: [rewrite]
cmds:
- defer: { task: restore }
- for:
matrix:
KIND: [basic, banana, potato]
THEME: [light, dark]
cmd: poetry run pyinstaller --noconfirm --distpath dist/forest-{{.ITEM.KIND}}-{{.ITEM.THEME}} spec/forest-{{.ITEM.KIND}}-{{.ITEM.THEME}}.spec
rewrite:
internal: true
desc: Run the source code rewriter
cmds:
- poetry run python tools/rewriter.py --rewrite
restore:
internal: true
desc: Restore the backup files
cmds:
- poetry run python tools/rewriter.py --restore
THEME: [sunvalley, forest, azure]
task: '{{.ITEM.THEME}}:build'
compress:
deps: [compress-sunvalley, compress-forest]
compress-sunvalley:
desc: Compress all artifacts
cmds:
- for:
matrix:
KIND: [basic, banana, potato]
cmd: '{{.SHELL}} -Command "Compress-Archive -Path dist/sunvalley-{{.ITEM.KIND}} -DestinationPath dist/sunvalley-{{.ITEM.KIND}}.zip -Force"'
compress-forest:
cmds:
- for:
matrix:
KIND: [basic, banana, potato]
THEME: [light, dark]
cmd: '{{.SHELL}} -Command "Compress-Archive -Path dist/forest-{{.ITEM.KIND}}-{{.ITEM.THEME}} -DestinationPath dist/forest-{{.ITEM.KIND}}-{{.ITEM.THEME}}.zip -Force"'
THEME: [sunvalley, forest, azure]
task: '{{.ITEM.THEME}}:compress'
clean:
desc: Clean up build and dist directories
cmds:
- |
{{.SHELL}} -Command "
Remove-Item -Path build/forest-*,build/sunvalley-*,dist/forest-*,dist/sunvalley-* -Recurse -Force"
- for:
matrix:
THEME: [sunvalley, forest, azure]
task: '{{.ITEM.THEME}}:clean'

View File

@ -1,10 +1,9 @@
# load a specific profile on start (file name without .toml ext)
# [configs]
# config="example"
# load with themes enabled? set the default mode
# load with themes enabled?
[theme]
enabled = true
mode = "light"
# load in extended mode? if so which orientation
[extends]
extended = true
@ -22,4 +21,4 @@ size = 3
default = 0
# show the navigation frame?
[navigation]
show = true
show = false

View File

@ -2,12 +2,12 @@
### set the ip then uncomment
# [connection-1]
# kind = 'banana'
# ip = '<ip address 1>'
# ip = 'localhost'
# streamname = 'Command1'
# port = 6980
# [connection-2]
# kind = 'potato'
# ip = '<ip address 2>'
# ip = 'gamepc.local'
# streamname = 'Command1'
# port = 6980

View File

@ -16,7 +16,7 @@ def write_outs(output, outs: tuple):
output.write(out)
def rewrite_app():
def rewrite_app(theme):
app_logger = logger.getChild('app')
app_logger.info('rewriting app.py')
infile = Path(SRC_DIR) / 'app.bk'
@ -34,24 +34,28 @@ def rewrite_app():
(
' self._vmr = vmr\n',
' self._theme = theme\n',
' self._theme_name = theme.split("-")[0]\n',
' self._theme_type = theme.split("-")[-1]\n',
' tcldir = Path.cwd() / "theme"\n',
' if not tcldir.is_dir():\n',
' tcldir = Path.cwd() / "_internal" / "theme"\n',
' self.tk.call("source", tcldir.resolve() / f"forest-{self._theme}.tcl")\n',
' match self._theme_name:\n',
' case "forest":\n',
' self.tk.call("source", tcldir.resolve() / f"{self._theme}.tcl")\n',
' case "azure":\n',
' self.tk.call("source", tcldir.resolve() / f"{self._theme_name}.tcl")\n',
),
)
# def connect()
case 'def connect(kind_id: str, vmr) -> App:\n':
output.write(
'def connect(kind_id: str, vmr, theme="light") -> App:\n'
)
output.write('def connect(kind_id: str, vmr, theme) -> App:\n')
case ' return VMMIN_cls(vmr)\n':
output.write(' return VMMIN_cls(vmr, theme)\n')
case _:
output.write(line)
def rewrite_builders():
def rewrite_builders(theme):
builders_logger = logger.getChild('builders')
builders_logger.info('rewriting builders.py')
infile = Path(SRC_DIR) / 'builders.bk'
@ -71,15 +75,26 @@ def rewrite_builders():
case 'import sv_ttk\n':
output.write('#import sv_ttk\n')
case ' self.app.resizable(False, False)\n':
write_outs(
output,
(
' self.app.resizable(False, False)\n'
' if _configuration.themes_enabled:\n',
' ttk.Style().theme_use(f"forest-{self.app._theme}")\n',
' self.logger.info(f"Forest Theme applied")\n',
),
)
if theme.startswith('forest'):
write_outs(
output,
(
' self.app.resizable(False, False)\n'
' if _configuration.themes_enabled:\n',
' ttk.Style().theme_use(self.app._theme)\n',
' self.logger.info(f"{self.app._theme} Theme applied")\n',
),
)
elif theme.startswith('azure'):
write_outs(
output,
(
' self.app.resizable(False, False)\n'
' if _configuration.themes_enabled:\n',
' self.app.tk.call("set_theme", self.app._theme_type)\n',
' self.logger.info(f"Azure {self.app._theme_type} Theme applied")\n',
),
)
ignore_next_lines = 6
# setting navframe button widths
case ' variable=self.navframe.submix,\n':
@ -171,12 +186,21 @@ def rewrite_builders():
)
case _:
if 'Toggle.TButton' in line:
output.write(line.replace('Toggle.TButton', 'ToggleButton'))
if theme.startswith('forest'):
output.write(
line.replace('Toggle.TButton', 'ToggleButton')
)
elif theme.startswith('azure'):
output.write(
line.replace(
'Toggle.TButton', 'Switch.TCheckbutton'
)
)
else:
output.write(line)
def rewrite_menu():
def rewrite_menu(theme):
menu_logger = logger.getChild('menu')
menu_logger.info('rewriting menu.py')
infile = Path(SRC_DIR) / 'menu.bk'
@ -199,7 +223,7 @@ def rewrite_menu():
output.write(line)
def prepare_for_build():
def prepare_for_build(theme):
################# MOVE FILES FROM PACKAGE DIR INTO SRC DIR #########################
for file in (
PACKAGE_DIR / 'app.py',
@ -211,12 +235,8 @@ def prepare_for_build():
file.rename(SRC_DIR / f'{file.stem}.bk')
###################### RUN THE FILE REWRITER FOR EACH *.BK #########################
steps = (
rewrite_app,
rewrite_builders,
rewrite_menu,
)
[step() for step in steps]
for step in (rewrite_app, rewrite_builders, rewrite_menu):
step(theme)
def cleanup():
@ -239,12 +259,13 @@ def cleanup():
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--rewrite', action='store_true')
parser.add_argument('--theme', type=str, default='forest')
parser.add_argument('--restore', action='store_true')
args = parser.parse_args()
if args.rewrite:
logger.info('preparing files for build')
prepare_for_build()
prepare_for_build(args.theme)
elif args.restore:
logger.info('cleaning up files')
cleanup()

View File

@ -60,7 +60,7 @@ _defaults = {
'submixes': {
'default': 0,
},
'navigation': {'show': True},
'navigation': {'show': False},
}