Fixes to make.py crossplatform and gcc flag-order compliant
This commit is contained in:
parent
fe3d00a5f5
commit
c741706a11
20
make.py
20
make.py
|
@ -6,8 +6,9 @@ from glob import glob
|
|||
from sane import *
|
||||
|
||||
COMPILER = 'gcc'
|
||||
COMPILE_FLAGS = ['-g',
|
||||
'--std=c99',
|
||||
COMPILE_FLAGS = ['-std=c99',
|
||||
'-g',
|
||||
'-O0',
|
||||
'-Wall',
|
||||
'-Werror',
|
||||
'-fopenmp']
|
||||
|
@ -19,7 +20,7 @@ EXE_NAME = 'main.exe'
|
|||
ROOT = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
if 'RELEASE' in os.environ:
|
||||
COMPILE_FLAGS.append('-O2')
|
||||
COMPILE_FLAGS[COMPILE_FLAGS.index('-O0')] = '-O2'
|
||||
|
||||
def as_object(source_path):
|
||||
"""Takes a source path and returns the path to the corresponding compiled object."""
|
||||
|
@ -43,12 +44,12 @@ def make_object_recipe(source_path):
|
|||
conditions=[condition],
|
||||
hooks=['obj_compile'])
|
||||
def compile_obj():
|
||||
sp.run([COMPILER, *COMPILE_FLAGS,
|
||||
'-c', source_path,
|
||||
'-o', object_path],
|
||||
shell=True)
|
||||
sp.run([COMPILER, '-c', *COMPILE_FLAGS,
|
||||
'-o', object_path,
|
||||
source_path])
|
||||
|
||||
source_files = glob('**/*.c', recursive=True)
|
||||
source_files = [os.path.realpath(path)
|
||||
for path in glob('**/*.c', recursive=True)]
|
||||
|
||||
for source_file in source_files:
|
||||
make_object_recipe(source_file)
|
||||
|
@ -67,8 +68,7 @@ def compile():
|
|||
def link():
|
||||
obj_files = glob(os.path.join(OBJ_DIR, '**', '*.obj').replace('\\', '/'),
|
||||
recursive=True)
|
||||
sp.run([COMPILER, *obj_files, *LINK_FLAGS, '-o', EXE_NAME],
|
||||
shell=True)
|
||||
sp.run([COMPILER, *LINK_FLAGS, '-o', EXE_NAME, *obj_files])
|
||||
|
||||
@recipe(info='Removes all compiled objects.')
|
||||
def clean():
|
||||
|
|
Loading…
Reference in New Issue