2015-05-26 16:08:52 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
import os
|
|
|
|
import ConfigParser
|
|
|
|
|
|
|
|
|
2015-05-27 11:02:13 +02:00
|
|
|
def get_l_option_section(config):
|
2015-05-27 17:49:31 +02:00
|
|
|
"""List of options chosen by the user"""
|
|
|
|
l = [o for o in ['OPENMP'] if config.getboolean("OPTION", o)]
|
|
|
|
l.append(config.get("OPTION", "MODE").strip())
|
|
|
|
return l
|
2015-05-26 16:08:52 +02:00
|
|
|
|
|
|
|
|
2015-05-27 11:02:13 +02:00
|
|
|
def get_compilation_option(pwd_cfg, flag_name):
|
2015-05-27 17:49:31 +02:00
|
|
|
"""
|
|
|
|
Return the flag compilation of a compile.cfg located in pwd_cfg
|
|
|
|
"""
|
2015-05-27 11:02:13 +02:00
|
|
|
config = ConfigParser.ConfigParser()
|
|
|
|
config.read(pwd_cfg)
|
2015-05-26 16:08:52 +02:00
|
|
|
|
2015-05-27 17:49:31 +02:00
|
|
|
if flag_name == "FC" and config.getboolean("OPTION","CACHE"):
|
|
|
|
l = ["cache_compile.py"]
|
|
|
|
else:
|
|
|
|
l = []
|
|
|
|
|
2015-05-27 11:02:13 +02:00
|
|
|
l_option_section = get_l_option_section(config)
|
2015-05-26 16:08:52 +02:00
|
|
|
|
|
|
|
for section in ["COMMON"] + l_option_section:
|
|
|
|
try:
|
2015-05-27 11:02:13 +02:00
|
|
|
l.extend(config.get(section, flag_name).split())
|
2015-05-26 16:08:52 +02:00
|
|
|
except ConfigParser.NoOptionError:
|
|
|
|
pass
|
|
|
|
|
|
|
|
return " ".join(l)
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
2015-06-08 14:49:10 +02:00
|
|
|
qpackage_root = os.environ['QP_ROOT']
|
2015-05-27 17:49:31 +02:00
|
|
|
pwd_cfg = os.path.join(qpackage_root, "config/gfortran_example.cfg")
|
2015-05-26 16:08:52 +02:00
|
|
|
|
2015-05-27 11:02:13 +02:00
|
|
|
print get_compilation_option(pwd_cfg, "FC")
|
2015-05-27 17:49:31 +02:00
|
|
|
print get_compilation_option(pwd_cfg, "FCFLAGS")
|