1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 17:05:26 +02:00

gcc cross compiler integration plugin.

This commit is contained in:
Doug Schaefer 2009-04-17 19:15:56 +00:00
parent d849341ad4
commit 1042ed5f25
11 changed files with 501 additions and 0 deletions

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.cdt.build.crossgcc</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View file

@ -0,0 +1,8 @@
#Sun Mar 22 23:47:05 PDT 2009
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6

View file

@ -0,0 +1,13 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Good
Bundle-SymbolicName: org.eclipse.cdt.build.crossgcc;singleton:=true
Bundle-Version: 1.0.0
Bundle-Activator: org.eclipse.cdt.internal.build.crossgcc.Activator
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.cdt.managedbuilder.core;bundle-version="5.0.100",
org.eclipse.cdt.managedbuilder.gnu.ui;bundle-version="5.0.100",
org.eclipse.cdt.core;bundle-version="5.1.0",
org.eclipse.core.resources;bundle-version="3.5.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6

View file

@ -0,0 +1,5 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.xml

View file

@ -0,0 +1,190 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.cdt.managedbuilder.core.buildDefinitions">
<managedBuildRevision
fileVersion="4.0.0">
</managedBuildRevision>
<toolChain
archList="all"
configurationEnvironmentSupplier="org.eclipse.cdt.internal.build.crossgcc.CrossEnvironmentVariableSupplier"
id="cdt.managedbuild.toolchain.gnu.cross.base"
isAbstract="false"
name="Cross GCC"
osList="all">
<targetPlatform
archList="all"
binaryParser="org.eclipse.cdt.core.ELF"
id="cdt.managedbuild.targetPlatform.gnu.cross"
isAbstract="false"
osList="all">
</targetPlatform>
<builder
id="cdt.managedbuild.builder.gnu.cross"
isAbstract="false"
isVariableCaseSensitive="false"
superClass="org.eclipse.cdt.build.core.internal.builder">
</builder>
<optionCategory
id="cdt.managedbuild.optionCategory.gnu.cross.settings"
name="Cross Settings">
</optionCategory>
<option
category="cdt.managedbuild.optionCategory.gnu.cross.settings"
id="cdt.managedbuild.option.gnu.cross.prefix"
isAbstract="false"
name="Prefix"
resourceFilter="all"
valueType="string">
</option>
<option
browseType="directory"
category="cdt.managedbuild.optionCategory.gnu.cross.settings"
id="cdt.managedbuild.option.gnu.cross.path"
isAbstract="false"
name="Path"
resourceFilter="all"
valueType="string">
</option>
<tool
commandLineGenerator="org.eclipse.cdt.internal.build.crossgcc.CrossCommandLineGenerator"
id="cdt.managedbuild.tool.gnu.cross.cpp.compiler"
isAbstract="false"
name="Cross G++ Compiler"
superClass="cdt.managedbuild.tool.gnu.cpp.compiler">
</tool>
<tool
commandLineGenerator="org.eclipse.cdt.internal.build.crossgcc.CrossCommandLineGenerator"
id="cdt.managedbuild.tool.gnu.cross.cpp.linker"
isAbstract="false"
name="Cross G++ Linker"
superClass="cdt.managedbuild.tool.gnu.cpp.linker">
</tool>
</toolChain>
<projectType
buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe"
id="cdt.managedbuild.target.gnu.cross.exe"
isAbstract="false"
isTest="false"
>
<configuration
name="Debug"
cleanCommand="rm -rf"
id="cdt.managedbuild.config.gnu.cross.exe.debug"
parent="cdt.managedbuild.config.gnu.base"
buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug">
<toolChain
superClass="cdt.managedbuild.toolchain.gnu.cross.base"
id="cdt.managedbuild.toolchain.gnu.cross.exe.debug">
</toolChain>
</configuration>
<configuration
name="Release"
cleanCommand="rm -rf"
id="cdt.managedbuild.config.gnu.cross.exe.release"
parent="cdt.managedbuild.config.gnu.base"
buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release">
<toolChain
superClass="cdt.managedbuild.toolchain.gnu.cross.base"
id="cdt.managedbuild.toolchain.gnu.cross.exe.release">
</toolChain>
</configuration>
</projectType>
<projectType
buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.sharedLib"
id="cdt.managedbuild.target.gnu.cross.so"
isAbstract="false"
isTest="false"
>
<configuration
name="Debug"
cleanCommand="rm -rf"
parent="cdt.managedbuild.config.gnu.base"
buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug"
id="cdt.managedbuild.config.gnu.cross.so.debug">
<toolChain
superClass="cdt.managedbuild.toolchain.gnu.cross.base"
id="cdt.managedbuild.toolchain.gnu.cross.so.debug">
</toolChain>
</configuration>
<configuration
name="Release"
cleanCommand="rm -rf"
parent="cdt.managedbuild.config.gnu.base"
buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release"
id="cdt.managedbuild.config.gnu.cross.so.release">
<toolChain
superClass="cdt.managedbuild.toolchain.gnu.cross.base"
id="cdt.managedbuild.toolchain.gnu.cross.so.release">
</toolChain>
</configuration>
</projectType>
<projectType
buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.staticLib"
id="cdt.managedbuild.target.gnu.cross.lib"
isAbstract="false"
isTest="false"
>
<configuration
name="Debug"
parent="cdt.managedbuild.config.gnu.base"
buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug"
cleanCommand="rm -rf"
id="cdt.managedbuild.config.gnu.cross.lib.debug">
<toolChain
superClass="cdt.managedbuild.toolchain.gnu.cross.base"
id="cdt.managedbuild.toolchain.gnu.cross.lib.debug">
</toolChain>
</configuration>
<configuration
name="Release"
parent="cdt.managedbuild.config.gnu.base"
buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release"
cleanCommand="rm -rf"
id="cdt.managedbuild.config.gnu.cross.lib.release">
<toolChain
superClass="cdt.managedbuild.toolchain.gnu.cross.base"
id="cdt.managedbuild.toolchain.gnu.cross.lib.release">
</toolChain>
</configuration>
</projectType>
</extension>
<extension
point="org.eclipse.cdt.core.templateProcessTypes">
<processType
name="setCrossCommand"
processRunner="org.eclipse.cdt.build.crossgcc.SetCrossCommandProcess">
<simple
name="projectName">
</simple>
<simple
name="prefix">
</simple>
<simple
name="path">
</simple>
</processType>
</extension>
<extension
point="org.eclipse.cdt.core.templates">
<template
id="tut.cross.good.setCrossCommand"
location="templates/setCrossCommand/template.xml"
projectType="org.eclipse.cdt.build.core.buildArtefactType.exe">
</template>
</extension>
<extension
point="org.eclipse.cdt.core.templateAssociations">
<template
id="tut.cross.good.setCrossCommand">
<toolChain
id="cdt.managedbuild.toolchain.gnu.cross.base">
</toolChain>
</template>
</extension>
</plugin>

