Skip to content

Commit 0012b54

Browse files
committed
Search correct path to executables in Windows.
1 parent e303eb8 commit 0012b54

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/compiler/main.cc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,6 @@ int main(int argc, char **argv)
324324
}
325325
for(auto &f : asm_files)
326326
{
327-
auto ca65 = os::compiler_path("ca65");
328327
auto asm_name = std::get<0>(f), obj_name = std::get<1>(f);
329328
auto lst_name = os::add_extension(obj_name, ".lst");
330329

@@ -336,15 +335,14 @@ int main(int argc, char **argv)
336335
for(auto &o : asm_opts)
337336
args.push_back(o);
338337
args.push_back(asm_name);
339-
auto e = os::prog_exec(ca65, args);
338+
auto e = os::prog_exec("ca65", args);
340339
if(e)
341340
return show_error("can't assemble file\n");
342341
if(!one_step)
343342
temp_files.push_back(obj_name);
344343
}
345344
if(link_files.size())
346345
{
347-
auto ld65 = os::compiler_path("ld65");
348346
//$LD65" -C "$CFGFILE" "$@" -o "$XEX" -Ln "$LBL" "$FB.lib"
349347
std::cerr << "LINK " << exe_name << "\n";
350348
std::vector<std::string> args{"ld65",
@@ -359,7 +357,7 @@ int main(int argc, char **argv)
359357
for(auto &f : link_files)
360358
args.push_back(f);
361359
args.push_back(lib_name);
362-
auto e = os::prog_exec(ld65, args);
360+
auto e = os::prog_exec("ld65", args);
363361
if(e)
364362
return show_error("can't assemble file\n");
365363
}

src/compiler/os.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ int os::prog_exec(std::string exe, std::vector<std::string> &args)
160160
{
161161
std::vector<const char *> pargs;
162162
#ifdef _WIN32
163+
auto exe_path = os::compiler_path(exe + ".exe");
163164
// Escape any string with spaces in it:
164165
std::vector<std::string> esc_args;
165166
for(const auto &s : args)
@@ -175,8 +176,9 @@ int os::prog_exec(std::string exe, std::vector<std::string> &args)
175176
pargs.push_back(nullptr);
176177
// win32 has the "spawn" function that calls the program and waits
177178
// for termination:
178-
return _spawnv(_P_WAIT, exe.c_str(), (char **)pargs.data());
179+
return _spawnv(_P_WAIT, exe_path.c_str(), (char **)pargs.data());
179180
#else
181+
auto exe_path = os::compiler_path(exe);
180182
// Create a vector with C pointers
181183
for(const auto &s : args)
182184
pargs.push_back(s.c_str());
@@ -205,7 +207,7 @@ int os::prog_exec(std::string exe, std::vector<std::string> &args)
205207
sigaction(SIGQUIT, &sa, nullptr);
206208
sigprocmask(SIG_SETMASK, &oldmask, nullptr);
207209
// Exec process
208-
execv(exe.c_str(), (char **)pargs.data());
210+
execv(exe_path.c_str(), (char **)pargs.data());
209211
// If we got here, it is an error
210212
_exit(127);
211213
}

0 commit comments

Comments
 (0)