Skip to content

Commit

Permalink
Windows, *_binary launcher: bazel-bin/x.EXE works
Browse files Browse the repository at this point in the history
  • Loading branch information
laszlocsomor committed Sep 17, 2019
1 parent 3740768 commit cb8539a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/tools/launcher/util/launcher_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,18 @@ bool DeleteDirectoryByPath(const wchar_t* path) {

wstring GetBinaryPathWithoutExtension(const wstring& binary) {
if (binary.size() >= 4 &&
binary.find(L".exe", binary.size() - 4) != wstring::npos) {
_wcsnicmp(binary.c_str() + binary.size() - 4, L".exe", 4) == 0) {
return binary.substr(0, binary.size() - 4);
}
return binary;
}

wstring GetBinaryPathWithExtension(const wstring& binary) {
return GetBinaryPathWithoutExtension(binary) + L".exe";
if (binary.size() >= 4 &&
_wcsnicmp(binary.c_str() + binary.size() - 4, L".exe", 4) == 0) {
return binary;
}
return binary + L".exe";
}

std::wstring BashEscapeArg(const std::wstring& argument) {
Expand Down
3 changes: 3 additions & 0 deletions src/tools/launcher/util/launcher_util_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ TEST_F(LaunchUtilTest, GetBinaryPathWithoutExtensionTest) {

TEST_F(LaunchUtilTest, GetBinaryPathWithExtensionTest) {
ASSERT_EQ(L"foo.exe", GetBinaryPathWithExtension(L"foo"));
ASSERT_EQ(L"foo.exe", GetBinaryPathWithExtension(L"foo.exe"));
ASSERT_EQ(L"foo.EXE", GetBinaryPathWithExtension(L"foo.EXE"));
ASSERT_EQ(L"foo.sh.exe", GetBinaryPathWithExtension(L"foo.sh.exe"));
ASSERT_EQ(L"foo.sh.EXE", GetBinaryPathWithExtension(L"foo.sh.EXE"));
ASSERT_EQ(L"foo.sh.exe", GetBinaryPathWithExtension(L"foo.sh"));
}

Expand Down

0 comments on commit cb8539a

Please sign in to comment.