Remake
Loading...
Searching...
No Matches
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 ( )
static

Load known dependencies from file .remake.

Definition at line 1471 of file remake.cpp.

1472{
1473 DEBUG_open << "Loading database... ";
1474 std::ifstream in(".remake");
1475 if (!in.good())
1476 {
1477 DEBUG_close << "not found\n";
1478 return;
1479 }
1481}
static void load_dependencies()
Definition remake.cpp:1471
#define DEBUG_close
Definition remake.cpp:817
#define DEBUG_open
Definition remake.cpp:816

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

◆ load_dependencies() [2/2]

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

Load dependencies from in.

Definition at line 1437 of file remake.cpp.

1438{
1439 if (false)
1440 {
1441 error:
1442 std::cerr << "Failed to load database" << std::endl;
1443 exit(EXIT_FAILURE);
1444 }
1445
1446 while (!in.eof())
1447 {
1448 string_list targets;
1449 if (!read_words(in, targets)) goto error;
1450 if (in.eof()) return;
1451 if (targets.empty()) goto error;
1452 DEBUG << "reading dependencies of target " << targets.front() << std::endl;
1453 if (in.get() != ':') goto error;
1455 dep->targets = targets;
1456 string_list deps;
1457 if (!read_words(in, deps)) goto error;
1458 dep->deps.insert(deps.begin(), deps.end());
1459 for (string_list::const_iterator i = targets.begin(),
1460 i_end = targets.end(); i != i_end; ++i)
1461 {
1462 dependencies[*i] = dep;
1463 }
1464 skip_empty(in);
1465 }
1466}
static void skip_empty(std::istream &in)
Definition remake.cpp:1034
static bool read_words(input_generator &in, string_list &res)
Definition remake.cpp:1286
std::list< std::string > string_list
Definition remake.cpp:469
static dependency_map dependencies
Definition remake.cpp:622
#define DEBUG
Definition remake.cpp:815

◆ save_dependencies()

static void save_dependencies ( )
static

Save all the dependencies in file .remake.

Definition at line 1487 of file remake.cpp.

1488{
1489 DEBUG_open << "Saving database... ";
1490 std::ofstream db(".remake");
1491 while (!dependencies.empty())
1492 {
1493 ref_ptr<dependency_t> dep = dependencies.begin()->second;
1494 for (string_list::const_iterator i = dep->targets.begin(),
1495 i_end = dep->targets.end(); i != i_end; ++i)
1496 {
1497 db << escape_string(*i) << ' ';
1498 dependencies.erase(*i);
1499 }
1500 db << ':';
1501 for (string_set::const_iterator i = dep->deps.begin(),
1502 i_end = dep->deps.end(); i != i_end; ++i)
1503 {
1504 db << ' ' << escape_string(*i);
1505 }
1506 db << std::endl;
1507 }
1508}

Referenced by server_mode().