1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-30 21:55:31 +02:00

RESOLVED - bug 256172: Add XLC v10.1 support feature

https://bugs.eclipse.org/bugs/show_bug.cgi?id=256172
This commit is contained in:
Chris Recoskie 2008-12-02 20:24:47 +00:00
parent 9888670468
commit 130514d961
11 changed files with 566 additions and 53 deletions

View file

@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.cdt.managedbuilder.xlc.ui; singleton := true
Bundle-Version: 5.0.0.qualifier
Bundle-Version: 6.0.0.qualifier
Bundle-Activator: org.eclipse.cdt.managedbuilder.xlc.ui.XLCUIPlugin
Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui,

View file

@ -61,6 +61,7 @@ OptionCategory.Comp = Compatibility
OptionCategory.Misc=Miscellaneous
OptionCategory.Assembler=Assembler Options
OptionCategory.General=General
OptionCategory.objcc=Object code control
# generic names used by multiple options
@ -170,11 +171,16 @@ Option.funcset=Place instructions for each function in a separate object file co
Option.ppline=Enable generation of #line directive in the preprocessed output (-qppline)
Option.upconv=Preserve the unsigned specification when performing integral promotions (-qupconv)
Option.namemangling=Name mangling scheme for external symbol names (-qnamemangling=)
Option.namemangling.v10.name=Name mangling scheme for external symbol names (-qnamemangling=)
Option.namemangling.ansi = ANSI (-qnamemangling=ansi)
Option.namemangling.v6 = VisualAge(R) C++ v6 (-qnamemangling=v6)
Option.namemangling.v5 = VisualAge(R) C++ v5 (-qnamemangling=v5)
Option.namemangling.v4 = VisualAge(R) C++ v4 (-qnamemangling=v4)
Option.namemangling.v3 = Compatibility mode (-qnamemangling=v3)
Option.namemangling.v7=IBM XL C/C++ v7 (-qnamemangling=v7)
Option.namemangling.v8=IBM XL C/C++ v8 (-qnamemangling=v8)
Option.namemangling.v9=IBM XL C/C++ v9 (-qnamemangling=v9)
Option.namemangling.v10=IBM XL C/C++ v10 (-qnamemangling=v10)
Option.objectmodel = Object model (-qobjmodel=)
Option.objectmodel.classic = classic (-qobjmodel=classic)
Option.objectmodel.ibm = IBM(R) (-qobjmodel=ibm)
@ -187,9 +193,15 @@ Option.staticinline = Treat inline functions as static (-qstaticinline)
Option.statsym = Add static variables to the symbol table (-qstatsym)
Option.threaded = Enable multi-threaded execution (-qthreaded)
Option.unique = Generate unique names for static constructor/deconstructor file compilation units (-qunique)
Option.unique.v10 = Generate unique names for static constructor/deconstructor file compilation units (-qunique)
Option.novftable = Do not generate virtual function table (-qnovftable)
Option.vrsave = Maintain the VRSAVE register (-qvrsave)
Option.weaksymbol = Generate weak symbols (-qweaksymbol)
Option.macros=Emit macro definitions to preprocessed output (-qshowmacros)
Option.macros.all=all (-qshowmacros=all)
Option.macros.pre=predefined (-qshowmacros=pre)
Option.macros.nopre=no macros (-qshowmacros=nopre)
Options.timestamps=Suppress insert of implicit timestamps into an object file (-qnotimestamps)
# Optimization options
Option.OptLevel = Optimization level
@ -253,8 +265,12 @@ Option.optimization.procunknown = Mark functions as unknown (-qprocunknown=)
Option.optimization.showpdf = Add additional call and block count profiling information to the executable (-qshowpdf)
Option.optimization.smallstack = Reduce the size of the stack frame (-qsmallstack)
Option.optimization.smp = Enable parallelization of code (-qsmp)
Option.optimization.smp.v10 = Specify parallelization of code (-qsmp=name1:name2:...:nameN)
Option.optimization.smp.v10.tooltip=Possible values: nostackcheck, opt, norec_locks, noomp, nonested_par, \nexplicit, auto, omp, nested_par, noauto, noexplicit, noopt, rec_locks, \nschedule=(runtime | auto | affinity=n | dynamic=n | guided=n | static=n), stackcheck, threshold=n
Option.optimization.Spill = Specify the register allocation spill area (-qspill=)
Option.optimization.Strict = Turn off aggressive optimizations (-qstrict)
Option.optimization.Strict=Turn off aggressive optimizations (-qstrict)
Option.optimization.Strict.v10 = Specify the optimizations (-qstrict=name1:name2:...:nameN)
Option.optimization.Strict.v10.tooltip=Possible values: all, none, precision, noprecision, exceptions, noexceptions, \nieeefp, noieeefp, nans, nonans, infinities, noinfinities, subnormals, nosubnormals, \nzerosigns, nozerosigns, operationprecision, nooperationprecision, order, noorder, \nassociation, noassociation, reductionorder, noreductionorder, guards, noguards, library, nolibrary
Option.optimization.loopinduction = Loop induction settings
Option.optimization.strict_induction = Strict induction
Option.optimization.nostrict_induction = No induction
@ -328,6 +344,13 @@ Option.t = Add prefix to designated programs (-t)
Option.maxmem = Amount of memory used during optimization (-qmaxmem=)
Option.path = Alternate program name for compiler components (-qpath=)
Option.tls = Specify the thread local storage model (-qtls=)
Option.tls.unsupported=unsupported
Option.tls.default=default
Option.tls.global-dynamic=global-dynamic
Option.tls.initial-exec=initial-exec
Option.tls.local-dynamic=local-dynamic
Option.tls.local-exec=local-exec
Option.tls.notls=No tls
# Listings and Messages options
Option.V = Report information on the progress of compilation (-V)
@ -349,7 +372,7 @@ Option.halt.warning = Warning (-qhalt=w)
Option.halt.error = Error (-qhalt=e)
Option.halt.severeError = Severe error (-qhalt=s)
Option.halt.unrecoverableError = Unrecoverable error (-qhalt=u)
Option.info = Produce informational messages (-qinfo= )
Option.info = Produce informational messages (-qinfo=)
Option.list = Produce a compiler listing that includes an object listing (-qlist)
Option.listopt = Produce a compiler listing that displays all options in effect(-qlistopt)
Option.phsinfo = Report the time taken in each compilation phase (-qphsinfo)

