PIPS
fpips.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include "genC.h"
#include "misc.h"
+ Include dependency graph for fpips.c:

Go to the source code of this file.

Macros

#define PIPS(c, v)   pips_main(c, v)
 
#define TPIPS(c, v)   tpips_main(c, v)
 
#define WPIPS(c, v)   wpips_main(c, v)
 
#define GPIPS(c, v)   gpips_main(c, v)
 
#define USAGE
 

Functions

int pips_main (int, char **)
 
int tpips_main (int, char **)
 
int wpips_main (int, char **)
 
int gpips_main (int, char **)
 
static int fpips_usage (int ret)
 print out usage informations. More...
 
static int fpips_version (int ret)
 print out fpips version. More...
 
int fpips_error (char *what, int __attribute__((unused)) argc, char __attribute__((unused)) **argv)
 non static to avoid a gcc warning if not called. More...
 
static int name_end_p (char *name, char *ref)
 returns whether name ends with ref More...
 
int fpips_main (int argc, char **argv)
 

Macro Definition Documentation

◆ GPIPS

#define GPIPS (   c,
 
)    gpips_main(c, v)

Definition at line 75 of file fpips.c.

◆ PIPS

#define PIPS (   c,
 
)    pips_main(c, v)

Definition at line 54 of file fpips.c.

◆ TPIPS

#define TPIPS (   c,
 
)    tpips_main(c, v)

Definition at line 61 of file fpips.c.

◆ USAGE

#define USAGE
Value:
"Usage: fpips [-hvGPTW] (other options and arguments...)\n" \
"\t-h: this help...\n" \
"\t-v: version\n" \
"\t-G: gpips\n" \
"\t-P: pips\n" \
"\t-T: tpips\n" \
"\t-W: wpips\n" \
"\tdefault: run as tpips\n\n"

Definition at line 78 of file fpips.c.

◆ WPIPS

#define WPIPS (   c,
 
)    wpips_main(c, v)

Definition at line 68 of file fpips.c.

Function Documentation

◆ fpips_error()

int fpips_error ( char *  what,
int __attribute__((unused))  argc,
char __attribute__((unused)) **  argv 
)

non static to avoid a gcc warning if not called.

Definition at line 108 of file fpips.c.

111 {
112  fprintf(stderr, "[fpips] sorry, %s not available (" STRINGIFY(SOFT_ARCH) ")\n", what);
113  return fpips_usage(1);
114 }
static int fpips_usage(int ret)
print out usage informations.
Definition: fpips.c:92
#define STRINGIFY(symbol)
If not using this 2-stage macro evaluation, the generated string is not the value of the macro but th...
Definition: misc-local.h:50
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...

References fpips_usage(), fprintf(), and STRINGIFY.

+ Here is the call graph for this function:

◆ fpips_main()

int fpips_main ( int  argc,
char **  argv 
)

should not happen

According to the shell or the debugger, the path may be complete or not... RK.

parsing of options may be continuate by called version.

else try tpips...

Definition at line 130 of file fpips.c.

131 {
132  int opt;
133 
134  debug_on("FPIPS_DEBUG_LEVEL");
135  pips_debug(1, "considering %s for execution\n", argv[0]);
136  debug_off();
137 
138  if (argc<1) return TPIPS(argc, argv); /* should not happen */
139 
140  /* According to the shell or the debugger, the path may be
141  complete or not... RK. */
142  if (name_end_p(argv[0], "gpips"))
143  return GPIPS(argc, argv);
144  if (name_end_p(argv[0], "tpips"))
145  return TPIPS(argc, argv);
146  if (name_end_p(argv[0], "wpips"))
147  return WPIPS(argc, argv);
148  if (name_end_p(argv[0], "/pips") || same_string_p(argv[0], "pips"))
149  return PIPS(argc, argv);
150 
151  /* parsing of options may be continuate by called version.
152  */
153  while ((opt = getopt(argc, argv, "hvGPTW"))!=-1)
154  {
155  switch (opt)
156  {
157  case 'h': fpips_usage(0); break;
158  case 'v': fpips_version(0); break;
159  case 'G': return GPIPS(argc, argv);
160  case 'P': return PIPS(argc, argv);
161  case 'T': return TPIPS(argc, argv);
162  case 'W': return WPIPS(argc, argv);
163  default: return fpips_version(1);
164  }
165  }
166 
167  /* else try tpips...
168  */
169  fprintf(stderr, "[fpips] default: running as tpips\n\n");
170  return TPIPS(argc, argv);
171 }
static int fpips_version(int ret)
print out fpips version.
Definition: fpips.c:100
#define PIPS(c, v)
Definition: fpips.c:54
static int name_end_p(char *name, char *ref)
returns whether name ends with ref
Definition: fpips.c:118
#define TPIPS(c, v)
Definition: fpips.c:61
#define GPIPS(c, v)
Definition: fpips.c:75
#define WPIPS(c, v)
Definition: fpips.c:68
#define debug_on(env)
Definition: misc-local.h:157
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
#define debug_off()
Definition: misc-local.h:160
#define same_string_p(s1, s2)

