All: Add --version flag
Jeffrey Pfau jeffrey@endrift.com
Tue, 20 Oct 2015 22:27:27 -0700
5 files changed,
34 insertions(+),
2 deletions(-)
M
CHANGES
→
CHANGES
@@ -31,6 +31,7 @@ - GBA BIOS: Implement RegisterRamReset for SIO registers
- GBA: Additional savestate sanity checks - GBA: Check for cycle count being too high - All: Reset next event to cycles instead of zero to interrupt + - All: Add --version flag 0.3.0: (2015-08-16) Features:
M
src/platform/commandline.c
→
src/platform/commandline.c
@@ -47,6 +47,7 @@ #endif
{ "help", no_argument, 0, 'h' }, { "movie", required_argument, 0, 'v' }, { "patch", required_argument, 0, 'p' }, + { "version", no_argument, 0, '\0' }, { 0, 0, 0, 0 } };@@ -68,8 +69,17 @@ if (subparser && subparser->extraOptions) {
// TODO: modularize options to subparsers strncat(options, subparser->extraOptions, sizeof(options) - strlen(options) - 1); } - while ((ch = getopt_long(argc, argv, options, _options, 0)) != -1) { + int index = 0; + while ((ch = getopt_long(argc, argv, options, _options, &index)) != -1) { + const struct option* opt = &_options[index]; switch (ch) { + case '\0': + if (strcmp(opt->name, "version") == 0) { + opts->showVersion = true; + } else { + return false; + } + break; case 'b': GBAConfigSetDefaultValue(config, "bios", optarg); break;@@ -122,7 +132,7 @@ }
argc -= optind; argv += optind; if (argc != 1) { - return opts->showHelp; + return opts->showHelp || opts->showVersion; } opts->fname = strdup(argv[0]); return true;@@ -226,7 +236,12 @@ #endif
puts(" -v, --movie FILE Play back a movie of recorded input"); puts(" -p, --patch FILE Apply a specified patch file when running"); puts(" -s, --frameskip N Skip every N frames"); + puts(" --version Print version and exit"); if (extraOptions) { puts(extraOptions); } } + +void version(const char* arg0) { + printf("%s %s (%s)\n", arg0, projectVersion, gitCommit); +}
M
src/platform/commandline.h
→
src/platform/commandline.h
@@ -31,6 +31,7 @@
enum DebuggerType debuggerType; bool debugAtStart; bool showHelp; + bool showVersion; }; struct SubParser {@@ -51,6 +52,7 @@ struct SubParser* subparser);
void freeArguments(struct GBAArguments* opts); void usage(const char* arg0, const char* extraOptions); +void version(const char* arg0); void initParserForGraphics(struct SubParser* parser, struct GraphicsOpts* opts); struct ARMDebugger* createDebugger(struct GBAArguments* opts, struct GBAThread* context);
M
src/platform/perf-main.c
→
src/platform/perf-main.c
@@ -77,6 +77,13 @@ GBAConfigFreeOpts(&opts);
GBAConfigDeinit(&config); return !parsed; } + if (args.showVersion) { + version(argv[0]); + freeArguments(&args); + GBAConfigFreeOpts(&opts); + GBAConfigDeinit(&config); + return 0; + } renderer.outputBuffer = malloc(256 * 256 * 4); renderer.outputBufferStride = 256;
M
src/platform/sdl/main.c
→
src/platform/sdl/main.c
@@ -67,6 +67,13 @@ GBAConfigFreeOpts(&opts);
GBAConfigDeinit(&config); return !parsed; } + if (args.showVersion) { + version(argv[0]); + freeArguments(&args); + GBAConfigFreeOpts(&opts); + GBAConfigDeinit(&config); + return 0; + } GBAConfigMap(&config, &opts);