From 8b954e69cb6a56e6aab7b1dc2c4abefcd9fd0712 Mon Sep 17 00:00:00 2001 From: James Blackburn Date: Sun, 13 Feb 2011 15:37:47 +0000 Subject: [PATCH] Bug 321040 - Getting Library search paths from Tool's Option --- .../cdt/managedbuilder/core/IOption.java | 16 +++++++++++--- .../managedbuilder/internal/core/Option.java | 21 +++++++++++++++++-- .../internal/core/OptionReference.java | 18 +++++++++++++++- 3 files changed, 49 insertions(+), 6 deletions(-) diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IOption.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IOption.java index 4cd39785be5..98605b465ae 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IOption.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IOption.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2010 IBM Corporation and others. + * Copyright (c) 2003, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -9,6 +9,7 @@ * IBM - Initial API and implementation * ARM Ltd. - basic tooltip support * James Blackburn (Broadcom Corp.) + * Petri Tuononen - [321040] Get Library Search Paths *******************************************************************************/ package org.eclipse.cdt.managedbuilder.core; @@ -340,8 +341,17 @@ public interface IOption extends IBuildObject { * * @since 7.0 */ - public String[] getLibraryFiles() throws BuildException ; - + public String[] getLibraryFiles() throws BuildException; + + /** + * @return an array or Strings containing the library paths + * passed to the linker. + * + * @throws BuildException if the option isn't of type IOption#LIBRARY_PATHS + * @since 8.0 + */ + public String[] getLibraryPaths() throws BuildException; + /** * @return a String containing the unique ID of the selected * enumeration in an enumerated option. For an option that has not been diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Option.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Option.java index 28bd57de110..8bd67325653 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Option.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Option.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2010 IBM Corporation and others. + * Copyright (c) 2003, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -8,6 +8,7 @@ * Contributors: * IBM - Initial API and implementation * ARM Ltd. - basic tooltip support + * Petri Tuononen - [321040] Get Library Search Paths *******************************************************************************/ package org.eclipse.cdt.managedbuilder.internal.core; @@ -1387,7 +1388,6 @@ public class Option extends BuildObject implements IOption, IBuildPropertiesRest } } - /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.core.IOption#getLibraryFiles() */ @@ -1405,6 +1405,23 @@ public class Option extends BuildObject implements IOption, IBuildPropertiesRest } } + /* (non-Javadoc) + * @see org.eclipse.cdt.managedbuilder.core.IOption#getLibraryPaths() + */ + public String[] getLibraryPaths() throws BuildException { + if (getValueType() != LIBRARY_PATHS) { + throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$ + } + @SuppressWarnings("unchecked") + ArrayList v = (ArrayList)getValue(); + if (v == null) { + return EMPTY_STRING_ARRAY; + } else { + v.trimToSize(); + return v.toArray(new String[v.size()]); + } + } + /* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.core.IOption#getDefaultEnumValue() */ diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/OptionReference.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/OptionReference.java index a5ea4c3ba33..44b4d2a4edb 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/OptionReference.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/OptionReference.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2010 IBM Corporation and others. + * Copyright (c) 2003, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -8,6 +8,7 @@ * Contributors: * IBM - Initial API and implementation * ARM Ltd. - basic tooltip support + * Petri Tuononen - [321040] Get Library Search Paths *******************************************************************************/ package org.eclipse.cdt.managedbuilder.internal.core; @@ -455,6 +456,21 @@ public class OptionReference implements IOption { throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$ } + /* (non-Javadoc) + * @see org.eclipse.cdt.managedbuilder.core.IOption#getLibraryPaths() + */ + public String[] getLibraryPaths() throws BuildException { + if (value == null) + return option.getLibraryPaths(); + else if (getValueType() == LIBRARY_PATHS) { + @SuppressWarnings("unchecked") + ArrayList list = (ArrayList)value; + return list.toArray(new String[list.size()]); + } + else + throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$ + } + /* (non-Javadoc) * @see org.eclipse.cdt.core.build.managed.IBuildObject#getName() */