check-makefile-subdirs Namespace Reference

Classes

class  Colours
 

Functions

def highlight (string)
 
def recursive_find_makefile_ams (base_dirs)
 
def list_subdirs_with_makefile_ams (base_dir)
 
def check_makefileam (direc)
 
def main ()
 

Variables

 COLOURS = Colours()
 

Function Documentation

◆ check_makefileam()

def check-makefile-subdirs.check_makefileam (   direc)
Compare subdirs variable in makefile in direc with actual sub
directories of direc containing a makefile.am (i.e. which can be built).
79 def check_makefileam(direc):
80  """Compare subdirs variable in makefile in direc with actual sub
81  directories of direc containing a makefile.am (i.e. which can be built).
82  """
83 
84  # Extract the subdirs variable from the Makefile if one exists
85  try:
86  subdirs_var_string = str(variable_from_makefile("SUBDIRS",
87  pjoin(direc, "Makefile")))
88  except NoMakefileError:
89  print("Makefile not found in", direc)
90  subdirs_var_string = ""
91 
92  subdirs_var = set(subdirs_var_string.split())
93 
94  # Check which subdirs really contain makefile.am s
95  subdirs_actual = set(list_subdirs_with_makefile_ams(direc))
96 
97  # If theres a difference then report it
98  if subdirs_var!= subdirs_actual:
99  print("Not the same in:", highlight(direc))
100 
101  var_takeout_actual = subdirs_var - subdirs_actual
102  print("In makefile SUBDIRS variable but not a sub-directory containing a makefile:\n",
103  list(var_takeout_actual))
104 
105  actual_takeout_var = subdirs_actual - subdirs_var
106  print("Sub-directories containing a makefile but not in SUBDIRS variable:\n",
107  list(actual_takeout_var))
108 
109  print("\n\n")
110  return False
111 
112  else:
113  return True
114 
115 
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet print(const Packet &a)
Definition: GenericPacketMath.h:1166
def check_makefileam(direc)
Definition: check-makefile-subdirs.py:79
def list_subdirs_with_makefile_ams(base_dir)
Definition: check-makefile-subdirs.py:65
def highlight(string)
Definition: check-makefile-subdirs.py:49
str
Definition: compute_granudrum_aor.py:141
str variable_from_makefile(str variable_name, str makefile_path="Makefile")
Definition: parallel_self_test.py:185
void set(Container &c, Position position, const Value &value)
Definition: stdlist_overload.cpp:36

References highlight(), list_subdirs_with_makefile_ams(), Eigen::internal.print(), set(), compute_granudrum_aor.str, and parallel_self_test.variable_from_makefile().

◆ highlight()

def check-makefile-subdirs.highlight (   string)
49 def highlight(string):
50  return COLOURS.Header + string + COLOURS.Endc
51 
52 

Referenced by check_makefileam().

◆ list_subdirs_with_makefile_ams()

def check-makefile-subdirs.list_subdirs_with_makefile_ams (   base_dir)
Get a list of the sub directories of base_dir which contain a file
called Makefile.am
65 def list_subdirs_with_makefile_ams(base_dir):
66  """Get a list of the sub directories of base_dir which contain a file
67  called Makefile.am
68  """
69 
70  sub_dirs = []
71  for f in glob.glob(pjoin(base_dir, "*", "Makefile.am")):
72  d = os.path.dirname(f)
73  rel_d = os.path.relpath(d, base_dir)
74  sub_dirs.append(rel_d)
75 
76  return sub_dirs
77 
78 

Referenced by check_makefileam().

◆ main()

def check-makefile-subdirs.main ( )
Compare subdirs variable in makefiles found recursively from the given
root directory with actual sub directories of their directory
containing a makefile.am (i.e. which can be built).
116 def main():
117  """Compare subdirs variable in makefiles found recursively from the given
118  root directory with actual sub directories of their directory
119  containing a makefile.am (i.e. which can be built).
120  """
121 
122  # Parse arguments
123  # ============================================================
124 
125  parser = argparse.ArgumentParser(description=main.__doc__,
126 
127  # Don't mess up my formating in the help message
128  formatter_class=argparse.RawDescriptionHelpFormatter)
129 
130  parser.add_argument('--oomph-root', '-C', action = "store")
131  parser.add_argument('--no-colour', action='store_true',
132  help='Disable colours in output.')
133  args = parser.parse_args()
134 
135  if args.no_colour:
136  COLOURS.disable()
137 
138  # Attempt to get the oomph-lib root dir from a Makefile in the current
139  # directory.
140  if args.oomph_root is None:
141  args.oomph_root = parallel_self_test.get_oomph_root()
142 
143  # Create list of folders to check
144  makefile_ams_to_check = recursive_find_makefile_ams([args.oomph_root])
145 
146  # Folders where it is not expected to be true due to various tricks
147  skiplist = [pjoin(args.oomph_root, "external_src"),
148  pjoin(args.oomph_root, "external_distributions"),
149  pjoin(args.oomph_root, "demo_drivers", "eigenproblems"),
150  pjoin(args.oomph_root, "demo_drivers", "mpi"),
151  ]
152 
153  print("Skipping directories:", skiplist, "\n")
154 
155  # Loop over directories and check the makefileams
156  successes = map(check_makefileam,
157  [r for r in makefile_ams_to_check if r not in skiplist])
158 
159 
160  # Return 0 if all ok, 1 otherwise
161  if all(successes):
162  return 0
163  else:
164  return 1
165 
166 
static constexpr Eigen::internal::all_t all
Definition: IndexedViewHelper.h:86
def recursive_find_makefile_ams(base_dirs)
Definition: check-makefile-subdirs.py:53
def main()
Definition: check-makefile-subdirs.py:116
str get_oomph_root()
Definition: parallel_self_test.py:237

References Eigen::placeholders.all, parallel_self_test.get_oomph_root(), Eigen::internal.print(), and recursive_find_makefile_ams().

◆ recursive_find_makefile_ams()

def check-makefile-subdirs.recursive_find_makefile_ams (   base_dirs)
Construct a list of directories to check in by searching for Makefile.am s.
53 def recursive_find_makefile_ams(base_dirs):
54  """Construct a list of directories to check in by searching for Makefile.am s."""
55 
56  sub_dirs = []
57  for base in base_dirs:
58  for root, dirs, files in os.walk(base):
59  if 'Makefile.am' in files:
60  sub_dirs.append(root)
61 
62  return sub_dirs
63 
64 

Referenced by main().

Variable Documentation

◆ COLOURS

check-makefile-subdirs.COLOURS = Colours()