all repos — mgba @ cd2443356b3e6a6b19d15511de3531354591873e

mGBA Game Boy Advance Emulator

All: Add --version flag
Jeffrey Pfau jeffrey@endrift.com
Tue, 20 Oct 2015 22:27:27 -0700
commit

cd2443356b3e6a6b19d15511de3531354591873e

parent

c82f0ba5de8fefbb0d0bc51f5296d06df01a5b2c

M CHANGESCHANGES

@@ -46,6 +46,7 @@ - GBA: Check for cycle count being too high

- GBA Config: Add "override" layer for better one-time configuration - SDL: Allow GBASDLAudio to be used without a thread context - All: Improved PowerPC support + - All: Add --version flag 0.3.0: (2015-08-16) Features:
M src/platform/commandline.csrc/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': GBAConfigSetOverrideValue(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;

@@ -228,7 +238,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.hsrc/platform/commandline.h

@@ -31,6 +31,7 @@

enum DebuggerType debuggerType; bool debugAtStart; bool showHelp; + bool showVersion; }; struct SubParser {

@@ -52,6 +53,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/sdl/main.csrc/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);
M src/platform/test/fuzz-main.csrc/platform/test/fuzz-main.c

@@ -67,6 +67,13 @@ freeArguments(&args);

GBAContextDeinit(&context); return !parsed; } + if (args.showVersion) { + version(argv[0]); + freeArguments(&args); + GBAConfigFreeOpts(&opts); + GBAConfigDeinit(&config); + return 0; + } struct GBAVideoSoftwareRenderer renderer; renderer.outputBuffer = 0;
M src/platform/test/perf-main.csrc/platform/test/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;