PIPS
pipsmake-local.h File Reference
#include "makefile.h"
+ Include dependency graph for pipsmake-local.h:

Go to the source code of this file.

Typedefs

typedef bool(* pipsmake_callback_handler_type) (void)
 

Functions

void pipsmake_error (const char *)
 symbols exported by lex / yacc More...
 
int pipsmake_lex (void)
 
int pipsmake_parse (void)
 
void yyerror (const char *)
 work around cproto 4.7t issue More...
 
void fprint_virtual_resources (FILE *, const char *, list)
 
void fprint_makefile (FILE *, makefile)
 
makefile parse_makefile (void)
 
rule find_rule_by_phase (const char *)
 this function returns the rule that defines builder pname More...
 
void add_rule (rule)
 
makefile open_makefile (const char *)
 
void save_makefile (const char *)
 
bool close_makefile (const char *)
 
int yywrap (void)
 symbols form lexer.l More...
 
int init_lex (void)
 
void yyerror_lex_part (const char *)
 

Variables

FILE * pipsmake_in
 

Typedef Documentation

◆ pipsmake_callback_handler_type

typedef bool(* pipsmake_callback_handler_type) (void)

Definition at line 25 of file pipsmake-local.h.

Function Documentation

◆ add_rule()

void add_rule ( rule  r)

Definition at line 1704 of file readmakefile.c.

1705 {
1706  string pn = rule_phase(r);
1707  bool active_phase = false;
1708 
1709  // Check resources produced by this rule
1711  string vrn = virtual_resource_name(vr);
1712  string phase;
1713 
1714  // We activated this rule to produce this resource only if
1715  // this resource is not already produced
1716  if ((phase = hash_get(activated, vrn)) == HASH_UNDEFINED_VALUE) {
1717  pips_debug(1, "Default function for %s is %s\n", vrn, pn);
1718 
1719  active_phase = true;
1720  hash_put(activated, vrn, pn);
1721 
1724  }
1725  else pips_debug(1, "Function %s not activated\n", pn);
1726  }
1727 
1728  // Check resources required for this rule if it is an active one
1729  if (active_phase) {
1731  string vrn = virtual_resource_name(vr);
1732  owner vro = virtual_resource_owner(vr);
1733  string phase;
1734 
1735  // We must use a resource already defined
1736  if ( owner_callers_p(vro) || owner_callees_p(vro) ) {}
1737  else {
1738  phase = hash_get(activated, vrn);
1739  if (phase == HASH_UNDEFINED_VALUE)
1740  {
1741  if (get_bool_property("PIPSMAKE_WARNINGS"))
1743  "%s: phase %s requires an undefined resource %s\n",
1744  PIPSMAKE_RC, pn, vrn);
1745  }
1746  // If we use a resource, another function should have produced it
1747  else if (strcmp(phase, pn) == 0) {
1749  "%s: phase %s cannot be active for the %s resource\n",
1750  PIPSMAKE_RC, phase, vrn);
1751  }
1752  else
1753  pips_debug(1, "Required resource %s is checked OK for Function %s\n",
1754  vrn, pn);
1755  }
1756  }
1757  }
1758 
1759  // FI: no check of rule name unicity; e.g. double declaration of sesamify
1761  if(rule_undefined_p(or))
1763  CONS(RULE, r, NIL));
1764  else
1765  pips_internal_error("Double declaration of phase \"%s\"\n"
1766  "Check pipsmake-rc.tex or pipsmake.rc\n",
1767  rule_phase(r));
1768 }
bool get_bool_property(const string)
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties....
#define STRING(x)
Definition: genC.h:87
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
Definition: list.c:344
#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 * hash_get(const hash_table htp, const void *key)
this function retrieves in the hash table pointed to by htp the couple whose key is equal to key.
Definition: hash.c:449
void hash_put(hash_table htp, const void *key, const void *val)
This functions stores a couple (key,val) in the hash table pointed to by htp.
Definition: hash.c:364
#define rule_phase(x)
Definition: makefile.h:244
#define RULE(x)
RULE.
Definition: makefile.h:209
#define virtual_resource_owner(x)
Definition: makefile.h:292
#define rule_required(x)
Definition: makefile.h:246
#define owner_callers_p(x)
Definition: makefile.h:158
#define virtual_resource_name(x)
Definition: makefile.h:290
#define makefile_active_phases(x)
Definition: makefile.h:84
#define rule_undefined_p(x)
Definition: makefile.h:216
#define rule_produced(x)
Definition: makefile.h:248
#define owner_callees_p(x)
Definition: makefile.h:155
#define VIRTUAL_RESOURCE(x)
VIRTUAL_RESOURCE.
Definition: makefile.h:260
#define makefile_rules(x)
Definition: makefile.h:82
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
#define pips_user_warning
Definition: misc-local.h:146
#define pips_internal_error
Definition: misc-local.h:149
#define HASH_UNDEFINED_VALUE
value returned by hash_get() when the key is not found; could also be called HASH_KEY_NOT_FOUND,...
Definition: newgen_hash.h:56
static hash_table activated
Definition: readmakefile.c:101
rule find_rule_by_phase(const char *pname)
this function returns the rule that defines builder pname
static makefile pipsmakefile
First part of user prologue.
Definition: readmakefile.c:100
char * strdup()