View file

@ -0,0 +1,66 @@
package org.eclipse.cdt.build.crossgcc;
import java.util.Map;
import org.eclipse.cdt.build.core.scannerconfig.CfgInfoContext;
import org.eclipse.cdt.build.core.scannerconfig.ICfgScannerConfigBuilderInfo2Set;
import org.eclipse.cdt.build.internal.core.scannerconfig2.CfgScannerConfigProfileManager;
import org.eclipse.cdt.core.templateengine.TemplateCore;
import org.eclipse.cdt.core.templateengine.process.ProcessArgument;
import org.eclipse.cdt.core.templateengine.process.ProcessFailureException;
import org.eclipse.cdt.core.templateengine.process.ProcessRunner;
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
public class SetCrossCommandProcess extends ProcessRunner {
@Override
public void process(TemplateCore template, ProcessArgument[] args,
String processId, IProgressMonitor monitor)
throws ProcessFailureException {
String projectName = args[0].getSimpleValue();
String prefix = args[1].getSimpleValue();
String path = args[2].getSimpleValue();
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
if (!project.exists())
return;
IManagedBuildInfo buildInfo = ManagedBuildManager.getBuildInfo(project);
if (buildInfo == null)
return;
IConfiguration[] configs = buildInfo.getManagedProject().getConfigurations();
for (IConfiguration config : configs) {
IToolChain toolchain = config.getToolChain();
IOption option = toolchain.getOptionBySuperClassId("cdt.managedbuild.option.gnu.cross.prefix");
ManagedBuildManager.setOption(config, toolchain, option, prefix);
option = toolchain.getOptionBySuperClassId("cdt.managedbuild.option.gnu.cross.path");
ManagedBuildManager.setOption(config, toolchain, option, path);
ICfgScannerConfigBuilderInfo2Set cbi = CfgScannerConfigProfileManager.getCfgScannerConfigBuildInfo(config);
Map<CfgInfoContext, IScannerConfigBuilderInfo2> map = cbi.getInfoMap();
IScannerConfigBuilderInfo2 bi = map.values().iterator().next();
String providerId = "specsFile";
String runCommand = bi.getProviderRunCommand(providerId);
bi.setProviderRunCommand(providerId, prefix + runCommand);
try {
bi.save();
} catch (CoreException e) {
throw new ProcessFailureException(e);
}
}
ManagedBuildManager.saveBuildInfo(project, true);
}
}

