org.eclipse.cdt.managedbuilder.llvm.util
Class LlvmToolOptionPathUtil

java.lang.Object
  extended by org.eclipse.cdt.managedbuilder.llvm.util.LlvmToolOptionPathUtil

public class LlvmToolOptionPathUtil
extends java.lang.Object

The main purpose of this class is to add include paths and libraries and library search paths for LLVM assembler and linker Tools which are added in Preferences->LLVM to all projects and build configurations that use LLVM ToolChain. Values added in Preferences->LLVM will show in Project->Properties->C/C++ General->Paths and Symbols tabs.


Field Summary
static int INCLUDE
           
private static java.lang.String[] inputTypes
           
static int LIB
           
static int LIB_PATH
           
private static java.lang.String linkerInputType
           
 
Constructor Summary
LlvmToolOptionPathUtil()
           
 
Method Summary
private static void addIncludePathToToolOption(org.eclipse.cdt.managedbuilder.core.IConfiguration cf, org.eclipse.cdt.managedbuilder.core.ITool cfTool, org.eclipse.cdt.managedbuilder.core.IOption option, java.lang.String newIncludePath)
          Adds include path for given Build configuration's Tool's Include path Option.
private static void addInputToToolOption(org.eclipse.cdt.managedbuilder.core.IConfiguration cf, org.eclipse.cdt.managedbuilder.core.ITool cfTool, org.eclipse.cdt.managedbuilder.core.IOption option, java.lang.String newValue, java.lang.String[] existingValues)
          Adds a new value to specific Option.
private static void addLibrarySearchPathToToolOption(org.eclipse.cdt.managedbuilder.core.IConfiguration cf, org.eclipse.cdt.managedbuilder.core.ITool cfTool, org.eclipse.cdt.managedbuilder.core.IOption option, java.lang.String newSearchPath)
          Adds new Library search path for the Linker's Library search path Option.
private static void addLibraryToToolOption(org.eclipse.cdt.managedbuilder.core.IConfiguration cf, org.eclipse.cdt.managedbuilder.core.ITool cfTool, org.eclipse.cdt.managedbuilder.core.IOption option, java.lang.String newLibrary)
          Adds new Library for the Linker's Libraries Option.
static void addLlvmIncludePath(java.lang.String includePath)
          Adds new include path to LLVM Assembler's Include path option for every project in the workspace that use LLVM Toolchain and for for every build configuration.
private static boolean addLlvmIncludePathToToolOption(org.eclipse.cdt.managedbuilder.core.IConfiguration cf, java.lang.String newIncludePath)
          Adds an include path to LLVM front-end's include path option.
static void addLlvmLib(java.lang.String lib)
          Adds a new Library to LLVM linker's Libraries Option for every project in the workspace that use LLVM Toolchain and for for every build configuration.
static void addLlvmLibSearchPath(java.lang.String libDir)
          Adds a new Library search path directory to LLVM linker's Library search path Option for every project in the workspace that use LLVM Toolchain and for for every build configuration.
private static boolean addLlvmLibSearchPathToToolOption(org.eclipse.cdt.managedbuilder.core.IConfiguration cf, java.lang.String libDir)
          Adds a Library search path to LLVM linker's Library search path Option.
private static boolean addLlvmLibToToolOption(org.eclipse.cdt.managedbuilder.core.IConfiguration cf, java.lang.String lib)
          Adds a Library to LLVM linker's Libraries Option.
static java.lang.String[] addNewPathToExistingPathList(java.lang.String[] existingPaths, java.lang.String newPath)
          Adds one or more paths to the list of paths.
private static boolean addPathToSelectedToolOptionBuildConf(org.eclipse.cdt.managedbuilder.core.IConfiguration cf, java.lang.String path, int var)
          Add a path to specific build configuration's Tool option.
private static void addPathToToolOption(java.lang.String path, int var)
          Adds a path to Tool option.
static java.lang.String arrayToString(java.lang.String[] array)
          Append an array of Strings to a String separated by a path separator.