References activated, CONS, find_rule_by_phase(), FOREACH, gen_nconc(), get_bool_property(), hash_get(), hash_put(), HASH_UNDEFINED_VALUE, makefile_active_phases, makefile_rules, NIL, owner_callees_p, owner_callers_p, pips_debug, pips_internal_error, pips_user_warning, pipsmakefile, RULE, rule_phase, rule_produced, rule_required, rule_undefined_p, strdup(), STRING, VIRTUAL_RESOURCE, virtual_resource_name, and virtual_resource_owner.

+ Here is the call graph for this function:

◆ close_makefile()

bool close_makefile ( const char *  name)
Parameters
nameame

Definition at line 1812 of file readmakefile.c.

1813 {
1814  save_makefile(name);
1816  return true;
1817 }
void free_makefile(makefile p)
Definition: makefile.c:19
#define makefile_undefined
Definition: makefile.h:58
void save_makefile(const char *name)

References free_makefile(), makefile_undefined, pipsmakefile, and save_makefile().

Referenced by check_delete_workspace(), and make_close_workspace().

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

◆ find_rule_by_phase()

rule find_rule_by_phase ( const char *  pname)

this function returns the rule that defines builder pname

walking thru rules

Parameters
pnamename

Definition at line 1686 of file readmakefile.c.

1687 {
1688  rule fr = rule_undefined;
1689  makefile m = parse_makefile();
1690 
1691  pips_debug(9, "searching rule for phase %s\n", pname);
1692 
1693  /* walking thru rules */
1694  FOREACH(RULE, r, makefile_rules(m)) {
1695  if (same_string_p(rule_phase(r), pname)) {
1696  fr = r;
1697  break;
1698  }
1699  }
1700 
1701  return fr;
1702 }
#define rule_undefined
Definition: makefile.h:215
#define same_string_p(s1, s2)
makefile parse_makefile(void)

References FOREACH, makefile_rules, parse_makefile(), pips_debug, RULE, rule_phase, rule_undefined, and same_string_p.

Referenced by activate_phase(), apply_without_reseting_up_to_date_resources(), concurrent_apply(), get_more_derived_resources(), safe_apply(), and safe_concurrent_apply().

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

◆ fprint_makefile()

void fprint_makefile ( FILE *  fd,
makefile  m 
)
Parameters
fdd

Definition at line 1649 of file readmakefile.c.

1650 {
1651  FOREACH(RULE, r, makefile_rules(m))
1652  {
1653  fprintf(fd, "%s\n", rule_phase(r));
1655  fprint_virtual_resources(fd, "\t<", rule_required(r));
1656  fprint_virtual_resources(fd, "\t>", rule_produced(r));
1658  fprint_virtual_resources(fd, "\t#", rule_modified(r));
1659  }
1660 }
#define rule_modified(x)
Definition: makefile.h:252
#define rule_pre_transformation(x)
Definition: makefile.h:254
#define rule_preserved(x)
Definition: makefile.h:250
void fprint_virtual_resources(FILE *fd, const char *dir, list lrv)
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...

