PIPS
openclose.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <string.h>
#include <sys/param.h>
#include "genC.h"
#include "database.h"
#include "linear.h"
#include "ri.h"
#include "properties.h"
#include "ri-util.h"
#include "pipsdbm.h"
#include "pipsmake.h"
#include "misc.h"
+ Include dependency graph for openclose.c:

Go to the source code of this file.

Macros

#define PIPSMAKE_FILE   "/pipsmake"
 Some modifications are made to save the current makefile (s.a. More...
 

Functions

string build_pgm_makefile (const char *__attribute__((unused)) n)
 
string make_open_workspace (const char *name)
 
bool make_close_workspace (bool is_quit)
 FI->GO: could be in top-level, no? More...
 
void checkpoint_workspace (void)
 checkpoint the current workspace, i.e. More...
 

Macro Definition Documentation

◆ PIPSMAKE_FILE

#define PIPSMAKE_FILE   "/pipsmake"

Some modifications are made to save the current makefile (s.a.

files pipsmake/readmakefile.y openclose.h ) They only occure between following tags: Some modifications are made to save the current makefile (s.a. files pipsmake/readmakefile.y pipsmake.h ) They only occure between following tags:

Bruno Baron returns the program makefile file name

Definition at line 62 of file openclose.c.

Function Documentation

◆ build_pgm_makefile()

string build_pgm_makefile ( const char *__attribute__((unused))  n)

Definition at line 63 of file openclose.c.

64 {
65  pips_assert("true", n==n);
66  string dir_name = db_get_meta_data_directory(),
67  res = strdup(concatenate(dir_name, PIPSMAKE_FILE, NULL));
68  free(dir_name);
69  return res;
70 }
void free(void *)
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
#define PIPSMAKE_FILE
Some modifications are made to save the current makefile (s.a.
Definition: openclose.c:62
string db_get_meta_data_directory(void)
Definition: workspace.c:139
char * strdup()

References concatenate(), db_get_meta_data_directory(), free(), pips_assert, PIPSMAKE_FILE, and strdup().

Referenced by open_makefile(), and save_makefile().

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

◆ checkpoint_workspace()

void checkpoint_workspace ( void  )

checkpoint the current workspace, i.e.

save everything so that it is possible to reopen it in case of failure.

FC 25/06/2003 this seems to break pipsmake internal data... pips_debug(3, "\tdeleting obsolete resources...\n"); delete_obsolete_resources();

Definition at line 129 of file openclose.c.

130 {
132  {
133  user_log("Checkpoint of workspace.\n");
134  /* FC 25/06/2003
135  * this seems to break pipsmake internal data...
136  pips_debug(3, "\tdeleting obsolete resources...\n");
137  delete_obsolete_resources();
138  */
139  pips_debug(3, "\tsaving resources...\n");
141  pips_debug(3, "\tproperties and makefile...\n");
142  save_properties();
144  }
145 }
void user_log(const char *format,...)
Definition: message.c:234
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
void db_checkpoint_workspace(void)
Definition: workspace.c:350
string db_get_current_workspace_name(void)
the function is used to check that there is some current workspace...
Definition: workspace.c:82
void save_makefile(const char *)
void save_properties(void)

References db_checkpoint_workspace(), db_get_current_workspace_name(), pips_debug, save_makefile(), save_properties(), and user_log().

Referenced by apply_a_rule(), and pips_signal_handler().

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

◆ make_close_workspace()

bool make_close_workspace ( bool  is_quit)

FI->GO: could be in top-level, no?

lazy...

dup because freed in db_close_workspace

Parameters
is_quits_quit

Definition at line 102 of file openclose.c.

103 {
104  bool res = true;
105  string name;
106 
107  if (db_get_current_module_name()) /* lazy... */
109 
110  /* dup because freed in db_close_workspace */
112 
113  res &= close_makefile(name);
114  save_properties();
115  res &= db_close_workspace(is_quit);
116 
117  if(res)
118  user_log("Workspace %s closed.\n\n", name);
119  else
120  user_log("Failed to close workspace %s.\n\n", name);
121 
122  free(name);
123  return res;
124 }
void db_reset_current_module_name(void)
Definition: database.c:1064
string db_get_current_module_name(void)
Also used to check whether set...
Definition: database.c:1059
bool db_close_workspace(bool)
Definition: workspace.c:367
bool close_makefile(const char *)

References close_makefile(), db_close_workspace(), db_get_current_module_name(), db_get_current_workspace_name(), db_reset_current_module_name(), free(), save_properties(), strdup(), and user_log().

Referenced by close_workspace().

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

◆ make_open_workspace()

string make_open_workspace ( const char *  name)

should be an error?

Parameters
nameame

Definition at line 72 of file openclose.c.

73 {
74  if (db_open_workspace(name))
75  {
76  if (open_properties())
77  {
78  if (open_makefile(name) != makefile_undefined)
79  {
80  pips_debug(7, "makefile opened\n");
81  }
82  else
83  {
84  /* should be an error? */
85  pips_user_warning("No special makefile for this workspace "
86  "%s/%s.database\n", get_cwd(), name);
87  }
88  }
89  else
90  {
91  pips_user_warning("Cannot read properties...\n");
92  db_close_workspace(true);
93  }
94  } else
95  pips_user_warning("No workspace %s to open\n", name);
96 
98 }
char * get_cwd(void)
returns the current working directory name.
Definition: file.c:486
#define makefile_undefined
Definition: makefile.h:58
#define pips_user_warning
Definition: misc-local.h:146
bool db_open_workspace(const char *)
Definition: workspace.c:380
makefile open_makefile(const char *)
bool open_properties(void)

References db_close_workspace(), db_get_current_workspace_name(), db_open_workspace(), get_cwd(), makefile_undefined, open_makefile(), open_properties(), pips_debug, and pips_user_warning.

Referenced by open_workspace().

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