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 1415 of file remake.cpp.

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

1416 {
1417  if (false)
1418  {
1419  error:
1420  std::cerr << "Failed to load database" << std::endl;
1421  exit(EXIT_FAILURE);
1422  }
1423 
1424  while (!in.eof())
1425  {
1426  string_list targets;
1427  if (!read_words(in, targets)) goto error;
1428  if (in.eof()) return;
1429  if (targets.empty()) goto error;
1430  DEBUG << "reading dependencies of target " << targets.front() << std::endl;
1431  if (in.get() != ':') goto error;
1433  dep->targets = targets;
1434  string_list deps;
1435  if (!read_words(in, deps)) goto error;
1436  dep->deps.insert(deps.begin(), deps.end());
1437  for (string_list::const_iterator i = targets.begin(),
1438  i_end = targets.end(); i != i_end; ++i)
1439  {
1440  dependencies[*i] = dep;
1441  }
1442  skip_empty(in);
1443  }
1444 }
static void load_dependencies ( )
static

Load known dependencies from file .remake.

Definition at line 1449 of file remake.cpp.

1450 {
1451  DEBUG_open << "Loading database... ";
1452  std::ifstream in(".remake");
1453  if (!in.good())
1454  {
1455  DEBUG_close << "not found\n";
1456  return;
1457  }
1458  load_dependencies(in);
1459 }
static void save_dependencies ( )
static

Save all the dependencies in file .remake.

Definition at line 1465 of file remake.cpp.

Referenced by server_mode().

1466 {
1467  DEBUG_open << "Saving database... ";
1468  std::ofstream db(".remake");
1469  while (!dependencies.empty())
1470  {
1471  ref_ptr<dependency_t> dep = dependencies.begin()->second;
1472  for (string_list::const_iterator i = dep->targets.begin(),
1473  i_end = dep->targets.end(); i != i_end; ++i)
1474  {
1475  db << escape_string(*i) << ' ';
1476  dependencies.erase(*i);
1477  }
1478  db << ':';
1479  for (string_set::const_iterator i = dep->deps.begin(),
1480  i_end = dep->deps.end(); i != i_end; ++i)
1481  {
1482  db << ' ' << escape_string(*i);
1483  }
1484  db << std::endl;
1485  }
1486 }