View file

@ -0,0 +1,50 @@
package org.eclipse.cdt.internal.build.crossgcc;
import org.eclipse.core.runtime.Plugin;
import org.osgi.framework.BundleContext;
/**
* The activator class controls the plug-in life cycle
*/
public class Activator extends Plugin {
// The plug-in ID
public static final String PLUGIN_ID = "tut.cross.good";
// The shared instance
private static Activator plugin;
/**
* The constructor
*/
public Activator() {
}
/*
* (non-Javadoc)
* @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
}
/*
* (non-Javadoc)
* @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}
/**
* Returns the shared instance
*
* @return the shared instance
*/
public static Activator getDefault() {
return plugin;
}
}

View file

@ -0,0 +1,24 @@
package org.eclipse.cdt.internal.build.crossgcc;
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo;
import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.internal.core.ManagedCommandLineGenerator;
public class CrossCommandLineGenerator extends ManagedCommandLineGenerator {
@Override
public IManagedCommandLineInfo generateCommandLineInfo(ITool tool,
String commandName, String[] flags, String outputFlag,
String outputPrefix, String outputName, String[] inputResources,
String commandLinePattern) {
IToolChain toolchain = (IToolChain)tool.getParent();
IOption option = toolchain.getOptionBySuperClassId("cdt.managedbuild.option.gnu.cross.prefix");
String prefix = (String)option.getValue();
String newCommandName = prefix + commandName;
return super.generateCommandLineInfo(tool, newCommandName, flags, outputFlag,
outputPrefix, outputName, inputResources, commandLinePattern);
}
}

View file

@ -0,0 +1,77 @@
package org.eclipse.cdt.internal.build.crossgcc;
import java.io.File;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
import org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSupplier;
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider;
import org.eclipse.core.runtime.Platform;
public class CrossEnvironmentVariableSupplier implements
IConfigurationEnvironmentVariableSupplier {
@Override
public IBuildEnvironmentVariable getVariable(String variableName,
IConfiguration configuration, IEnvironmentVariableProvider provider) {
if (PathEnvironmentVariable.isVar(variableName))
return PathEnvironmentVariable.create(configuration);
else
return null;
}
@Override
public IBuildEnvironmentVariable[] getVariables(
IConfiguration configuration, IEnvironmentVariableProvider provider) {
IBuildEnvironmentVariable path = PathEnvironmentVariable.create(configuration);
return path != null ? new IBuildEnvironmentVariable[] { path } : new IBuildEnvironmentVariable[0];
}
private static class PathEnvironmentVariable implements IBuildEnvironmentVariable {
public static String name = "PATH";
private File path;
private PathEnvironmentVariable(File path) {
this.path = path;
}
public static PathEnvironmentVariable create(IConfiguration configuration) {
IToolChain toolchain = configuration.getToolChain();
IOption option = toolchain.getOptionBySuperClassId("cdt.managedbuild.option.gnu.cross.path");
String path = (String)option.getValue();
return new PathEnvironmentVariable(new File(path, "bin"));
}
public static boolean isVar(String name) {
// Windows has case insensitive env var names
return Platform.getOS().equals(Platform.OS_WIN32)
? name.equalsIgnoreCase(PathEnvironmentVariable.name)
: name.equals(PathEnvironmentVariable.name);
}
@Override
public String getDelimiter() {
return Platform.getOS().equals(Platform.OS_WIN32) ? ";" : ":";
}
@Override
public String getName() {
return name;
}
@Override
public int getOperation() {
return IBuildEnvironmentVariable.ENVVAR_PREPEND;
}
@Override
public String getValue() {
return path.getAbsolutePath();
}
}
}

View file

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<template type="ProjTempl" version="1.0" supplier="Eclipse.org" revision="1.0" author="EclipseCon"
copyright="Copyright (c) 2009 EclipseCon 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"
id="EmptyProject" label="Cross-Compile Project" description="Set up a cross compiler"
help="help.html">
<property-group id="command" label="Command" description="The Cross Compile Command" type="PAGES-ONLY" help="help.html">
<property id="prefix"
label="Tool command prefix"
description="The prefix to attach to the build commands, e.g. gcc"
type="input"
pattern=".*"
default=""
hidden="false"
persist="true"/>
<property id="path"
label="Tool command path"
description="The root directory for the toolchain"
type="browsedir"
pattern=".*"
default=""
hidden="false"
persist="true"/>
</property-group>
<process type="tut.cross.good.setCrossCommand">
<simple name="projectName" value="$(projectName)"/>
<simple name="prefix" value="$(prefix)"/>
<simple name="path" value="$(path)"/>
</process>
</template>