aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/cpp/runfiles/BUILD1
-rw-r--r--tools/cpp/runfiles/BUILD.tools14
-rw-r--r--tools/cpp/runfiles/runfiles.h15
3 files changed, 18 insertions, 12 deletions
diff --git a/tools/cpp/runfiles/BUILD b/tools/cpp/runfiles/BUILD
index a8f47b9a59..7373b03e37 100644
--- a/tools/cpp/runfiles/BUILD
+++ b/tools/cpp/runfiles/BUILD
@@ -17,6 +17,7 @@ filegroup(
srcs = [
"BUILD.tools",
"runfiles.cc",
+ "runfiles.h",
],
visibility = ["//tools:__pkg__"],
)
diff --git a/tools/cpp/runfiles/BUILD.tools b/tools/cpp/runfiles/BUILD.tools
index 8f0a9cf143..ef9518c05b 100644
--- a/tools/cpp/runfiles/BUILD.tools
+++ b/tools/cpp/runfiles/BUILD.tools
@@ -1,10 +1,8 @@
# This package will host the C++ runfiles library when it's finally released.
-# TODO(laszlocsomor): uncomment the cc_library below when the C++ runfiles library is ready to be
-# released.
-# cc_library(
-# name = "runfiles",
-# srcs = ["runfiles.cc"],
-# hdrs = ["runfiles.h"],
-# visibility = ["//visibility:public"],
-# )
+cc_library(
+ name = "runfiles",
+ srcs = ["runfiles.cc"],
+ hdrs = ["runfiles.h"],
+ visibility = ["//visibility:public"],
+)
diff --git a/tools/cpp/runfiles/runfiles.h b/tools/cpp/runfiles/runfiles.h
index 8c016a3030..b2bfe30517 100644
--- a/tools/cpp/runfiles/runfiles.h
+++ b/tools/cpp/runfiles/runfiles.h
@@ -44,13 +44,20 @@
//
// std::unique_ptr<Runfiles> runfiles(Runfiles::Create(argv[0], &error));
//
-// for (const auto i : runfiles->EnvVars()) {
-// setenv(i.first, i.second, 1);
-// }
// std::string path = runfiles->Rlocation("path/to/binary"));
// if (!path.empty()) {
+// ... // create "args" argument vector for execv
+// const auto envvars = runfiles->EnvVars();
// pid_t child = fork();
-// ...
+// if (child) {
+// int status;
+// waitpid(child, &status, 0);
+// } else {
+// for (const auto i : envvars) {
+// setenv(i.first.c_str(), i.second.c_str(), 1);
+// }
+// execv(args[0], args);
+// }
#ifndef TOOLS_CPP_RUNFILES_RUNFILES_H_
#define TOOLS_CPP_RUNFILES_RUNFILES_H_ 1