aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar laszlocsomor <laszlocsomor@google.com>2018-03-21 02:52:51 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-03-21 02:54:02 -0700
commit33c08852e9145120367ff37275adaeed33809a0a (patch)
tree6def05946747bca91658feb9a84c3d3f2fdb177f
parent8a5a0a3ed1e19768b6ee024189307bb4ac27460d (diff)
Automated rollback of commit 8a5a0a3ed1e19768b6ee024189307bb4ac27460d.
*** Reason for rollback *** breaks building //src:bazel *** Original change description *** runfiles,C++: move to //tools/cpp/runfiles Move the C++ runfiles library to the location of the rest of the C++ tools. Also change the C++ namespace to reflect the directory hierarchy. We have not yet announced nor released the C++ runfiles library so these refactorings are fine. See https://github.com/bazelbuild/bazel/issues/4460 Closes #4873. PiperOrigin-RevId: 189883066
-rw-r--r--src/main/cpp/util/BUILD2
-rw-r--r--src/tools/runfiles/BUILD31
-rw-r--r--src/tools/runfiles/runfiles.cc (renamed from tools/cpp/runfiles/runfiles.cc)6
-rw-r--r--src/tools/runfiles/runfiles.h (renamed from tools/cpp/runfiles/runfiles.h)21
-rw-r--r--src/tools/runfiles/runfiles_test.cc (renamed from tools/cpp/runfiles/runfiles_test.cc)10
-rw-r--r--tools/BUILD2
-rw-r--r--tools/cpp/runfiles/BUILD31
-rw-r--r--tools/cpp/runfiles/BUILD.tools2
8 files changed, 46 insertions, 59 deletions
diff --git a/src/main/cpp/util/BUILD b/src/main/cpp/util/BUILD
index 0ab331d6c8..11db4ca047 100644
--- a/src/main/cpp/util/BUILD
+++ b/src/main/cpp/util/BUILD
@@ -47,9 +47,9 @@ cc_library(
":ijar",
"//src/test/cpp/util:__pkg__",
"//src/tools/launcher:__subpackages__",
+ "//src/tools/runfiles:__pkg__",
"//src/tools/singlejar:__pkg__",
"//third_party/def_parser:__pkg__",
- "//tools/cpp/runfiles:__pkg__",
],
deps = [
":blaze_exit_code",
diff --git a/src/tools/runfiles/BUILD b/src/tools/runfiles/BUILD
index 5ac490d1e2..d3545fd3e7 100644
--- a/src/tools/runfiles/BUILD
+++ b/src/tools/runfiles/BUILD
@@ -20,6 +20,8 @@ filegroup(
name = "embedded_tools",
srcs = [
"BUILD.tools",
+ "runfiles.cc",
+ "runfiles.h",
"runfiles.py",
"//src/tools/runfiles/java/com/google/devtools/build/runfiles:embedded_tools",
],
@@ -38,6 +40,35 @@ py_test(
deps = [":py-runfiles"],
)
+cc_library(
+ name = "cc-runfiles",
+ srcs = ["runfiles.cc"],
+ hdrs = ["runfiles.h"],
+ # This library is available to clients under
+ # @bazel_tools//tools/runfiles:cc-runfiles, with the same source files.
+ # The include statement in runfiles.cc that includes runfiles.h must work
+ # both here in the //src/tools/runfiles package, and in the
+ # @bazel_tools//tools/runfiles package.
+ # runfiles.cc includes "tools/runfiles/runfiles.h" so we need to tell the
+ # compiler to prepend "src" to it so the include path is valid.
+ # Alternatively we could omit this "copts" attribute here and add some
+ # include path manipulating attributes to
+ # @bazel_tools//tools/runfiles:cc-runfiles instead -- that would work too,
+ # but I (laszlocsomor@) find this solution (i.e. the "copts" attribute on
+ # this rule) to be simpler.
+ copts = ["-Isrc"],
+)
+
+cc_test(
+ name = "cc-runfiles-test",
+ srcs = ["runfiles_test.cc"],
+ deps = [
+ ":cc-runfiles",
+ "//src/main/cpp/util:file",
+ "//third_party:gtest",
+ ],
+)
+
sh_library(
name = "runfiles_sh_lib",
srcs = ["runfiles.sh"],
diff --git a/tools/cpp/runfiles/runfiles.cc b/src/tools/runfiles/runfiles.cc
index 9ecc033a04..b1a870558b 100644
--- a/tools/cpp/runfiles/runfiles.cc
+++ b/src/tools/runfiles/runfiles.cc
@@ -11,7 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "tools/cpp/runfiles/runfiles.h"
+#include "tools/runfiles/runfiles.h"
#ifdef COMPILER_MSVC
#include <windows.h>
@@ -32,8 +32,6 @@
#endif // COMPILER_MSVC
namespace bazel {
-namespace tools {
-namespace cpp {
namespace runfiles {
using std::function;
@@ -316,6 +314,4 @@ Runfiles* Runfiles::CreateDirectoryBased(const string& directory_path,
}
} // namespace runfiles
-} // namespace cpp
-} // namespace tools
} // namespace bazel
diff --git a/tools/cpp/runfiles/runfiles.h b/src/tools/runfiles/runfiles.h
index d4af4627b7..20e9dca1e1 100644
--- a/tools/cpp/runfiles/runfiles.h
+++ b/src/tools/runfiles/runfiles.h
@@ -16,13 +16,13 @@
//
// Usage:
//
-// #include "tools/cpp/runfiles/runfiles.h"
+// #include "tools/runfiles/runfiles.h"
// ...
-// using namespace bazel::tools::cpp::runfiles::Runfiles;
//
// int main(int argc, char** argv) {
// std::string error;
-// std::unique_ptr<Runfiles> runfiles(Runfiles::Create(argv[0], &error));
+// std::unique_ptr<bazel::runfiles::Runfiles> runfiles(
+// bazel::runfiles::Runfiles::Create(argv[0], &error));
// if (runfiles == nullptr) {
// ... // error handling
// }
@@ -39,18 +39,19 @@
// If you want to explicitly create a manifest- or directory-based
// implementation, you can do so as follows:
//
-// std::unique_ptr<Runfiles> runfiles1(
-// Runfiles::CreateManifestBased(
+// std::unique_ptr<bazel::runfiles::Runfiles> runfiles1(
+// bazel::runfiles::Runfiles::CreateManifestBased(
// "path/to/foo.runfiles/MANIFEST", &error));
//
-// std::unique_ptr<Runfiles> runfiles2(
-// Runfiles::CreateDirectoryBased(
+// std::unique_ptr<bazel::runfiles::Runfiles> runfiles2(
+// bazel::runfiles::Runfiles::CreateDirectoryBased(
// "path/to/foo.runfiles", &error));
//
// If you want to start child processes that also need runfiles, you need to set
// the right environment variables for them:
//
-// std::unique_ptr<Runfiles> runfiles(Runfiles::Create(argv[0], &error));
+// std::unique_ptr<bazel::runfiles::Runfiles> runfiles(
+// bazel::runfiles::Runfiles::Create(argv[0], &error));
//
// for (const auto i : runfiles->EnvVars()) {
// setenv(i.first, i.second, 1);
@@ -69,8 +70,6 @@
#include <vector>
namespace bazel {
-namespace tools {
-namespace cpp {
namespace runfiles {
class Runfiles {
@@ -180,8 +179,6 @@ bool TestOnly_IsAbsolute(const std::string& path);
} // namespace testing
} // namespace runfiles
-} // namespace cpp
-} // namespace tools
} // namespace bazel
#endif // BAZEL_SRC_TOOLS_RUNFILES_RUNFILES_H_
diff --git a/tools/cpp/runfiles/runfiles_test.cc b/src/tools/runfiles/runfiles_test.cc
index eb27ce1d93..9fe95aa19b 100644
--- a/tools/cpp/runfiles/runfiles_test.cc
+++ b/src/tools/runfiles/runfiles_test.cc
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "tools/cpp/runfiles/runfiles.h"
+#include "src/tools/runfiles/runfiles.h"
#ifdef COMPILER_MSVC
#include <windows.h>
@@ -31,13 +31,11 @@
#define LINE() T(__LINE__)
namespace bazel {
-namespace tools {
-namespace cpp {
namespace runfiles {
namespace {
-using bazel::tools::cpp::runfiles::testing::TestOnly_CreateRunfiles;
-using bazel::tools::cpp::runfiles::testing::TestOnly_IsAbsolute;
+using bazel::runfiles::testing::TestOnly_CreateRunfiles;
+using bazel::runfiles::testing::TestOnly_IsAbsolute;
using std::cerr;
using std::endl;
using std::function;
@@ -472,6 +470,4 @@ TEST_F(RunfilesTest, IsAbsolute) {
} // namespace
} // namespace runfiles
-} // namespace cpp
-} // namespace tools
} // namespace bazel
diff --git a/tools/BUILD b/tools/BUILD
index 14a8115edc..4488574d28 100644
--- a/tools/BUILD
+++ b/tools/BUILD
@@ -48,7 +48,7 @@ filegroup(
"//tools/build_rules:embedded_tools_srcs",
"//tools/buildstamp:srcs",
"//tools/coverage:srcs",
- "//tools/cpp:embedded_tools",
+ "//tools/cpp:srcs",
"//tools/genrule:srcs",
"//tools/j2objc:srcs",
"//tools/jdk:package-srcs",
diff --git a/tools/cpp/runfiles/BUILD b/tools/cpp/runfiles/BUILD
deleted file mode 100644
index 6937bfb6a4..0000000000
--- a/tools/cpp/runfiles/BUILD
+++ /dev/null
@@ -1,31 +0,0 @@
-filegroup(
- name = "srcs",
- srcs = glob(["**"]),
- visibility = ["//tools/cpp:__pkg__"],
-)
-
-filegroup(
- name = "embedded_tools",
- srcs = [
- "BUILD.tools",
- "runfiles.cc",
- "runfiles.h",
- ],
- visibility = ["//tools/cpp:__pkg__"],
-)
-
-cc_library(
- name = "runfiles",
- srcs = ["runfiles.cc"],
- hdrs = ["runfiles.h"],
-)
-
-cc_test(
- name = "runfiles-test",
- srcs = ["runfiles_test.cc"],
- deps = [
- ":runfiles",
- "//src/main/cpp/util:file",
- "//third_party:gtest",
- ],
-)
diff --git a/tools/cpp/runfiles/BUILD.tools b/tools/cpp/runfiles/BUILD.tools
deleted file mode 100644
index ffc1769a1f..0000000000
--- a/tools/cpp/runfiles/BUILD.tools
+++ /dev/null
@@ -1,2 +0,0 @@
-# This package will host the C++ runfiles library when it's ready.
-# Follow the progress on https://github.com/bazelbuild/bazel/issues/4460