Get extapi.bc path
| 134 | |
| 135 | // Get extapi.bc path |
| 136 | std::string ExtAPI::getExtBcPath() |
| 137 | { |
| 138 | // Try to locate extapi.bc in the following order: |
| 139 | // 1. If setExtBcPath() has been called, use that path. |
| 140 | // 2. If the command line argument -extapi=path/to/extapi.bc is provided, use that path. |
| 141 | // 3. If SVF is being developed and used directly from a build directory, try the build dir (SVF_BUILD_DIR). |
| 142 | // 4. If the SVF_DIR environment variable is set, try $SVF_DIR with the standard relative path. |
| 143 | // 5. If installed via npm, use `npm root` and append the standard relative path. |
| 144 | // 6. As a last resort, use the directory of the loaded libSVFCore.so (or .dylib) and append extapi.bc. |
| 145 | |
| 146 | std::vector<std::string> candidatePaths; |
| 147 | |
| 148 | // 1. Use path set by setExtBcPath() |
| 149 | if (!extBcPath.empty()) |
| 150 | return extBcPath; |
| 151 | |
| 152 | // 2. Use command line argument -extapi=... |
| 153 | if (setExtBcPath(Options::ExtAPIPath())) |
| 154 | { |
| 155 | return extBcPath; |
| 156 | } |
| 157 | else |
| 158 | { |
| 159 | candidatePaths.push_back(Options::ExtAPIPath()); |
| 160 | } |
| 161 | |
| 162 | // 3. SVF developer: try build directory (SVF_BUILD_DIR) |
| 163 | if (setExtBcPath(SVF_BUILD_DIR "/lib/extapi.bc")) |
| 164 | { |
| 165 | return extBcPath; |
| 166 | } |
| 167 | else |
| 168 | { |
| 169 | candidatePaths.push_back(SVF_BUILD_DIR "/lib/extapi.bc"); |
| 170 | } |
| 171 | |
| 172 | // 4. Use $SVF_DIR environment variable + standard relative path |
| 173 | if (setExtBcPath(getFilePath("SVF_DIR"))) |
| 174 | { |
| 175 | return extBcPath; |
| 176 | } |
| 177 | else |
| 178 | { |
| 179 | candidatePaths.push_back(getFilePath("SVF_DIR")); |
| 180 | } |
| 181 | |
| 182 | // 5. Use npm root + standard relative path (for npm installations) |
| 183 | if (setExtBcPath(getFilePath("npm root"))) |
| 184 | { |
| 185 | return extBcPath; |
| 186 | } |
| 187 | else |
| 188 | { |
| 189 | candidatePaths.push_back(getFilePath("npm root")); |
| 190 | } |
| 191 | |
| 192 | // 6. Use the directory of the loaded libSVFCore.so/.dylib + extapi.bc |
| 193 | std::string soPath = getCurrentSOPath(); |
no test coverage detected