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

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

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

Load known dependencies from file .remake.

Definition at line 1358 of file remake.cpp.

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

Save all the dependencies in file .remake.

Definition at line 1374 of file remake.cpp.

Referenced by server_mode().

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