Remake
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions
Target status

Functions

static status_t const & get_status (std::string const &target)
 
static void update_status (std::string const &target)
 
static bool still_need_rebuild (std::string const &target)
 

Detailed Description

Function Documentation

static status_t const& get_status ( std::string const &  target)
static

Compute and memoize the status of target:

  • if the file does not exist, the target is obsolete,
  • if any dependency is obsolete or younger than the file, it is obsolete,
  • otherwise it is up-to-date.
Note
For rules with multiple targets, all the targets share the same status. (If one is obsolete, they all are.) The second rule above is modified in that case: the latest target is chosen, not the oldest!

Definition at line 1779 of file remake.cpp.

Referenced by handle_clients(), and server_mode().

1780 {
1781  std::pair<status_map::iterator,bool> i =
1782  status.insert(std::make_pair(target, status_t()));
1783  status_t &ts = i.first->second;
1784  if (!i.second) return ts;
1785  DEBUG_open << "Checking status of " << target << "... ";
1786  dependency_map::const_iterator j = dependencies.find(target);
1787  if (j == dependencies.end())
1788  {
1789  struct stat s;
1790  if (stat(target.c_str(), &s) != 0)
1791  {
1792  DEBUG_close << "missing\n";
1793  ts.status = Todo;
1794  ts.last = 0;
1795  return ts;
1796  }
1797  DEBUG_close << "up-to-date\n";
1798  ts.status = Uptodate;
1799  ts.last = s.st_mtime;
1800  return ts;
1801  }
1802  dependency_t const &dep = *j->second;
1803  status_e st = Uptodate;
1804  time_t latest = 0;
1805  for (string_list::const_iterator k = dep.targets.begin(),
1806  k_end = dep.targets.end(); k != k_end; ++k)
1807  {
1808  struct stat s;
1809  if (stat(k->c_str(), &s) != 0)
1810  {
1811  if (st == Uptodate) DEBUG_close << *k << " missing\n";
1812  s.st_mtime = 0;
1813  st = Todo;
1814  }
1815  status[*k].last = s.st_mtime;
1816  if (s.st_mtime > latest) latest = s.st_mtime;
1817  }
1818  if (st == Todo) goto update;
1819  for (string_set::const_iterator k = dep.deps.begin(),
1820  k_end = dep.deps.end(); k != k_end; ++k)
1821  {
1822  status_t const &ts_ = get_status(*k);
1823  if (latest < ts_.last)
1824  {
1825  DEBUG_close << "older than " << *k << std::endl;
1826  st = Todo;
1827  goto update;
1828  }
1829  if (ts_.status == Uptodate) continue;
1830  if (st == Uptodate)
1831  DEBUG << "obsolete dependency " << *k << std::endl;
1832  st = Recheck;
1833  }
1834  if (st == Uptodate) DEBUG_close << "all siblings up-to-date\n";
1835  update:
1836  for (string_list::const_iterator k = dep.targets.begin(),
1837  k_end = dep.targets.end(); k != k_end; ++k)
1838  {
1839  status[*k].status = st;
1840  }
1841  return ts;
1842 }
static bool still_need_rebuild ( std::string const &  target)
static

Check whether all the prerequisites of target ended being up-to-date.

Definition at line 1881 of file remake.cpp.

Referenced by complete_request().

1882 {
1883  DEBUG_open << "Rechecking obsoleteness of " << target << "... ";
1884  status_map::const_iterator i = status.find(target);
1885  assert(i != status.end());
1886  if (i->second.status != Recheck) return true;
1887  dependency_map::const_iterator j = dependencies.find(target);
1888  assert(j != dependencies.end());
1889  dependency_t const &dep = *j->second;
1890  for (string_set::const_iterator k = dep.deps.begin(),
1891  k_end = dep.deps.end(); k != k_end; ++k)
1892  {
1893  if (status[*k].status != Uptodate) return true;
1894  }
1895  for (string_list::const_iterator k = dep.targets.begin(),
1896  k_end = dep.targets.end(); k != k_end; ++k)
1897  {
1898  status[*k].status = Uptodate;
1899  }
1900  DEBUG_close << "no longer obsolete\n";
1901  return false;
1902 }
static void update_status ( std::string const &  target)
static

Change the status of target to Remade or Uptodate depending on whether its modification time changed.

Definition at line 1848 of file remake.cpp.

Referenced by complete_job().

1849 {
1850  DEBUG_open << "Rechecking status of " << target << "... ";
1851  status_map::iterator i = status.find(target);
1852  assert(i != status.end());
1853  status_t &ts = i->second;
1854  ts.status = Remade;
1855  if (ts.last >= now)
1856  {
1857  DEBUG_close << "possibly remade\n";
1858  return;
1859  }
1860  struct stat s;
1861  if (stat(target.c_str(), &s) != 0)
1862  {
1863  DEBUG_close << "missing\n";
1864  ts.last = 0;
1865  }
1866  else if (s.st_mtime != ts.last)
1867  {
1868  DEBUG_close << "remade\n";
1869  ts.last = s.st_mtime;
1870  }
1871  else
1872  {
1873  DEBUG_close << "unchanged\n";
1874  ts.status = Uptodate;
1875  }
1876 }