References FOREACH, fprint_virtual_resources(), fprintf(), makefile_rules, RULE, rule_modified, rule_phase, rule_pre_transformation, rule_preserved, rule_produced, and rule_required.

+ Here is the call graph for this function:

◆ fprint_virtual_resources()

void fprint_virtual_resources ( FILE *  fd,
const char *  dir,
list  lrv 
)
Parameters
fdd
dirir
lrvrv

Definition at line 1611 of file readmakefile.c.

1612 {
1613  FOREACH(VIRTUAL_RESOURCE, vr, lrv)
1614  {
1615  owner o = virtual_resource_owner(vr);
1616  string n = virtual_resource_name(vr);
1617 
1618  switch (owner_tag(o)) {
1619  case is_owner_program:
1620  fprintf(fd, " %s program.%s\n", dir, n);
1621  break;
1622  case is_owner_module:
1623  fprintf(fd, " %s module.%s\n", dir, n);
1624  break;
1625  case is_owner_main:
1626  fprintf(fd, " %s main.%s\n", dir, n);
1627  break;
1628  case is_owner_callees:
1629  fprintf(fd, " %s callees.%s\n", dir, n);
1630  break;
1631  case is_owner_callers:
1632  fprintf(fd, " %s callers.%s\n", dir, n);
1633  break;
1634  case is_owner_all:
1635  fprintf(fd, " %s all.%s\n", dir, n);
1636  break;
1637  case is_owner_select:
1638  fprintf(fd, " %s select.%s\n", dir, n);
1639  break;
1641  fprintf(fd, " %s compilation_unit.%s\n", dir, n);
1642  break;
1643  default:
1644  pips_internal_error("bad owner tag (%d)\n", owner_tag(o));
1645  }
1646  }
1647 }
#define owner_tag(x)
Definition: makefile.h:145
@ is_owner_main
Definition: makefile.h:111
@ is_owner_callees
Definition: makefile.h:112
@ is_owner_select
Definition: makefile.h:115
@ is_owner_compilation_unit
Definition: makefile.h:116
@ is_owner_module
Definition: makefile.h:110
@ is_owner_callers
Definition: makefile.h:113
@ is_owner_all
Definition: makefile.h:114
@ is_owner_program
Definition: makefile.h:109

References FOREACH, fprintf(), is_owner_all, is_owner_callees, is_owner_callers, is_owner_compilation_unit, is_owner_main, is_owner_module, is_owner_program, is_owner_select, owner_tag, pips_internal_error, VIRTUAL_RESOURCE, virtual_resource_name, and virtual_resource_owner.

+ Here is the call graph for this function:

◆ init_lex()

int init_lex ( void  )

Referenced by parse_makefile().

+ Here is the caller graph for this function:

◆ open_makefile()

makefile open_makefile ( const char *  name)
Parameters
nameame

Definition at line 1770 of file readmakefile.c.

1771 {
1772  FILE * fd;
1773  char * mkf_name;
1774 
1775  mkf_name = build_pgm_makefile(name);
1776  fd = fopen(mkf_name, "r");
1777 
1779  {
1782  pips_debug(1, "current makefile erased\n");
1783  }
1784 
1785  if (fd)
1786  {
1788  safe_fclose(fd, mkf_name);
1789  }
1790  else
1791  {
1792  pips_user_warning("pipsmake file not found in database...\n");
1794  }
1795 
1796  free(mkf_name);
1797  return pipsmakefile;
1798 }
makefile read_makefile(FILE *f)
Definition: makefile.c:49
int safe_fclose(FILE *stream, const char *filename)
Definition: file.c:77
#define makefile_undefined_p(x)
Definition: makefile.h:59
string build_pgm_makefile(const char *__attribute__((unused)) n)
Definition: openclose.c:63
void free(void *)