References debug_off, debug_on, fpips_usage(), fpips_version(), fprintf(), GPIPS, name_end_p(), PIPS, pips_debug, same_string_p, TPIPS, and WPIPS.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fpips_usage()

static int fpips_usage ( int  ret)
static

print out usage informations.

Definition at line 92 of file fpips.c.

93 {
94  fprintf(stderr, USAGE);
95  return ret;
96 }
#define ret(why, what)
true if not a remapping for old.
Definition: dynamic.c:986
#define USAGE
Definition: fpips.c:78

References fprintf(), ret, and USAGE.

Referenced by fpips_error(), and fpips_main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fpips_version()

static int fpips_version ( int  ret)
static

print out fpips version.

Definition at line 100 of file fpips.c.

101 {
102  fprintf(stderr, "[fpips] (ARCH=" STRINGIFY(SOFT_ARCH) ", DATE=" STRINGIFY(UTC_DATE) ")\n\n");
103  return ret;
104 }
#define UTC_DATE
Definition: pips_version.h:5

References fprintf(), ret, STRINGIFY, and UTC_DATE.

Referenced by fpips_main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gpips_main()

int gpips_main ( int  ,
char **   
)

◆ name_end_p()

static int name_end_p ( char *  name,
char *  ref 
)
static

returns whether name ends with ref

Definition at line 118 of file fpips.c.

119 {
120  int nlen = strlen(name), rlen = strlen(ref);
121  if (nlen<rlen) return false;
122  while (rlen>0)
123  if (ref[--rlen]!=name[--nlen])
124  return false;
125  return true;
126 }
static reference ref
Current stmt (an integer)
Definition: adg_read_paf.c:163

References ref.

Referenced by fpips_main().

+ Here is the caller graph for this function:

◆ pips_main()

int pips_main ( int  argc,
char **  argv 
)

Definition at line 160 of file pips.c.

