X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=cli%2Fcli_diff.cpp;h=76cdce1d6f0dc3874366370419070e766668ace9;hb=7a9fb5103e052150232b64cb5d99374cda3f1234;hp=4d249739e373fd4e6213db4a828c2fad89ccc325;hpb=03c5d3d41dc219051cbbb8b84ea505e15ff433c4;p=apitrace diff --git a/cli/cli_diff.cpp b/cli/cli_diff.cpp index 4d24973..76cdce1 100644 --- a/cli/cli_diff.cpp +++ b/cli/cli_diff.cpp @@ -29,20 +29,33 @@ #include #include "cli.hpp" -#include "os_path.hpp" +#include "os_string.hpp" #include "os_process.hpp" -#include "trace_tools.hpp" +#include "cli_resources.hpp" static const char *synopsis = "Identify differences between two traces."; +static os::String +find_command(void) +{ + return findScript("tracediff.py"); +} + static void usage(void) { - std::cout - << "usage: apitrace diff \n" - << synopsis << "\n" - "\n" - " Both input files should be the result of running 'apitrace trace'.\n"; + os::String command = find_command(); + if (!command.length()) { + exit(1); + } + + char *args[4]; + args[0] = (char *) "python"; + args[1] = (char *) command.str(); + args[2] = (char *) "--help"; + args[3] = NULL; + + os::execute(args); } static int @@ -50,59 +63,24 @@ command(int argc, char *argv[]) { int i; - for (i = 0; i < argc; ++i) { - const char *arg = argv[i]; - - if (arg[0] != '-') { - break; - } - - if (!strcmp(arg, "--")) { - i++; - break; - } else if (!strcmp(arg, "--help")) { - usage(); - return 0; - } else { - std::cerr << "error: unknown option " << arg << "\n"; - usage(); - return 1; - } - } - - if (argc - i != 2) { - std::cerr << "Error: diff requires exactly two trace files as arguments.\n"; - usage(); + os::String command = find_command(); + if (!command.length()) { return 1; } - char *file1, *file2; - - file1 = argv[i]; - file2 = argv[i+1]; - -#define CLI_DIFF_TRACEDIFF_COMMAND "tracediff.sh" - - os::Path command = trace::findFile("scripts/" CLI_DIFF_TRACEDIFF_COMMAND, - APITRACE_SCRIPTS_INSTALL_DIR "/" CLI_DIFF_TRACEDIFF_COMMAND, - true); + os::String apitracePath = os::getProcessName(); - char* args[4]; - - args[0] = (char *) command.str(); - args[1] = file1; - args[2] = file2; - args[3] = NULL; - -#ifdef _WIN32 - std::cerr << "The 'apitrace diff' command is not yet supported on this O/S.\n"; - return 1; -#else - os::Path apitrace = os::getProcessName(); - setenv("APITRACE", apitrace.str(), 1); + std::vector args; + args.push_back("python"); + args.push_back(command.str()); + args.push_back("--apitrace"); + args.push_back(apitracePath.str()); + for (i = 1; i < argc; i++) { + args.push_back(argv[i]); + } + args.push_back(NULL); - return os::execute(args); -#endif + return os::execute((char * const *)&args[0]); } const Command diff_command = {