Skip to content

Commit 1035ef2

Browse files
committed
Also use clang executable to identify LLVM tools installation
1 parent 5b76b3e commit 1035ef2

File tree

2 files changed

+21
-17
lines changed

2 files changed

+21
-17
lines changed

llvm/org.eclipse.cdt.managedbuilder.llvm.ui/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-Name: %pluginName
44
Bundle-SymbolicName: org.eclipse.cdt.managedbuilder.llvm.ui;singleton:=true
5-
Bundle-Version: 1.4.400.qualifier
5+
Bundle-Version: 1.4.500.qualifier
66
Bundle-Activator: org.eclipse.cdt.managedbuilder.llvm.ui.LlvmUIPlugin
77
Bundle-Vendor: %providerName
88
Bundle-Localization: plugin

llvm/org.eclipse.cdt.managedbuilder.llvm.ui/src/org/eclipse/cdt/managedbuilder/llvm/ui/LlvmEnvironmentVariableSupplier.java

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2010, 2016 Nokia Siemens Networks Oyj, Finland.
2+
* Copyright (c) 2010, 2025 Nokia Siemens Networks Oyj, Finland.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,11 +13,13 @@
1313
* Leo Hippelainen - Initial implementation
1414
* Petri Tuononen - Initial implementation
1515
* Marc-Andre Laperle (Ericsson)
16+
* John Dallaway - Improve LLVM tools installation detection (#1175)
1617
*******************************************************************************/
1718
package org.eclipse.cdt.managedbuilder.llvm.ui;
1819

1920
import java.io.File;
2021
import java.util.HashMap;
22+
import java.util.List;
2123

2224
import org.eclipse.cdt.internal.core.MinGW;
2325
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
@@ -48,6 +50,7 @@ public class LlvmEnvironmentVariableSupplier implements IConfigurationEnvironmen
4850
private static final String ENV_VAR_NAME_INCLUDE_PATH = "INCLUDE_PATH"; //$NON-NLS-1$
4951
private static final String ENV_VAR_NAME_LIBRARY_PATH = "LLVM_LIB_SEARCH_PATH"; //$NON-NLS-1$
5052
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$
5154

5255
/**
5356
* Initializes llvm environment variable paths from the system environment variables.
@@ -268,31 +271,32 @@ private static String getDirIfLlvmFound(String candidatePath, String subPath) {
268271
llvmPath = llvmPath + Separators.getFileSeparator() + subPath;
269272
}
270273
// Return a full path for LLVM executable if it's valid, otherwise null.
271-
return getBinDirIfLlvm_ar(llvmPath);
274+
return getBinDirIfLlvm(llvmPath);
272275
}
273276

274277
/**
275278
* Returns the full path for llvm executable if the bin path given
276279
* as a parameter is found and executable exists in that path.
277280
*
278281
* @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
280283
*/
281-
private static String getBinDirIfLlvm_ar(String binPathTemp) {
284+
private static String getBinDirIfLlvm(String binPathTemp) {
282285
//if given directory is found
283286
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+
}
296300
}
297301
}
298302
return null;

0 commit comments

Comments
 (0)