References build_pgm_makefile(), free(), free_makefile(), makefile_undefined, makefile_undefined_p, parse_makefile(), pips_debug, pips_user_warning, pipsmakefile, read_makefile(), and safe_fclose().

Referenced by make_open_workspace().

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

◆ parse_makefile()

makefile parse_makefile ( void  )

Definition at line 1663 of file readmakefile.c.

1664 {
1665  // do it only once
1667  {
1668  debug_on("PIPSMAKE_DEBUG_LEVEL");
1669 
1670  pipsmake_in = fopen_config(PIPSMAKE_RC, NULL, "PIPS_PIPSMAKERC");
1671 
1672  init_lex();
1673  yyparse();
1674  safe_fclose(pipsmake_in, "PIPS_PIPSMAKERC");
1675 
1676  ifdebug(8) fprint_makefile(stderr, pipsmakefile);
1677 
1678  debug_off();
1679  }
1680 
1682 }
FILE * fopen_config(const char *canonical_name, const char *cproperty, const char *cenv)
Definition: file.c:952
#define debug_on(env)
Definition: misc-local.h:157
#define debug_off()
Definition: misc-local.h:160
FILE * pipsmake_in
Definition: pipsmake.h:142
int init_lex(void)
#define yyparse
------—.
Definition: readmakefile.c:68
void fprint_makefile(FILE *fd, makefile m)
return(s1)
#define ifdebug(n)
Definition: sg.c:47

References debug_off, debug_on, fopen_config(), fprint_makefile(), ifdebug, init_lex(), makefile_undefined, pipsmake_in, pipsmakefile, safe_fclose(), and yyparse.

Referenced by activate_phase(), active_phase_p(), build_options_menu_and_panel(), find_rule_by_resource(), fprint_activated(), get_more_derived_resources(), open_module_if_unique(), retrieve_active_phases(), and save_active_phases().

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

◆ pipsmake_error()

void pipsmake_error ( const char *  )

symbols exported by lex / yacc

◆ pipsmake_lex()

int pipsmake_lex ( void  )

◆ pipsmake_parse()

int pipsmake_parse ( void  )

◆ save_makefile()

void save_makefile ( const char *  name)
Parameters
nameame

Definition at line 1801 of file readmakefile.c.

1802 {
1803  char * mkf_name = build_pgm_makefile(name);
1804  FILE * fd = safe_fopen(mkf_name, "w");
1806  safe_fclose(fd, mkf_name);
1807  pips_debug(1, "makefile written on %s\n", mkf_name);
1808  free(mkf_name);
1809 }
void write_makefile(FILE *f, makefile p)
Definition: makefile.c:46
FILE * safe_fopen(const char *filename, const char *what)
Definition: file.c:67

References build_pgm_makefile(), free(), pips_debug, pipsmakefile, safe_fclose(), safe_fopen(), and write_makefile().

Referenced by checkpoint_workspace().

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

◆ yyerror()

void yyerror ( const char *  s)

work around cproto 4.7t issue

symbols from readmakefile.y

work around cproto 4.7t issue

Definition at line 1927 of file genread_yacc.c.

1928 {
1929  int c, n=40;
1930  newgen_lexer_position(stderr);
1931  fprintf(stderr, "%s before ", s);
1932 
1933  while (n-->0 && ((c=genread_input()) != EOF))
1934  putc(c, stderr);
1935 
1936  fprintf(stderr, "\n\n");
1937 
1938  fatal("Incorrect object written by GEN_WRITE\n", (char *) NULL);
1939 }
int genread_input(void)
void newgen_lexer_position(FILE *)
First part of user prologue.
Definition: genread_lex.c:831
void fatal(char *,...)

◆ yyerror_lex_part()

void yyerror_lex_part ( const char *  )

◆ yywrap()

int yywrap ( void  )

symbols form lexer.l

Variable Documentation

◆ pipsmake_in

FILE * pipsmake_in
extern

Definition at line 142 of file pipsmake.h.

Referenced by parse_makefile(), and yyerror().