diff options
author | Laszlo Csomor <laszlocsomor@google.com> | 2017-08-03 10:50:29 +0200 |
---|---|---|
committer | Dmitry Lomov <dslomov@google.com> | 2017-08-03 12:10:09 +0200 |
commit | 837e1b3d4859140d29aaa6bbab8fbb008e6d701e (patch) | |
tree | a4e26afbd16151ae314010ca962877484ee11cf7 /src/tools/launcher/launcher.cc | |
parent | d4fa181f8607c35230b7efa1ce94188b51508962 (diff) |
Windows, sh_bin. launcher: export runfiles envvars
Fix the exe launcher of sh_binary rules to export
the RUNFILES_MANIFEST_ONLY and
RUNFILES_MANIFEST_FILE environment variables.
Fixes https://github.com/bazelbuild/bazel/issues/3492
Change-Id: I8507565f44c8b59f8218570306375cc083a41e03
PiperOrigin-RevId: 164095286
Diffstat (limited to 'src/tools/launcher/launcher.cc')
-rw-r--r-- | src/tools/launcher/launcher.cc | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/tools/launcher/launcher.cc b/src/tools/launcher/launcher.cc index 86e9d8d473..d3a023eb8b 100644 --- a/src/tools/launcher/launcher.cc +++ b/src/tools/launcher/launcher.cc @@ -34,27 +34,28 @@ using std::vector; BinaryLauncherBase::BinaryLauncherBase( const LaunchDataParser::LaunchInfo& _launch_info, int argc, char* argv[]) - : launch_info(_launch_info) { - this->workspace_name = GetLaunchInfoByKey(WORKSPACE_NAME); + : launch_info(_launch_info), + manifest_file(FindManifestFile(argv[0])), + workspace_name(GetLaunchInfoByKey(WORKSPACE_NAME)) { for (int i = 0; i < argc; i++) { this->commandline_arguments.push_back(argv[i]); } - ParseManifestFile(&this->manifest_file_map, FindManifestFile()); + ParseManifestFile(&this->manifest_file_map, this->manifest_file); } -string BinaryLauncherBase::FindManifestFile() const { +string BinaryLauncherBase::FindManifestFile(const char* argv0) { // Get the name of the binary - string binary = GetBinaryPathWithoutExtension(this->commandline_arguments[0]); + string binary = GetBinaryPathWithoutExtension(argv0); // Try to find <path to binary>.runfiles/MANIFEST string manifest_file = binary + ".runfiles\\MANIFEST"; - if (DoesFilePathExist(manifest_file)) { + if (DoesFilePathExist(manifest_file.c_str())) { return manifest_file; } // Also try to check if <path to binary>.runfiles_manifest exists manifest_file = binary + ".runfiles_manifest"; - if (DoesFilePathExist(manifest_file)) { + if (DoesFilePathExist(manifest_file.c_str())) { return manifest_file; } @@ -125,6 +126,8 @@ void BinaryLauncherBase::CreateCommandLine( ExitCode BinaryLauncherBase::LaunchProcess( const string& executable, const vector<string>& arguments) const { + SetEnvironmentVariableA("RUNFILES_MANIFEST_ONLY", "1"); + SetEnvironmentVariableA("RUNFILES_MANIFEST_FILE", manifest_file.c_str()); CmdLine cmdline; CreateCommandLine(&cmdline, executable, arguments); PROCESS_INFORMATION processInfo = {0}; |