mirror of
https://github.com/cc65/cc65.git
synced 2024-11-15 11:05:56 +00:00
Have cl65 run the binaries from its own directory.
While ca65, cc65 and ld65 have built-in paths cl65 doesn't. That means that up to now cl65 depended on the binaries being found in the path env var. However it makes sense to presume that the binaries are located in the very same directory cl65 is located in. So whatever pathname was suitable to run cl65 should be suitable to run the other binaries too. But if for some reason there's no valid argv[0] or if it doesn't contain at least one directory delimiter ('/' or '\') then fall back to relying on the path env var.
This commit is contained in:
parent
2e7fdb23ee
commit
912b0d9e93
@ -283,14 +283,22 @@ static void CmdAddFile (CmdDesc* Cmd, const char* File)
|
||||
|
||||
|
||||
|
||||
static void CmdInit (CmdDesc* Cmd, const char* Path)
|
||||
/* Initialize the command using the given path to the executable */
|
||||
static void CmdInit (CmdDesc* Cmd, const char* Path, const char* Name)
|
||||
/* Initialize the command using the given path and name of the executable */
|
||||
{
|
||||
char* FullName;
|
||||
|
||||
FullName = (char*) xmalloc (strlen (Path) + strlen (Name) + 1);
|
||||
strcpy (FullName, Path);
|
||||
strcat (FullName, Name);
|
||||
|
||||
/* Remember the command */
|
||||
Cmd->Name = xstrdup (Path);
|
||||
Cmd->Name = xstrdup (FullName);
|
||||
|
||||
/* Use the command name as first argument */
|
||||
CmdAddArg (Cmd, Path);
|
||||
CmdAddArg (Cmd, FullName);
|
||||
|
||||
xfree (FullName);
|
||||
}
|
||||
|
||||
|
||||
@ -1283,17 +1291,34 @@ int main (int argc, char* argv [])
|
||||
{ "--zeropage-name", 1, OptZeropageName },
|
||||
};
|
||||
|
||||
char* CmdPath;
|
||||
unsigned I;
|
||||
|
||||
/* Initialize the cmdline module */
|
||||
InitCmdLine (&argc, &argv, "cl65");
|
||||
|
||||
/* Initialize the command descriptors */
|
||||
CmdInit (&CC65, "cc65");
|
||||
CmdInit (&CA65, "ca65");
|
||||
CmdInit (&CO65, "co65");
|
||||
CmdInit (&LD65, "ld65");
|
||||
CmdInit (&GRC, "grc65");
|
||||
if (argc == 0) {
|
||||
CmdPath = xstrdup ("");
|
||||
} else {
|
||||
char* Ptr;
|
||||
CmdPath = xstrdup (argv[0]);
|
||||
Ptr = strrchr (CmdPath, '/');
|
||||
if (Ptr == 0) {
|
||||
Ptr = strrchr (CmdPath, '\\');
|
||||
}
|
||||
if (Ptr == 0) {
|
||||
*CmdPath = '\0';
|
||||
} else {
|
||||
*(Ptr + 1) = '\0';
|
||||
}
|
||||
}
|
||||
CmdInit (&CC65, CmdPath, "cc65");
|
||||
CmdInit (&CA65, CmdPath, "ca65");
|
||||
CmdInit (&CO65, CmdPath, "co65");
|
||||
CmdInit (&LD65, CmdPath, "ld65");
|
||||
CmdInit (&GRC, CmdPath, "grc65");
|
||||
xfree (CmdPath);
|
||||
|
||||
/* Our default target is the C64 instead of "none" */
|
||||
Target = TGT_C64;
|
||||
|
Loading…
Reference in New Issue
Block a user