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