- " file named <program>.trace. That trace file can then be used\n"
- " with other apitrace utilities for replay or analysis.\n";
-}
-
-/* We only support "apitrace trace" on POSIX-like systems (not WIN32) */
-#ifndef _WIN32
-
-
-#ifdef __APPLE__
-#define CLI_TRACE_VARIABLE "DYLD_LIBRARY_PATH"
-#define CLI_TRACE_WRAPPER "OpenGL"
-#else
-#define CLI_TRACE_VARIABLE "LD_PRELOAD"
-#define CLI_TRACE_WRAPPER "glxtrace.so"
-#endif
-
-static os::Path
-find_wrapper(const char *filename)
-{
- os::Path complete;
-
- /* First look in the same directory from which this process is
- * running, (to support developers running a compiled program that
- * has not been installed. */
-#if 1
- os::Path process_dir = os::getProcessName();
-
- process_dir.trimFilename();
-
- complete = process_dir;
- complete.join("wrappers");
- complete.join(filename);
-#else
- complete = APITRACE_BINARY_DIR "/wrappers";
- complete.join(filename);
-#endif
-
- if (complete.exists())
- return complete;
-
- /* Second, look in the directory for installed wrappers. */
- complete = APITRACE_WRAPPER_INSTALL_DIR;
- complete.join(filename);
-
- if (complete.exists())
- return complete;
-
- std::cerr << "error: cannot find " << filename << " (looked in " <<
- APITRACE_WRAPPER_INSTALL_DIR << ")\n";
- exit(1);
-
- return "";
-}
-
-static int
-do_trace_posix(int argc, char *argv[])
-{
- os::Path binary = find_wrapper(CLI_TRACE_WRAPPER);
-
- /* On Mac OS X, using DYLD_LIBRARY_PATH, we actually set the
- * directory, not the file. */
-#ifdef __APPLE__
- binary.trimFilename();
-#endif
-
- if (verbose) {
- std::cerr << CLI_TRACE_VARIABLE << "=" << binary.str() << "\n";
- }
-
- setenv(CLI_TRACE_VARIABLE, binary.str(), 1);
-
- if (verbose) {
- const char *sep = "";
- for (char **arg = argv; *arg; ++arg) {
- std::cerr << *arg << sep;
- sep = " ";
- }
- std::cerr << "\n";
- }
-
- execvp(argv[0], argv);
-
- std::cerr << "Error: Failed to execute " << argv[0] << "\n";
-
- return 1;
+ " file. That trace file can then be used\n"
+ " with other apitrace utilities for replay or analysis.\n"
+ "\n"
+ " -v, --verbose verbose output\n"
+ " -a, --api API specify API to trace (gl or egl);\n"
+ " default is `gl`\n"
+ " -o, --output TRACE specify output trace file;\n"
+ " default is `PROGRAM.trace`\n";