Fix single process build + code format
This commit is contained in:
parent
f5965cc91e
commit
d683ab022f
2 changed files with 48 additions and 20 deletions
25
setup.cfg
Normal file
25
setup.cfg
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
[flake8]
|
||||||
|
max-line-length=120
|
||||||
|
ignore=D10,D203,D204
|
||||||
|
|
||||||
|
[pycodestyle]
|
||||||
|
max-line-length=120
|
||||||
|
ignore=D10,D203,D204
|
||||||
|
|
||||||
|
[pylint.DESIGN]
|
||||||
|
max-args=16
|
||||||
|
min-public-methods=0
|
||||||
|
max-attributes=16
|
||||||
|
max-locals=64
|
||||||
|
|
||||||
|
[pylint.FORMAT]
|
||||||
|
max-line-length=120
|
||||||
|
|
||||||
|
[pylint.MESSAGE CONTROL]
|
||||||
|
disable=missing-module-docstring, missing-function-docstring, missing-class-docstring, relative-beyond-top-level, too-few-public-methods, import-error
|
||||||
|
|
||||||
|
[pylint.SIMILARITIES]
|
||||||
|
min-similarity-lines=6
|
||||||
|
|
||||||
|
[pydocstyle]
|
||||||
|
ignore=D10,D203,D204
|
||||||
43
umake.py
43
umake.py
|
|
@ -33,7 +33,8 @@ class Config:
|
||||||
|
|
||||||
|
|
||||||
class ConsoleColor:
|
class ConsoleColor:
|
||||||
"""Simple shortcut to use colors in console"""
|
"""Simple shortcut to use colors in console."""
|
||||||
|
|
||||||
HEADER = '\033[95m'
|
HEADER = '\033[95m'
|
||||||
BLUE = '\033[94m'
|
BLUE = '\033[94m'
|
||||||
GREEN = '\033[92m'
|
GREEN = '\033[92m'
|
||||||
|
|
@ -45,8 +46,8 @@ class ConsoleColor:
|
||||||
|
|
||||||
|
|
||||||
def get_hash(path: Path) -> str:
|
def get_hash(path: Path) -> str:
|
||||||
with open(path, 'r') as hashing_file:
|
hash_obj = hashlib.md5()
|
||||||
hash_obj = hashlib.md5()
|
with open(path, 'r', encoding='utf-8') as hashing_file:
|
||||||
hash_obj.update(hashing_file.read().encode())
|
hash_obj.update(hashing_file.read().encode())
|
||||||
return hash_obj.hexdigest()
|
return hash_obj.hexdigest()
|
||||||
|
|
||||||
|
|
@ -66,7 +67,7 @@ def make(config: Config):
|
||||||
|
|
||||||
if config.PRE_COMPILE_FUNCTION is not None:
|
if config.PRE_COMPILE_FUNCTION is not None:
|
||||||
config.PRE_COMPILE_FUNCTION()
|
config.PRE_COMPILE_FUNCTION()
|
||||||
if 'IGNORE_APPS' in config.__dict__ :
|
if 'IGNORE_APPS' in config.__dict__:
|
||||||
config.IGNORE_APPS = []
|
config.IGNORE_APPS = []
|
||||||
|
|
||||||
# Update flags and directories for mode debug/release
|
# Update flags and directories for mode debug/release
|
||||||
|
|
@ -86,7 +87,7 @@ def make(config: Config):
|
||||||
|
|
||||||
hash_dict = {}
|
hash_dict = {}
|
||||||
if (config.OBJECT_DIR / 'hash.json').exists():
|
if (config.OBJECT_DIR / 'hash.json').exists():
|
||||||
with open(config.OBJECT_DIR / 'hash.json', 'r') as hash_file:
|
with open(config.OBJECT_DIR / 'hash.json', 'r', encoding='utf-8') as hash_file:
|
||||||
hash_dict = json.loads(hash_file.read())
|
hash_dict = json.loads(hash_file.read())
|
||||||
|
|
||||||
# Get source dependencies
|
# Get source dependencies
|
||||||
|
|
@ -101,9 +102,9 @@ def make(config: Config):
|
||||||
dependency_dict[str(source_path)] = job.stdout.split('.o: ')[1].replace('\n', '').replace('\\ ', '').split(' ')
|
dependency_dict[str(source_path)] = job.stdout.split('.o: ')[1].replace('\n', '').replace('\\ ', '').split(' ')
|
||||||
if error_paths:
|
if error_paths:
|
||||||
for error_path, error_text in error_paths:
|
for error_path, error_text in error_paths:
|
||||||
print(ConsoleColor.RED + f'Error checking dependencies for {error_path}:\n'
|
print(f'{ConsoleColor.RED}Error checking dependencies for {error_path}:'
|
||||||
+ ConsoleColor.ENDCOLOR + error_text)
|
f'\n{ConsoleColor.ENDCOLOR + error_text}')
|
||||||
with open(config.OBJECT_DIR / 'hash.json', 'w') as hash_file:
|
with open(config.OBJECT_DIR / 'hash.json', 'w', encoding='utf-8') as hash_file:
|
||||||
hash_file.write(json.dumps(hash_dict, indent=1))
|
hash_file.write(json.dumps(hash_dict, indent=1))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
@ -119,17 +120,17 @@ def make(config: Config):
|
||||||
dependency_hash = get_hash(dependency_path)
|
dependency_hash = get_hash(dependency_path)
|
||||||
if str(dependency_path) not in hash_dict or hash_dict[str(dependency_path)] != dependency_hash:
|
if str(dependency_path) not in hash_dict or hash_dict[str(dependency_path)] != dependency_hash:
|
||||||
dependency_changed = True
|
dependency_changed = True
|
||||||
print(ConsoleColor.ORANGE + f'Dependency changed for {source_path} : {dependency_path}'
|
print(f'{ConsoleColor.ORANGE}Dependency changed for {source_path} :'
|
||||||
+ ConsoleColor.ENDCOLOR)
|
f' {dependency_path} {ConsoleColor.ENDCOLOR}')
|
||||||
break
|
break
|
||||||
if (dependency_changed or not object_path.exists()
|
if (dependency_changed or not object_path.exists()
|
||||||
or str(source_path) not in hash_dict or hash_dict[str(source_path)] != source_hash):
|
or str(source_path) not in hash_dict or hash_dict[str(source_path)] != source_hash):
|
||||||
todo_list.append((source_path, cmd))
|
todo_list.append((source_path, cmd))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if not todo_list and all([(config.BIN_DIR / app_path).exists() for app_path in config.APPS
|
if not todo_list and all(
|
||||||
if app_path not in config.IGNORE_APPS]):
|
[(config.BIN_DIR / app_path).exists() for app_path in config.APPS if app_path not in config.IGNORE_APPS]):
|
||||||
print(ConsoleColor.GREEN + 'Nothing to do' + ConsoleColor.ENDCOLOR)
|
print(f'{ConsoleColor.GREEN}Nothing to do{ConsoleColor.ENDCOLOR}')
|
||||||
return
|
return
|
||||||
|
|
||||||
# Running compilation processes
|
# Running compilation processes
|
||||||
|
|
@ -151,6 +152,7 @@ def make(config: Config):
|
||||||
# Update hash if no error
|
# Update hash if no error
|
||||||
for dependency_path in dependency_dict[str(job_path)]:
|
for dependency_path in dependency_dict[str(job_path)]:
|
||||||
hash_dict[str(dependency_path)] = get_hash(dependency_path)
|
hash_dict[str(dependency_path)] = get_hash(dependency_path)
|
||||||
|
del source_path
|
||||||
for job_path, job in jobs: # Wait the last jobs to finish
|
for job_path, job in jobs: # Wait the last jobs to finish
|
||||||
job.wait()
|
job.wait()
|
||||||
if job.returncode != 0:
|
if job.returncode != 0:
|
||||||
|
|
@ -160,7 +162,7 @@ def make(config: Config):
|
||||||
for dependency_path in dependency_dict[str(job_path)]:
|
for dependency_path in dependency_dict[str(job_path)]:
|
||||||
hash_dict[str(dependency_path)] = get_hash(dependency_path)
|
hash_dict[str(dependency_path)] = get_hash(dependency_path)
|
||||||
else: # Single-process
|
else: # Single-process
|
||||||
for source_path, source_hash, cmd in todo_list:
|
for source_path, cmd in todo_list:
|
||||||
print(ConsoleColor.BLUE + cmd + ConsoleColor.ENDCOLOR)
|
print(ConsoleColor.BLUE + cmd + ConsoleColor.ENDCOLOR)
|
||||||
job = subprocess.run(cmd, check=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
job = subprocess.run(cmd, check=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
||||||
universal_newlines=True, shell=True)
|
universal_newlines=True, shell=True)
|
||||||
|
|
@ -170,10 +172,11 @@ def make(config: Config):
|
||||||
# Update hash if no error
|
# Update hash if no error
|
||||||
for dependency_path in dependency_dict[str(source_path)]:
|
for dependency_path in dependency_dict[str(source_path)]:
|
||||||
hash_dict[str(dependency_path)] = get_hash(dependency_path)
|
hash_dict[str(dependency_path)] = get_hash(dependency_path)
|
||||||
|
del source_path
|
||||||
if error_paths:
|
if error_paths:
|
||||||
for error_path, error_text in error_paths:
|
for error_path, error_text in error_paths:
|
||||||
print(ConsoleColor.RED + f'Error compiling {error_path}:\n' + ConsoleColor.ENDCOLOR + error_text)
|
print(ConsoleColor.RED + f'Error compiling {error_path}:\n' + ConsoleColor.ENDCOLOR + error_text)
|
||||||
with open(config.OBJECT_DIR / 'hash.json', 'w') as hash_file:
|
with open(config.OBJECT_DIR / 'hash.json', 'w', encoding='utf-8') as hash_file:
|
||||||
hash_file.write(json.dumps(hash_dict, indent=1))
|
hash_file.write(json.dumps(hash_dict, indent=1))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
@ -202,12 +205,12 @@ def make(config: Config):
|
||||||
app_path, oldest_job = jobs.pop()
|
app_path, oldest_job = jobs.pop()
|
||||||
oldest_job.wait()
|
oldest_job.wait()
|
||||||
if oldest_job.returncode != 0:
|
if oldest_job.returncode != 0:
|
||||||
error_paths.append((source_path, oldest_job.stdout.read() + oldest_job.stderr.read()))
|
error_paths.append((app_path, oldest_job.stdout.read() + oldest_job.stderr.read()))
|
||||||
break
|
break
|
||||||
for job_path, job in jobs: # Wait the last jobs to finish
|
for job_path, job in jobs: # Wait the last jobs to finish
|
||||||
job.wait()
|
job.wait()
|
||||||
if job.returncode != 0:
|
if job.returncode != 0:
|
||||||
error_paths.append((source_path, job.stdout.read() + job.stderr.read()))
|
error_paths.append((app_path, job.stdout.read() + job.stderr.read()))
|
||||||
else: # Single-process
|
else: # Single-process
|
||||||
for app_path, app_object_path in zip(config.APPS, all_app_objects):
|
for app_path, app_object_path in zip(config.APPS, all_app_objects):
|
||||||
if app_path in config.IGNORE_APPS:
|
if app_path in config.IGNORE_APPS:
|
||||||
|
|
@ -223,13 +226,13 @@ def make(config: Config):
|
||||||
job = subprocess.run(cmd, check=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
job = subprocess.run(cmd, check=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
||||||
universal_newlines=True, shell=True)
|
universal_newlines=True, shell=True)
|
||||||
if job.returncode != 0:
|
if job.returncode != 0:
|
||||||
error_paths.append((source_path, job.stdout + job.stderr))
|
error_paths.append((app_path, job.stdout + job.stderr))
|
||||||
if error_paths:
|
if error_paths:
|
||||||
for error_path, error_text in error_paths:
|
for error_path, error_text in error_paths:
|
||||||
print(ConsoleColor.RED + f'Error linking {error_path}:\n' + ConsoleColor.ENDCOLOR + error_text)
|
print(ConsoleColor.RED + f'Error linking {error_path}:\n' + ConsoleColor.ENDCOLOR + error_text)
|
||||||
with open(os.path.join(config.OBJECT_DIR, 'hash.json'), 'w') as hash_file:
|
with open(os.path.join(config.OBJECT_DIR, 'hash.json'), 'w', encoding='utf-8') as hash_file:
|
||||||
hash_file.write(json.dumps(hash_dict, indent=1))
|
hash_file.write(json.dumps(hash_dict, indent=1))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
with open(config.OBJECT_DIR / 'hash.json', 'w') as hash_file:
|
with open(config.OBJECT_DIR / 'hash.json', 'w', encoding='utf-8') as hash_file:
|
||||||
hash_file.write(json.dumps(hash_dict, indent=1))
|
hash_file.write(json.dumps(hash_dict, indent=1))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue