Add ability to print progress in a fun way. (#2)
This adds the ability to specify both code/data fractions and item specifiers
This commit is contained in:
parent
e84ce8db06
commit
04c8b45f93
|
@ -15,6 +15,7 @@ import json
|
|||
import os
|
||||
import platform
|
||||
import sys
|
||||
import math
|
||||
|
||||
from pathlib import Path
|
||||
from . import ninja_syntax
|
||||
|
@ -64,6 +65,13 @@ class ProjectConfig:
|
|||
self.progress_modules = True # Include combined "modules" category
|
||||
self.progress_each_module = True # Include individual modules, disable for large numbers of modules
|
||||
|
||||
# Progress fancy printing
|
||||
self.progress_use_fancy = False
|
||||
self.progress_code_fancy_frac = 0
|
||||
self.progress_code_fancy_item = ""
|
||||
self.progress_data_fancy_frac = 0
|
||||
self.progress_data_fancy_item = ""
|
||||
|
||||
def validate(self):
|
||||
required_attrs = [
|
||||
"build_dir",
|
||||
|
@ -927,8 +935,12 @@ def calculate_progress(config):
|
|||
def __init__(self, name):
|
||||
self.name = name
|
||||
self.code_total = 0
|
||||
self.code_fancy_frac = config.progress_code_fancy_frac
|
||||
self.code_fancy_item = config.progress_code_fancy_item
|
||||
self.code_progress = 0
|
||||
self.data_total = 0
|
||||
self.data_fancy_frac = config.progress_data_fancy_frac
|
||||
self.data_fancy_item = config.progress_data_fancy_item
|
||||
self.data_progress = 0
|
||||
self.objects_progress = 0
|
||||
self.objects_total = 0
|
||||
|
@ -1002,6 +1014,17 @@ def calculate_progress(config):
|
|||
)
|
||||
print(f" Code: {unit.code_progress} / {unit.code_total} bytes")
|
||||
print(f" Data: {unit.data_progress} / {unit.data_total} bytes")
|
||||
if config.progress_use_fancy:
|
||||
print(
|
||||
"\nYou have {} out of {} {} and collected {} out of {} {}.".format(
|
||||
math.floor(code_frac * unit.code_fancy_frac),
|
||||
unit.code_fancy_frac,
|
||||
unit.code_fancy_item,
|
||||
math.floor(data_frac * unit.data_fancy_frac),
|
||||
unit.data_fancy_frac,
|
||||
unit.data_fancy_item,
|
||||
)
|
||||
)
|
||||
|
||||
if all_progress:
|
||||
print_category(all_progress)
|
||||
|
|
Loading…
Reference in New Issue