1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 09:46:02 +02:00
This commit is contained in:
John Dallaway 2025-05-30 18:00:43 +01:00 committed by GitHub
commit f31c30ec31
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2010, 2016 Nokia Siemens Networks Oyj, Finland. * Copyright (c) 2010, 2025 Nokia Siemens Networks Oyj, Finland.
* *
* This program and the accompanying materials * This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0 * are made available under the terms of the Eclipse Public License 2.0
@ -13,11 +13,13 @@
* Leo Hippelainen - Initial implementation * Leo Hippelainen - Initial implementation
* Petri Tuononen - Initial implementation * Petri Tuononen - Initial implementation
* Marc-Andre Laperle (Ericsson) * Marc-Andre Laperle (Ericsson)
* John Dallaway - Improve LLVM tools installation detection (#1175)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.managedbuilder.llvm.ui; package org.eclipse.cdt.managedbuilder.llvm.ui;
import java.io.File; import java.io.File;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import org.eclipse.cdt.internal.core.MinGW; import org.eclipse.cdt.internal.core.MinGW;
import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IConfiguration;
@ -48,6 +50,7 @@ public class LlvmEnvironmentVariableSupplier implements IConfigurationEnvironmen
private static final String ENV_VAR_NAME_INCLUDE_PATH = "INCLUDE_PATH"; //$NON-NLS-1$ private static final String ENV_VAR_NAME_INCLUDE_PATH = "INCLUDE_PATH"; //$NON-NLS-1$
private static final String ENV_VAR_NAME_LIBRARY_PATH = "LLVM_LIB_SEARCH_PATH"; //$NON-NLS-1$ private static final String ENV_VAR_NAME_LIBRARY_PATH = "LLVM_LIB_SEARCH_PATH"; //$NON-NLS-1$
private static final String ENV_VAR_NAME_LIBRARIES = "LIBRARIES"; //$NON-NLS-1$ private static final String ENV_VAR_NAME_LIBRARIES = "LIBRARIES"; //$NON-NLS-1$
private static final List<String> LLVM_BIN_SELECTION_TOOLS = List.of("llvm-ar", "clang"); //$NON-NLS-1$ //$NON-NLS-2$
/** /**
* Initializes llvm environment variable paths from the system environment variables. * Initializes llvm environment variable paths from the system environment variables.
@ -268,7 +271,7 @@ public class LlvmEnvironmentVariableSupplier implements IConfigurationEnvironmen
llvmPath = llvmPath + Separators.getFileSeparator() + subPath; llvmPath = llvmPath + Separators.getFileSeparator() + subPath;
} }
// Return a full path for LLVM executable if it's valid, otherwise null. // Return a full path for LLVM executable if it's valid, otherwise null.
return getBinDirIfLlvm_ar(llvmPath); return getBinDirIfLlvm(llvmPath);
} }
/** /**
@ -276,23 +279,24 @@ public class LlvmEnvironmentVariableSupplier implements IConfigurationEnvironmen
* as a parameter is found and executable exists in that path. * as a parameter is found and executable exists in that path.
* *
* @param binPathTemp User provided bin directory path * @param binPathTemp User provided bin directory path
* @return bin path where llvm-ar is located if executable exists * @return bin path where LLVM is located if executable exists
*/ */
private static String getBinDirIfLlvm_ar(String binPathTemp) { private static String getBinDirIfLlvm(String binPathTemp) {
//if given directory is found //if given directory is found
if (new Path(binPathTemp).toFile().isDirectory()) { if (new Path(binPathTemp).toFile().isDirectory()) {
String llvm_executable = "llvm-ar"; //$NON-NLS-1$ for (String llvm_executable : LLVM_BIN_SELECTION_TOOLS) {
File arFileFullPath = null; File arFileFullPath = null;
// If OS is Windows -> add .exe to the executable name. // If OS is Windows -> add .exe to the executable name.
if (System.getProperty("os.name").toLowerCase().indexOf("win") >= 0) { //$NON-NLS-1$//$NON-NLS-2$ if (System.getProperty("os.name").toLowerCase().indexOf("win") >= 0) { //$NON-NLS-1$//$NON-NLS-2$
llvm_executable = llvm_executable + ".exe"; //$NON-NLS-1$ llvm_executable = llvm_executable + ".exe"; //$NON-NLS-1$
} }
// Form full executable path // Form full executable path
arFileFullPath = new File(binPathTemp, llvm_executable); arFileFullPath = new File(binPathTemp, llvm_executable);
// Check if file exists -> proper LLVM installation exists. // Check if file exists -> proper LLVM installation exists.
if (arFileFullPath.isFile()) { if (arFileFullPath.isFile()) {
// Return path where llvm-ar exists. // Return path where LLVM executable exists.
return binPathTemp; return binPathTemp;
}
} }
} }
return null; return null;