diff options
-rw-r--r-- | src/test/py/bazel/launcher_test.py | 7 | ||||
-rw-r--r-- | src/tools/launcher/launcher.cc | 10 | ||||
-rw-r--r-- | src/tools/launcher/util/launcher_util.cc | 4 |
3 files changed, 17 insertions, 4 deletions
diff --git a/src/test/py/bazel/launcher_test.py b/src/test/py/bazel/launcher_test.py index 3487545820..92f93e552e 100644 --- a/src/test/py/bazel/launcher_test.py +++ b/src/test/py/bazel/launcher_test.py @@ -76,7 +76,8 @@ class LauncherTest(test_base.TestBase): if self.IsWindows(): self.assertRegexpMatches(stdout[1], r'java_runfiles=.*foo\\foo.runfiles') self.assertEqual(stdout[2], 'runfiles_manifest_only=1') - self.assertRegexpMatches(stdout[3], r'^runfiles_manifest_file.*MANIFEST$') + self.assertRegexpMatches( + stdout[3], r'^runfiles_manifest_file=[a-zA-Z]:[/\\].*MANIFEST$') else: self.assertRegexpMatches(stdout[1], r'java_runfiles=.*/foo/foo.runfiles') self.assertEqual(stdout[2], 'runfiles_manifest_only=') @@ -150,7 +151,9 @@ class LauncherTest(test_base.TestBase): self.assertEqual(stdout[0], 'hello shell') if self.IsWindows(): self.assertEqual(stdout[1], 'runfiles_manifest_only=1') - self.assertRegexpMatches(stdout[2], r'^runfiles_manifest_file.*MANIFEST$') + self.assertRegexpMatches(stdout[2], + (r'^runfiles_manifest_file=' + r'[a-zA-Z]:/.*/foo/bin1.sh.runfiles/MANIFEST$')) else: # TODO(laszlocsomor): Find out whether the runfiles-related envvars should # be set on Linux (e.g. $RUNFILES, $RUNFILES_MANIFEST_FILE). Currently diff --git a/src/tools/launcher/launcher.cc b/src/tools/launcher/launcher.cc index d3a023eb8b..9aaa8a5924 100644 --- a/src/tools/launcher/launcher.cc +++ b/src/tools/launcher/launcher.cc @@ -13,6 +13,7 @@ // limitations under the License. #include <windows.h> +#include <algorithm> #include <fstream> #include <iostream> #include <sstream> @@ -47,8 +48,12 @@ string BinaryLauncherBase::FindManifestFile(const char* argv0) { // Get the name of the binary string binary = GetBinaryPathWithoutExtension(argv0); + // The path will be set as the RUNFILES_MANIFEST_FILE envvar and used by the + // shell script, so let's convert backslashes to forward slashes. + std::replace(binary.begin(), binary.end(), '\\', '/'); + // Try to find <path to binary>.runfiles/MANIFEST - string manifest_file = binary + ".runfiles\\MANIFEST"; + string manifest_file = binary + ".runfiles/MANIFEST"; if (DoesFilePathExist(manifest_file.c_str())) { return manifest_file; } @@ -64,6 +69,9 @@ string BinaryLauncherBase::FindManifestFile(const char* argv0) { void BinaryLauncherBase::ParseManifestFile(ManifestFileMap* manifest_file_map, const string& manifest_path) { + // TODO(laszlocsomor): prefix manifest_path with the longpath prefix. + // std::ifstream supports long paths, but only if they are in the correct + // format, e.g. "\\\\?\\c:\\imagine\\some\\very\\long\\path.txt". ifstream manifest_file(manifest_path.c_str()); if (!manifest_file) { diff --git a/src/tools/launcher/util/launcher_util.cc b/src/tools/launcher/util/launcher_util.cc index 610516bcc3..247c7050c5 100644 --- a/src/tools/launcher/util/launcher_util.cc +++ b/src/tools/launcher/util/launcher_util.cc @@ -68,7 +68,9 @@ void PrintError(const char* format, ...) { } bool DoesFilePathExist(const char* path) { - DWORD dwAttrib = GetFileAttributes(path); + // TODO(laszlocsomor): convert `path` to (const wchar_t*), add longpath-prefix + // and use GetFileAttributesW. + DWORD dwAttrib = GetFileAttributesA(path); return (dwAttrib != INVALID_FILE_ATTRIBUTES && !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY)); |