Commit 7257dfa5 authored by Jean-Baptiste Mouret's avatar Jean-Baptiste Mouret
Browse files

new command ./waf --write_params + write params at the right place

parent d218e5bc
......@@ -242,3 +242,9 @@ def output_params(folder):
text_file = open(folder + "/params_" + folder[4:] + ".txt", "w")
text_file.write(output)
text_file.close()
def write_default_params(fname):
output = params.get_default_params()
text_file = open(fname, "w")
text_file.write(output)
text_file.close()
......@@ -63,7 +63,7 @@ def extract_params(fname):
d = re.findall('defaults::\w+', line)[0]
dd = d.split('::')[1]
defaults += [dd]
if 'BO_PARAM(' in line and not "#define" in line:
if 'BO_PARAM(' in line and not "#define" in line and not '//' in line:
namespace, struct = extract_namespace(level)
type, name, value = extract_param(line)
d = extract_ifdef(ifdefs)
......@@ -97,8 +97,7 @@ def underline(k):
out += s + '\n'
return out
def get_output(file):
output = ""
def extract_defaults():
# find the default params
dirs = make_dirlist('src/', ['.hpp'])
params = []
......@@ -109,6 +108,26 @@ def get_output(file):
for i in params:
if 'defaults' in i.namespace:
defaults[i.struct][i.name] = i
return defaults
def get_default_params():
output = ''
defaults = extract_defaults()
for k in defaults.keys():
output += underline(k)
for kk in defaults[k].keys():
output += '- ' + str(defaults[k][kk].type) + ' ' + str(defaults[k][kk].name) + ' = ' + str(defaults[k][kk].value) + ' [defined in ' + str(defaults[k][kk].fname) + ']'
if defaults[k][kk].ifdef:
output += ' ' + str(defaults[k][kk].ifdef)
output += '\n'
output += '\n'
return output
def get_output(file):
get_default_params()
output = ""
defaults = extract_defaults()
# find the params in the current file
p, d = extract_params(file)
struct_set = set()
......@@ -124,7 +143,7 @@ def get_output(file):
if kk in plist[k]:
output += '- ' + str(plist[k][kk].type) + ' ' + str(plist[k][kk].name) + ' = ' + str(plist[k][kk].value) + ' [defined in ' + plist[k][kk].fname + ']' + str(plist[k][kk].ifdef) + '\n'
else:
output += '- ' + str(defaults[k][kk].type) + ' ' + str(defaults[k][kk].name) + ' = ' + str(defaults[k][kk].value) + ' [default value, from ' + ']' + str(defaults[k][kk].ifdef) + '\n'
output += '- ' + str(defaults[k][kk].type) + ' ' + str(defaults[k][kk].name) + ' = ' + str(defaults[k][kk].value) + ' [default value, from ' + str(defaults[k][kk].fname) + ']' + str(defaults[k][kk].ifdef) + '\n'
output += '\n'
return output
......@@ -27,6 +27,7 @@ def options(opt):
opt.load('openmp')
opt.load('nlopt')
opt.load('libcmaes')
opt.load('xcode')
opt.add_option('--exp', type='string', help='exp(s) to build, separate by comma', dest='exp')
opt.add_option('--qsub', type='string', help='config file (json) to submit to torque', dest='qsub')
......@@ -35,9 +36,9 @@ def options(opt):
opt.add_option('--local_serial', type='string', help='config file (json) to run local', dest='local_serial')
opt.add_option('--experimental', action='store_true', help='specify to compile the experimental examples', dest='experimental')
opt.add_option('--nb_replicates', type='int', help='number of replicates performed during the benchmark', dest='nb_rep')
# tests
opt.add_option('--tests', action='store_true', help='compile tests or not', dest='tests')
opt.load('xcode')
opt.add_option('--write_params', type='string', help='write all the default values of parameters in a file (used by the documentation system)', dest='write_params')
for i in glob.glob('exp/*'):
if os.path.isdir(i):
opt.recurse(i)
......@@ -92,6 +93,9 @@ def configure(conf):
conf.recurse('src/benchmarks')
def build(bld):
if bld.options.write_params:
limbo.write_default_params(bld.options.write_params)
print 'default parameters written in ' + bld.options.write_params
bld.recurse('src/')
if bld.options.exp:
for i in bld.options.exp.split(','):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment