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

Load known dependencies from file .remake.

Definition at line 1473 of file remake.cpp.

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

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

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

◆ save_dependencies()

static void save_dependencies ( )
static

Save all the dependencies in file .remake.

Definition at line 1489 of file remake.cpp.

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

Referenced by server_mode().