private static org.eclipse.cdt.managedbuilder.core.IConfiguration[] getAllBuildConfigs(org.eclipse.core.resources.IProject proj)
          Returns all build configurations of the project.
private static org.eclipse.cdt.managedbuilder.core.ITool getIToolByInputType(org.eclipse.cdt.managedbuilder.core.IConfiguration cf, java.lang.String ext)
          Returns ITool associated with the input extension.
private static org.eclipse.cdt.managedbuilder.core.IOption getIToolPathOption(org.eclipse.cdt.managedbuilder.core.ITool cfTool, java.lang.String optionId)
          Returns Tool's Option type by Id.
private static org.eclipse.cdt.managedbuilder.core.ITool getLlvmFrontEnd(org.eclipse.cdt.managedbuilder.core.IConfiguration cf)
          Return LLVM front-end according to the input type.
private static org.eclipse.cdt.managedbuilder.core.IOption getLlvmFrontEndIncludePathOption(org.eclipse.cdt.managedbuilder.core.IConfiguration cf)
          Returns LLVM front-end Include path Option type.
private static org.eclipse.cdt.managedbuilder.core.ITool getLlvmLinker(org.eclipse.cdt.managedbuilder.core.IConfiguration cf)
          Returns LLVM linker.
private static org.eclipse.cdt.managedbuilder.core.IOption getLlvmLinkerLibrariesOption(org.eclipse.cdt.managedbuilder.core.IConfiguration cf)
          Returns LLVM Linker Libraries Option type.
private static org.eclipse.cdt.managedbuilder.core.IOption getLlvmLinkerLibrarySearchPathOption(org.eclipse.cdt.managedbuilder.core.IConfiguration cf)
          Returns LLVM Linker Library search path Option type.
private static java.lang.String getOptionId(org.eclipse.cdt.managedbuilder.core.ITool cfTool, int optionValueType)
          Returns Tool's option id.
static org.eclipse.core.resources.IProject[] getProjectsInWorkspace()
          Returns all projects in the workspace.
private static boolean pathExists(java.lang.String path)
          Checks if a file path exists.
private static void removeIncludePathFromToolOption(org.eclipse.cdt.managedbuilder.core.IConfiguration cf, org.eclipse.cdt.managedbuilder.core.ITool cfTool, org.eclipse.cdt.managedbuilder.core.IOption option, java.lang.String removeIncludePath)
          Removes an include path from given Build configuration's Tool's Include path Option.
private static void removeInputFromToolOption(org.eclipse.cdt.managedbuilder.core.IConfiguration cf, org.eclipse.cdt.managedbuilder.core.ITool cfTool, org.eclipse.cdt.managedbuilder.core.IOption option, java.lang.String removeValue, java.lang.String[] existingValues)
          Removes a value from a specific Option.
private static void removeLibraryFromToolOption(org.eclipse.cdt.managedbuilder.core.IConfiguration cf, org.eclipse.cdt.managedbuilder.core.ITool cfTool, org.eclipse.cdt.managedbuilder.core.IOption option, java.lang.String removeLibrary)
          Removes a new Library from the Linker's Libraries Option.
private static void removeLibrarySearchPathFromToolOption(org.eclipse.cdt.managedbuilder.core.IConfiguration cf, org.eclipse.cdt.managedbuilder.core.ITool cfTool, org.eclipse.cdt.managedbuilder.core.IOption option, java.lang.String removeSearchPath)
          Removes a Library search path from the Linker's Library search path Option.
static void removeLlvmIncludePath(java.lang.String includePath)
          Removes an include path from LLVM Assembler's Include path option for every project in the workspace that use LLVM Toolchain and for for every build configuration.
private static boolean removeLlvmIncludePathFromToolOption(org.eclipse.cdt.managedbuilder.core.IConfiguration cf, java.lang.String removeIncludePath)
          Removes an include path from LLVM front-end's include path option.
static void removeLlvmLib(java.lang.String lib)
          Removes a Library to LLVM linker's Libraries Option for every project in the workspace that use LLVM Toolchain and for for every build configuration.
