Print parsed compiler flags, some cosmetic changes for added consistency

This commit is contained in:
Giacomo Fiorin 2019-10-17 22:53:13 -04:00
parent c578e4e7fc
commit 693e34b587
1 changed files with 13 additions and 9 deletions

View File

@ -57,7 +57,7 @@ suffix = args.extramake
def get_lammps_machine_flags(machine):
"""Parse Makefile.machine from LAMMPS, return dictionary of compiler flags"""
if not os.path.exists("../../src/MAKE/MACHINES/Makefile.%s" % machine):
sys.exit("Cannot locate src/MAKE/MACHINES/Makefile.%s" % machine)
sys.exit("ERROR: Cannot locate src/MAKE/MACHINES/Makefile.%s" % machine)
lines = open("../../src/MAKE/MACHINES/Makefile.%s" % machine,
'r').readlines()
machine_flags = {}
@ -70,6 +70,8 @@ def get_lammps_machine_flags(machine):
(words[0] == 'SHFLAGS') or (words[0] == 'ARCHIVE') or
(words[0] == 'ARFLAGS') or (words[0] == 'SHELL')):
machine_flags[words[0]] = ' '.join(words[2:])
if machine_flags:
print("Detected the following flags: ", machine_flags)
return machine_flags
def gen_colvars_makefile_machine(machine, machine_flags):
@ -103,7 +105,7 @@ if not os.path.exists("Makefile.%s" % machine):
machine_flags = get_lammps_machine_flags(machine)
gen_colvars_makefile_machine(machine, machine_flags)
if not os.path.exists("Makefile.%s" % machine):
sys.exit("lib/%s/Makefile.%s does not exist" % (lib,machine))
sys.exit("ERROR: lib/%s/Makefile.%s does not exist" % (lib,machine))
# create Makefile.auto as copy of Makefile.machine
# reset EXTRAMAKE if requested
@ -123,15 +125,17 @@ fp.close()
n_cpus = get_cpus()
print("Building lib%s.a ..." % lib)
cmd = ["make -f Makefile.auto clean; make -f Makefile.auto -j%d" % n_cpus]
cmd = "make -f Makefile.auto clean; make -f Makefile.auto -j%d" % n_cpus
try:
txt = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True);
txt = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT);
print(txt.decode('UTF-8'))
except subprocess.CalledProcessError as e:
print("Make failed with:\n %s" % e.output.decode('UTF-8'))
sys.exit(1)
sys.exit("Make failed with:\n %s" % e.output.decode('UTF-8'))
if os.path.exists("lib%s.a" % lib):
print("Build was successful")
else:
sys.exit("Build of lib/%s/lib%s.a was NOT successful" % (lib, lib))
if os.path.exists("lib%s.a" % lib): print("Build was successful")
else: sys.exit("Build of lib/%s/lib%s.a was NOT successful" % (lib,lib))
if not os.path.exists("Makefile.lammps"):
print("lib/%s/Makefile.lammps was NOT created" % lib)
print("WARNING: lib/%s/Makefile.lammps was NOT created" % lib)