bazel: Drop dependency on util/flags.h in runfiles helper

Bazel's `Runfiles::Create()` does not actually need a value for `argv0` in
order to find runfiles for the current `cc_binary`.

- Rename `runfiles.cc` to `runfiles_nobazel.cc`

PiperOrigin-RevId: 443061178
Change-Id: I31e16d69d24aecbc403f9407fc08c615bb1e8f9f
This commit is contained in:
Christian Blichmann 2022-04-20 04:45:41 -07:00 committed by Copybara-Service
parent 456d9f341e
commit 5159addd1b
3 changed files with 3 additions and 4 deletions

View File

@ -22,7 +22,7 @@ namespace sapi {
std::string GetTestTempPath(absl::string_view name) {
// When using Bazel, the environment variable TEST_TMPDIR is guaranteed to be
// set.
// See https://docs.bazel.build/versions/master/test-encyclopedia.html for
// See https://bazel.build/reference/test-encyclopedia#initial-conditions for
// details.
const char* test_tmpdir = getenv("TEST_TMPDIR");
return file::JoinPath(test_tmpdir ? test_tmpdir : ".", name);

View File

@ -125,7 +125,7 @@ cc_library(
cc_library(
name = "runfiles",
srcs = ["runfiles.cc"],
srcs = ["runfiles_bazel.cc"],
hdrs = ["runfiles.h"],
copts = sapi_platform_copts(),
visibility = ["//visibility:public"],

View File

@ -15,7 +15,6 @@
#include <cstdlib>
#include "absl/strings/str_format.h"
#include "sandboxed_api/util/flag.h"
#include "sandboxed_api/util/path.h"
#include "sandboxed_api/util/raw_logging.h"
#include "sandboxed_api/util/runfiles.h"
@ -28,7 +27,7 @@ std::string GetDataDependencyFilePath(absl::string_view relative_path) {
static Runfiles* runfiles = []() {
std::string error;
auto* runfiles = Runfiles::Create(gflags::GetArgv0(), &error);
auto* runfiles = Runfiles::Create(/*argv=*/"" /* unknown */, &error);
SAPI_RAW_CHECK(runfiles != nullptr, error.c_str());
// Setup environment for child processes.