Remake
Functions
Dependency database

Functions

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

Detailed Description

Function Documentation

§ load_dependencies() [1/2]

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

Load dependencies from in.

Definition at line 1422 of file remake.cpp.

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

1423 {
1424  if (false)
1425  {
1426  error:
1427  std::cerr << "Failed to load database" << std::endl;
1428  exit(EXIT_FAILURE);
1429  }
1430 
1431  while (!in.eof())
1432  {
1433  string_list targets;
1434  if (!read_words(in, targets)) goto error;
1435  if (in.eof()) return;
1436  if (targets.empty()) goto error;
1437  DEBUG << "reading dependencies of target " << targets.front() << std::endl;
1438  if (in.get() != ':') goto error;
1440  dep->targets = targets;
1441  string_list deps;
1442  if (!read_words(in, deps)) goto error;
1443  dep->deps.insert(deps.begin(), deps.end());
1444  for (string_list::const_iterator i = targets.begin(),
1445  i_end = targets.end(); i != i_end; ++i)
1446  {
1447  dependencies[*i] = dep;
1448  }
1449  skip_empty(in);
1450  }
1451 }
std::list< std::string > string_list
Definition: remake.cpp:456
string_list targets
Definition: remake.cpp:498
static bool read_words(input_generator &in, string_list &res)
Definition: remake.cpp:1271
string_set deps
Definition: remake.cpp:499
#define DEBUG
Definition: remake.cpp:800
static void skip_empty(std::istream &in)
Definition: remake.cpp:1019
static dependency_map dependencies
Definition: remake.cpp:609

§ load_dependencies() [2/2]

static void load_dependencies ( )
static

Load known dependencies from file .remake.

Definition at line 1456 of file remake.cpp.

1457 {
1458  DEBUG_open << "Loading database... ";
1459  std::ifstream in(".remake");
1460  if (!in.good())
1461  {
1462  DEBUG_close << "not found\n";
1463  return;
1464  }
1465  load_dependencies(in);
1466 }
#define DEBUG_open
Definition: remake.cpp:801
#define DEBUG_close
Definition: remake.cpp:802
static void load_dependencies(std::istream &in)
Definition: remake.cpp:1422

§ save_dependencies()

static void save_dependencies ( )
static

Save all the dependencies in file .remake.

Definition at line 1472 of file remake.cpp.

Referenced by server_mode().

1473 {
1474  DEBUG_open << "Saving database... ";
1475  std::ofstream db(".remake");
1476  while (!dependencies.empty())
1477  {
1478  ref_ptr<dependency_t> dep = dependencies.begin()->second;
1479  for (string_list::const_iterator i = dep->targets.begin(),
1480  i_end = dep->targets.end(); i != i_end; ++i)
1481  {
1482  db << escape_string(*i) << ' ';
1483  dependencies.erase(*i);
1484  }
1485  db << ':';
1486  for (string_set::const_iterator i = dep->deps.begin(),
1487  i_end = dep->deps.end(); i != i_end; ++i)
1488  {
1489  db << ' ' << escape_string(*i);
1490  }
1491  db << std::endl;
1492  }
1493 }
#define DEBUG_open
Definition: remake.cpp:801
string_list targets
Definition: remake.cpp:498
string_set deps
Definition: remake.cpp:499
static dependency_map dependencies
Definition: remake.cpp:609