rickjr/bin/overlayhelper/source/overlayhelper.cpp

70 lines
1.4 KiB
C++

// overlayhelper
//
// - generate linker script crap, so that we can resolve addresses larger
// than 32-bit with mos llvm (hacky work around for 16 bit address linker)
#include <stdio.h>
#include <stdlib.h>
#include "cfile.h"
//------------------------------------------------------------------------------
void helpText()
{
printf("overlayhelper - v1.0\n");
printf("--------------------\n");
printf("Convert macros found in C code, into mos-llvm .ld linker format\n");
printf("\noverlayhelper [options] <file.c>\n");
printf(" -v verbose\n\n");
exit(-1);
}
//------------------------------------------------------------------------------
int main(int argc, char* argv[])
{
char* pInfilePath = nullptr;
bool bVerbose = false;
for (int idx = 1; idx < argc; ++idx )
{
char* arg = argv[ idx ];
if ('-' == arg[0])
{
// Parse as an option
if ('v'==arg[1])
{
bVerbose = true;
}
}
else if (nullptr == pInfilePath)
{
// Assume the first non-option is an input file path
pInfilePath = argv[ idx ];
}
else
{
// Oh Crap, we have a non-option, but we don't know what to do with
// it
printf("ERROR: Invalid option, Arg %d = %s\n\n", idx, argv[ idx ]);
helpText();
}
}
if (pInfilePath)
{
// Load the .c File
CFile *pCFile = new CFile(std::string(pInfilePath));
delete pCFile;
}
else
{
helpText();
}
return 0;
}