aboutsummaryrefslogtreecommitdiff
path: root/build2/functions-builtin.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2019-06-24 12:01:19 +0200
committerKaren Arutyunov <karen@codesynthesis.com>2019-07-01 18:13:55 +0300
commit977d07a3ae47ef204665d1eda2d642e5064724f3 (patch)
tree525a3d6421f61ce789b690191d3c30fc09be3517 /build2/functions-builtin.cxx
parent7161b24963dd9da4d218f92c736b77c35c328a2d (diff)
Split build system into library and driver
Diffstat (limited to 'build2/functions-builtin.cxx')
-rw-r--r--build2/functions-builtin.cxx56
1 files changed, 0 insertions, 56 deletions
diff --git a/build2/functions-builtin.cxx b/build2/functions-builtin.cxx
deleted file mode 100644
index 138a364..0000000
--- a/build2/functions-builtin.cxx
+++ /dev/null
@@ -1,56 +0,0 @@
-// file : build2/functions-builtin.cxx -*- C++ -*-
-// copyright : Copyright (c) 2014-2019 Code Synthesis Ltd
-// license : MIT; see accompanying LICENSE file
-
-#include <build2/function.hxx>
-#include <build2/variable.hxx>
-
-namespace build2
-{
- // Return NULL value if an environment variable is not set, untyped value
- // otherwise.
- //
- static inline value
- getenvvar (const string& name)
- {
- optional<string> v (getenv (name));
-
- if (!v)
- return value ();
-
- names r;
- r.emplace_back (to_name (move (*v)));
- return value (move (r));
- }
-
- void
- builtin_functions ()
- {
- function_family f ("builtin");
-
- f["type"] = [](value* v) {return v->type != nullptr ? v->type->name : "";};
-
- f["null"] = [](value* v) {return v->null;};
- f["empty"] = [](value* v) {return v->null || v->empty ();};
-
- f["identity"] = [](value* v) {return move (*v);};
-
- // string
- //
- f["string"] = [](bool b) {return b ? "true" : "false";};
- f["string"] = [](uint64_t i) {return to_string (i);};
- f["string"] = [](name n) {return to_string (n);};
-
- // getenv
- //
- f["getenv"] = [](string name)
- {
- return getenvvar (name);
- };
-
- f["getenv"] = [](names name)
- {
- return getenvvar (convert<string> (move (name)));
- };
- }
-}