1 /*********************************************************************
3 * Copyright 2011 Intel Corporation
6 * Permission is hereby granted, free of charge, to any person
7 * obtaining a copy of this software and associated documentation
8 * files (the "Software"), to deal in the Software without
9 * restriction, including without limitation the rights to use, copy,
10 * modify, merge, publish, distribute, sublicense, and/or sell copies
11 * of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be
15 * included in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
21 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
22 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 *********************************************************************/
31 #include "os_string.hpp"
33 #include "cli_resources.hpp"
37 findProgram(const char*programFilename)
39 os::String programPath;
41 os::String processDir = os::getProcessName();
42 processDir.trimFilename();
44 programPath = processDir;
45 programPath.join(programFilename);
46 if (programPath.exists()) {
51 // Try absolute install directory
52 programPath = APITRACE_PROGRAMS_INSTALL_DIR;
53 programPath.join(programFilename);
54 if (programPath.exists()) {
63 findWrapper(const char *wrapperFilename)
65 os::String wrapperPath;
67 os::String processDir = os::getProcessName();
68 processDir.trimFilename();
70 // Try relative build directory
71 // XXX: Just make build and install directory layout match
72 wrapperPath = processDir;
73 wrapperPath.join("wrappers");
74 wrapperPath.join(wrapperFilename);
75 if (wrapperPath.exists()) {
79 // Try relative install directory
80 wrapperPath = processDir;
82 wrapperPath.join("..\\lib\\wrappers");
83 #elif defined(__APPLE__)
84 wrapperPath.join("../lib/wrappers");
86 wrapperPath.join("../lib/apitrace/wrappers");
88 wrapperPath.join(wrapperFilename);
89 if (wrapperPath.exists()) {
94 // Try absolute install directory
95 wrapperPath = APITRACE_WRAPPERS_INSTALL_DIR;
96 wrapperPath.join(wrapperFilename);
97 if (wrapperPath.exists()) {
106 findScript(const char *scriptFilename)
108 os::String scriptPath;
110 os::String processDir = os::getProcessName();
111 processDir.trimFilename();
113 // Try relative build directory
114 // XXX: Just make build and install directory layout match
115 scriptPath = processDir;
116 scriptPath.join("scripts");
117 scriptPath.join(scriptFilename);
118 if (scriptPath.exists()) {
122 // Try relative install directory
123 scriptPath = processDir;
125 scriptPath.join("..\\lib\\scripts");
126 #elif defined(__APPLE__)
127 scriptPath.join("../lib/scripts");
129 scriptPath.join("../lib/apitrace/scripts");
131 scriptPath.join(scriptFilename);
132 if (scriptPath.exists()) {
137 // Try absolute install directory
138 scriptPath = APITRACE_SCRIPTS_INSTALL_DIR;
139 scriptPath.join(scriptFilename);
140 if (scriptPath.exists()) {
145 std::cerr << "error: cannot find " << scriptFilename << " script\n";