View file

@ -218,6 +218,17 @@
builtIn="true"
value="__IBMC__">
</listOptionValue>
</option>
<option
applicabilityCalculator="org.eclipse.cdt.managedbuilder.xlc.ui.properties.XLCApplicabilityCalculator"
category="xlc.c.compiler.category.objcc"
command="-qunique"
defaultValue="false"
id="org.eclipse.cdt.managedbuilder.xlc.ui.cpp.option.output.unique.v10"
isAbstract="false"
name="%Option.unique.v10"
resourceFilter="all"
valueType="boolean">
</option>
</tool>
<tool
@ -275,6 +286,7 @@
valueType="string">
</option>
<option
applicabilityCalculator="org.eclipse.cdt.managedbuilder.xlc.ui.properties.XLCApplicabilityCalculator"
category="xlc.c.compiler.category.output"
id="org.eclipse.cdt.managedbuilder.xlc.ui.cpp.option.namemangling"
isAbstract="false"
@ -312,6 +324,66 @@
name="%Option.namemangling.v3">
</enumeratedOptionValue>
</option>
<option
applicabilityCalculator="org.eclipse.cdt.managedbuilder.xlc.ui.properties.XLCApplicabilityCalculator"
category="xlc.c.compiler.category.output"
id="org.eclipse.cdt.managedbuilder.xlc.ui.cpp.option.namemangling.v10"
isAbstract="false"
name="%Option.namemangling.v10.name"
resourceFilter="all"
valueType="enumerated">
<enumeratedOptionValue
id="org.eclipse.cdt.managedbuilder.xlc.ui.cpp.option.namemangling.default"
isDefault="true"
name="%Option.default">
</enumeratedOptionValue>
<enumeratedOptionValue
command="-qnamemangling=ansi"
id="org.eclipse.cdt.managedbuilder.xlc.ui.cpp.option.namemangling.ansi"
name="%Option.namemangling.ansi">
</enumeratedOptionValue>
<enumeratedOptionValue
command="-qnamemangling=v10"
id="org.eclipse.cdt.managedbuilder.xlc.ui.cpp.option.namemangling.v10"
name="%Option.namemangling.v10">
</enumeratedOptionValue>
<enumeratedOptionValue
command="-qnamemangling=v9"
id="org.eclipse.cdt.managedbuilder.xlc.ui.cpp.option.namemangling.v9"
name="%Option.namemangling.v9">
</enumeratedOptionValue>
<enumeratedOptionValue
command="-qnamemangling=v8"
id="org.eclipse.cdt.managedbuilder.xlc.ui.cpp.option.namemangling.v8"
name="%Option.namemangling.v8">
</enumeratedOptionValue>
<enumeratedOptionValue
command="-qnamemangling=v7"
id="org.eclipse.cdt.managedbuilder.xlc.ui.cpp.option.namemangling.v7"
name="%Option.namemangling.v7">
</enumeratedOptionValue>
<enumeratedOptionValue
command="-qnamemangling=v6"
id="org.eclipse.cdt.managedbuilder.xlc.ui.enumeratedOptionValue22"
name="%Option.namemangling.v6">
</enumeratedOptionValue>
<enumeratedOptionValue
command="-qnamemangling=v5"
id="org.eclipse.cdt.managedbuilder.xlc.ui.cpp.option.namemangling.v5"
name="%Option.namemangling.v5">
</enumeratedOptionValue>
<enumeratedOptionValue
command="-qnamemangling=v4"
id="org.eclipse.cdt.managedbuilder.xlc.ui.cpp.option.namemangling.v4"
name="%Option.namemangling.v4">
</enumeratedOptionValue>
<enumeratedOptionValue
command="-qnamemangling=v3"
id="org.eclipse.cdt.managedbuilder.xlc.ui.cpp.option.namemangling.v3"
name="%Option.namemangling.v3">
</enumeratedOptionValue>
</option>
<option
category="xlc.c.compiler.category.output"
id="org.eclipse.cdt.managedbuilder.xlc.ui.cpp.option.objectmodel"
@ -370,7 +442,7 @@
</enumeratedOptionValue>
</option>
<option
category="xlc.c.compiler.category.output"
category="xlc.c.compiler.category.objcc"
command="-qunique"
defaultValue="false"
id="org.eclipse.cdt.managedbuilder.xlc.ui.cpp.option.output.unique"
@ -572,6 +644,7 @@
superClass="cdt.managedbuild.tool.xlc.assembler">
</tool>
</toolChain>
</configuration>
</projectType>
@ -836,6 +909,7 @@
</toolChain>
</configuration>
</projectType>
<tool
id="org.eclipse.cdt.managedbuilder.xlc.ui.tool.abstractCompiler"
isAbstract="true"
@ -1589,7 +1663,7 @@
</enumeratedOptionValue>
</option>
<option
applicabilityCalculator="org.eclipse.cdt.managedbuilder.xlc.ui.properties.XLCv8ApplicabiltyCalculator"
applicabilityCalculator="org.eclipse.cdt.managedbuilder.xlc.ui.properties.XLCApplicabilityCalculator"
category="xlc.c.compiler.category.optimization"
id="xlc.c.compiler.option.optimization.arch"
name="%Option.optimization.arch"
@ -1721,7 +1795,7 @@
</enumeratedOptionValue>
</option>
<option
applicabilityCalculator="org.eclipse.cdt.managedbuilder.xlc.ui.properties.XLCv9ApplicabilityCalculator"
applicabilityCalculator="org.eclipse.cdt.managedbuilder.xlc.ui.properties.XLCApplicabilityCalculator"
category="xlc.c.compiler.category.optimization"
id="xlc.c.compiler.option.optimization.arch.9.0"
name="%Option.optimization.arch"
@ -1823,7 +1897,7 @@
</enumeratedOptionValue>
</option>
<option
applicabilityCalculator="org.eclipse.cdt.managedbuilder.xlc.ui.properties.XLCv8ApplicabiltyCalculator"
applicabilityCalculator="org.eclipse.cdt.managedbuilder.xlc.ui.properties.XLCApplicabilityCalculator"
category="xlc.c.compiler.category.optimization"
id="xlc.c.compiler.option.optimization.tune"
name="%Option.optimization.tune"
@ -1950,7 +2024,7 @@
</enumeratedOptionValue>
</option>
<option
applicabilityCalculator="org.eclipse.cdt.managedbuilder.xlc.ui.properties.XLCv9ApplicabilityCalculator"
applicabilityCalculator="org.eclipse.cdt.managedbuilder.xlc.ui.properties.XLCApplicabilityCalculator"
category="xlc.c.compiler.category.optimization"
id="xlc.c.compiler.option.optimization.tune.9.0"
name="%Option.optimization.tune"
@ -2217,12 +2291,22 @@
valueType="boolean">
</option>
<option
defaultValue="false"
name="%Option.optimization.smp"
category="xlc.c.compiler.category.optimization"
command="-qsmp"
id="xlc.c.compiler.option.optimization.smp"
valueType="boolean">
applicabilityCalculator="org.eclipse.cdt.managedbuilder.xlc.ui.properties.XLCApplicabilityCalculator"
category="xlc.c.compiler.category.optimization"
command="-qsmp"
defaultValue="false"
id="xlc.c.compiler.option.optimization.smp"
name="%Option.optimization.smp"
valueType="boolean">
</option>
<option
applicabilityCalculator="org.eclipse.cdt.managedbuilder.xlc.ui.properties.XLCApplicabilityCalculator"
category="xlc.c.compiler.category.optimization"
command="-qsmp="
id="xlc.c.compiler.option.optimization.smp.v10"
name="%Option.optimization.smp.v10"
tip="%Option.optimization.smp.v10.tooltip"
valueType="string">
</option>
<option
name="%Option.optimization.Spill"
@ -2232,12 +2316,22 @@
valueType="string">
</option>
<option
defaultValue="false"
name="%Option.optimization.Strict"
category="xlc.c.compiler.category.optimization"
command="-qstrict"
id="xlc.c.compiler.option.optimization.strict"
valueType="boolean">
applicabilityCalculator="org.eclipse.cdt.managedbuilder.xlc.ui.properties.XLCApplicabilityCalculator"
category="xlc.c.compiler.category.optimization"
command="-qstrict"
defaultValue="false"
id="xlc.c.compiler.option.optimization.strict"
name="%Option.optimization.Strict"
valueType="boolean">
</option>
<option
applicabilityCalculator="org.eclipse.cdt.managedbuilder.xlc.ui.properties.XLCApplicabilityCalculator"
category="xlc.c.compiler.category.optimization"
command="-qstrict="
id="xlc.c.compiler.option.optimization.strict.v10"
name="%Option.optimization.Strict.v10"
tip="%Option.optimization.Strict.v10.tooltip"
valueType="string">
</option>
<option
name="%Option.optimization.loopinduction"
@ -2436,11 +2530,61 @@
valueType="string">
</option>
<option
name="%Option.tls"
category="xlc.c.compiler.category.cc"
command="-qtls="
id="xlc.c.compiler.option.cc.tls"
valueType="string">
applicabilityCalculator="org.eclipse.cdt.managedbuilder.xlc.ui.properties.XLCApplicabilityCalculator"
category="xlc.c.compiler.category.cc"
command="-qtls="
id="xlc.c.compiler.option.cc.tls"
name="%Option.tls"
valueType="string">
</option>
<option
applicabilityCalculator="org.eclipse.cdt.managedbuilder.xlc.ui.properties.XLCApplicabilityCalculator"
category="xlc.c.compiler.category.objcc"
id="xlc.c.compiler.option.cc.tls.v10"
name="%Option.tls"
valueType="enumerated">
<enumeratedOptionValue
id="xlc.c.compiler.option.cc.tls.none"
isDefault="true"
name="%Option.none">
</enumeratedOptionValue>
<enumeratedOptionValue
command="-qtls=unsupported"
id="xlc.c.compiler.option.cc.tls.unsupported"
isDefault="true"
name="%Option.tls.unsupported">
</enumeratedOptionValue>
<enumeratedOptionValue
command="-qtls=default"
id="xlc.c.compiler.option.cc.tls.default"
name="%Option.tls.default">
</enumeratedOptionValue>
<enumeratedOptionValue
command="-qtls=global-dynamic"
id="xlc.c.compiler.option.cc.tls.global-dynamic"
name="%Option.tls.global-dynamic">
</enumeratedOptionValue>
<enumeratedOptionValue
command="-qtls=initial-exec"
id="xlc.c.compiler.option.cc.tls.initial-exec"
name="%Option.tls.initial-exec">
</enumeratedOptionValue>
<enumeratedOptionValue
command="-qtls=local-exec"
id="xlc.c.compiler.option.cc.tls.local-exec"
name="%Option.tls.local-exec">
</enumeratedOptionValue>
<enumeratedOptionValue
command="-qtls=local-dynamic"
id="xlc.c.compiler.option.cc.tls.local-dynamic"
name="%Option.tls.local-dynamic">
</enumeratedOptionValue>
<enumeratedOptionValue
command="-qnotls"
id="xlc.c.compiler.option.cc.tls.notls"
name="%Option.tls.notls">
</enumeratedOptionValue>
</option>
<optionCategory
name="%OptionCategory.lm"
@ -2545,7 +2689,7 @@
<option
name="%Option.info"
category="xlc.c.compiler.category.lm"
category="xlc.c.compiler.category.ecd"
command="-qinfo="
id="xlc.c.compiler.option.lm.info"
valueType="string">
@ -2805,7 +2949,7 @@
<!-- Version 9 Options -->
<option
applicabilityCalculator="org.eclipse.cdt.managedbuilder.xlc.ui.properties.XLCv9ApplicabilityCalculator"
applicabilityCalculator="org.eclipse.cdt.managedbuilder.xlc.ui.properties.XLCApplicabilityCalculator"
category="xlc.c.compiler.category.ifp"
id="xlc.c.compiler.option.ifp.dfp"
name="%Option.dfp"
@ -2828,7 +2972,7 @@
</option>
<option
applicabilityCalculator="org.eclipse.cdt.managedbuilder.xlc.ui.properties.XLCv9ApplicabilityCalculator"
applicabilityCalculator="org.eclipse.cdt.managedbuilder.xlc.ui.properties.XLCApplicabilityCalculator"
category="xlc.c.compiler.category.output"
command="-C!"
defaultValue="false"
@ -2837,7 +2981,7 @@
valueType="boolean">
</option>
<option
applicabilityCalculator="org.eclipse.cdt.managedbuilder.xlc.ui.properties.XLCv9ApplicabilityCalculator"
applicabilityCalculator="org.eclipse.cdt.managedbuilder.xlc.ui.properties.XLCApplicabilityCalculator"
category="xlc.c.compiler.category.ecd"
command="-qoptdebug"
defaultValue="false"
@ -2860,6 +3004,45 @@
buildVariable="OBJS"
id="cdt.managedbuild.tool.xlc.c.compiler.output">
</outputType>
<option
applicabilityCalculator="org.eclipse.cdt.managedbuilder.xlc.ui.properties.XLCApplicabilityCalculator"
category="xlc.c.compiler.category.output"
id="xlc.c.compiler.option.output.macros"
name="%Option.macros"
valueType="enumerated">
<enumeratedOptionValue
id="xlc.c.compiler.option.output.macros.none"
isDefault="true"
name="%Option.none">
</enumeratedOptionValue>
<enumeratedOptionValue
command="-qshowmacros=all"
id="xlc.c.compiler.option.output.macros.all"
name="%Option.macros.all">
</enumeratedOptionValue>
<enumeratedOptionValue
command="-qshowmacros=pre"
id="xlc.c.compiler.option.output.macros.pre"
name="%Option.macros.pre">
</enumeratedOptionValue>
<enumeratedOptionValue
command="-qshowmacros=nopre"
id="xlc.c.compiler.option.output.macros.nopre"
name="%Option.macros.nopre">
</enumeratedOptionValue>
</option>
<option
applicabilityCalculator="org.eclipse.cdt.managedbuilder.xlc.ui.properties.XLCApplicabilityCalculator"
category="xlc.c.compiler.category.output"
command="-qnotimestamps"
id="xlc.c.compiler.option.output.timestamps"
name="%Options.timestamps"
valueType="boolean">
</option>
<optionCategory
id="xlc.c.compiler.category.objcc"
name="%OptionCategory.objcc">
</optionCategory>
</tool>
<tool
id="org.eclipse.cdt.managedbuilder.xlc.ui.tool.abstractLinker"
@ -3098,10 +3281,6 @@
id="cdt.managedbuild.tool.xlc.c.linker.so.debug.output">
</outputType>
</tool>
</extension>
<extension
@ -3159,6 +3338,7 @@
<projectType
projectTypeID="cdt.managedbuild.target.xlc.lib">
</projectType>
</wizardPage>
</extension>
<extension

View file

@ -17,6 +17,7 @@ public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.cdt.managedbuilder.xlc.ui.messages"; //$NON-NLS-1$
public static String XLCompiler_v8;
public static String XLCompiler_v9;
public static String XLCompiler_v10;
public static String XLCompilerPreferencePage_0;
public static String XLCompilerPreferencePage_1;
public static String XLCompilerPreferencePage_2;

View file

@ -11,6 +11,7 @@
XLCompiler_v8=v8.0
XLCompiler_v9=v9.0
XLCompiler_v10=v10.1
XLCompilerPreferencePage_0=XL C/C++ Compiler Preferences
XLCompilerPreferencePage_1=Compiler Root Path:
XLCompilerPreferencePage_2=Compiler Version:

View file

@ -24,5 +24,6 @@ public class PreferenceConstants {
public static final String P_XL_COMPILER_VERSION_8_NAME = Messages.XLCompiler_v8;
public static final String P_XL_COMPILER_VERSION_9_NAME = Messages.XLCompiler_v9;
public static final String P_XL_COMPILER_VERSION_10_NAME = Messages.XLCompiler_v10;
}

View file

@ -58,16 +58,13 @@ public class XLCompilerPreferencePage
{
// always return true, as we don't want to fail cases when compiler is installed remotely
// just warn user
if (getPage() != null)
if (!super.doCheckState())
{
if (!super.doCheckState())
{
getPage().setMessage(Messages.XLCompilerPreferencePage_3, IMessageProvider.WARNING);
}
else
{
getPage().setMessage(originalMessage, 0);
}
setMessage(Messages.XLCompilerPreferencePage_3, IMessageProvider.WARNING);
}
else
{
setMessage(originalMessage);
}
return true;
@ -83,7 +80,8 @@ public class XLCompilerPreferencePage
addField(pathEditor);
String[][] versionEntries = {{PreferenceConstants.P_XL_COMPILER_VERSION_8_NAME, Messages.XLCompiler_v8},
{PreferenceConstants.P_XL_COMPILER_VERSION_9_NAME, Messages.XLCompiler_v9}};
{PreferenceConstants.P_XL_COMPILER_VERSION_9_NAME, Messages.XLCompiler_v9},
{PreferenceConstants.P_XL_COMPILER_VERSION_10_NAME, Messages.XLCompiler_v10}};
addField(new ComboFieldEditor(PreferenceConstants.P_XLC_COMPILER_VERSION,
Messages.XLCompilerPreferencePage_2, versionEntries, getFieldEditorParent()));

View file

@ -0,0 +1,279 @@
/*******************************************************************************
* Copyright (c) 2007 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.xlc.ui.properties;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.ResourceBundle;
import java.util.Set;
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IFolderInfo;
import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IOptionApplicability;
import org.eclipse.cdt.managedbuilder.xlc.ui.XLCUIPlugin;
import org.eclipse.cdt.managedbuilder.xlc.ui.preferences.PreferenceConstants;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.jface.preference.IPreferenceStore;
/**
* @author rkerimov
*
* This applicability calculator hides/shows options that are specific to the XL compiler versions
*
*/
public class XLCApplicabilityCalculator implements IOptionApplicability
{
private static final String BUNDLE_NAME = "org/eclipse/cdt/managedbuilder/xlc/ui/properties/applicability.properties";
private static final String PROP_NAME_VERSION_ORDER = "xlc.applicability.version.order";
private static final String PROP_VALUE_PLUS = "+";
private static boolean initialized;
private static List versionOrder;
private static Map applicabilityMap;
public XLCApplicabilityCalculator()
{
if (!initialized)
{
Properties props = null;
ClassLoader loader = this.getClass().getClassLoader();
InputStream input = null;
if (loader != null)
input = loader.getResourceAsStream(BUNDLE_NAME);
if (input == null)
input = ClassLoader.getSystemResourceAsStream(BUNDLE_NAME);
try
{
if (input != null)
{
props = new Properties();
props.load(input);
Set entrySet = props.entrySet();
Iterator iterator = entrySet.iterator();
while (iterator.hasNext())
{
Map.Entry entry = (Map.Entry) iterator.next();
String key = (String) entry.getKey();
String value = (String) entry.getValue();
if (value == null)
value = "";
if (key.equals(PROP_NAME_VERSION_ORDER))
{
versionOrder = new ArrayList();
String[] versions = value.split(",");
if (versions != null)
{
for (int i = 0; i < versions.length; i ++)
{
versionOrder.add(versions[i].trim());
}
}
}
else
{
if (applicabilityMap == null)
applicabilityMap = new HashMap();
List applicList = (List) applicabilityMap.get(key);
if (applicList == null)
{
applicList = new ArrayList();
applicabilityMap.put(key, applicList);
}
boolean hasGreaterOption = false;
//find if ends with + and set as separate option
if (value.endsWith(PROP_VALUE_PLUS))
{
hasGreaterOption = true;
value = value.substring(0, value.length() - PROP_VALUE_PLUS.length());
}
String[] versions = value.split(",");
if (versions != null)
{
for (int i = 0; i < versions.length; i ++)
{
applicList.add(versions[i].trim());
}
}
if (hasGreaterOption)
applicList.add(PROP_VALUE_PLUS);
}
}
}
}
catch (IOException e)
{
e.printStackTrace();
}
finally
{
if (input != null)
{
try
{
input.close();
}
catch (IOException e)
{
// ignore
}
}
}
initialized = true;
}
}
private boolean isApplicable(IBuildObject configuration, IHoldsOptions holder, IOption option)
{
// first we check the preference for this project, if it exists
IProject project = null;
if(configuration instanceof IConfiguration)
{
IConfiguration config = (IConfiguration) configuration;
IManagedProject managedProject = config.getManagedProject();
project = (IProject) managedProject.getOwner();
}
else if(configuration instanceof IFolderInfo)
{
IFolderInfo folderInfo = (IFolderInfo) configuration;
IConfiguration config = folderInfo.getParent();
IManagedProject managedProject = config.getManagedProject();
project = (IProject) managedProject.getOwner();
}
if (project == null)
return false;
String currentVersion = null;
try {
currentVersion = project.getPersistentProperty(new QualifiedName("",
PreferenceConstants.P_XLC_COMPILER_VERSION));
} catch (CoreException e) {
e.printStackTrace();
}
if(currentVersion == null)
{
// if the property isn't set, then use the workbench preference
IPreferenceStore prefStore = XLCUIPlugin.getDefault().getPreferenceStore();
currentVersion = prefStore.getString(PreferenceConstants.P_XLC_COMPILER_VERSION);
}
//if applicability list is empty that means all options applicable to all versions
if (applicabilityMap == null)
return true;
//if applicability list for this option is not defined then option has no applicability restrictions
List applicList = (List) applicabilityMap.get(option.getId());
if (applicList == null || applicList.isEmpty())
return true;
//if version is defined in the list - perfect match
if (applicList.contains(currentVersion))
return true;
//if applicability is defined as 'starting from this version and greater', i.e. 'v8.0+',
//then we need to find out if current version is greater than the last valid in the list
String lastOption = (String) applicList.get(applicList.size() - 1);
if (lastOption != null && lastOption.equals(PROP_VALUE_PLUS))
{
//if 'greater than' option is specified but no version order exists, consider config error and return false
if (versionOrder == null)
return false;
//check for the last valid version in applicability list
String validVersion = null;
//start with element before the +
for (int k = applicList.size() - 2; k >= 0; k --)
{
String version = (String) applicList.get(k);
if (versionOrder.contains(version))
{
validVersion = version;
break;
}
}
//if version that applicability starts with doesn't exist - config error
if (validVersion == null)
return false;
//compare if current compiler version is greater than the applicability version
if (versionOrder.indexOf(currentVersion) > versionOrder.indexOf(validVersion))
return true;
}
return false;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IOptionApplicability#isOptionEnabled(org.eclipse.cdt.managedbuilder.core.IBuildObject, org.eclipse.cdt.managedbuilder.core.IHoldsOptions, org.eclipse.cdt.managedbuilder.core.IOption)
*/
public boolean isOptionEnabled(IBuildObject configuration,
IHoldsOptions holder, IOption option) {
return isApplicable(configuration, holder, option);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IOptionApplicability#isOptionUsedInCommandLine(org.eclipse.cdt.managedbuilder.core.IBuildObject, org.eclipse.cdt.managedbuilder.core.IHoldsOptions, org.eclipse.cdt.managedbuilder.core.IOption)
*/
public boolean isOptionUsedInCommandLine(IBuildObject configuration,
IHoldsOptions holder, IOption option) {
return isApplicable(configuration, holder, option);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.managedbuilder.core.IOptionApplicability#isOptionVisible(org.eclipse.cdt.managedbuilder.core.IBuildObject, org.eclipse.cdt.managedbuilder.core.IHoldsOptions, org.eclipse.cdt.managedbuilder.core.IOption)
*/
public boolean isOptionVisible(IBuildObject configuration,
IHoldsOptions holder, IOption option) {
return isApplicable(configuration, holder, option);
}
}

View file

@ -45,16 +45,13 @@ public class XLCompilerPropertyPage extends FieldEditorPreferencePage implements
{
// always return true, as we don't want to fail cases when compiler is installed remotely
// just warn user
if (getPage() != null)
if (!super.doCheckState())
{
if (!super.doCheckState())
{
getPage().setMessage(Messages.XLCompilerPropertyPage_2, IMessageProvider.WARNING);
}
else
{
getPage().setMessage(originalMessage, 0);
}
setMessage(Messages.XLCompilerPropertyPage_2, IMessageProvider.WARNING);
}
else
{
setMessage(originalMessage);
}
return true;
@ -90,7 +87,8 @@ public class XLCompilerPropertyPage extends FieldEditorPreferencePage implements
fPathEditor.setStringValue(currentPath);
String[] versionEntries = {PreferenceConstants.P_XL_COMPILER_VERSION_8_NAME,
PreferenceConstants.P_XL_COMPILER_VERSION_9_NAME};
PreferenceConstants.P_XL_COMPILER_VERSION_9_NAME,
PreferenceConstants.P_XL_COMPILER_VERSION_10_NAME};
Composite versionParent = getFieldEditorParent();

View file

@ -0,0 +1,31 @@
###############################################################################
# Copyright (c) 2007, 2008 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
# http://www.eclipse.org/legal/epl-v10.html
#
# Contributors:
# IBM Corporation - initial API and implementation
###############################################################################
xlc.applicability.version.order=v8.0,v9.0,v10.1
xlc.c.compiler.option.optimization.arch=v8.0
xlc.c.compiler.option.optimization.arch.9.0=v9.0+
xlc.c.compiler.option.optimization.tune=v8.0
xlc.c.compiler.option.optimization.tune.9.0=v9.0+
xlc.c.compiler.option.ifp.dfp=v9.0+
xlc.c.compiler.option.preprocessor.PreprocessRemoveComments=v9.0+
xlc.c.compiler.option.ecd.optdebug=v9.0+
xlc.c.compiler.option.optimization.smp=v8.0,v9.0
xlc.c.compiler.option.optimization.smp.v10=v10.1
xlc.c.compiler.option.optimization.strict=v8.0,v9.0
xlc.c.compiler.option.optimization.strict.v10=v10.1
org.eclipse.cdt.managedbuilder.xlc.ui.cpp.option.output.unique.v10=v10.1
org.eclipse.cdt.managedbuilder.xlc.ui.cpp.option.namemangling=v8.0,v9.0
org.eclipse.cdt.managedbuilder.xlc.ui.cpp.option.namemangling.v10=v10.1
xlc.c.compiler.option.cc.tls=v8.0,v9.0
xlc.c.compiler.option.cc.tls.v10=v10.1
xlc.c.compiler.option.output.macros=v10.1
xlc.c.compiler.option.output.timestamps=v10.1

View file

@ -172,6 +172,7 @@ public class XLCSettingsWizardPage extends MBSCustomPage {
// populate the combo
fVersionCombo.add(PreferenceConstants.P_XL_COMPILER_VERSION_8_NAME);
fVersionCombo.add(PreferenceConstants.P_XL_COMPILER_VERSION_9_NAME);
fVersionCombo.add(PreferenceConstants.P_XL_COMPILER_VERSION_10_NAME);
// set the default based on the workbench preference
String compilerVersion = prefStore.getString(PreferenceConstants.P_XLC_COMPILER_VERSION);