|
1 | 1 | /******************************************************************************* |
2 | | - * Copyright (c) 2010, 2016 Nokia Siemens Networks Oyj, Finland. |
| 2 | + * Copyright (c) 2010, 2025 Nokia Siemens Networks Oyj, Finland. |
3 | 3 | * |
4 | 4 | * This program and the accompanying materials |
5 | 5 | * are made available under the terms of the Eclipse Public License 2.0 |
|
13 | 13 | * Leo Hippelainen - Initial implementation |
14 | 14 | * Petri Tuononen - Initial implementation |
15 | 15 | * Marc-Andre Laperle (Ericsson) |
| 16 | + * John Dallaway - Improve LLVM tools installation detection (#1175) |
16 | 17 | *******************************************************************************/ |
17 | 18 | package org.eclipse.cdt.managedbuilder.llvm.ui; |
18 | 19 |
|
19 | 20 | import java.io.File; |
20 | 21 | import java.util.HashMap; |
| 22 | +import java.util.List; |
21 | 23 |
|
22 | 24 | import org.eclipse.cdt.internal.core.MinGW; |
23 | 25 | import org.eclipse.cdt.managedbuilder.core.IConfiguration; |
@@ -48,6 +50,7 @@ public class LlvmEnvironmentVariableSupplier implements IConfigurationEnvironmen |
48 | 50 | private static final String ENV_VAR_NAME_INCLUDE_PATH = "INCLUDE_PATH"; //$NON-NLS-1$ |
49 | 51 | private static final String ENV_VAR_NAME_LIBRARY_PATH = "LLVM_LIB_SEARCH_PATH"; //$NON-NLS-1$ |
50 | 52 | private static final String ENV_VAR_NAME_LIBRARIES = "LIBRARIES"; //$NON-NLS-1$ |
| 53 | + private static final List<String> LLVM_BIN_SELECTION_TOOLS = List.of("llvm-ar", "clang"); //$NON-NLS-1$ //$NON-NLS-2$ |
51 | 54 |
|
52 | 55 | /** |
53 | 56 | * Initializes llvm environment variable paths from the system environment variables. |
@@ -268,31 +271,32 @@ private static String getDirIfLlvmFound(String candidatePath, String subPath) { |
268 | 271 | llvmPath = llvmPath + Separators.getFileSeparator() + subPath; |
269 | 272 | } |
270 | 273 | // Return a full path for LLVM executable if it's valid, otherwise null. |
271 | | - return getBinDirIfLlvm_ar(llvmPath); |
| 274 | + return getBinDirIfLlvm(llvmPath); |
272 | 275 | } |
273 | 276 |
|
274 | 277 | /** |
275 | 278 | * Returns the full path for llvm executable if the bin path given |
276 | 279 | * as a parameter is found and executable exists in that path. |
277 | 280 | * |
278 | 281 | * @param binPathTemp User provided bin directory path |
279 | | - * @return bin path where llvm-ar is located if executable exists |
| 282 | + * @return bin path where LLVM is located if executable exists |
280 | 283 | */ |
281 | | - private static String getBinDirIfLlvm_ar(String binPathTemp) { |
| 284 | + private static String getBinDirIfLlvm(String binPathTemp) { |
282 | 285 | //if given directory is found |
283 | 286 | if (new Path(binPathTemp).toFile().isDirectory()) { |
284 | | - String llvm_executable = "llvm-ar"; //$NON-NLS-1$ |
285 | | - File arFileFullPath = null; |
286 | | - // If OS is Windows -> add .exe to the executable name. |
287 | | - if (System.getProperty("os.name").toLowerCase().indexOf("win") >= 0) { //$NON-NLS-1$//$NON-NLS-2$ |
288 | | - llvm_executable = llvm_executable + ".exe"; //$NON-NLS-1$ |
289 | | - } |
290 | | - // Form full executable path |
291 | | - arFileFullPath = new File(binPathTemp, llvm_executable); |
292 | | - // Check if file exists -> proper LLVM installation exists. |
293 | | - if (arFileFullPath.isFile()) { |
294 | | - // Return path where llvm-ar exists. |
295 | | - return binPathTemp; |
| 287 | + for (String llvm_executable : LLVM_BIN_SELECTION_TOOLS) { |
| 288 | + File arFileFullPath = null; |
| 289 | + // If OS is Windows -> add .exe to the executable name. |
| 290 | + if (System.getProperty("os.name").toLowerCase().indexOf("win") >= 0) { //$NON-NLS-1$//$NON-NLS-2$ |
| 291 | + llvm_executable = llvm_executable + ".exe"; //$NON-NLS-1$ |
| 292 | + } |
| 293 | + // Form full executable path |
| 294 | + arFileFullPath = new File(binPathTemp, llvm_executable); |
| 295 | + // Check if file exists -> proper LLVM installation exists. |
| 296 | + if (arFileFullPath.isFile()) { |
| 297 | + // Return path where LLVM executable exists. |
| 298 | + return binPathTemp; |
| 299 | + } |
296 | 300 | } |
297 | 301 | } |
298 | 302 | return null; |
|
0 commit comments