private static boolean removeLlvmLibFromToolOption(org.eclipse.cdt.managedbuilder.core.IConfiguration cf, java.lang.String removeLib)
          Removes a Library from LLVM linker's Libraries Option.
static void removeLlvmLibSearchPath(java.lang.String libDir)
          Removes a Library search path directory from LLVM linker's Library search path Option for every project in the workspace that use LLVM Toolchain and for for every build configuration.
private static boolean removeLlvmLibSearchPathFromToolOption(org.eclipse.cdt.managedbuilder.core.IConfiguration cf, java.lang.String removeLibDir)
          Removes a Library search path from LLVM linker's Library search path Option.
static java.lang.String[] removePathFromExistingPathList(java.lang.String[] existingPaths, java.lang.String removePath)
          Removes one path from the list of paths.
private static boolean removePathFromSelectedToolOptionBuildConf(org.eclipse.cdt.managedbuilder.core.IConfiguration cf, java.lang.String path, int var)
          Removes a path from specific build configuration's Tool option.
private static void removePathFromToolOption(java.lang.String path, int var)
          Removes a path from Tool option.
static java.lang.String[] stringToArray(java.lang.String str)
          Split paths to a String array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

linkerInputType

private static final java.lang.String linkerInputType
See Also:
Constant Field Values

inputTypes

private static final java.lang.String[] inputTypes

INCLUDE

public static final int INCLUDE
See Also:
Constant Field Values

LIB

public static final int LIB
See Also:
Constant Field Values

LIB_PATH

public static final int LIB_PATH
See Also:
Constant Field Values
Constructor Detail

LlvmToolOptionPathUtil

public LlvmToolOptionPathUtil()
Method Detail

addLlvmIncludePath

public static void addLlvmIncludePath(java.lang.String includePath)
Adds new include path to LLVM Assembler's Include path option for every project in the workspace that use LLVM Toolchain and for for every build configuration.

Parameters:
includePath - Include path for LLVM assembler's Include Option

removeLlvmIncludePath

public static void removeLlvmIncludePath(java.lang.String includePath)
Removes an include path from LLVM Assembler's Include path option for every project in the workspace that use LLVM Toolchain and for for every build configuration.

Parameters:
includePath - Include path for LLVM assembler's Include Option

addLlvmLib

public static void addLlvmLib(java.lang.String lib)
Adds a new Library to LLVM linker's Libraries Option for every project in the workspace that use LLVM Toolchain and for for every build configuration.

Parameters:
lib - Library name for the LLVM linker's Libraries Option

removeLlvmLib

public static void removeLlvmLib(java.lang.String lib)
Removes a Library to LLVM linker's Libraries Option for every project in the workspace that use LLVM Toolchain and for for every build configuration.

Parameters:
lib - Library name for the LLVM linker's Libraries Option

addLlvmLibSearchPath

public static void addLlvmLibSearchPath(java.lang.String libDir)
Adds a new Library search path directory to LLVM linker's Library search path Option for every project in the workspace that use LLVM Toolchain and for for every build configuration.

Parameters:
libDir - Library search path directory for LLVM linker's Library search path Option

removeLlvmLibSearchPath

public static void removeLlvmLibSearchPath(java.lang.String libDir)
Removes a Library search path directory from LLVM linker's Library search path Option for every project in the workspace that use LLVM Toolchain and for for every build configuration.

Parameters:
libDir - Library search path directory for LLVM linker's Library search path Option

addPathToToolOption

private static void addPathToToolOption(java.lang.String path,
                                        int var)
Adds a path to Tool option.

Parameters:
path - Path to add to Tool option
var - Tool option's value

removePathFromToolOption

private static void removePathFromToolOption(java.lang.String path,
                                             int var)
Removes a path from Tool option.

Parameters:
path - Path to remove from Tool option
var - Tool option's value

addPathToSelectedToolOptionBuildConf

private static boolean addPathToSelectedToolOptionBuildConf(org.eclipse.cdt.managedbuilder.core.IConfiguration cf,
                                                            java.lang.String path,
                                                            int var)
Add a path to specific build configuration's Tool option.

