Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authorLeo Treggiari2005-05-31 20:45:39 +0000
committerLeo Treggiari2005-05-31 20:45:39 +0000
commitbaf9bdc130983a34f377cac90306dbf88e85a579 (patch)
tree11920dc914b5426012aab8008648494500c74e4c /build
parent03a6a074aed01a01d6be53f1954366ac3f1bb329 (diff)
downloadorg.eclipse.cdt-baf9bdc130983a34f377cac90306dbf88e85a579.tar.gz
org.eclipse.cdt-baf9bdc130983a34f377cac90306dbf88e85a579.tar.xz
org.eclipse.cdt-baf9bdc130983a34f377cac90306dbf88e85a579.zip
Add new class GnuLinkOutputNameProvider
Diffstat (limited to 'build')
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuLinkOutputNameProvider.java102
1 files changed, 102 insertions, 0 deletions
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuLinkOutputNameProvider.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuLinkOutputNameProvider.java
new file mode 100644
index 00000000000..e6151940585
--- /dev/null
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/GnuLinkOutputNameProvider.java
@@ -0,0 +1,102 @@
+/**********************************************************************
+ * Copyright (c) 2005 Intel Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * Intel Corporation - Initial API and implementation
+ **********************************************************************/
+
+package org.eclipse.cdt.managedbuilder.makegen.gnu;
+
+import org.eclipse.cdt.managedbuilder.core.IManagedOutputNameProvider;
+import org.eclipse.cdt.managedbuilder.core.IOption;
+import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+
+//
+// This class provides a name for the Gnu Linker tool when it is not used
+// as the target tool of a tool-chain
+//
+public class GnuLinkOutputNameProvider implements IManagedOutputNameProvider {
+
+ public IPath[] getOutputNames(ITool tool, IPath[] primaryInputNames) {
+ IPath[] name = new IPath[1];
+
+ // Determine a default name from the input file name
+ String fileName = "default"; //$NON-NLS-1$
+ if (primaryInputNames != null && primaryInputNames.length > 0) {
+ fileName = primaryInputNames[0].removeFileExtension().lastSegment();
+ if (fileName.startsWith("$(") && fileName.endsWith(")")) { //$NON-NLS-1$ //$NON-NLS-2$
+ fileName = fileName.substring(2,fileName.length()-1);
+ }
+ }
+
+ // If we are building a shared library, determine if the user has specified a name using the
+ // soname option
+ boolean isSO = false;
+ String soName = ""; //$NON-NLS-1$
+ if (hasAncestor(tool, "cdt.managedbuild.tool.gnu.c.linker")) { //$NON-NLS-1$
+ IOption optShared = tool.getOptionBySuperClassId("gnu.c.link.option.shared"); //$NON-NLS-1$
+ if (optShared != null) {
+ try {
+ isSO = optShared.getBooleanValue();
+ } catch (Exception e) {}
+ }
+ if (isSO) {
+ IOption optSOName = tool.getOptionBySuperClassId("gnu.c.link.option.soname"); //$NON-NLS-1$
+ if (optSOName != null) {
+ try {
+ soName = optSOName.getStringValue();
+ } catch (Exception e) {}
+ }
+ }
+ } else
+ if (hasAncestor(tool, "cdt.managedbuild.tool.gnu.cpp.linker")) { //$NON-NLS-1$
+ IOption optShared = tool.getOptionBySuperClassId("gnu.cpp.link.option.shared"); //$NON-NLS-1$
+ if (optShared != null) {
+ try {
+ isSO = optShared.getBooleanValue();
+ } catch (Exception e) {}
+ }
+ if (isSO) {
+ IOption optSOName = tool.getOptionBySuperClassId("gnu.cpp.link.option.soname"); //$NON-NLS-1$
+ if (optSOName != null) {
+ try {
+ soName = optSOName.getStringValue();
+ } catch (Exception e) {}
+ }
+ }
+ }
+
+ // If this is a shared library, use the specified name
+ if (isSO && soName != null && soName.length() > 0) {
+ fileName = soName;
+ } else {
+ // Add the outputPrefix
+ String outputPrefix = tool.getPrimaryOutputType().getOutputPrefix();
+ if (outputPrefix != null && outputPrefix.length() > 0) {
+ fileName = outputPrefix + fileName;
+ }
+ // Add the primary output type extension
+ String[] exts = tool.getPrimaryOutputType().getOutputExtensions();
+ if (exts != null && exts[0].length() > 0) {
+ fileName += IManagedBuilderMakefileGenerator.DOT + exts[0];
+ }
+ }
+
+ name[0] = Path.fromOSString(fileName);
+ return name;
+ }
+
+ protected boolean hasAncestor(ITool tool, String id) {
+ do {
+ if (id.equals(tool.getId())) return true;
+ } while ((tool = tool.getSuperClass()) != null);
+ return false;
+ }
+}

Back to the top