Restructured search path handling.
git-svn-id: svn://svn.cc65.org/cc65/trunk@4662 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 2003-2009, Ullrich von Bassewitz */
|
||||
/* (C) 2003-2010, Ullrich von Bassewitz */
|
||||
/* Roemerstrasse 52 */
|
||||
/* D-70794 Filderstadt */
|
||||
/* EMail: uz@cc65.org */
|
||||
@@ -33,14 +33,23 @@
|
||||
|
||||
|
||||
|
||||
/* common */
|
||||
#include "searchpath.h"
|
||||
|
||||
/* ld65 */
|
||||
#include "filepath.h"
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Data */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
SearchPath* LibSearchPath; /* Library path */
|
||||
SearchPath* ObjSearchPath; /* Object file path */
|
||||
SearchPath* CfgSearchPath; /* Config file path */
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Code */
|
||||
/*****************************************************************************/
|
||||
@@ -50,29 +59,36 @@
|
||||
void InitSearchPaths (void)
|
||||
/* Initialize the path search list */
|
||||
{
|
||||
/* Create the search path lists */
|
||||
LibSearchPath = NewSearchPath ();
|
||||
ObjSearchPath = NewSearchPath ();
|
||||
CfgSearchPath = NewSearchPath ();
|
||||
|
||||
/* Always search all stuff in the current directory */
|
||||
AddSearchPath ("", SEARCH_LIB | SEARCH_OBJ | SEARCH_CFG);
|
||||
AddSearchPath (LibSearchPath, "");
|
||||
AddSearchPath (ObjSearchPath, "");
|
||||
AddSearchPath (CfgSearchPath, "");
|
||||
|
||||
/* Add some compiled in search paths if defined at compile time */
|
||||
#if defined(LD65_LIB)
|
||||
AddSearchPath (LD65_LIB, SEARCH_LIB);
|
||||
AddSearchPath (LibSearchPath, LD65_LIB);
|
||||
#endif
|
||||
#if defined(LD65_OBJ)
|
||||
AddSearchPath (LD65_OBJ, SEARCH_OBJ);
|
||||
AddSearchPath (ObjSearchPath, LD65_OBJ);
|
||||
#endif
|
||||
#if defined(LD65_CFG)
|
||||
AddSearchPath (LD65_CFG, SEARCH_CFG);
|
||||
AddSearchPath (CfgSearchPath, LD65_CFG);
|
||||
#endif
|
||||
|
||||
/* Add specific paths from the environment */
|
||||
AddSearchPathFromEnv ("LD65_CFG", SEARCH_CFG);
|
||||
AddSearchPathFromEnv ("LD65_LIB", SEARCH_LIB);
|
||||
AddSearchPathFromEnv ("LD65_OBJ", SEARCH_OBJ);
|
||||
AddSearchPathFromEnv (LibSearchPath, "LD65_LIB");
|
||||
AddSearchPathFromEnv (ObjSearchPath, "LD65_OBJ");
|
||||
AddSearchPathFromEnv (CfgSearchPath, "LD65_CFG");
|
||||
|
||||
/* Add paths relative to a main directory defined in an env var */
|
||||
AddSubSearchPathFromEnv ("CC65_HOME", "cfg", SEARCH_CFG);
|
||||
AddSubSearchPathFromEnv ("CC65_HOME", "lib", SEARCH_LIB);
|
||||
AddSubSearchPathFromEnv ("CC65_HOME", "obj", SEARCH_OBJ);
|
||||
AddSubSearchPathFromEnv (LibSearchPath, "CC65_HOME", "lib");
|
||||
AddSubSearchPathFromEnv (ObjSearchPath, "CC65_HOME", "obj");
|
||||
AddSubSearchPathFromEnv (CfgSearchPath, "CC65_HOME", "cfg");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 2003 Ullrich von Bassewitz */
|
||||
/* R<EFBFBD>merstrasse 52 */
|
||||
/* D-70794 Filderstadt */
|
||||
/* EMail: uz@cc65.org */
|
||||
/* (C) 2003-2010, Ullrich von Bassewitz */
|
||||
/* Roemerstrasse 52 */
|
||||
/* D-70794 Filderstadt */
|
||||
/* EMail: uz@cc65.org */
|
||||
/* */
|
||||
/* */
|
||||
/* This software is provided 'as-is', without any expressed or implied */
|
||||
@@ -37,7 +37,7 @@
|
||||
#define FILEPATH_H
|
||||
|
||||
|
||||
|
||||
|
||||
/* common */
|
||||
#include "searchpath.h"
|
||||
|
||||
@@ -49,9 +49,9 @@
|
||||
|
||||
|
||||
|
||||
#define SEARCH_LIB 0x0001U /* Library path */
|
||||
#define SEARCH_OBJ 0x0002U /* Object file path */
|
||||
#define SEARCH_CFG 0x0004U /* Config file path */
|
||||
extern SearchPath* LibSearchPath; /* Library path */
|
||||
extern SearchPath* ObjSearchPath; /* Object file path */
|
||||
extern SearchPath* CfgSearchPath; /* Config file path */
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 1998-2009, Ullrich von Bassewitz */
|
||||
/* (C) 1998-2010, Ullrich von Bassewitz */
|
||||
/* Roemerstrasse 52 */
|
||||
/* D-70794 Filderstadt */
|
||||
/* EMail: uz@cc65.org */
|
||||
@@ -177,11 +177,11 @@ static void LinkFile (const char* Name, FILETYPE Type)
|
||||
switch (Type) {
|
||||
|
||||
case FILETYPE_LIB:
|
||||
PathName = SearchFile (Name, SEARCH_LIB);
|
||||
PathName = SearchFile (LibSearchPath, Name);
|
||||
break;
|
||||
|
||||
case FILETYPE_OBJ:
|
||||
PathName = SearchFile (Name, SEARCH_OBJ);
|
||||
PathName = SearchFile (ObjSearchPath, Name);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -282,7 +282,7 @@ static void DefineSymbol (const char* Def)
|
||||
static void OptCfgPath (const char* Opt attribute ((unused)), const char* Arg)
|
||||
/* Specify a config file search path */
|
||||
{
|
||||
AddSearchPath (Arg, SEARCH_CFG);
|
||||
AddSearchPath (CfgSearchPath, Arg);
|
||||
}
|
||||
|
||||
|
||||
@@ -296,7 +296,7 @@ static void OptConfig (const char* Opt attribute ((unused)), const char* Arg)
|
||||
Error ("Cannot use -C/-t twice");
|
||||
}
|
||||
/* Search for the file */
|
||||
PathName = SearchFile (Arg, SEARCH_CFG);
|
||||
PathName = SearchFile (CfgSearchPath, Arg);
|
||||
if (PathName == 0) {
|
||||
Error ("Cannot find config file `%s'", Arg);
|
||||
} else {
|
||||
@@ -405,7 +405,7 @@ static void OptLib (const char* Opt attribute ((unused)), const char* Arg)
|
||||
static void OptLibPath (const char* Opt attribute ((unused)), const char* Arg)
|
||||
/* Specify a library file search path */
|
||||
{
|
||||
AddSearchPath (Arg, SEARCH_LIB);
|
||||
AddSearchPath (LibSearchPath, Arg);
|
||||
}
|
||||
|
||||
|
||||
@@ -441,7 +441,7 @@ static void OptObj (const char* Opt attribute ((unused)), const char* Arg)
|
||||
static void OptObjPath (const char* Opt attribute ((unused)), const char* Arg)
|
||||
/* Specify an object file search path */
|
||||
{
|
||||
AddSearchPath (Arg, SEARCH_OBJ);
|
||||
AddSearchPath (ObjSearchPath, Arg);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user