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"
32 #include "trace_tools.hpp"
39 findProgram(const char*programFilename)
41 os::String programPath;
43 os::String processDir = os::getProcessName();
44 processDir.trimFilename();
46 programPath = processDir;
47 programPath.join(programFilename);
48 if (programPath.exists()) {
53 // Try absolute install directory
54 programPath = APITRACE_PROGRAMS_INSTALL_DIR;
55 programPath.join(programFilename);
56 if (programPath.exists()) {
65 findWrapper(const char *wrapperFilename)
67 os::String wrapperPath;
69 os::String processDir = os::getProcessName();
70 processDir.trimFilename();
72 // Try relative build directory
73 // XXX: Just make build and install directory layout match
74 wrapperPath = processDir;
75 wrapperPath.join("wrappers");
76 wrapperPath.join(wrapperFilename);
77 if (wrapperPath.exists()) {
81 // Try relative install directory
82 wrapperPath = processDir;
84 wrapperPath.join("..\\lib\\wrappers");
85 #elif defined(__APPLE__)
86 wrapperPath.join("../lib/wrappers");
88 wrapperPath.join("../lib/apitrace/wrappers");
90 wrapperPath.join(wrapperFilename);
91 if (wrapperPath.exists()) {
96 // Try absolute install directory
97 wrapperPath = APITRACE_WRAPPERS_INSTALL_DIR;
98 wrapperPath.join(wrapperFilename);
99 if (wrapperPath.exists()) {
108 findScript(const char *scriptFilename)
110 os::String scriptPath;
112 os::String processDir = os::getProcessName();
113 processDir.trimFilename();
115 // Try relative build directory
116 // XXX: Just make build and install directory layout match
117 scriptPath = processDir;
118 scriptPath.join("scripts");
119 scriptPath.join(scriptFilename);
120 if (scriptPath.exists()) {
124 // Try relative install directory
125 scriptPath = processDir;
127 scriptPath.join("..\\lib\\scripts");
128 #elif defined(__APPLE__)
129 scriptPath.join("../lib/scripts");
131 scriptPath.join("../lib/apitrace/scripts");
133 scriptPath.join(scriptFilename);
134 if (scriptPath.exists()) {
139 // Try absolute install directory
140 scriptPath = APITRACE_SCRIPTS_INSTALL_DIR;
141 scriptPath.join(scriptFilename);
142 if (scriptPath.exists()) {
147 std::cerr << "error: cannot find " << scriptFilename << " script\n";
153 } /* namespace trace */