GNUnet  0.11.x
Public Member Functions | Data Fields | Private Member Functions
talerbuildconfig.BuildConfig Class Reference

Public Member Functions

def __init__ (self)
 
def add_tool (self, tool)
 
def enable_prefix (self)
 
def enable_configmk (self)
 
def run (self)
 

Data Fields

 make_variables
 
 tools
 
 tool_results
 
 args
 
 prefix_enabled
 
 configmk_enabled
 

Private Member Functions

def _set_tool (self, name, value, version=None)
 

Detailed Description

Definition at line 57 of file talerbuildconfig.py.

Constructor & Destructor Documentation

◆ __init__()

def talerbuildconfig.BuildConfig.__init__ (   self)

Definition at line 58 of file talerbuildconfig.py.

58  def __init__(self):
59  # Pairs of (key, value) for config.mk variables
60  self.make_variables = []
61  self.tools = []
62  self.tool_results = {}
63  self.args = None
64  self.prefix_enabled = False
65  self.configmk_enabled = False
66 

Member Function Documentation

◆ add_tool()

def talerbuildconfig.BuildConfig.add_tool (   self,
  tool 
)

Definition at line 67 of file talerbuildconfig.py.

References talerbuildconfig.BuildConfig.tools.

67  def add_tool(self, tool):
68  if isinstance(tool, Tool):
69  self.tools.append(tool)
70  else:
71  raise Exception("Not a tool instance: " + repr(tool))
72 

◆ _set_tool()

def talerbuildconfig.BuildConfig._set_tool (   self,
  name,
  value,
  version = None 
)
private

Definition at line 73 of file talerbuildconfig.py.

References talerbuildconfig.BuildConfig.tool_results.

73  def _set_tool(self, name, value, version=None):
74  self.tool_results[name] = (value, version)
75 

◆ enable_prefix()

def talerbuildconfig.BuildConfig.enable_prefix (   self)
If enabled, process the --prefix argument.

Definition at line 76 of file talerbuildconfig.py.

References talerbuildconfig.BuildConfig.prefix_enabled.

76  def enable_prefix(self):
77  """If enabled, process the --prefix argument."""
78  self.prefix_enabled = True
79 

◆ enable_configmk()

def talerbuildconfig.BuildConfig.enable_configmk (   self)
If enabled, output the config.mk makefile fragment.

Definition at line 80 of file talerbuildconfig.py.

References talerbuildconfig.BuildConfig.configmk_enabled.

80  def enable_configmk(self):
81  """If enabled, output the config.mk makefile fragment."""
82  self.configmk_enabled = True
83 

◆ run()

def talerbuildconfig.BuildConfig.run (   self)

Definition at line 84 of file talerbuildconfig.py.

References CommandContext.args, talerbuildconfig.BuildConfig.args, GNUNET_FS_DirScanner.args, GNUNET_TESTING_Peer.args, talerbuildconfig.BuildConfig.configmk_enabled, talerbuildconfig.BuildConfig.prefix_enabled, talerbuildconfig.BuildConfig.tool_results, and talerbuildconfig.BuildConfig.tools.

84  def run(self):
85  parser = argparse.ArgumentParser()
86  if self.prefix_enabled:
87  parser.add_argument(
88  "--prefix",
89  type=str,
90  default="/usr/local",
91  help="Directory prefix for installation",
92  )
93  for tool in self.tools:
94  tool.args(parser)
95  args = self.args = parser.parse_args()
96 
97  for tool in self.tools:
98  res = tool.check(self)
99  if not res:
100  print(f"Error: tool {tool.name} not available")
101  if hasattr(tool, "hint"):
102  print(f"Hint: {tool.hint}")
103 
104  for tool in self.tools:
105  path, version = self.tool_results[tool.name]
106  if version is None:
107  print(f"found {tool.name} as {path}")
108  else:
109  print(f"found {tool.name} as {path} (version {version})")
110 
111  if self.configmk_enabled:
112  with open("config.mk", "w") as f:
113  print("writing config.mk")
114  f.write("# this makefile fragment is autogenerated by configure.py\n")
115  if self.prefix_enabled:
116  f.write(f"prefix = {args.prefix}\n")
117  for tool in self.tools:
118  path, version = self.tool_results[tool.name]
119  f.write(f"{tool.name} = {path}\n")
120 
121 
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
Main function that will be run.
Definition: gnunet-abd.c:732

Field Documentation

◆ make_variables

talerbuildconfig.BuildConfig.make_variables

Definition at line 60 of file talerbuildconfig.py.

◆ tools

talerbuildconfig.BuildConfig.tools

◆ tool_results

talerbuildconfig.BuildConfig.tool_results

◆ args

talerbuildconfig.BuildConfig.args

Definition at line 63 of file talerbuildconfig.py.

Referenced by talerbuildconfig.BuildConfig.run().

◆ prefix_enabled

talerbuildconfig.BuildConfig.prefix_enabled

◆ configmk_enabled

talerbuildconfig.BuildConfig.configmk_enabled

The documentation for this class was generated from the following file: