gambit is hosted by Hepforge, IPPP Durham
GAMBIT  v1.5.0-2191-ga4742ac
a Global And Modular Bsm Inference Tool
scanner+_harvester Namespace Reference

Functions

def main (argv)
 

Variables

string toolsfile = "./Utils/scripts/harvesting_tools.py"
 

Function Documentation

◆ main()

def scanner+_harvester.main (   argv)

Definition at line 45 of file scanner+_harvester.py.

References harvesting_tools.comment_remover(), int, harvesting_tools.neatsplit(), Gambit::ColliderBit.print(), Gambit::Utils.split(), harvesting_tools.update_only_if_different(), and Gambit::Scanner.zip().

45 def main(argv):
46 
47  exclude_plugins=set([])
48  plugins = []
49  static_links = ""
50  flag = {"missing": "0", "found": "1", "excluded": "2"}
51 
52  # Handle command line options
53  verbose = False
54  try:
55  build_dir = argv[0]
56  opts, args = getopt.getopt(argv[1:],"vx:",["verbose","exclude-scanners="])
57  except getopt.GetoptError:
58  print( 'Usage: scanner+_harvester.py build_dir [flags]' )
59  print( ' flags:' )
60  print( ' -v : More verbose output' )
61  print( ' -x scanner1,scanner2,... : Exclude scanner1, scanner2, etc.' )
62  sys.exit(2)
63  for opt, arg in opts:
64  if opt in ('-v','--verbose'):
65  verbose = True
66  print('scanner+_harvester.py: verbose=True')
67  elif opt in ('-x','--exclude-plugins','--exclude-plugin'):
68  exclude_plugins.update(neatsplit(",",arg))
69  # info for the different plugin types
70  src_paths = sorted(["./ScannerBit/src/scanners", "./ScannerBit/src/objectives"])
71  inc_paths = sorted(["./ScannerBit/include/gambit/ScannerBit/scanners", "./ScannerBit/include/gambit/ScannerBit/objectives"])
72  plug_type = sorted(["scanner", "objective"])
73  config_files = []
74  for ptype in plug_type:
75  config_files += ["./config/" + ptype + "_locations.yaml"]
76 
77  # these map the linking flags and library paths to the appropriate plugin library
78  scanbit_plugins = dict()
79  scanbit_incs = dict()
80  scanbit_libs = dict()
81  scanbit_links = dict()
82  scanbit_reqs = dict()
83  scanbit_auto_libs = dict()
84  scanbit_auto_incs = dict()
85  scanbit_link_libs = dict()
86  scanbit_lib_hints = dict()
87  scanbit_inc_files = dict()
88  scanbit_flags = dict()
89  scanbit_cxx_flags = dict()
90  #scanbit_static_links = dict()
91 
92 
93  scanbit_srcs = [ name for name in os.listdir("./ScannerBit/src") if os.path.isfile('./ScannerBit/src/' + name) if name.endswith(".cpp") or name.endswith(".c") or name.endswith(".cc") or name.endswith(".cxx") ]
94  scanbit_hdrs = [ name for name in os.listdir("./ScannerBit/include/gambit/ScannerBit") if os.path.isfile('./ScannerBit/include/gambit/ScannerBit/' + name) if name.endswith(".hpp") or name.endswith(".h") ]
95  prior_srcs = []
96  prior_hdrs = []
97 
98  if os.path.exists("./ScannerBit/src/priors"):
99  prior_srcs = [ root + "/" + f for root,dirs,files in os.walk("./ScannerBit/src/priors") for f in files if f.endswith(".cpp") or f.endswith(".c") or f.endswith(".cc") or f.endswith(".cxx") ]
100  if os.path.exists("./ScannerBit/include/gambit/ScannerBit/priors"):
101  prior_hdrs = [ root + "/" + f for root,dirs,files in os.walk("./ScannerBit/include/gambit/ScannerBit/priors") for f in files if f.endswith(".hpp") or f.endswith(".h") ]
102 
103  prior_txt_out = "#ifndef PRIOR_LIST_HPP\n#define PRIOR_LIST_HPP\n\n"
104 
105  cmakelist_txt_out = "set( scannerbit_sources\n"
106  for source in sorted(scanbit_srcs):
107  cmakelist_txt_out += " "*16 + "src/" + source + "\n"
108  for source in sorted(prior_srcs):
109  cmakelist_txt_out += " "*16 + "src/" + source.split('/ScannerBit/src/')[1] + "\n"
110  cmakelist_txt_out += ")\n\n"
111 
112  cmakelist_txt_out += "set( scannerbit_headers\n"
113  for header in sorted(scanbit_hdrs):
114  cmakelist_txt_out += " "*16 + "include/gambit/ScannerBit/" + header + "\n"
115  for header in sorted(prior_hdrs):
116  cmakelist_txt_out += " "*16 + "include/gambit/ScannerBit/" + header.split('/ScannerBit/include/gambit/ScannerBit/')[1] + "\n"
117  prior_txt_out += "#include \"" + "gambit/ScannerBit/" + header.split('/ScannerBit/include/gambit/ScannerBit/')[1] + "\"\n"
118  cmakelist_txt_out += ")\n\nadd_gambit_library( ScannerBit OPTION OBJECT SOURCES ${scannerbit_sources} HEADERS ${scannerbit_headers} )\n\n"
119 
120  prior_txt_out += "\n#endif\n"
121 
122 
123 
124  scan_helper_srcs = []
125  scan_helper_hdrs = []
126 
127  if os.path.exists("./ScannerBit/src/scanlibs"):
128  scan_helper_srcs = [ root + "/" + f for root,dirs,files in os.walk("./ScannerBit/src/scanlibs") for f in files if f.endswith(".cpp") or f.endswith(".c") or f.endswith(".cc") or f.endswith(".cxx") ]
129 
130  if os.path.exists("./ScannerBit/include/gambit/ScannerBit/scanlibs"):
131  scan_helper_hdrs = [ root + "/" + f for root,dirs,files in os.walk("./ScannerBit/include/gambit/ScannerBit/scanlibs") for f in files if f.endswith(".hpp") or f.endswith(".h") ]
132 
133  cmakelist_txt_out += "set( scanner_scanlibs_sources\n"
134  for source in sorted(scan_helper_srcs):
135  cmakelist_txt_out += " "*16 + "src/" + source.split('/ScannerBit/src/')[1] + "\n"
136  cmakelist_txt_out += ")\n\n"
137 
138  cmakelist_txt_out += "set( scanner_scanlibs_headers\n"
139  for header in sorted(scan_helper_hdrs):
140  cmakelist_txt_out += " "*16 + "include/gambit/ScannerBit/" + header.split('/ScannerBit/include/gambit/ScannerBit/')[1] + "\n"
141  cmakelist_txt_out += ")\n\n"
142 
143 
144  # loop through the different plugin types
145  for i in range(len(plug_type)):
146  scanbit_plugins[plug_type[i]] = dict()
147  scanbit_incs[plug_type[i]] = dict()
148  scanbit_libs[plug_type[i]] = dict()
149  scanbit_links[plug_type[i]] = dict()
150  scanbit_reqs[plug_type[i]] = dict()
151  scanbit_auto_libs[plug_type[i]] = dict()
152  scanbit_auto_incs[plug_type[i]] = dict()
153  scanbit_link_libs[plug_type[i]] = dict()
154  scanbit_lib_hints[plug_type[i]] = dict()
155  scanbit_inc_files[plug_type[i]] = dict()
156  scanbit_flags[plug_type[i]] = dict()
157  scanbit_cxx_flags[plug_type[i]] = dict()
158  #scanbit_static_links[plug_type[i]] = dict()
159 
160  # loop through the different plugin types
161  for i in range(len(plug_type)):
162  scanbit_plugins[plug_type[i]] = dict()
163  #scanbit_static_links[plug_type[i]] = dict()
164  directories = [ name for name in os.listdir(src_paths[i]) if os.path.isdir(src_paths[i] + "/" + name) ]
165 
166  for directory in sorted(directories):
167  scanbit_plugins[plug_type[i]][directory] = []
168  exclude_list = []
169  cmakelist_txt_out_tmp = ""
170  # Find all source files in the ScannerBit scanner and test_function plugin directories
171  sources = [ root + "/" + f for root,dirs,files in os.walk(src_paths[i] + "/" + directory) for f in files if f.endswith(".cpp") or f.endswith(".c") or f.endswith(".cc") or f.endswith(".cxx") ]
172  headers = []
173  if os.path.exists(inc_paths[i] + "/" + directory):
174  headers = [ root + "/" + f for root,dirs,files in os.walk(inc_paths[i] + "/" + directory) for f in files if f.endswith(".hpp") or f.endswith(".h") ]
175 
176  # Work through the source files to find all plugins that need external linkage
177  for source in sorted(sources):
178  with open(source) as f:
179  last_plugin = ""
180  last_version= ""
181  last_plugin_file=[]
182  processed = False
183  if verbose: print(" Scanning source file {0} for ScannerBit plugin declarations.".format(source))
184  text = comment_remover(f.read())
185  it = re.finditer(r'\breqd_inifile_entries\s*?\(.*?\)|\bREQD_INIFILE_ENTRIES\s*?\(.*?\)', text, re.DOTALL)
186  ini_finds = [[m.span()[0], -1, re.sub(r'\s', '', m.group())] for m in it]
187  it = re.finditer(r'\bobjective_plugin\s*?\(.*?\)\s*?\{|\bOBJECTIVE_PLUGIN\s*?\(.*?\)\s*?\{', text, re.DOTALL)
188  obj_finds = [[m.span()[0], 0, m.group()] for m in it]
189  it = re.finditer(r'\bscanner_plugin\s*?\(.*?\)\s*?\{|\bSCANNER_PLUGIN\s*?\(.*?\)\s*?\{', text, re.DOTALL)
190  scan_finds = [[m.span()[0], 1, m.group()] for m in it]
191  it = re.finditer(r'\breqd_libraries\s*?\(.*?\)|\bREQD_LIBRARIES\s*?\(.*?\)', text, re.DOTALL)
192  lib_finds = [[m.span()[0], -2, re.sub(r'\s', '', m.group())] for m in it]
193  it = re.finditer(r'\breqd_headers\s*?\(.*?\)|\bREQD_HEADERS\s*?\(.*?\)', text, re.DOTALL)
194  inc_finds = [[m.span()[0], -3, re.sub(r'\s', '', m.group())] for m in it]
195  it = re.finditer(r'\bset_flag\s*?\(.*?\)|\bSET_FLAG\s*?\(.*?\)', text, re.DOTALL)
196  flag_finds = [[m.span()[0], -4, re.sub(r'\s', '', m.group())] for m in it]
197  it = re.finditer(r'\bcxx_flags\s*?\(.*?\)|\bCXX_FLAGS\s*?\(.*?\)', text, re.DOTALL)
198  cxx_finds = [[m.span()[0], -5, re.sub(r'\s|"', '', m.group())] for m in it]
199  all_finds = sorted(scan_finds + obj_finds + ini_finds + lib_finds + inc_finds + flag_finds + cxx_finds)
200  for find in all_finds:
201  if find[1] >= 0:
202  processed = False
203  splitline = neatsplit(r'\(|\)|,|\s|\{',find[2])
204  if len(splitline) != 0:
205  plugin_name = splitline[1]
206  mod_version = ["0","0","0",""]
207  plugin_type = plug_type[find[1]];
208  if splitline[2] == "version": mod_version[0:len(splitline[3:])] = splitline[3:]
209  token = plugin_name+"__t__"+plugin_type+"__v__"+"_".join([x for x in mod_version])
210  status = "ok"
211  for x in exclude_plugins:
212  if (plugin_name+"_"+"_".join([y for y in mod_version])).startswith(x):
213  status = "excluded"
214 
215  last_plugin_file=[plugin_name, plugin_type, mod_version, status, token, [], directory, plug_type[i]]
216  scanbit_plugins[plug_type[i]][directory] += [last_plugin_file]
217 
218  last_plugin = plugin_name
219 
220  last_version = mod_version[0]
221  if mod_version[1] != "": last_version += "." + mod_version[1]
222  if mod_version[2] != "": last_version += "." + mod_version[2]
223  if mod_version[3] != "": last_version += "-" + mod_version[3]
224 
225  elif find[1] == -1:
226  if not last_plugin in scanbit_reqs[plug_type[i]]:
227  scanbit_reqs[plug_type[i]][last_plugin] = dict()
228  if last_version in scanbit_reqs[plug_type[i]][last_plugin]:
229  if scanbit_reqs[plug_type[i]][last_plugin][last_version][0] == "":
230  scanbit_reqs[plug_type[i]][last_plugin][last_version][0] = find[2][21:-1]
231  else:
232  scanbit_reqs[plug_type[i]][last_plugin][last_version][0] += "," + find[2][21:-1]
233  else:
234  scanbit_reqs[plug_type[i]][last_plugin][last_version] = [find[2][21:-1], "", "", [], [], [], []]
235 
236  elif find[1] == -2:
237  if not directory in scanbit_auto_libs[plug_type[i]]:
238  scanbit_auto_libs[plug_type[i]][directory] = neatsplit(',|\"', find[2][15:-1])
239  else:
240  scanbit_auto_libs[plug_type[i]][directory] += neatsplit(',|\"', find[2][15:-1])
241 
242  if not last_plugin in scanbit_reqs[plug_type[i]]:
243  scanbit_reqs[plug_type[i]][last_plugin] = dict()
244  if last_version in scanbit_reqs[plug_type[i]][last_plugin]:
245  if scanbit_reqs[plug_type[i]][last_plugin][last_version][1] == "":
246  scanbit_reqs[plug_type[i]][last_plugin][last_version][1] = find[2][15:-1]
247  else:
248  scanbit_reqs[plug_type[i]][last_plugin][last_version][1] += "," + find[2][15:-1]
249  else:
250  scanbit_reqs[plug_type[i]][last_plugin][last_version] = ["", find[2][15:-1], "", [], [], [], []]
251 
252  if (not processed) and (last_plugin_file[3] != "excluded"):
253  last_plugin_file[3] = "link_needed"
254  processed = True
255  plugins += [last_plugin_file]
256 
257  elif find[1] == -3:
258  if not directory in scanbit_auto_incs[plug_type[i]]:
259  scanbit_auto_incs[plug_type[i]][directory] = neatsplit(',|\"', find[2][13:-1])
260  else:
261  scanbit_auto_incs[plug_type[i]][directory] += neatsplit(',|\"', find[2][13:-1])
262 
263  if not last_plugin in scanbit_reqs[plug_type[i]]:
264  scanbit_reqs[plug_type[i]][last_plugin] = dict()
265  if last_version in scanbit_reqs[plug_type[i]][last_plugin]:
266  if scanbit_reqs[plug_type[i]][last_plugin][last_version][2] == "":
267  scanbit_reqs[plug_type[i]][last_plugin][last_version][2] = find[2][13:-1]
268  else:
269  scanbit_reqs[plug_type[i]][last_plugin][last_version][2] += "," + find[2][13:-1]
270  else:
271  scanbit_reqs[plug_type[i]][last_plugin][last_version] = ["", "", find[2][13:-1], [], [], [], []]
272 
273  if (not processed) and (last_plugin_file[3] != "excluded"):
274  processed = True
275  plugins += [last_plugin_file]
276 
277  elif find[1] == -4:
278  flags = neatsplit(",", find[2][9:-1]);
279  if len(flags) > 0:
280  if not last_plugin in scanbit_flags[plug_type[i]]:
281  scanbit_flags[plug_type[i]][last_plugin] = dict()
282  if not last_version in scanbit_flags[plug_type[i]][last_plugin]:
283  scanbit_flags[plug_type[i]][last_plugin][last_version] = dict()
284  scanbit_flags[plug_type[i]][last_plugin][last_version][flags[0]] = []
285  scanbit_flags[plug_type[i]][last_plugin][last_version][flags[0]] += flags[1:]
286 
287  elif find[1] == -5:
288  flags = neatsplit(",", find[2][10:-1]);
289  if len(flags) > 0:
290  if not directory in scanbit_cxx_flags[plug_type[i]]:
291  scanbit_cxx_flags[plug_type[i]][directory] = []
292  scanbit_cxx_flags[plug_type[i]][directory] += flags
293 
294  # Add plugin source files to CMakeLists.txt. Only add those for non-excluded plugins.
295  # bjf> added "!=[]" to the conditional due to error during cmake. Hope it makes sense.
296  if(last_plugin_file!=[] and last_plugin_file[3] == "excluded"):
297  exclude_list += [last_plugin_file[0]+" "+".".join([y for y in last_plugin_file[2] if y != ""])]
298  else:
299  cmakelist_txt_out_tmp += " "*16 + "src/" + source.split('/ScannerBit/src/')[1] + "\n"
300 
301  # Add entries for this plugin only if there are non-excluded sources found.
302  if (cmakelist_txt_out_tmp != ""):
303  # First do the sources
304  cmakelist_txt_out = cmakelist_txt_out+"set( " + plug_type[i] + "_plugin_sources_" + directory + "\n" + cmakelist_txt_out_tmp + ")\n\n"
305  # Now do the headers
306  cmakelist_txt_out += "set( " + plug_type[i] + "_plugin_headers_" + directory + "\n"
307  for header in sorted(headers):
308  cmakelist_txt_out += " "*16 + "include/gambit/ScannerBit/" + header.split('/ScannerBit/include/gambit/ScannerBit/')[1] + "\n"
309  cmakelist_txt_out += ")\n\n"
310  # Otherwise notify that the plugin is ditched.
311  else:
312  for x in exclude_list:
313  cmakelist_txt_out += "message(\"${BoldCyan} X Excluding " + x + " from ScannerBit configuration.${ColourReset}\")\n\n"
314 
315  # Loop over all plugin types
316  for config_file, plugin_type in zip(config_files, plug_type):
317 
318  # Check for the user-defined version of the location file.
319  location_files = []
320  if os.path.isfile(config_file):
321  location_files += [config_file]
322 
323  # Now make sure the default version of the locations yaml file is present.
324  if not os.path.isfile(config_file+".default"):
325  print("ERROR: "+config_file+".default not found!")
326  sys.exit(2)
327  location_files += [config_file+".default"]
328 
329  # Loop over all the plugins of this type
330  for plugin in plugins:
331 
332  plugin_name = plugin[0]
333  inc_commands = []
334  auto_libs = []
335  auto_incs = []
336  linkcommands = ""
337  linklibs = []
338  #staticlinkcommands = ""
339  linkdirs = []
340  linkhints = []
341  inc_files = []
342  detected_plugins = [("none","none")]
343 
344  # Loop over the found yaml location files
345  for current_location_file in location_files:
346 
347  # Load the locations yaml file, and work out which libs are present
348  yaml_loader = yaml.full_load if hasattr(yaml, 'full_load') else yaml.load
349  yaml_file = yaml_loader(open(current_location_file))
350 
351  if yaml_file:
352  if plugin_name in yaml_file and plugin[1] == plugin_type:
353  version_bits = plugin[2]
354  maj_version = int(".".join([x for x in version_bits[0:1]]))
355  min_version = float(".".join([x for x in version_bits[0:2]]))
356  pat_version = ".".join([x for x in version_bits[0:3]])
357  ful_version = "-".join([pat_version, version_bits[3]])
358  version = ".".join([x for x in version_bits[0:3]])
359  if (version_bits[3] != ""):
360  version = "-".join([version, version_bits[3]])
361  ini_version = ""
362  if ful_version in yaml_file[plugin_name]:
363  ini_version = ful_version
364  elif pat_version in yaml_file[plugin_name]:
365  ini_version = pat_version
366  elif min_version in yaml_file[plugin_name]:
367  ini_version = min_version
368  elif maj_version in yaml_file[plugin_name]:
369  ini_version = maj_version
370  elif "any_version" in yaml_file[plugin_name]:
371  ini_version = "any_version"
372 
373  if ini_version != "" and (plugin_name, ini_version) not in detected_plugins:
374  detected_plugins += [(plugin_name, ini_version)]
375  options_list = yaml_file[plugin_name][ini_version]
376  if type(options_list) is dict: #not list:
377  options_list = [options_list,]
378  for f in options_list:
379  if type(f) is dict:
380  for key, value in f.items():
381  if key in ("lib", "libs", "library", "libraries", "library_path", "library_paths", "-lib", "-libs", "-library", "-libraries", "-library_path", "-library_paths"):
382  libs = neatsplit(',|\s|;', value)
383  for lib in libs:
384  if os.path.isfile(lib):
385  lib_full = os.path.abspath(lib)
386  print(" Found library {0} needed for ScannerBit plugin {1} v{2}".format(lib,plugin_name,version))
387  if lib_full.endswith(".a"):
388  static_links += lib_full + " "
389  [libdir, lib] = os.path.split(lib_full)
390  lib = re.sub(r"^lib|\..*$","",lib)
391  #staticlinkcommands += "-L" + libdir + " -l" + lib + " "
392  else:
393  [libdir, lib] = os.path.split(lib_full)
394  lib = re.sub(r"^lib|\..*$","",lib)
395  linkcommands += "-L" + libdir + " -l" + lib + " "
396  linkdirs += [libdir]
397 
398  linklibs += [[lib, lib_full]]
399  scanbit_reqs[plugin[7]][plugin_name][version][3] += [lib]
400  elif os.path.isdir(lib):
401  lib = os.path.abspath(lib)
402  print(" Found library path {0} needed for ScannerBit plugin {1} v{2}".format(lib,plugin_name,version))
403  linkhints += [lib]
404  elif lib == "ROOT" or lib == "GSL":
405  auto_libs += [lib]
406  #scanbit_reqs[plugin[7]][plugin_name][version][3] += [lib]
407  if scanbit_reqs[plugin[7]][plugin_name][version][1] == "":
408  scanbit_reqs[plugin[7]][plugin_name][version][1] = "\"" + lib + "\""
409  else:
410  scanbit_reqs[plugin[7]][plugin_name][version][1] += ",\"" + lib + "\""
411  else:
412  [libdir, lib] = os.path.split(lib)
413  #lib = re.sub("^lib|\..*$","",lib)
414  lib = "\"" + lib + "\""
415  scanbit_reqs[plugin[7]][plugin_name][version][4] += [lib]
416 
417  elif key in ("inc", "incs", "include", "includes", "include_path", "include_paths", "-inc", "-incs", "-include", "-includes", "-include_path", "-include_paths", "hdr", "hdrs", "header", "headers", "-hdr", "-hdrs", "-header", "-headers"):
418  incs = neatsplit(',|\s|;', value)
419  for inc in incs:
420  if os.path.isdir(inc):
421  inc = os.path.abspath(inc)
422  print(" Found include path {0} needed for ScannerBit plugin {1} v{2}".format(inc,plugin_name,version))
423  inc_commands += [inc]
424  scanbit_reqs[plugin[7]][plugin_name][version][5] += [inc]
425  elif os.path.isfile(inc):
426  inc = os.path.abspath(inc)
427  print(" Found include file {0} needed for ScannerBit plugin {1} v{2}".format(inc,plugin_name,version))
428  [incdir, inc] = os.path.split(inc)
429  inc_commands += [incdir]
430  scanbit_reqs[plugin[7]][plugin_name][version][5] += [incdir]
431  inc_files += [[inc, incdir]]
432  elif inc == "ROOT" or inc == "GSL":
433  auto_incs += [inc]
434  #scanbit_reqs[plugin[7]][plugin_name][version][5] += [inc]
435  if scanbit_reqs[plugin[7]][plugin_name][version][2] == "":
436  scanbit_reqs[plugin[7]][plugin_name][version][2] = "\"" + inc + "\""
437  else:
438  scanbit_reqs[plugin[7]][plugin_name][version][2] += ",\"" + inc + "\""
439  else:
440  plugin[3] = "missing"
441  scanbit_reqs[plugin[7]][plugin_name][version][6] += [inc]
442  else:
443  print(" Unknown infile option \"{0}\" needed for ScannerBit plugin {1} v{2}".format(key,plugin_name,version))
444  else:
445  print(" Unknown YAML format in file {0}.".format(currrent_location_file))
446 
447  # add links commands to map (keys: {plug_type, directory}) to be linked to later
448  #if staticlinkcommands != "":
449  # if plugin[6] in scanbit_static_links[plugin[7]]:
450  # scanbit_static_links[plugin[7]][plugin[6]] += staticlinkcommands
451  # else:
452  # scanbit_static_links[plugin[7]][plugin[6]] = staticlinkcommands
453  if inc_commands != []:
454  if plugin[6] in scanbit_incs[plugin[7]]:
455  scanbit_incs[plugin[7]][plugin[6]] += inc_commands
456  else:
457  scanbit_incs[plugin[7]][plugin[6]] = inc_commands
458  if linkcommands != "":
459  if plugin[6] in scanbit_links[plugin[7]]:
460  scanbit_links[plugin[7]][plugin[6]] += linkcommands
461  else:
462  scanbit_links[plugin[7]][plugin[6]] = linkcommands
463  if linkdirs != []:
464  if plugin[6] in scanbit_libs[plugin[7]]:
465  scanbit_libs[plugin[7]][plugin[6]] += linkdirs
466  else:
467  scanbit_libs[plugin[7]][plugin[6]] = linkdirs
468  if auto_libs != []:
469  if plugin[6] in scanbit_auto_libs[plugin[7]]:
470  scanbit_auto_libs[plugin[7]][plugin[6]] += auto_libs
471  else:
472  scanbit_auto_libs[plugin[7]][plugin[6]] = auto_libs
473  if auto_incs != []:
474  if plugin[6] in scanbit_auto_incs[plugin[7]]:
475  scanbit_auto_incs[plugin[7]][plugin[6]] += auto_incs
476  else:
477  scanbit_auto_incs[plugin[7]][plugin[6]] = auto_incs
478  if linklibs != []:
479  if plugin[6] in scanbit_link_libs[plugin[7]]:
480  scanbit_link_libs[plugin[7]][plugin[6]] += linklibs
481  else:
482  scanbit_link_libs[plugin[7]][plugin[6]] = linklibs
483  if linkhints != []:
484  if plugin[6] in scanbit_lib_hints[plugin[7]]:
485  scanbit_lib_hints[plugin[7]][plugin[6]] += linkhints
486  else:
487  scanbit_lib_hints[plugin[7]][plugin[6]] = linkhints
488  if inc_files != []:
489  if plugin[6] in scanbit_inc_files[plugin[7]]:
490  scanbit_inc_files[plugin[7]][plugin[6]] += inc_files
491  else:
492  scanbit_inc_files[plugin[7]][plugin[6]] = inc_files
493 
494  # Make a candidate priors_rollcall.hpp file
495  towrite = "\
496 // GAMBIT: Global and Modular BSM Inference Tool \n\
497 //************************************************\n\
498 /// \\file \n\
499 /// \n\
500 /// Priors rollcall file for ScannerBit. \n\
501 /// \n\
502 /// This file has been automatically generated by\n\
503 /// scanner+_harvester.py. Please do not modify.\n\
504 /// \n\
505 ///***********************************************\n\
506 /// \n\
507 /// Authors: \n\
508 /// \n\
509 /// \\author The GAMBIT Collaboration \n\
510 /// \\date "+datetime.datetime.now().strftime("%I:%M%p on %B %d, %Y")+"\n\
511 /// \n\
512 ///***********************************************\n\n"
513 
514  towrite += prior_txt_out
515 
516  header = "./ScannerBit/include/gambit/ScannerBit/priors_rollcall.hpp"
517  candidate = build_dir+"/priors_rollcall.hpp.candidate"
518  with open(candidate,"w") as f: f.write(towrite)
519  update_only_if_different(header, candidate)
520 
521  if verbose: print("Finished writing ScannerBit/include/gambit/ScannerBit/priors_rollcall.hpp")
522 
523  # Make a candidate ScannerBit CMakelists.txt file
524 
525  library_names = []
526 
527  towrite = """\
528 # GAMBIT: Global and Modular BSM Inference Tool
529 #************************************************
530 # \\file
531 #
532 # Cmake CMakeLists.txt file for ScannerBit.
533 #
534 # This file has been automatically generated by
535 # scanner+_harvester.py. Please do not modify.
536 #
537 #************************************************
538 #
539 # Authors:
540 #
541 # \\author The GAMBIT Collaboration
542 # \\date """+datetime.datetime.now().strftime("%I:%M%p on %B %d, %Y")+"""
543 #
544 #************************************************\n"""
545  towrite += cmakelist_txt_out
546  towrite += """\
547 # Add the ScannerBit linking flag utility
548 add_executable(scanlibs ${scanner_scanlibs_sources} ${scanner_scanlibs_headers})
549 if(${CMAKE_VERSION} VERSION_GREATER 2.8.10)
550  target_include_directories(scanlibs PUBLIC ${PROJECT_SOURCE_DIR}/cmake/include)
551 else()
552  include_directories(${PROJECT_SOURCE_DIR}/cmake/include)
553 endif()
554 add_dependencies(scanlibs yaml-cpp)
555 target_link_libraries(scanlibs yaml-cpp)
556 set_target_properties(scanlibs PROPERTIES RUNTIME_OUTPUT_DIRECTORY \"${PROJECT_SOURCE_DIR}/ScannerBit/bin\")
557 
558 # Specify known plugin include paths
559 set( PLUGIN_INCLUDE_DIRECTORIES
560  ${PROJECT_BINARY_DIR}
561  ${PROJECT_BINARY_DIR}/cmake
562  ${GAMBIT_INCDIRS}
563  ${mkpath_INCLUDE_DIR}
564  ${yaml_INCLUDE_DIR}
565  ${Boost_INCLUDE_DIR}
566  ${GSL_INCLUDE_DIRS}
567  ${ROOT_INCLUDE_DIR}
568  ${ROOT_INCLUDE_DIRS}
569  ${PROJECT_SOURCE_DIR}/ScannerBit/include/gambit/ScannerBit
570 )\n
571 if( ${PLUG_VERBOSE} )
572  message(\"*** begin PLUG_INCLUDE_DIRECTORIES ***\")
573  foreach(dir ${PLUGIN_INCLUDE_DIRECTORIES})
574  message(STATUS \"dir='${dir}'\")
575  endforeach()
576  message(\"*** end PLUG_INCLUDE_DIRECTORIES ***\")
577 endif()
578 
579 set( reqd_lib_output )
580 set( exclude_lib_output )
581 set( PLUGIN_COMPILE_FLAGS \"${BACKEND_CXX_FLAGS}\")\n
582 if(MPI_C_FOUND)
583  set( PLUGIN_COMPILE_FLAGS \"${PLUGIN_COMPILE_FLAGS} ${MPI_C_COMPILE_FLAGS}\" )
584  set( PLUGIN_COMPILE_DIRECTORIES
585  ${PLUGIN_COMPILE_DIRECTORIES}
586  ${MPI_C_COMPILE_PATH}
587  )
588  set( PLUGIN_INCLUDE_DIRECTORIES
589  ${PLUGIN_INCLUDE_DIRECTORIES}
590  ${MPI_C_INCLUDE_PATH}
591  )
592 endif()\n
593 if(MPI_CXX_FOUND)
594  set( PLUGIN_COMPILE_FLAGS \"${PLUGIN_COMPILE_FLAGS} ${MPI_CXX_COMPILE_FLAGS}\" )
595  set( PLUGIN_COMPILE_DIRECTORIES
596  ${PLUGIN_COMPILE_DIRECTORIES}
597  ${MPI_CXX_COMPILE_PATH}
598  )
599  set( PLUGIN_INCLUDE_DIRECTORIES
600  ${PLUGIN_INCLUDE_DIRECTORIES}
601  ${MPI_CXX_INCLUDE_PATH}
602  )
603 endif()
604 """
605 
606 
607  # now link the shared libraries to their respective plugin libraries
608  for i in range(len(plug_type)):
609  directories = [ name for name in os.listdir(src_paths[i]) if os.path.isdir(src_paths[i] + "/" + name) ]
610  for directory in sorted(directories):
611  library_names.append("lib" + plug_type[i] + "_" + directory + ".so")
612 
613  towrite += "#################### lib" + plug_type[i] + "_" + directory + ".so ####################\n\n"
614 
615  towrite += "set (" + plug_type[i] + "_ok_flag_" + directory + " \"\")\n\n"
616  towrite += "set (" + plug_type[i] + "_compile_flags_" + directory + " \"${PLUGIN_COMPILE_FLAGS}"
617  if plug_type[i] in scanbit_cxx_flags:
618  if directory in scanbit_cxx_flags[plug_type[i]]:
619  towrite += " "
620  towrite += " ".join(scanbit_cxx_flags[plug_type[i]][directory])
621  towrite += "\")\n\n"
622 
623  for plug in scanbit_plugins[plug_type[i]][directory]:
624  if plug[3] == "excluded":
625  towrite += "set (" + plug_type[i] + "_ok_flag_" + directory + " \"\\n - user excluded plugin: \\\"" + plug[4].split("__t__")[0] + "\\\"\")\n"
626  if verbose: print("excluding ", plug[4])
627 
628  towrite += "set (" + plug_type[i] + "_plugin_libraries_" + directory + "\n"
629  if plug_type[i] in scanbit_libs:
630  if directory in scanbit_libs[plug_type[i]]:
631  towrite += " "*16 + "\"" + scanbit_links[plug_type[i]][directory] + "\"\n"
632  towrite += ")\n\n"
633 
634  towrite += "set (" + plug_type[i] + "_plugin_lib_paths_" + directory + "\n"
635  if plug_type[i] in scanbit_lib_hints:
636  if directory in scanbit_lib_hints[plug_type[i]]:
637  for lib in scanbit_lib_hints[plug_type[i]][directory]:
638  towrite += " "*16 + lib + "\n"
639  towrite += ")\n\n"
640 
641  towrite += "set (" + plug_type[i] + "_plugin_rpath_" + directory + "\n"
642  if plug_type[i] in scanbit_libs:
643  if directory in scanbit_libs[plug_type[i]]:
644  unique_libdirs = set(p for p in scanbit_libs[plug_type[i]][directory])
645  if unique_libdirs:
646  for libdir in unique_libdirs:
647  towrite += " "*16 + libdir +"\n"
648  towrite += ")\n\n"
649 
650  towrite += "set (" + plug_type[i] + "_plugin_includes_" + directory + "\n"
651  towrite += " "*16 + "${PLUGIN_INCLUDE_DIRECTORIES}\n"
652  towrite += " "*16 + "${CMAKE_CURRENT_SOURCE_DIR}/include/gambit/ScannerBit/" + plug_type[i] + "s/" + directory + "\n"
653  if plug_type[i] in scanbit_incs:
654  if directory in scanbit_incs[plug_type[i]]:
655  for inc in scanbit_incs[plug_type[i]][directory]:
656  towrite += " "*16 + inc + "\n"
657  towrite += ")\n\n"
658 
659  towrite += "set (" + plug_type[i] + "_plugin_linked_libs_" + directory + " \"\")\n"
660  if plug_type[i] in scanbit_link_libs:
661  if directory in scanbit_link_libs[plug_type[i]]:
662  for lib in scanbit_link_libs[plug_type[i]][directory]:
663  towrite += "set (" + plug_type[i] + "_plugin_linked_libs_" + directory + " \"${" + plug_type[i] + "_plugin_linked_libs_" + directory + "}"
664  towrite += " " + lib[0] + ": " + lib[1] + "\\n\")\n"
665  towrite += "\n"
666  towrite += "set (" + plug_type[i] + "_plugin_lib_full_paths_" + directory + "\n"
667  if plug_type[i] in scanbit_link_libs:
668  if directory in scanbit_link_libs[plug_type[i]]:
669  for lib in scanbit_link_libs[plug_type[i]][directory]:
670  towrite += " "*16 + lib[1] + "\n"
671  towrite += ")\n\n"
672 
673  towrite += "set (" + plug_type[i] + "_plugin_found_incs_" + directory + " \"\")\n"
674  if plug_type[i] in scanbit_incs:
675  if directory in scanbit_incs[plug_type[i]]:
676  for inc in scanbit_incs[plug_type[i]][directory]:
677  towrite += "set (" + plug_type[i] + "_plugin_found_incs_" + directory + " \"${" + plug_type[i] + "_plugin_found_incs_" + directory + "}"
678  towrite += " \\\"" + plug_type[i] + "_locations.yaml\\\": " + inc + "\\n\")\n"
679  if plug_type[i] in scanbit_inc_files:
680  if directory in scanbit_inc_files[plug_type[i]]:
681  for inc in scanbit_inc_files[plug_type[i]][directory]:
682  towrite += "set (" + plug_type[i] + "_plugin_found_incs_" + directory + " \"${" + plug_type[i] + "_plugin_found_incs_" + directory + "}"
683  towrite += " \\\"" + inc[0] + "\\\": " + inc[1] + "\\n\")\n"
684 
685  towrite += "\n"
686 
687  if plug_type[i] in scanbit_auto_libs:
688  if directory in scanbit_auto_libs[plug_type[i]]:
689  if plug_type[i] in scanbit_link_libs:
690  if directory in scanbit_link_libs[plug_type[i]]:
691  temp = [p[0] for p in scanbit_link_libs[plug_type[i]][directory]]
692  scanbit_auto_libs[plug_type[i]][directory] = set(lib for lib in scanbit_auto_libs[plug_type[i]][directory] if not lib in temp);
693 
694  temp = set(lib for lib in scanbit_auto_libs[plug_type[i]][directory])
695  for lib in temp:
696  if lib == "ROOT":
697  towrite += "if (" + lib + "_FOUND)\n"
698  towrite += " "*4 + "foreach (" + lib + "_LIB ${" + lib + "_LIBRARIES})\n"
699  towrite += " "*8 + "get_filename_component(lib_path ${" + lib + "_LIB} PATH)\n"
700  towrite += " "*8 + "get_filename_component(lib_name ${" + lib + "_LIB} NAME_WE)\n"
701  towrite += " "*8 + "string (REGEX REPLACE \"^lib\" \"\" lib_name ${lib_name})\n"
702  towrite += " "*8 + "set (" + plug_type[i] + "_plugin_libraries_" + directory
703  towrite += " \"${" + plug_type[i] + "_plugin_libraries_" + directory + "}"
704  towrite += " -L${lib_path} -l${lib_name}\")\n"
705  towrite += " "*8 + "set (" + plug_type[i] + "_plugin_lib_full_paths_" + directory
706  towrite += " ${" + plug_type[i] + "_plugin_lib_full_paths_" + directory + "}"
707  towrite += " ${" + lib + "_LIBRARIES})\n"
708  towrite += " "*8 + "set (" + plug_type[i] + "_plugin_linked_libs_" + directory
709  towrite += " \"${" + plug_type[i] + "_plugin_linked_libs_" + directory +"} " + lib + ": ${" + lib + "_LIB}\\n\")\n"
710  towrite += " "*4 + "endforeach()\n"
711  towrite += " "*4 + "set (" + plug_type[i] + "_plugin_rpath_" + directory
712  towrite += " \"${" + plug_type[i] + "_plugin_rpath_" + directory + "};${" + lib + "_LIBRARY_DIR}\")\n"
713  towrite += "endif()\n\n"
714  else:
715  lib_name = plug_type[i] + "_" + directory + "_" + lib + "_LIBRARY"
716  towrite += "unset(" + lib_name + " CACHE)\n"
717  towrite += "find_library( " + lib_name + " " + lib + " HINTS ${" + plug_type[i] + "_plugin_lib_paths_" + directory + "} )\n"
718  towrite += "if( " + lib_name + " STREQUAL \"" + lib_name + "-NOTFOUND\" )\n"
719  towrite += " message(\"-- Did not find "+ plug_type[i] + " library " + lib + " for " + directory + ". Disabling scanners that depend on this.\")\n"
720  # next line will exclude plugins if no lib found. Note that if you un-comment this line
721  # all plugins plugins defined in this library will be excluded.
722  # towrite += " set (" + plug_type[i] + "_ok_flag_" + directory + " \"${" + plug_type[i] + "_ok_flag_" + directory + "} \\n - library missing: \\\"lib" + lib + ".so\\\"\")\n"
723  towrite += "else()\n"
724  towrite += " "*4 + "get_filename_component(lib_path ${" + lib_name + "} PATH)\n"
725  towrite += " "*4 + "get_filename_component(lib_name ${" + lib_name + "} NAME_WE)\n"
726  towrite += " "*4 + "string (REGEX REPLACE \"^lib\" \"\" lib_name ${lib_name})\n"
727  towrite += " "*4 + "set (" + plug_type[i] + "_plugin_libraries_" + directory
728  towrite += " \"${" + plug_type[i] + "_plugin_libraries_" + directory + "}"
729  towrite += " -L${lib_path} -l${lib_name}\")\n"
730  towrite += " "*8 + "set (" + plug_type[i] + "_plugin_lib_full_paths_" + directory
731  towrite += " ${" + plug_type[i] + "_plugin_lib_full_paths_" + directory + "}"
732  towrite += " ${" + lib_name + "})\n"
733  towrite += " "*4 + "set (" + plug_type[i] + "_plugin_rpath_" + directory
734  towrite += " \"${" + plug_type[i] + "_plugin_rpath_" + directory + "};${lib_path}\")\n"
735  towrite += " "*4 + "set (" + plug_type[i] + "_plugin_linked_libs_" + directory
736  towrite += " \"${" + plug_type[i] + "_plugin_linked_libs_" + directory +"} " + lib + ": ${" + lib_name + "}\\n\")\n"
737  towrite += " message(\"-- Found "+ plug_type[i] + " library: ${" + lib_name + "}\")\n"
738  towrite += "endif()\n\n"
739 
740  if plug_type[i] in scanbit_auto_incs:
741  if directory in scanbit_auto_incs[plug_type[i]]:
742  if plug_type[i] in scanbit_inc_files:
743  if directory in scanbit_inc_files[plug_type[i]]:
744  temp = [p[0] for p in scanbit_inc_files[plug_type[i]][directory]]
745  scanbit_auto_incs[plug_type[i]][directory] = set(inc for inc in scanbit_auto_incs[plug_type[i]][directory] if not inc in temp);
746 
747  temp = set(inc for inc in scanbit_auto_incs[plug_type[i]][directory])
748  for inc in temp:
749  if inc == "ROOT":
750  towrite += "if (" + inc + "_FOUND)\n"
751  towrite += " "*4 + "set (" + plug_type[i] + "_plugin_includes_" + directory + "\n"
752  towrite += " "*8 + "${" + plug_type[i] + "_plugin_includes_" + directory + "}\n"
753  towrite += " "*8 + "${ROOT_INCLUDE_DIRS}\n"
754  towrite += " "*4 + ")\n"
755  towrite += " "*4 + "set (" + plug_type[i] + "_plugin_found_incs_" + directory
756  towrite += " \"${" + plug_type[i] + "_plugin_found_incs_" + directory + "}"
757  towrite += " \\\"" + inc + "\\\": ${ROOT_INCLUDE_DIRS}\\n\")\n"
758  towrite += "endif()\n\n"
759  else:
760  inc_name = plug_type[i] + "_" + directory + "_" + re.sub(r";|/|\.", "_", inc) + "_INCLUDE_PATH"
761  towrite += "unset(" + inc_name + " CACHE)\n"
762  towrite += "find_path( " + inc_name + " \"" + inc + "\" HINTS ${" + plug_type[i] + "_plugin_includes_" + directory + "})\n"
763  towrite += "if( NOT " + inc_name + " STREQUAL \"" + inc_name + "-NOTFOUND\" )\n"
764  towrite += " "*4 + "set (" + plug_type[i] + "_plugin_includes_" + directory + "\n"
765  towrite += " "*8 + "${" + plug_type[i] + "_plugin_includes_" + directory + "}\n"
766  towrite += " "*8 + "${" + inc_name + "}\n"
767  towrite += " "*4 + ")\n"
768  towrite += " "*4 + "set (" + plug_type[i] + "_plugin_found_incs_" + directory
769  towrite += " \"${" + plug_type[i] + "_plugin_found_incs_" + directory + "}"
770  towrite += " \\\"" + inc + "\\\": ${" + inc_name + "}\\n\")\n"
771  towrite += " message(\"-- Found " + plug_type[i] + " header: ${" + inc_name + "}/" + inc + "\")\n"
772  towrite += "else()\n"
773  towrite += " message(\"-- Did not find "+ plug_type[i] + " header " + inc + ". Disabling scanners that depend on this.\")\n"
774  towrite += " set (" + plug_type[i] + "_ok_flag_" + directory + " \"${" + plug_type[i] + "_ok_flag_" + directory + "} \\n - file missing: \\\"" + inc + "\\\"\")\n"
775  towrite += "endif()\n\n"
776  towrite += "if( NOT ${" + plug_type[i] + "_plugin_linked_libs_" + directory + "} STREQUAL \"\" OR NOT ${" + plug_type[i] + "_plugin_found_incs_" + directory + "} STREQUAL \"\")\n"
777  towrite += " "*4 + "set ( reqd_lib_output \"${reqd_lib_output}lib" + plug_type[i] + "_" + directory + ".so:\\n\" )\n"
778  towrite += " "*4 + "if( NOT ${" + plug_type[i] + "_plugin_linked_libs_" + directory + "} STREQUAL \"\" )\n"
779  towrite += " "*8 + "set ( reqd_lib_output \"${reqd_lib_output} linked_libs: \\n${" + plug_type[i] + "_plugin_linked_libs_" + directory + "}\")\n"
780  towrite += " "*4 + "endif()\n"
781  towrite += " "*4 + "if( NOT ${" + plug_type[i] + "_plugin_found_incs_" + directory + "} STREQUAL \"\" )\n"
782  towrite += " "*8 + "set ( reqd_lib_output \"${reqd_lib_output} found_incs: \\n${" + plug_type[i] + "_plugin_found_incs_" + directory + "}\")\n"
783  towrite += " "*4 + "endif()\n"
784  towrite += "endif()\n\n"
785 
786  towrite += "if ( " + plug_type[i] + "_ok_flag_" + directory + " STREQUAL \"\" )\n"
787  towrite += " "*4 + "add_gambit_library( " + plug_type[i] + "_" + directory + " VISIBLE OPTION SHARED SOURCES ${"
788  towrite += plug_type[i] + "_plugin_sources_" + directory + "} HEADERS ${"
789  towrite += plug_type[i] + "_plugin_headers_" + directory + "} )\n"
790  towrite += " "*4 + "set_target_properties( " + plug_type[i] + "_" + directory + "\n" + " "*23 + "PROPERTIES\n"
791  towrite += " "*23 + "INSTALL_RPATH \"${" + plug_type[i] + "_plugin_rpath_" + directory + "}\"\n";
792  towrite += " "*23 + "COMPILE_FLAGS \"${" + plug_type[i] + "_compile_flags_" + directory + "}\"\n"
793  towrite += " "*23 + "INCLUDE_DIRECTORIES \"${" + plug_type[i] + "_plugin_includes_" + directory + "}\"\n"
794  towrite += " "*23 + "ARCHIVE_OUTPUT_DIRECTORY \"${CMAKE_CURRENT_SOURCE_DIR}/lib\"\n"
795  towrite += " "*23 + "LIBRARY_OUTPUT_DIRECTORY \"${CMAKE_CURRENT_SOURCE_DIR}/lib\")\n"
796  towrite += " "*4 + "target_link_libraries( " + plug_type[i] + "_" + directory + " ${" + plug_type[i] + "_plugin_lib_full_paths_" + directory + "})\n"
797  #towrite += "target_include_directories( " + inc_dirs ")\n\n"
798  #towrite += " "*4 + "add_dependencies(gambit " + plug_type[i] + "_" + directory + ")\n"
799  towrite += " "*4 + "set (SCANNERBIT_PLUGINS " + " ${SCANNERBIT_PLUGINS} " + plug_type[i] + "_" + directory + ")\n"
800  towrite += "else()\n"
801  towrite += " "*4 + "set ( exclude_lib_output \"${exclude_lib_output}lib" + plug_type[i] + "_" + directory + ".so:\\n"
802  towrite += " plugins:\\n"
803  for plug in scanbit_plugins[plug_type[i]][directory]:
804  towrite += " - " + plug[4] + "\\n"
805  towrite += " reason: ${" + plug_type[i] + "_ok_flag_" + directory + "}\\n\\n\" )\n"
806  towrite += "endif()\n\n"
807 
808  towrite += "set(SCANNERBIT_PLUGINS ${SCANNERBIT_PLUGINS} PARENT_SCOPE)\n"
809  towrite += "file( WRITE ${PROJECT_SOURCE_DIR}/scratch/build_time/scanbit_excluded_libs.yaml \"${exclude_lib_output}\" )\n"
810  towrite += "file( WRITE ${PROJECT_SOURCE_DIR}/scratch/build_time/scanbit_linked_libs.yaml \"${reqd_lib_output}\" )\n\n"
811 
812  towrite += "#################################################################################\n\n"
813  towrite += "foreach (plugin ${SCANNERBIT_PLUGINS})\n"
814  towrite += " "*4 + "add_dependencies(ScannerBit ${plugin})\n"
815  towrite += "endforeach()\n"
816 
817  cmake = "./ScannerBit/CMakeLists.txt"
818  candidate = build_dir+"/ScannerBit_CMakeLists.txt.candidate"
819  with open(candidate,"w") as f: f.write(towrite)
820  update_only_if_different(cmake, candidate)
821 
822  towrite = "\n".join(library_names)
823  cmake = "./ScannerBit/lib/plugin_libraries.list"
824  candidate = build_dir+"/ScannerBit_lib_plugin_libraries.list.candidate"
825  with open(candidate,"w") as f: f.write(towrite)
826  update_only_if_different(cmake, candidate)
827 
828  if verbose: print("Finished writing ScannerBit/CMakeLists.txt")
829 
830  # Make a candidate scanbit_reqd_entries.yaml file
831  towrite = "\
832 # GAMBIT: Global and Modular BSM Inference Tool \n\
833 #************************************************\n\
834 # \\file \n\
835 # \n\
836 # Scanner required arguments for GAMBIT. \n\
837 # \n\
838 # This file has been automatically generated by \n\
839 # scanner+_harvester.py. Please do not modify. \n\
840 # \n\
841 #************************************************\n\
842 # \n\
843 # Authors: \n\
844 # \n\
845 # \\author The GAMBIT Collaboration \n\
846 # \\date "+datetime.datetime.now().strftime("%I:%M%p on %B %d, %Y")+"\n\
847 # \n\
848 #************************************************\n\n"
849 
850  for type_key in scanbit_reqs:
851  towrite += type_key + ":\n"
852  for plug_key in scanbit_reqs[type_key]:
853  towrite += " "*2 + plug_key + ":\n"
854  for version_key in scanbit_reqs[type_key][plug_key]:
855  towrite += " "*4 + version_key + ":\n"
856  #if scanbit_reqs[type_key][plug_key][version_key][0] != "":
857  towrite += " "*6 + "reqd_inifile_entries: [" + scanbit_reqs[type_key][plug_key][version_key][0] + "]\n"
858  #if scanbit_reqs[type_key][plug_key][version_key][1] != "":
859  towrite += " "*6 + "reqd_libraries: [" + scanbit_reqs[type_key][plug_key][version_key][1] + "]\n"
860  towrite += " "*6 + "reqd_include_paths: [" + scanbit_reqs[type_key][plug_key][version_key][2] + "]\n"
861  towrite += " "*6 + "linked_libraries: [" + ",".join(scanbit_reqs[type_key][plug_key][version_key][3]) + "]\n"
862  towrite += " "*6 + "not_linked_libraries: [" + ",".join(scanbit_reqs[type_key][plug_key][version_key][4]) + "]\n"
863  towrite += " "*6 + "found_include_paths: [" + ",".join(scanbit_reqs[type_key][plug_key][version_key][5]) + "]\n"
864  towrite += " "*6 + "not_found_include_paths: [" + ",".join(scanbit_reqs[type_key][plug_key][version_key][6]) + "]\n"
865  towrite += "\n"
866 
867  req_entries = "./scratch/build_time/scanbit_reqd_entries.yaml"
868  candidate = build_dir+"/scanbit_reqd_entries.yaml.candidate"
869  with open(candidate,"w") as f: f.write(towrite)
870  update_only_if_different(req_entries, candidate)
871 
872  if verbose: print("Finished writing scratch/build_time/scanbit_reqd_entries.yaml")
873 
874  # Make a candidate scanbit_reqd_entries.yaml file
875  towrite = "\
876 # GAMBIT: Global and Modular BSM Inference Tool \n\
877 #************************************************\n\
878 # \\file \n\
879 # \n\
880 # Scanner flags for GAMBIT. \n\
881 # \n\
882 # This file has been automatically generated by \n\
883 # scanner+_harvester.py. Please do not modify. \n\
884 # \n\
885 #************************************************\n\
886 # \n\
887 # Authors: \n\
888 # \n\
889 # \\author The GAMBIT Collaboration \n\
890 # \\date "+datetime.datetime.now().strftime("%I:%M%p on %B %d, %Y")+"\n\
891 # \n\
892 #************************************************\n\n"
893 
894  for type_key in scanbit_flags:
895  towrite += type_key + ":\n"
896  for plug_key in scanbit_flags[type_key]:
897  towrite += " "*2 + plug_key + ":\n"
898  for version_key in scanbit_flags[type_key][plug_key]:
899  towrite += " "*4 + version_key + ":\n"
900  for flag in scanbit_flags[type_key][plug_key][version_key]:
901  if len(scanbit_flags[type_key][plug_key][version_key][flag]) > 1:
902  towrite += " "*6 + flag + ": [" + ", ".join(scanbit_flags[type_key][plug_key][version_key][flag]) + "]\n"
903  else:
904  towrite += " "*6 + flag + ": " + scanbit_flags[type_key][plug_key][version_key][flag][0] + "\n"
905  towrite += "\n"
906 
907  flag_entries = "./scratch/build_time/scanbit_flags.yaml"
908  candidate = build_dir+"/scanbit_flags.yaml.candidate"
909  with open(candidate,"w") as f: f.write(towrite)
910  update_only_if_different(flag_entries, candidate)
911 
912  if verbose: print("Finished writing scratch/build_time/scanbit_flags.yaml")
913 
914  # Make a candidate linkedout.cmake file
915  towrite = "\
916 # GAMBIT: Global and Modular BSM Inference Tool \n\
917 #************************************************\n\
918 # \\file \n\
919 # \n\
920 # Cmake linking and rpath commands for GAMBIT. \n\
921 # \n\
922 # This file has been automatically generated by \n\
923 # scanner+_harvester.py. Please do not modify. \n\
924 # \n\
925 #************************************************\n\
926 # \n\
927 # Authors: \n\
928 # \n\
929 # \\author The GAMBIT Collaboration \n\
930 # \\date "+datetime.datetime.now().strftime("%I:%M%p on %B %d, %Y")+"\n\
931 # \n\
932 #************************************************\n\
933  \n\
934 if (${CMAKE_SYSTEM_NAME} MATCHES \"Darwin\") \n"
935 
936  if static_links != "":
937  towrite += " "*4 + "foreach(program ${uses_scannerbit})\n"
938  towrite += " "*8 + "target_link_libraries( ${program} -Wl,-force_load " + static_links + ")\n"
939  towrite += " "*4 + "endforeach()\n"
940  towrite += "else()\n"
941  if static_links != "":
942  towrite += " "*4 + "foreach(program ${uses_scannerbit})\n"
943  towrite += " "*8 + "target_link_libraries( ${program} -Wl,--whole-archive " + static_links + " -Wl,--no-whole-archive )\n"
944  towrite += " "*4 + "endforeach()\n"
945  towrite += "endif()\n"
946 
947  linked_out = build_dir+"/linkedout.cmake"
948  candidate = linked_out+".candidate"
949  with open(candidate,"w") as f: f.write(towrite)
950  update_only_if_different(linked_out, candidate)
951 
952  if verbose: print("Finished writing linkedout.cmake")
953 
954 # Handle command line arguments (verbosity)
void print(MixMatrix A)
Helper function to print a matrix.
EXPORT_SYMBOLS std::vector< std::string > split(const std::string &input, const std::string &delimiter)
Split string into vector of strings, using a delimiter string.
def comment_remover(text)
def update_only_if_different(existing, candidate, verbose=True)
auto zip(const T &... containers) -> boost::iterator_range< boost::zip_iterator< decltype(boost::make_tuple(std::begin(containers)...))>>
Use for combine container in a range loop: for (auto &&x : zip(a, b)){...}.
def neatsplit(regex, string)
DS5_MSPCTM DS_INTDOF int
Here is the call graph for this function:

Variable Documentation

◆ toolsfile

string scanner+_harvester.toolsfile = "./Utils/scripts/harvesting_tools.py"

Definition at line 41 of file scanner+_harvester.py.