From 75068e7d753cf6cbe45a4bf294000dca9bd41d8b Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 4 Sep 2006 21:06:23 +0000 Subject: * Use a proper namespace. * Optimise header file usage a bit. * Compile the parser as C++. --- src/libstore/build.cc | 53 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 21 deletions(-) (limited to 'src/libstore/build.cc') diff --git a/src/libstore/build.cc b/src/libstore/build.cc index c953707a5126..647671036de1 100644 --- a/src/libstore/build.cc +++ b/src/libstore/build.cc @@ -1,3 +1,13 @@ +#include "build.hh" +#include "references.hh" +#include "pathlocks.hh" +#include "misc.hh" +#include "globals.hh" +#include "gc.hh" +#include "store.hh" +#include "db.hh" +#include "util.hh" + #include #include #include @@ -15,13 +25,11 @@ #include #include -#include "build.hh" -#include "references.hh" -#include "pathlocks.hh" -#include "misc.hh" -#include "globals.hh" -#include "gc.hh" +namespace nix { + +using std::map; + /* !!! TODO derivationFromPath shouldn't be used here */ @@ -38,8 +46,8 @@ class Worker; /* A pointer to a goal. */ class Goal; -typedef shared_ptr GoalPtr; -typedef weak_ptr WeakGoalPtr; +typedef boost::shared_ptr GoalPtr; +typedef boost::weak_ptr WeakGoalPtr; /* Set of goals. */ typedef set Goals; @@ -50,7 +58,7 @@ typedef map WeakGoalMap; -class Goal : public enable_shared_from_this +class Goal : public boost::enable_shared_from_this { public: typedef enum {ecBusy, ecSuccess, ecFailed} ExitCode; @@ -447,8 +455,8 @@ static void killUser(uid_t uid) if (kill(-1, SIGKILL) == -1) throw SysError(format("cannot kill processes for UID `%1%'") % uid); - } catch (exception & e) { - cerr << format("build error: %1%\n") % e.what(); + } catch (std::exception & e) { + std::cerr << format("build error: %1%\n") % e.what(); quickExit(1); } quickExit(0); @@ -930,8 +938,8 @@ DerivationGoal::HookReply DerivationGoal::tryBuildHook() throw SysError(format("executing `%1%'") % buildHook); - } catch (exception & e) { - cerr << format("build error: %1%\n") % e.what(); + } catch (std::exception & e) { + std::cerr << format("build error: %1%\n") % e.what(); } quickExit(1); } @@ -1326,8 +1334,8 @@ void DerivationGoal::startBuilder() throw SysError(format("executing `%1%'") % drv.builder); - } catch (exception & e) { - cerr << format("build error: %1%\n") % e.what(); + } catch (std::exception & e) { + std::cerr << format("build error: %1%\n") % e.what(); } quickExit(1); } @@ -1593,7 +1601,7 @@ private: Pid pid; /* Lock on the store path. */ - shared_ptr outputLock; + boost::shared_ptr outputLock; typedef void (SubstitutionGoal::*GoalState)(); GoalState state; @@ -1719,7 +1727,7 @@ void SubstitutionGoal::tryToRun() } /* Acquire a lock on the output path. */ - outputLock = shared_ptr(new PathLocks); + outputLock = boost::shared_ptr(new PathLocks); outputLock->lockPaths(singleton(storePath), (format("waiting for lock on `%1%'") % storePath).str()); @@ -1767,8 +1775,8 @@ void SubstitutionGoal::tryToRun() throw SysError(format("executing `%1%'") % sub.program); - } catch (exception & e) { - cerr << format("substitute error: %1%\n") % e.what(); + } catch (std::exception & e) { + std::cerr << format("substitute error: %1%\n") % e.what(); } quickExit(1); } @@ -1930,8 +1938,8 @@ static void removeGoal(GoalPtr goal, WeakGoalMap & goalMap) void Worker::removeGoal(GoalPtr goal) { - ::removeGoal(goal, derivationGoals); - ::removeGoal(goal, substitutionGoals); + nix::removeGoal(goal, derivationGoals); + nix::removeGoal(goal, substitutionGoals); if (topGoals.find(goal) != topGoals.end()) { topGoals.erase(goal); /* If a top-level goal failed, then kill all other goals @@ -2160,3 +2168,6 @@ void ensurePath(const Path & path) if (goal->getExitCode() != Goal::ecSuccess) throw Error(format("path `%1%' does not exist and cannot be created") % path); } + + +} -- cgit 1.4.1