Remake
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions
Dependency database

Functions

static void load_dependencies (std::istream &in)
 
static void load_dependencies ()
 
static void save_dependencies ()
 

Detailed Description

Function Documentation

static void load_dependencies ( std::istream &  in)
static

Load dependencies from in.

Definition at line 1325 of file remake.cpp.

Referenced by load_dependencies(), main(), and server_mode().

1326 {
1327  if (false)
1328  {
1329  error:
1330  std::cerr << "Failed to load database" << std::endl;
1331  exit(EXIT_FAILURE);
1332  }
1333 
1334  while (!in.eof())
1335  {
1336  string_list targets;
1337  if (!read_words(in, targets)) goto error;
1338  if (in.eof()) return;
1339  if (targets.empty()) goto error;
1340  DEBUG << "reading dependencies of target " << targets.front() << std::endl;
1341  if (in.get() != ':') goto error;
1343  dep->targets = targets;
1344  string_list deps;
1345  if (!read_words(in, deps)) goto error;
1346  dep->deps.insert(deps.begin(), deps.end());
1347  for (string_list::const_iterator i = targets.begin(),
1348  i_end = targets.end(); i != i_end; ++i)
1349  {
1350  dependencies[*i] = dep;
1351  }
1352  skip_empty(in);
1353  }
1354 }
static void load_dependencies ( )
static

Load known dependencies from file .remake.

Definition at line 1359 of file remake.cpp.

1360 {
1361  DEBUG_open << "Loading database... ";
1362  std::ifstream in(".remake");
1363  if (!in.good())
1364  {
1365  DEBUG_close << "not found\n";
1366  return;
1367  }
1368  load_dependencies(in);
1369 }
static void save_dependencies ( )
static

Save all the dependencies in file .remake.

Definition at line 1375 of file remake.cpp.

Referenced by server_mode().

1376 {
1377  DEBUG_open << "Saving database... ";
1378  std::ofstream db(".remake");
1379  while (!dependencies.empty())
1380  {
1381  ref_ptr<dependency_t> dep = dependencies.begin()->second;
1382  for (string_list::const_iterator i = dep->targets.begin(),
1383  i_end = dep->targets.end(); i != i_end; ++i)
1384  {
1385  db << escape_string(*i) << ' ';
1386  dependencies.erase(*i);
1387  }
1388  db << ':';
1389  for (string_set::const_iterator i = dep->deps.begin(),
1390  i_end = dep->deps.end(); i != i_end; ++i)
1391  {
1392  db << ' ' << escape_string(*i);
1393  }
1394  db << std::endl;
1395  }
1396 }