aboutsummaryrefslogtreecommitdiff
path: root/bbot/worker/worker.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2018-06-15 12:04:27 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2018-06-15 14:18:07 +0300
commit2068fd01f5acebeea9f0b92fbc43426772b10538 (patch)
tree915696faddac6d1bd14e9e010957fedefb38f484 /bbot/worker/worker.cxx
parentc41d662f29c7d4129b71b9c8a8c639e92ac40c0b (diff)
Use portable environment variable manipulation functions
Diffstat (limited to 'bbot/worker/worker.cxx')
-rw-r--r--bbot/worker/worker.cxx32
1 files changed, 22 insertions, 10 deletions
diff --git a/bbot/worker/worker.cxx b/bbot/worker/worker.cxx
index 5fff9bc..b9eeeb2 100644
--- a/bbot/worker/worker.cxx
+++ b/bbot/worker/worker.cxx
@@ -6,8 +6,6 @@
# include <signal.h> // signal()
#else
# include <libbutl/win32-utility.hxx>
-
-# include <stdlib.h> // getenv(), _putenv()
#endif
#include <map>
@@ -38,6 +36,12 @@ using std::endl;
namespace bbot
{
+ int
+ main (int argc, char* argv[]);
+
+ static void
+ build (size_t argc, const char* argv[]);
+
process_path argv0;
worker_options ops;
@@ -212,7 +216,7 @@ run_b (tracer& t,
return run_b (t, log, warn_detect, envvars, buildspec, forward<A> (a)...);
}
-static void
+static void bbot::
build (size_t argc, const char* argv[])
{
tracer trace ("build");
@@ -687,10 +691,10 @@ build (size_t argc, const char* argv[])
//
string paths ("PATH=" + (install_root / "bin").string ());
- if (char const* s = getenv ("PATH"))
+ if (optional<string> s = getenv ("PATH"))
{
paths += path::traits::path_separator;
- paths += s;
+ paths += *s;
}
small_vector<string, 1> envvars {move (paths)};
@@ -960,7 +964,7 @@ bootstrap ()
serialize_manifest (bm, cout, "stdout", "bootstrap");
}
-int
+int bbot::
main (int argc, char* argv[])
try
{
@@ -976,15 +980,15 @@ try
//
#ifdef _WIN32
{
- string mp ("PATH=");
- if (const char* p = getenv ("PATH"))
+ string mp;
+ if (optional<string> p = getenv ("PATH"))
{
- mp += p;
+ mp = move (*p);
mp += ';';
}
mp += "/bin";
- _putenv (mp.c_str ());
+ setenv ("PATH", mp);
}
#endif
@@ -1086,6 +1090,8 @@ try
case mode::build: build (static_cast<size_t> (argc),
const_cast<const char**> (argv)); break;
}
+
+ return 0;
}
catch (const failed&)
{
@@ -1096,3 +1102,9 @@ catch (const cli::exception& e)
error << e;
return 1;
}
+
+int
+main (int argc, char* argv[])
+{
+ return bbot::main (argc, argv);
+}