Parameters:
cf - Build configuration
path - Path or file name to add
var - Value of the option type
Returns:
boolean True if path was added successfully

removePathFromSelectedToolOptionBuildConf

private static boolean removePathFromSelectedToolOptionBuildConf(org.eclipse.cdt.managedbuilder.core.IConfiguration cf,
                                                                 java.lang.String path,
                                                                 int var)
Removes a path from specific build configuration's Tool option.

Parameters:
cf - Build configuration
path - Path or file name to remove
var - Value of the option type
Returns:
boolean True if path was removed successfully

getProjectsInWorkspace

public static org.eclipse.core.resources.IProject[] getProjectsInWorkspace()
Returns all projects in the workspace.

Returns:
IProject[]

getAllBuildConfigs

private static org.eclipse.cdt.managedbuilder.core.IConfiguration[] getAllBuildConfigs(org.eclipse.core.resources.IProject proj)
Returns all build configurations of the project.

Parameters:
proj - IProject Project
Returns:
IConfiguration[] Build configurations

addLlvmIncludePathToToolOption

private static boolean addLlvmIncludePathToToolOption(org.eclipse.cdt.managedbuilder.core.IConfiguration cf,
                                                      java.lang.String newIncludePath)
Adds an include path to LLVM front-end's include path option.

Parameters:
cf - IConfiguration Build configuration
newIncludePath - Include path to be added to LLVM front-end's Include path option

removeLlvmIncludePathFromToolOption

private static boolean removeLlvmIncludePathFromToolOption(org.eclipse.cdt.managedbuilder.core.IConfiguration cf,
                                                           java.lang.String removeIncludePath)
Removes an include path from LLVM front-end's include path option.

Parameters:
cf - IConfiguration Build configuration
removeIncludePath - Include path to be removed from LLVM front-end's Include path option

addLlvmLibToToolOption

private static boolean addLlvmLibToToolOption(org.eclipse.cdt.managedbuilder.core.IConfiguration cf,
                                              java.lang.String lib)
Adds a Library to LLVM linker's Libraries Option.

Parameters:
cf - IConfiguration Build configuration
lib - Library name
Returns:
boolean Returns true if Library Option was added successfully for the LLVM Linker.

removeLlvmLibFromToolOption

private static boolean removeLlvmLibFromToolOption(org.eclipse.cdt.managedbuilder.core.IConfiguration cf,
                                                   java.lang.String removeLib)
Removes a Library from LLVM linker's Libraries Option.

Parameters:
cf - IConfiguration Build configuration
removeLib - Library name
Returns:
boolean Returns true if Library Option was removed successfully from the LLVM Linker.

addLlvmLibSearchPathToToolOption

private static boolean addLlvmLibSearchPathToToolOption(org.eclipse.cdt.managedbuilder.core.IConfiguration cf,
                                                        java.lang.String libDir)
Adds a Library search path to LLVM linker's Library search path Option.

Parameters:
cf - IConfiguration Build configuration
libDir - Library search path
Returns:
boolean Returns true if Library search path Option was added successfully for the LLVM Linker.

removeLlvmLibSearchPathFromToolOption

private static boolean removeLlvmLibSearchPathFromToolOption(org.eclipse.cdt.managedbuilder.core.IConfiguration cf,
                                                             java.lang.String removeLibDir)
Removes a Library search path from LLVM linker's Library search path Option.

Parameters:
cf - IConfiguration Build configuration
removeLibDir - Library search path
Returns:
boolean Returns true if Library search path Option was removed successfully from the LLVM Linker.

addIncludePathToToolOption

private static void addIncludePathToToolOption(org.eclipse.cdt.managedbuilder.core.IConfiguration cf,
                                               org.eclipse.cdt.managedbuilder.core.ITool cfTool,
                                               org.eclipse.cdt.managedbuilder.core.IOption option,
                                               java.lang.String newIncludePath)
Adds include path for given Build configuration's Tool's Include path Option.

Parameters:
cf - IConfiguration Build configuration
cfTool - ITool Tool
option - Tool Option type
newIncludePath - Include path to be added to Tool's Include path option

removeIncludePathFromToolOption

