Added a separate include search path for binary includes. These aren't
searched any longer in the standard include path. git-svn-id: svn://svn.cc65.org/cc65/trunk@4558 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 2000-2009, Ullrich von Bassewitz */
|
||||
/* (C) 2000-2010, Ullrich von Bassewitz */
|
||||
/* Roemerstrasse 52 */
|
||||
/* D-70794 Filderstadt */
|
||||
/* EMail: uz@cc65.org */
|
||||
@@ -41,37 +41,27 @@
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Data */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
#define INC_STD 0x0001U
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Code */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
void AddIncludePath (const char* NewPath)
|
||||
void AddIncludePath (const char* NewPath, unsigned Where)
|
||||
/* Add a new include path to the existing one */
|
||||
{
|
||||
AddSearchPath (NewPath, INC_STD);
|
||||
AddSearchPath (NewPath, Where);
|
||||
}
|
||||
|
||||
|
||||
|
||||
char* FindInclude (const char* Name)
|
||||
char* FindInclude (const char* Name, unsigned Where)
|
||||
/* Find an include file. Return a pointer to a malloced area that contains
|
||||
* the complete path, if found, return 0 otherwise.
|
||||
*/
|
||||
{
|
||||
/* Search in the include directories */
|
||||
return SearchFile (Name, INC_STD);
|
||||
return SearchFile (Name, Where);
|
||||
}
|
||||
|
||||
|
||||
@@ -79,7 +69,7 @@ char* FindInclude (const char* Name)
|
||||
void ForgetAllIncludePaths (void)
|
||||
/* Remove all include search paths. */
|
||||
{
|
||||
ForgetAllSearchPaths (INC_STD);
|
||||
ForgetAllSearchPaths (INC_STD | INC_BIN);
|
||||
}
|
||||
|
||||
|
||||
@@ -88,7 +78,8 @@ void InitIncludePaths (void)
|
||||
/* Initialize the include path search list */
|
||||
{
|
||||
/* Add some standard paths to the include search path */
|
||||
AddSearchPath ("", INC_STD); /* Current directory */
|
||||
AddSearchPath ("", INC_STD); /* Current directory */
|
||||
AddSearchPath ("", INC_BIN);
|
||||
|
||||
/* Add some compiled in search paths if defined at compile time */
|
||||
#ifdef CA65_INC
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 2000-2009, Ullrich von Bassewitz */
|
||||
/* (C) 2000-2010, Ullrich von Bassewitz */
|
||||
/* Roemerstrasse 52 */
|
||||
/* D-70794 Filderstadt */
|
||||
/* EMail: uz@cc65.org */
|
||||
@@ -38,16 +38,27 @@
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Data */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
#define INC_STD 0x0001U /* Add to standard include path */
|
||||
#define INC_BIN 0x0002U /* Add to binary include path */
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Code */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
void AddIncludePath (const char* NewPath);
|
||||
void AddIncludePath (const char* NewPath, unsigned Where);
|
||||
/* Add a new include path to the existing one */
|
||||
|
||||
char* FindInclude (const char* Name);
|
||||
char* FindInclude (const char* Name, unsigned Where);
|
||||
/* Find an include file. Return a pointer to a malloced area that contains
|
||||
* the complete path, if found, return 0 otherwise.
|
||||
*/
|
||||
|
||||
@@ -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 */
|
||||
@@ -106,6 +106,7 @@ static void Usage (void)
|
||||
"\n"
|
||||
"Long options:\n"
|
||||
" --auto-import\t\tMark unresolved symbols as import\n"
|
||||
" --bin-include-dir dir\tSet a search path for binary includes\n"
|
||||
" --cpu type\t\tSet cpu type\n"
|
||||
" --debug-info\t\tAdd debug info to object file\n"
|
||||
" --feature name\tSet an emulation feature\n"
|
||||
@@ -341,6 +342,14 @@ static void OptAutoImport (const char* Opt attribute ((unused)),
|
||||
|
||||
|
||||
|
||||
static void OptBinIncludeDir (const char* Opt attribute ((unused)), const char* Arg)
|
||||
/* Add an include search path for binaries */
|
||||
{
|
||||
AddIncludePath (Arg, INC_BIN);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void OptCPU (const char* Opt attribute ((unused)), const char* Arg)
|
||||
/* Handle the --cpu option */
|
||||
{
|
||||
@@ -408,7 +417,7 @@ static void OptIgnoreCase (const char* Opt attribute ((unused)),
|
||||
static void OptIncludeDir (const char* Opt attribute ((unused)), const char* Arg)
|
||||
/* Add an include search path */
|
||||
{
|
||||
AddIncludePath (Arg);
|
||||
AddIncludePath (Arg, INC_STD);
|
||||
}
|
||||
|
||||
|
||||
@@ -785,6 +794,7 @@ int main (int argc, char* argv [])
|
||||
/* Program long options */
|
||||
static const LongOpt OptTab[] = {
|
||||
{ "--auto-import", 0, OptAutoImport },
|
||||
{ "--bin-include-dir", 1, OptBinIncludeDir },
|
||||
{ "--cpu", 1, OptCPU },
|
||||
{ "--debug-info", 0, OptDebugInfo },
|
||||
{ "--feature", 1, OptFeature },
|
||||
|
||||
@@ -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 */
|
||||
@@ -1113,8 +1113,8 @@ static void DoIncBin (void)
|
||||
F = fopen (SB_GetConstBuf (&Name), "rb");
|
||||
if (F == 0) {
|
||||
|
||||
/* Search for the file in the include directories. */
|
||||
char* PathName = FindInclude (SB_GetConstBuf (&Name));
|
||||
/* Search for the file in the binary include directory */
|
||||
char* PathName = FindInclude (SB_GetConstBuf (&Name), INC_BIN);
|
||||
if (PathName == 0 || (F = fopen (PathName, "r")) == 0) {
|
||||
/* Not found or cannot open, print an error and bail out */
|
||||
ErrorSkip ("Cannot open include file `%m%p': %s", &Name, strerror (errno));
|
||||
@@ -1135,18 +1135,18 @@ static void DoIncBin (void)
|
||||
|
||||
/* If a count was not given, calculate it now */
|
||||
if (Count < 0) {
|
||||
Count = Size - Start;
|
||||
if (Count < 0) {
|
||||
/* Nothing to read - flag this as a range error */
|
||||
ErrorSkip ("Range error");
|
||||
goto Done;
|
||||
}
|
||||
Count = Size - Start;
|
||||
if (Count < 0) {
|
||||
/* Nothing to read - flag this as a range error */
|
||||
ErrorSkip ("Range error");
|
||||
goto Done;
|
||||
}
|
||||
} else {
|
||||
/* Count was given, check if it is valid */
|
||||
if (Start + Count > Size) {
|
||||
ErrorSkip ("Range error");
|
||||
goto Done;
|
||||
}
|
||||
/* Count was given, check if it is valid */
|
||||
if (Start + Count > Size) {
|
||||
ErrorSkip ("Range error");
|
||||
goto Done;
|
||||
}
|
||||
}
|
||||
|
||||
/* Seek to the start position */
|
||||
@@ -1155,12 +1155,12 @@ static void DoIncBin (void)
|
||||
/* Read chunks and insert them into the output */
|
||||
while (Count > 0) {
|
||||
|
||||
unsigned char Buf [1024];
|
||||
unsigned char Buf [1024];
|
||||
|
||||
/* Calculate the number of bytes to read */
|
||||
/* Calculate the number of bytes to read */
|
||||
size_t BytesToRead = (Count > (long)sizeof(Buf))? sizeof(Buf) : (size_t) Count;
|
||||
|
||||
/* Read chunk */
|
||||
/* Read chunk */
|
||||
size_t BytesRead = fread (Buf, 1, BytesToRead, F);
|
||||
if (BytesToRead != BytesRead) {
|
||||
/* Some sort of error */
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 1998-2008 Ullrich von Bassewitz */
|
||||
/* Roemerstrasse 52 */
|
||||
/* D-70794 Filderstadt */
|
||||
/* EMail: uz@cc65.org */
|
||||
/* (C) 1998-2010, Ullrich von Bassewitz */
|
||||
/* Roemerstrasse 52 */
|
||||
/* D-70794 Filderstadt */
|
||||
/* EMail: uz@cc65.org */
|
||||
/* */
|
||||
/* */
|
||||
/* This software is provided 'as-is', without any expressed or implied */
|
||||
@@ -452,7 +452,7 @@ int NewInputFile (const char* Name)
|
||||
/* We are on include level. Search for the file in the include
|
||||
* directories.
|
||||
*/
|
||||
PathName = FindInclude (Name);
|
||||
PathName = FindInclude (Name, INC_STD);
|
||||
if (PathName == 0 || (F = fopen (PathName, "r")) == 0) {
|
||||
/* Not found or cannot open, print an error and bail out */
|
||||
Error ("Cannot open include file `%s': %s", Name, strerror (errno));
|
||||
|
||||
Reference in New Issue
Block a user