Minor fixes * Sub-directory app

This commit is contained in:
Corentin 2021-06-19 01:39:06 +09:00
commit 06981cd027
2 changed files with 7 additions and 4 deletions

View file

@ -9,6 +9,7 @@ from umake import make
class Config: class Config:
CC = 'g++' # Compiler to call CC = 'g++' # Compiler to call
APPS = ['app_name'] # Output binaries (need to be found as .cpp directly in SOURCE_DIR) 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) JOB_COUNT = int(os.cpu_count() * 0.8) # Concurent jobs (multi-processing)
BIN_DIR = 'bin' # Output directory (binaries) BIN_DIR = 'bin' # Output directory (binaries)

View file

@ -4,6 +4,7 @@ from argparse import ArgumentParser
import hashlib import hashlib
import json import json
import os import os
from pathlib import Path
import subprocess import subprocess
import shutil import shutil
import sys import sys
@ -132,19 +133,20 @@ def make(config: Config):
for app_name in config.APPS: for app_name in config.APPS:
if 'IGNORE_APPS' in config.__dict__ and app_name in config.IGNORE_APPS: if 'IGNORE_APPS' in config.__dict__ and app_name in config.IGNORE_APPS:
continue 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] 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 object_files = [object_path for _, object_path in compile_list
if os.path.basename(object_path) not in app_objects] 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]) cmd = ' '.join([config.CC, config.COMMON_FLAGS, *object_files, '-o', str(app_path), config.LINK_FLAGS])
print(cmd)
complete = subprocess.run(cmd, check=False, shell=True) complete = subprocess.run(cmd, check=False, shell=True)
if complete.returncode != 0: if complete.returncode != 0:
error_path = app_name error_path = app_name
if error_path: if error_path:
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') as hash_file:
hash_file.write(json.dumps(hash_dict, indent=1)) hash_file.write(json.dumps(hash_dict, indent=1))
print('Error linking f{error_path}') print(f'Error linking {error_path}')
sys.exit(1) sys.exit(1)
# Updating header hashes only if everything compiled and linked correctly # Updating header hashes only if everything compiled and linked correctly