Updates to make.py

Include libraries, allow for multiple compile and link flags for the
environment, always include debug symbols, and misc changes.
This commit is contained in:
Miguel M 2023-05-30 16:16:21 +01:00
parent 3ef2e95c69
commit 10451dcde9
1 changed files with 8 additions and 6 deletions

14
make.py
View File

@ -17,7 +17,8 @@ COMPILE_FLAGS = [
"-pedantic-errors",
"-fopenmp",
]
LINK_FLAGS = []
LINK_FLAGS = ["-fopenmp"]
LIBRARIES = ["-lm"]
OBJ_DIR = os.path.join("obj", "release" if ("RELEASE" in os.environ) else "debug")
SRC_DIR = "src"
EXE_NAME = "main." + ("release" if ("RELEASE" in os.environ) else "debug") + ".exe"
@ -28,11 +29,12 @@ if "RELEASE" in os.environ:
COMPILE_FLAGS[COMPILE_FLAGS.index("-O0")] = "-O2"
COMPILE_FLAGS[COMPILE_FLAGS.index("-g3")] = "-g"
COMPILE_FLAGS.append("-DRELEASE")
COMPILE_FLAGS.append("-g")
LINK_FLAGS.append("-DRELEASE")
else:
COMPILE_FLAGS.append("-fsanitize=address,undefined")
LINK_FLAGS.append("-fsanitize=address,undefined")
if "COMPILE_FLAGS" in os.environ:
COMPILE_FLAGS.extend(os.environ["COMPILE_FLAGS"].split(";"))
if "LINK_FLAGS" in os.environ:
LINK_FLAGS.extend(os.environ["LINK_FLAGS"].split(";"))
def as_object(source_path):
@ -88,7 +90,7 @@ def link():
obj_files = glob(
os.path.join(OBJ_DIR, "**", "*.obj").replace("\\", "/"), recursive=True
)
sp.run([COMPILER, *LINK_FLAGS, "-o", EXE_NAME, *obj_files])
sp.run([COMPILER, *LINK_FLAGS, "-o", EXE_NAME, *obj_files, *LIBRARIES])
@recipe(info="Removes all compiled objects.")