Proper argument parsing, reenable header file generation
This commit is contained in:
parent
e152f4e626
commit
04d3edce72
@ -4,6 +4,7 @@
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <stdarg.h>
|
||||
#include <getopt.h>
|
||||
#ifdef WIN32
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
@ -32,26 +32,56 @@ static inline void FixMinGWPath(char* buf)
|
||||
int usage(const char* prog)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Usage:\n\n"
|
||||
"%s output.shbin input1.pica input2.pica ...\n", prog);
|
||||
return 0;
|
||||
"Usage: %s [options] files...\n"
|
||||
"Options:\n"
|
||||
" -o, --out=<file> Specifies the name of the SHBIN file to generate\n"
|
||||
" -h, --header=<file> Specifies the name of the header file to generate\n"
|
||||
, prog);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
if (argc < 3)
|
||||
return usage(argv[0]);
|
||||
char *shbinFile = NULL, *hFile = NULL;
|
||||
|
||||
char* shbinFile = argv[1];
|
||||
//char* hFile = argc > 3 ? argv[3] : NULL;
|
||||
static struct option long_options[] =
|
||||
{
|
||||
{ "out", required_argument, NULL, 'o' },
|
||||
{ "header", required_argument, NULL, 'h' },
|
||||
{ "help", no_argument, NULL, '?' },
|
||||
{ NULL, 0, NULL, 0 }
|
||||
};
|
||||
|
||||
int opt, optidx = 0;
|
||||
while ((opt = getopt_long(argc, argv, "o:h:?", long_options, &optidx)) != -1)
|
||||
{
|
||||
switch (opt)
|
||||
{
|
||||
case 'o': shbinFile = optarg; break;
|
||||
case 'h': hFile = optarg; break;
|
||||
default: return usage(argv[0]);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
FixMinGWPath(shbinFile);
|
||||
//FixMinGWPath(hFile);
|
||||
FixMinGWPath(hFile);
|
||||
#endif
|
||||
|
||||
if (optind == argc)
|
||||
{
|
||||
fprintf(stderr, "%s: no input files are specified\n", argv[0]);
|
||||
return usage(argv[0]);
|
||||
}
|
||||
|
||||
if (!shbinFile)
|
||||
{
|
||||
fprintf(stderr, "%s: no output file is specified\n", argv[0]);
|
||||
return usage(argv[0]);
|
||||
}
|
||||
|
||||
int rc = 0;
|
||||
for (int i = 2; i < argc; i ++)
|
||||
for (int i = optind; i < argc; i ++)
|
||||
{
|
||||
char* vshFile = argv[i];
|
||||
|
||||
@ -63,25 +93,25 @@ int main(int argc, char* argv[])
|
||||
if (!sourceCode)
|
||||
{
|
||||
fprintf(stderr, "error: cannot open input file: %s\n");
|
||||
return 1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
rc = AssembleString(sourceCode, vshFile);
|
||||
free(sourceCode);
|
||||
if (rc != 0)
|
||||
return rc;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
rc = RelocateProduct();
|
||||
if (rc != 0)
|
||||
return rc;
|
||||
return EXIT_FAILURE;
|
||||
|
||||
FileClass f(shbinFile, "wb");
|
||||
|
||||
if (f.openerror())
|
||||
{
|
||||
fprintf(stderr, "Can't open output file!");
|
||||
return 1;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
u32 progSize = g_outputBuf.size();
|
||||
@ -194,7 +224,6 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (hFile)
|
||||
{
|
||||
FILE* f2 = fopen(hFile, "w");
|
||||
@ -206,11 +235,12 @@ int main(int argc, char* argv[])
|
||||
|
||||
fprintf(f2, "// Generated by picasso\n");
|
||||
fprintf(f2, "#pragma once\n");
|
||||
const char* prefix = g_isGeoShader ? "GSH" : "VSH";
|
||||
const char* prefix = g_dvleTable.front().isGeoShader ? "GSH" : "VSH"; // WARNING: HORRIBLE HACK - PLEASE FIX!!!!!!!
|
||||
for (int i = 0; i < g_uniformCount; i ++)
|
||||
{
|
||||
Uniform& u = g_uniformTable[i];
|
||||
const char* name = u.name.c_str();
|
||||
if (*name == '_') continue; // Hidden uniform
|
||||
if (u.type == UTYPE_FVEC)
|
||||
fprintf(f2, "#define %s_FVEC_%s 0x%02X\n", prefix, name, u.pos-0x20);
|
||||
else if (u.type == UTYPE_IVEC)
|
||||
@ -227,7 +257,6 @@ int main(int argc, char* argv[])
|
||||
|
||||
fclose(f2);
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user