Skip to content

Commit 0c9d20d

Browse files
committed
fixes #1151, autoconfig projects won't compile
1 parent d956bac commit 0c9d20d

1 file changed

Lines changed: 25 additions & 4 deletions

File tree

src/omake/os.cpp

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* Software License Agreement
22
*
3-
* Copyright(C) 1994-2025 David Lindauer, (LADSoft)
3+
* Copyright(C) 1994-2026 David Lindauer, (LADSoft)
44
*
55
* This file is part of the Orange C Compiler package.
66
*
@@ -141,6 +141,27 @@ static Variable* var_lookup_shell_names()
141141
}
142142
return v;
143143
}
144+
static std::string TranslateUnixShellForMsys2(Variable* v)
145+
{
146+
if (v)
147+
{
148+
// for msys2, we gotta strip the unix path off
149+
// we don't need to add the .exe file extension, we just gotta get rid of the path
150+
auto rv = v->GetValue();
151+
auto n = rv.find_last_of('/');
152+
if (n == std::string::npos)
153+
{
154+
n = rv.find_last_of('\\');
155+
}
156+
if (n != std::string::npos)
157+
{
158+
rv = rv.substr(n + 1);
159+
}
160+
OrangeC::Utils::BasicLogger::extremedebug("Translated unix shell to ", rv);
161+
return rv;
162+
}
163+
return v ? v->GetValue() : "";
164+
}
144165
std::string OS::LookupShellNames()
145166
{
146167
Variable* v = var_lookup_shell_names();
@@ -516,7 +537,7 @@ int OS::Spawn(const std::string command, EnvironmentStrings& environment, std::s
516537
Variable* shell_flags = VariableContainer::Instance()->Lookup(".SHELLFLAGS");
517538
if (IsUnixLikeShell(shell))
518539
{
519-
cmd = v->GetValue() + " " + shell_flags->GetValue() + " ";
540+
cmd = TranslateUnixShellForMsys2(v) + " " + shell_flags->GetValue() + " ";
520541
// we couldn't simply set MAKE properly because they may change the shell in the script
521542
v = VariableContainer::Instance()->Lookup("MAKE");
522543
if (v && v->GetValue().find_first_of("\\") != std::string::npos)
@@ -831,7 +852,7 @@ std::string OS::SpawnWithRedirect(const std::string command)
831852
}
832853
if (IsUnixLikeShell(v->GetValue()))
833854
{
834-
cmd = v->GetValue() + " -c ";
855+
cmd = TranslateUnixShellForMsys2(v) + " -c ";
835856
// we couldn't simply set MAKE properly because they may change the shell in the script
836857
v = VariableContainer::Instance()->Lookup("MAKE");
837858
if (v && v->GetValue().find_first_of("\\") != std::string::npos)
@@ -1151,4 +1172,4 @@ std::string OS::NormalizeFileName(const std::string file)
11511172
}
11521173
return name;
11531174
}
1154-
int OS::GetProcessId() { return getpid(); }
1175+
int OS::GetProcessId() { return getpid(); }

0 commit comments

Comments
 (0)