private static void removeIncludePathFromToolOption(org.eclipse.cdt.managedbuilder.core.IConfiguration cf,
                                                    org.eclipse.cdt.managedbuilder.core.ITool cfTool,
                                                    org.eclipse.cdt.managedbuilder.core.IOption option,
                                                    java.lang.String removeIncludePath)
Removes an include path from given Build configuration's Tool's Include path Option.

Parameters:
cf - IConfiguration Build configuration
cfTool - ITool Tool
option - Tool Option type
removeIncludePath - Include path to be removed from Tool's Include path option

addLibraryToToolOption

private static void addLibraryToToolOption(org.eclipse.cdt.managedbuilder.core.IConfiguration cf,
                                           org.eclipse.cdt.managedbuilder.core.ITool cfTool,
                                           org.eclipse.cdt.managedbuilder.core.IOption option,
                                           java.lang.String newLibrary)
Adds new Library for the Linker's Libraries Option.

Parameters:
cf - IConfiguration Build configuration
cfTool - ITool Tool
option - Tool Option type
newLibrary - Library

removeLibraryFromToolOption

private static void removeLibraryFromToolOption(org.eclipse.cdt.managedbuilder.core.IConfiguration cf,
                                                org.eclipse.cdt.managedbuilder.core.ITool cfTool,
                                                org.eclipse.cdt.managedbuilder.core.IOption option,
                                                java.lang.String removeLibrary)
Removes a new Library from the Linker's Libraries Option.

Parameters:
cf - IConfiguration Build configuration
cfTool - ITool Tool
option - Tool Option type
removeLibrary - Library

addLibrarySearchPathToToolOption

private static void addLibrarySearchPathToToolOption(org.eclipse.cdt.managedbuilder.core.IConfiguration cf,
                                                     org.eclipse.cdt.managedbuilder.core.ITool cfTool,
                                                     org.eclipse.cdt.managedbuilder.core.IOption option,
                                                     java.lang.String newSearchPath)
Adds new Library search path for the Linker's Library search path Option.

Parameters:
cf - IConfiguration Build configuration
cfTool - ITool Tool
option - Tool Option type
newSearchPath - Library search path

removeLibrarySearchPathFromToolOption

private static void removeLibrarySearchPathFromToolOption(org.eclipse.cdt.managedbuilder.core.IConfiguration cf,
                                                          org.eclipse.cdt.managedbuilder.core.ITool cfTool,
                                                          org.eclipse.cdt.managedbuilder.core.IOption option,
                                                          java.lang.String removeSearchPath)
Removes a Library search path from the Linker's Library search path Option. Since CDT 8.0 (Bugzilla Bug 321040)

Parameters:
cf - IConfiguration Build configuration
cfTool - ITool Tool
option - Tool Option type
removeSearchPath - Library search path

addInputToToolOption

private static void addInputToToolOption(org.eclipse.cdt.managedbuilder.core.IConfiguration cf,
                                         org.eclipse.cdt.managedbuilder.core.ITool cfTool,
                                         org.eclipse.cdt.managedbuilder.core.IOption option,
                                         java.lang.String newValue,
                                         java.lang.String[] existingValues)
Adds a new value to specific Option.

Parameters:
cf - IConfiguration Build configuration
cfTool - ITool Tool
option - Tool Option type
newValue - New value to be added to the Option type
existingValues - Existing Option type values

removeInputFromToolOption

private static void removeInputFromToolOption(org.eclipse.cdt.managedbuilder.core.IConfiguration cf,
                                              org.eclipse.cdt.managedbuilder.core.ITool cfTool,
                                              org.eclipse.cdt.managedbuilder.core.IOption option,
                                              java.lang.String removeValue,
                                              java.lang.String[] existingValues)
Removes a value from a specific Option.

Parameters:
cf - IConfiguration Build configuration
cfTool - ITool Tool
option - Tool Option type
removeValue - Value to be removed from the Option type
existingValues - Existing Option type values

getLlvmFrontEnd

