From 06981cd0274e113a2aa350b688456824aa0cae94 Mon Sep 17 00:00:00 2001 From: Corentin Date: Sat, 19 Jun 2021 01:39:06 +0900 Subject: [PATCH] Minor fixes * Sub-directory app --- make.py | 1 + umake.py | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/make.py b/make.py index e641584..e461b49 100644 --- a/make.py +++ b/make.py @@ -9,6 +9,7 @@ from umake import make class Config: CC = 'g++' # Compiler to call APPS = ['app_name'] # Output binaries (need to be found as .cpp directly in SOURCE_DIR) + IGNORE_APPS = [] JOB_COUNT = int(os.cpu_count() * 0.8) # Concurent jobs (multi-processing) BIN_DIR = 'bin' # Output directory (binaries) diff --git a/umake.py b/umake.py index 4c598e6..deada08 100755 --- a/umake.py +++ b/umake.py @@ -4,6 +4,7 @@ from argparse import ArgumentParser import hashlib import json import os +from pathlib import Path import subprocess import shutil import sys @@ -132,19 +133,20 @@ def make(config: Config): for app_name in config.APPS: if 'IGNORE_APPS' in config.__dict__ and app_name in config.IGNORE_APPS: continue - app_path = os.path.join(config.BIN_DIR, app_name) + app_path = Path(config.BIN_DIR, app_name) + if not app_path.parent.exists(): + app_path.parent.mkdir(parents=True) app_objects = [file_name + '.o' for file_name in config.APPS if file_name != app_name] object_files = [object_path for _, object_path in compile_list if os.path.basename(object_path) not in app_objects] - cmd = ' '.join([config.CC, config.COMMON_FLAGS, *object_files, '-o', app_path, config.LINK_FLAGS]) - print(cmd) + cmd = ' '.join([config.CC, config.COMMON_FLAGS, *object_files, '-o', str(app_path), config.LINK_FLAGS]) complete = subprocess.run(cmd, check=False, shell=True) if complete.returncode != 0: error_path = app_name if error_path: with open(os.path.join(config.OBJECT_DIR, 'hash.json'), 'w') as hash_file: hash_file.write(json.dumps(hash_dict, indent=1)) - print('Error linking f{error_path}') + print(f'Error linking {error_path}') sys.exit(1) # Updating header hashes only if everything compiled and linked correctly