Add -ii option to change default include path

This commit is contained in:
drmortalwombat 2025-05-11 18:29:57 +02:00
parent ba05ec743d
commit 6fe76e478f
3 changed files with 40 additions and 31 deletions

View File

@ -110,6 +110,7 @@ The compiler is command line driven, and creates an executable .prg file.
* -v : verbose output for diagnostics
* -v2 : more verbose output
* -i : additional include paths
* -ii : set default include path
* -o : optional output file name
* -rt : alternative runtime library, replaces the crt.c (or empty for none)
* -e : execute the result in the integrated emulator
@ -129,6 +130,7 @@ The compiler is command line driven, and creates an executable .prg file.
* -Oz : enable auto placement of global variables in zero page (part of O3)
* -Op : optimize constant parameters
* -Oo : optimize size using "outliner" (extract repeated code sequences into functions)
* -Ox : optimize pointer arithmetic by blocking shorter arrays to not cross page boundaries
* -g : create source level debug info and add source line numbers to asm listing
* -gp : create source level debug info and add source line numbers to asm listing and static profile data
* -tf : target format, may be prg, crt or bin

View File

@ -5,7 +5,7 @@
#define JUMP_TO_BRANCH 1
#define CHECK_NULLPTR 0
#define REYCLE_JUMPS 1
#define DISASSEMBLE_OPT 1
#define DISASSEMBLE_OPT 0
static bool CheckFunc;
static bool CheckCase;

View File

@ -111,38 +111,12 @@ int main2(int argc, const char** argv)
GrowingArray<const char*> dataFiles(nullptr);
GrowingArray<bool> dataFileCompressed(false);
bool emulate = false, profile = false, customCRT = false;
int trace = 0;
compiler->mPreprocessor->AddPath(basePath);
strcpy_s(includePath, basePath);
{
FILE* crtFile;
char crtFileNamePath[FILENAME_MAX];
crtFileNamePath[FILENAME_MAX - 1] = '\0';
strcpy_s(crtFileNamePath, basePath);
strcat_s(crtFileNamePath, "include/crt.h");
if (!fopen_s(&crtFile, crtFileNamePath, "r"))
strcat_s(includePath, "include/");
else
{
strcpy_s(crtFileNamePath, basePath);
strcat_s(crtFileNamePath, "include/oscar64/crt.h");
if (!fopen_s(&crtFile, crtFileNamePath, "r"))
strcat_s(includePath, "include/oscar64/");
else
{
printf("Could not locate Oscar64 includes under %s\n", basePath);
return 20;
}
}
fclose(crtFile);
}
compiler->mPreprocessor->AddPath(includePath);
strcpy_s(crtPath, includePath);
strcat_s(crtPath, "crt.c");
bool emulate = false, profile = false;
int trace = 0;
strcat_s(includePath, "include");
targetPath[0] = 0;
diskPath[0] = 0;
@ -185,6 +159,10 @@ int main2(int argc, const char** argv)
{
compiler->mPreprocessor->AddPath(arg + 3);
}
else if (arg[1] == 'i' && arg[2] == 'i' && arg[3] == '=')
{
strcpy_s(includePath, arg + 4);
}
else if (arg[1] == 'f' && arg[2] == '=')
{
dataFiles.Push(arg + 3);
@ -578,6 +556,35 @@ int main2(int argc, const char** argv)
// Add runtime module
compiler->mPreprocessor->AddPath(includePath);
if (!customCRT)
{
FILE* crtFile;
char crtFileNamePath[FILENAME_MAX];
crtFileNamePath[FILENAME_MAX - 1] = '\0';
strcpy_s(crtFileNamePath, includePath);
strcat_s(crtFileNamePath, "/crt.h");
if (fopen_s(&crtFile, crtFileNamePath, "r"))
{
strcpy_s(crtFileNamePath, basePath);
strcat_s(crtFileNamePath, "include/oscar64/crt.h");
if (!fopen_s(&crtFile, crtFileNamePath, "r"))
strcat_s(includePath, "include/oscar64/");
else
{
printf("Could not locate Oscar64 includes under %s\n", basePath);
return 20;
}
}
fclose(crtFile);
strcpy_s(crtPath, includePath);
strcat_s(crtPath, "/crt.c");
}
if (crtPath[0])
compiler->mCompilationUnits->AddUnit(loc, crtPath, nullptr);