private static org.eclipse.cdt.managedbuilder.core.ITool getLlvmFrontEnd(org.eclipse.cdt.managedbuilder.core.IConfiguration cf)
Return LLVM front-end according to the input type.

Parameters:
cf - IConfiguration Build configuration
Returns:
ITool LLVM front-end

getLlvmLinker

private static org.eclipse.cdt.managedbuilder.core.ITool getLlvmLinker(org.eclipse.cdt.managedbuilder.core.IConfiguration cf)
Returns LLVM linker.

Parameters:
cf - IConfiguration Build configuration
Returns:
ITool LLVM linker

getIToolByInputType

private static org.eclipse.cdt.managedbuilder.core.ITool getIToolByInputType(org.eclipse.cdt.managedbuilder.core.IConfiguration cf,
                                                                             java.lang.String ext)
Returns ITool associated with the input extension.

Parameters:
cf - IConfiguration Build configuration
ext - input extension associated with ITool
Returns:
ITool Tool that matches input extension

getLlvmFrontEndIncludePathOption

private static org.eclipse.cdt.managedbuilder.core.IOption getLlvmFrontEndIncludePathOption(org.eclipse.cdt.managedbuilder.core.IConfiguration cf)
Returns LLVM front-end Include path Option type.

Parameters:
cf - IConfiguration Project build configuration
Returns:
IOption Tool option type

getLlvmLinkerLibrariesOption

private static org.eclipse.cdt.managedbuilder.core.IOption getLlvmLinkerLibrariesOption(org.eclipse.cdt.managedbuilder.core.IConfiguration cf)
Returns LLVM Linker Libraries Option type.

Parameters:
cf - IConfiguration Project build configuration
Returns:
IOption Tool option type

getLlvmLinkerLibrarySearchPathOption

private static org.eclipse.cdt.managedbuilder.core.IOption getLlvmLinkerLibrarySearchPathOption(org.eclipse.cdt.managedbuilder.core.IConfiguration cf)
Returns LLVM Linker Library search path Option type.

Parameters:
cf - IConfiguration Project build configuration
Returns:
IOption Tool option type

getOptionId

private static java.lang.String getOptionId(org.eclipse.cdt.managedbuilder.core.ITool cfTool,
                                            int optionValueType)
Returns Tool's option id.

Parameters:
cfTool - ITool Tool
optionValueType - Option's value type.
Returns:
optionId Tool's option id.

getIToolPathOption

private static org.eclipse.cdt.managedbuilder.core.IOption getIToolPathOption(org.eclipse.cdt.managedbuilder.core.ITool cfTool,
                                                                              java.lang.String optionId)
Returns Tool's Option type by Id.

Parameters:
cfTool - ITool Tool
optionId - String Tool option type id
Returns:
IOption Tool option type

addNewPathToExistingPathList

public static java.lang.String[] addNewPathToExistingPathList(java.lang.String[] existingPaths,
                                                              java.lang.String newPath)
Adds one or more paths to the list of paths.

Parameters:
existingPaths - Existing list of paths to add to
newPath - New path to add. May include multiple directories with a path delimiter java.io.File.pathSeparator (usually semicolon (Win) or colon (Linux/Mac), OS specific)
Returns:
String[] List that includes existing paths as well as new paths.

removePathFromExistingPathList

public static java.lang.String[] removePathFromExistingPathList(java.lang.String[] existingPaths,
                                                                java.lang.String removePath)
Removes one path from the list of paths.

Parameters:
existingPaths - Existing list of paths to remove from
removePath - Path to be removed.
Returns:
String[] List that includes existing paths without the path that was removed.

stringToArray

public static java.lang.String[] stringToArray(java.lang.String str)
Split paths to a String array.

Parameters:
str - String of paths separated by a path separator.
Returns:
String array containing multiple paths.

arrayToString

public static java.lang.String arrayToString(java.lang.String[] array)
Append an array of Strings to a String separated by a path separator.

Parameters:
array - An array of Strings.
Returns:
string which contains all indexes of a String array separated by a path separator.

pathExists

private static boolean pathExists(java.lang.String path)
Checks if a file path exists.

Returns:
boolean True if the file exists.