161 {
162  volatile bool success = true;
163  pips_checks();
165 
169 
170  pips_parse_arguments(argc, argv);
171 
172  debug_on("PIPS_DEBUG_LEVEL");
174 
176  {
177  // no need to pop_pips_context() at top-level
178  // FI: are you sure make_close_program() cannot call user_error() ?
179  close_workspace(true);
180  success = false;
181  }
182  TRY
183  {
184  // Initialize workspace
188  }
189  else {
190  user_log("Cannot create workspace %s!\n", wspace);
191  exit(1);
192  }
193  } else {
194  // Workspace must be opened
195  if (!open_workspace(wspace)) {
196  user_log("Cannot open workspace %s!\n", wspace);
197  exit(1);
198  }
199  }
200 
201  // Open module
202  if (module != NULL)
204  else
206 
207  // Activate rules
208  if (success && selected_rules)
209  {
211  }
212 
213  // Perform applies
214  if (success && performed_rule && module)
215  {
217  if (success) {
218  user_log("%s performed for %s.\n", performed_rule, module);
219  }
220  else {
221  user_log("Cannot perform %s for %s.\n", performed_rule, module);
222  }
223  }
224 
225  // Build resources
227  {
228  FOREACH(STRING, build_resource_name, build_resource_names)
229  {
230  success = safe_make(build_resource_name, module);
231  if (!success)
232  {
233  user_log("Cannot build %s for %s.\n", build_resource_name, module);
234  break;
235  }
236  }
237  }
238  // whether success or not...
239  close_workspace(true);
240 
242  }
243 
244  debug_off();
245 
246  return !success;
247 }
void user_log(const char *format,...)
Definition: message.c:234
void set_pips_meta_informations(const char *revs, const char *date, const char *comp)
Definition: message.c:102
#define CATCH(what)
@ any_exception_error
catch all
#define UNCATCH(what)
#define TRY
void set_exception_callbacks(exception_callback_t, exception_callback_t)
size_t gen_array_nitems(const gen_array_t a)
Definition: array.c:131
bool open_module(const char *name)
tpips used to convert lower cases into upper cases for all module names, but this is no longer possib...
Definition: dbm.c:95
bool open_module_if_unique(void)
Open the module of a workspace if there is only one.
Definition: dbm.c:144
bool create_workspace(gen_array_t files)
FI: should be called "initialize_workspace()"; a previous call to db_create_workspace() is useful to ...
Definition: dbm.c:180
bool close_workspace(bool is_quit)
Definition: dbm.c:346
bool open_workspace(const char *name)
should be: success (cf wpips.h)
Definition: dbm.c:309
void push_pips_context(char const *file, char const *function, int line)
exception.c
Definition: exception.c:43
void pop_pips_context(char const *file, char const *function, int line)
Definition: exception.c:50
#define STRING(x)
Definition: genC.h:87
bool success
Definition: gpips-local.h:59
#define FOREACH(_fe_CASTER, _fe_item, _fe_list)
Apply/map an instruction block on all the elements of a list.
Definition: newgen_list.h:179
void pips_checks(void)
add checkings here (FI: why in help.c?) SG : PIPS_ROOT should not be required :)
Definition: help.c:100
#define exit(code)
Definition: misc-local.h:54
void initialize_newgen()
cproto-generated files
Definition: newgen.c:48
static list selected_rules
Definition: pips.c:78
char * soft_revisions
could be shared somewhere?
Definition: revisions.c:33
static list build_resource_names
Definition: pips.c:76
char * cc_version
Definition: revisions.c:41
static void select_rule(char *rule_name)
Definition: pips.c:149
char * soft_date
Definition: revisions.c:39
static char * performed_rule
Definition: pips.c:75
static char * wspace
Definition: pips.c:73
static void pips_parse_arguments(int argc, char *argv[])
Definition: pips.c:80
static char * module
Definition: pips.c:74
static gen_array_t source_files
Definition: pips.c:77
bool db_create_workspace(const char *)
Definition: workspace.c:282
bool safe_make(const char *res_n, const char *module_n)
Definition: pipsmake.c:1717
bool safe_apply(const char *phase_n, const char *module_n)
Definition: pipsmake.c:1723
void initialize_signal_catcher(void)
Definition: signal.c:126
const char * entity_local_name(entity e)
entity_local_name modified so that it does not core when used in vect_fprint, since someone thought t...
Definition: entity.c:453
void initialize_sc(char *(*var_to_string)(Variable))
Definition: sc_debug.c:253
void * Variable
arithmetique is a requirement for vecteur, but I do not want to inforce it in all pips files....
Definition: vecteur-local.h:60

References any_exception_error, build_resource_names, CATCH, cc_version, close_workspace(), create_workspace(), db_create_workspace(), debug_off, debug_on, entity_local_name(), exit, FOREACH, gen_array_nitems(), initialize_newgen(), initialize_sc(), initialize_signal_catcher(), module, open_module(), open_module_if_unique(), open_workspace(), performed_rule, pips_checks(), pips_parse_arguments(), pop_pips_context(), push_pips_context(), safe_apply(), safe_make(), select_rule(), selected_rules, set_exception_callbacks(), set_pips_meta_informations(), soft_date, soft_revisions, source_files, STRING, TRY, UNCATCH, user_log(), and wspace.

+ Here is the call graph for this function:

◆ tpips_main()

int tpips_main ( int  ,
char **   
)

◆ wpips_main()

int wpips_main ( int  ,
char **   
)