mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-21 21:52:10 +02:00
Bug 525591: autotools: Initial core build implementation
Add core, UI and feature plugins for the new autotools project which uses template wizard and core build. The template wizard currently supports generating a simple autotools project as described using a template manifest. The project generator sets new autotools nature associated with new autotools build config provider. The generated autotools project has been tested to compile fine with gcc (x86_64-linux-gnu-gcc) toolchain. Change-Id: I8349999d551bb693725a246340cf46266150fadc Signed-off-by: Chin Huat Ang <chin.huat.ang@intel.com>
This commit is contained in:
parent
4bf930decb
commit
a974ba9c9e
37 changed files with 886 additions and 0 deletions
17
build/org.eclipse.cdt.core.autotools-feature/.project
Normal file
17
build/org.eclipse.cdt.core.autotools-feature/.project
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>org.eclipse.cdt.core.autotools-feature</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.FeatureBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.pde.FeatureNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -0,0 +1,2 @@
|
|||
bin.includes = feature.xml,\
|
||||
feature.properties
|
|
@ -0,0 +1,17 @@
|
|||
###############################################################################
|
||||
# Copyright (c) 2017 Intel 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
|
||||
###############################################################################
|
||||
|
||||
featureName=C/C++ Autotools Build Support - Experimental
|
||||
providerName=Eclipse CDT
|
||||
description=Support for projects built using Autotools
|
||||
copyright=\
|
||||
Copyright (c) 2017 Intel Corporation and others.\n\
|
||||
All rights reserved. This program and the accompanying materials\n\
|
||||
are made available under the terms of the Eclipse Public License v1.0\n\
|
||||
which accompanies this distribution, and is available at\n\
|
||||
http://www.eclipse.org/legal/epl-v10.html
|
36
build/org.eclipse.cdt.core.autotools-feature/feature.xml
Normal file
36
build/org.eclipse.cdt.core.autotools-feature/feature.xml
Normal file
|
@ -0,0 +1,36 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<feature
|
||||
id="org.eclipse.cdt.core.autotools"
|
||||
label="%featureName"
|
||||
version="1.0.0.qualifier"
|
||||
provider-name="%providerName"
|
||||
license-feature="org.eclipse.license"
|
||||
license-feature-version="0.0.0">
|
||||
|
||||
<description>
|
||||
%description
|
||||
</description>
|
||||
|
||||
<copyright>
|
||||
%copyright
|
||||
</copyright>
|
||||
|
||||
<license url="%licenseURL">
|
||||
%license
|
||||
</license>
|
||||
|
||||
<plugin
|
||||
id="org.eclipse.cdt.core.autotools.ui"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="org.eclipse.cdt.core.autotools.core"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
</feature>
|
7
build/org.eclipse.cdt.core.autotools.core/.classpath
Normal file
7
build/org.eclipse.cdt.core.autotools.core/.classpath
Normal 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.8"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
28
build/org.eclipse.cdt.core.autotools.core/.project
Normal file
28
build/org.eclipse.cdt.core.autotools.core/.project
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>org.eclipse.cdt.core.autotools.core</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>
|
|
@ -0,0 +1,7 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
|
@ -0,0 +1,15 @@
|
|||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: %pluginName
|
||||
Bundle-SymbolicName: org.eclipse.cdt.core.autotools.core;singleton:=true
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Bundle-Activator: org.eclipse.cdt.core.autotools.core.internal.Activator
|
||||
Require-Bundle: org.eclipse.core.runtime,
|
||||
org.eclipse.tools.templates.freemarker;bundle-version="1.0.0",
|
||||
org.eclipse.cdt.core;bundle-version="6.3.1",
|
||||
org.eclipse.core.resources;bundle-version="3.12.0"
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Bundle-Vendor: %providerName
|
||||
Export-Package: org.eclipse.cdt.core.autotools.core
|
||||
Bundle-Localization: plugin
|
24
build/org.eclipse.cdt.core.autotools.core/about.html
Normal file
24
build/org.eclipse.cdt.core.autotools.core/about.html
Normal file
|
@ -0,0 +1,24 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>About</title></head>
|
||||
|
||||
<body lang="EN-US">
|
||||
<h2>About This Content</h2>
|
||||
|
||||
<p>June 22, 2007</p>
|
||||
<h3>License</h3>
|
||||
|
||||
<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise
|
||||
indicated below, the Content is provided to you under the terms and conditions of the
|
||||
Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available
|
||||
at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
|
||||
For purposes of the EPL, "Program" will mean the Content.</p>
|
||||
|
||||
<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
|
||||
being redistributed by another party ("Redistributor") and different terms and conditions may
|
||||
apply to your use of any object code in the Content. Check the Redistributor's license that was
|
||||
provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
|
||||
indicated below, the terms and conditions of the EPL still apply to any source code in the Content
|
||||
and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
|
||||
|
||||
</body></html>
|
|
@ -0,0 +1,8 @@
|
|||
source.. = src/
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.,\
|
||||
plugin.xml,\
|
||||
about.html,\
|
||||
templates/,\
|
||||
plugin.properties
|
10
build/org.eclipse.cdt.core.autotools.core/plugin.properties
Normal file
10
build/org.eclipse.cdt.core.autotools.core/plugin.properties
Normal file
|
@ -0,0 +1,10 @@
|
|||
###############################################################################
|
||||
# Copyright (c) 2017 Intel 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
|
||||
###############################################################################
|
||||
|
||||
pluginName=CDT Autotools Core
|
||||
providerName=Eclipse CDT
|
22
build/org.eclipse.cdt.core.autotools.core/plugin.xml
Normal file
22
build/org.eclipse.cdt.core.autotools.core/plugin.xml
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?eclipse version="3.4"?>
|
||||
<plugin>
|
||||
<extension
|
||||
id="autotoolsNature"
|
||||
point="org.eclipse.core.resources.natures">
|
||||
<runtime>
|
||||
<run
|
||||
class="org.eclipse.cdt.core.autotools.core.AutotoolsNature">
|
||||
</run>
|
||||
</runtime>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.cdt.core.buildConfigProvider">
|
||||
<provider
|
||||
class="org.eclipse.cdt.core.autotools.core.AutotoolsBuildConfigurationProvider"
|
||||
id="org.eclipse.cdt.core.autotools.core.provider"
|
||||
natureId="org.eclipse.cdt.core.autotools.core.autotoolsNature">
|
||||
</provider>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
|
@ -0,0 +1,78 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2017 Intel 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:
|
||||
* Intel Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.core.autotools.core;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.core.IConsoleParser;
|
||||
import org.eclipse.cdt.core.build.CBuildConfiguration;
|
||||
import org.eclipse.cdt.core.build.IToolChain;
|
||||
import org.eclipse.cdt.core.resources.IConsole;
|
||||
import org.eclipse.cdt.core.autotools.core.internal.Activator;
|
||||
import org.eclipse.core.resources.IBuildConfiguration;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
|
||||
public class AutotoolsBuildConfiguration extends CBuildConfiguration {
|
||||
|
||||
public static final String AUTOTOOLS_GENERATOR = "autotools.generator"; //$NON-NLS-1$
|
||||
public static final String AUTOTOOLS_ARGUMENTS = "autotools.arguments"; //$NON-NLS-1$
|
||||
public static final String BUILD_COMMAND = "autotools.command.build"; //$NON-NLS-1$
|
||||
public static final String CLEAN_COMMAND = "autotools.command.clean"; //$NON-NLS-1$
|
||||
|
||||
public AutotoolsBuildConfiguration(IBuildConfiguration config, String name) throws CoreException {
|
||||
super(config, name);
|
||||
}
|
||||
|
||||
public AutotoolsBuildConfiguration(IBuildConfiguration config, String name, IToolChain toolChain) {
|
||||
super(config, name, toolChain, "run"); // TODO: why "run"
|
||||
}
|
||||
|
||||
@Override
|
||||
public IProject[] build(int kind, Map<String, String> args, IConsole console, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
|
||||
IProject project = getProject();
|
||||
|
||||
execute(Arrays.asList(new String[] { "autoreconf", "--install" }), project.getLocation(), console, monitor);
|
||||
execute(Arrays.asList(new String[] { "./configure" }), project.getLocation(), console, monitor);
|
||||
execute(Arrays.asList(new String[] { "make" }), project.getLocation(), console, monitor);
|
||||
|
||||
return new IProject[] { project };
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clean(IConsole console, IProgressMonitor monitor) throws CoreException {
|
||||
execute(Arrays.asList(new String[] { "make", "clean" }), getProject().getLocation(), console, monitor);
|
||||
}
|
||||
|
||||
protected void execute(List<String> command, IPath dir, IConsole console, IProgressMonitor monitor) throws CoreException {
|
||||
|
||||
ProcessBuilder builder = new ProcessBuilder(command).directory(dir.toFile());
|
||||
|
||||
try {
|
||||
Process process = builder.start();
|
||||
watchProcess(process, new IConsoleParser[0], console);
|
||||
} catch (IOException e) {
|
||||
throw new CoreException(Activator.errorStatus("Error executing: " + String.join(" ", command), e));
|
||||
}
|
||||
|
||||
getProject().refreshLocal(IResource.DEPTH_INFINITE, monitor);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,104 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2017 Intel 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:
|
||||
* Intel Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.core.autotools.core;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.core.build.CBuildConfiguration;
|
||||
import org.eclipse.cdt.core.build.ICBuildConfiguration;
|
||||
import org.eclipse.cdt.core.build.ICBuildConfigurationManager;
|
||||
import org.eclipse.cdt.core.build.ICBuildConfigurationProvider;
|
||||
import org.eclipse.cdt.core.build.IToolChain;
|
||||
import org.eclipse.cdt.core.build.IToolChainManager;
|
||||
import org.eclipse.cdt.core.autotools.core.internal.Activator;
|
||||
import org.eclipse.core.resources.IBuildConfiguration;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
|
||||
public class AutotoolsBuildConfigurationProvider implements ICBuildConfigurationProvider {
|
||||
|
||||
public static final String ID = Activator.PLUGIN_ID + ".provider"; //$NON-NLS-1$
|
||||
|
||||
private ICBuildConfigurationManager configManager = Activator.getService(ICBuildConfigurationManager.class);
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICBuildConfiguration getCBuildConfiguration(IBuildConfiguration config, String name) throws CoreException {
|
||||
IToolChain toolChain = null;
|
||||
|
||||
// try the toolchain for the local target
|
||||
Map<String, String> properties = new HashMap<>();
|
||||
properties.put(IToolChain.ATTR_OS, Platform.getOS());
|
||||
properties.put(IToolChain.ATTR_ARCH, Platform.getOSArch());
|
||||
IToolChainManager toolChainManager = Activator.getService(IToolChainManager.class);
|
||||
for (IToolChain tc : toolChainManager.getToolChainsMatching(properties)) {
|
||||
toolChain = tc;
|
||||
break;
|
||||
}
|
||||
|
||||
// local didn't work, try and find one that does
|
||||
if (toolChain == null) {
|
||||
for (IToolChain tc : toolChainManager.getToolChainsMatching(new HashMap<>())) {
|
||||
toolChain = tc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (toolChain != null) {
|
||||
return new AutotoolsBuildConfiguration(config, name, toolChain);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICBuildConfiguration createBuildConfiguration(IProject project, IToolChain toolChain, String launchMode,
|
||||
IProgressMonitor monitor) throws CoreException {
|
||||
// See if there is one already
|
||||
for (IBuildConfiguration config : project.getBuildConfigs()) {
|
||||
ICBuildConfiguration cconfig = config.getAdapter(ICBuildConfiguration.class);
|
||||
if (cconfig != null) {
|
||||
CBuildConfiguration cmakeConfig = cconfig.getAdapter(AutotoolsBuildConfiguration.class);
|
||||
if (cmakeConfig != null && cmakeConfig.getToolChain().equals(toolChain)
|
||||
&& launchMode.equals(cmakeConfig.getLaunchMode())) {
|
||||
return cconfig;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// get matching toolchain file if any
|
||||
Map<String, String> properties = new HashMap<>();
|
||||
String os = toolChain.getProperty(IToolChain.ATTR_OS);
|
||||
if (os != null && !os.isEmpty()) {
|
||||
properties.put(IToolChain.ATTR_OS, os);
|
||||
}
|
||||
String arch = toolChain.getProperty(IToolChain.ATTR_ARCH);
|
||||
if (!arch.isEmpty()) {
|
||||
properties.put(IToolChain.ATTR_ARCH, arch);
|
||||
}
|
||||
|
||||
// create config
|
||||
String configName = "autotools." + launchMode + '.' + toolChain.getId(); //$NON-NLS-1$
|
||||
IBuildConfiguration config = configManager.createBuildConfiguration(this, project, configName, monitor);
|
||||
CBuildConfiguration autotoolsConfig = new AutotoolsBuildConfiguration(config, configName);
|
||||
configManager.addBuildConfiguration(config, autotoolsConfig);
|
||||
return autotoolsConfig;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2017 Intel 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:
|
||||
* Intel Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.core.autotools.core;
|
||||
|
||||
import org.eclipse.cdt.core.build.CBuilder;
|
||||
import org.eclipse.cdt.core.autotools.core.internal.Activator;
|
||||
import org.eclipse.core.resources.ICommand;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IProjectDescription;
|
||||
import org.eclipse.core.resources.IProjectNature;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
|
||||
public class AutotoolsNature implements IProjectNature {
|
||||
|
||||
public static final String ID = Activator.PLUGIN_ID + ".autotoolsNature"; //$NON-NLS-1$
|
||||
|
||||
private IProject project;
|
||||
|
||||
public static void setupBuilder(IProjectDescription projDesc) throws CoreException {
|
||||
ICommand command = projDesc.newCommand();
|
||||
CBuilder.setupBuilder(command);
|
||||
projDesc.setBuildSpec(new ICommand[] { command });
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configure() throws CoreException {
|
||||
IProjectDescription projDesc = project.getDescription();
|
||||
setupBuilder(projDesc);
|
||||
project.setDescription(projDesc, new NullProgressMonitor());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deconfigure() throws CoreException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IProject getProject() {
|
||||
return project;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProject(IProject project) {
|
||||
this.project = project;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2017 Intel 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:
|
||||
* Intel Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.core.autotools.core;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.core.CCProjectNature;
|
||||
import org.eclipse.cdt.core.CProjectNature;
|
||||
import org.eclipse.cdt.core.build.CBuilder;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.IPathEntry;
|
||||
import org.eclipse.cdt.core.autotools.core.internal.Activator;
|
||||
import org.eclipse.core.resources.ICommand;
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IProjectDescription;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.tools.templates.core.IGenerator;
|
||||
import org.eclipse.tools.templates.freemarker.FMProjectGenerator;
|
||||
import org.eclipse.tools.templates.freemarker.SourceRoot;
|
||||
import org.eclipse.tools.templates.freemarker.TemplateManifest;
|
||||
import org.osgi.framework.Bundle;
|
||||
|
||||
public class AutotoolsProjectGenerator extends FMProjectGenerator implements IGenerator {
|
||||
|
||||
public AutotoolsProjectGenerator(String manifestFile) {
|
||||
super(manifestFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initProjectDescription(IProjectDescription description) {
|
||||
description
|
||||
.setNatureIds(
|
||||
new String[] { CProjectNature.C_NATURE_ID, CCProjectNature.CC_NATURE_ID, AutotoolsNature.ID });
|
||||
ICommand command = description.newCommand();
|
||||
CBuilder.setupBuilder(command);
|
||||
description.setBuildSpec(new ICommand[] { command });
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bundle getSourceBundle() {
|
||||
return Activator.getContext().getBundle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generate(Map<String, Object> model, IProgressMonitor monitor) throws CoreException {
|
||||
super.generate(model, monitor);
|
||||
|
||||
List<IPathEntry> entries = new ArrayList<>();
|
||||
IProject project = getProject();
|
||||
|
||||
// Create the source folders
|
||||
TemplateManifest manifest = getManifest();
|
||||
if (manifest != null) {
|
||||
List<SourceRoot> srcRoots = getManifest().getSrcRoots();
|
||||
if (srcRoots != null && !srcRoots.isEmpty()) {
|
||||
for (SourceRoot srcRoot : srcRoots) {
|
||||
IFolder sourceFolder = project.getFolder(srcRoot.getDir());
|
||||
if (!sourceFolder.exists()) {
|
||||
sourceFolder.create(true, true, monitor);
|
||||
}
|
||||
|
||||
entries.add(CoreModel.newSourceEntry(sourceFolder.getFullPath()));
|
||||
}
|
||||
} else {
|
||||
entries.add(CoreModel.newSourceEntry(getProject().getFullPath()));
|
||||
}
|
||||
}
|
||||
|
||||
entries.add(CoreModel.newOutputEntry(getProject().getFullPath())); //$NON-NLS-1$
|
||||
CoreModel.getDefault().create(project).setRawPathEntries(entries.toArray(new IPathEntry[entries.size()]),
|
||||
monitor);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2017 Intel 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:
|
||||
* Intel Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.core.autotools.core.internal;
|
||||
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.osgi.framework.BundleActivator;
|
||||
import org.osgi.framework.BundleContext;
|
||||
import org.osgi.framework.ServiceReference;
|
||||
|
||||
public class Activator implements BundleActivator {
|
||||
|
||||
// The plug-in ID
|
||||
public static final String PLUGIN_ID = "org.eclipse.cdt.core.autotools.core"; //$NON-NLS-1$
|
||||
|
||||
private static BundleContext context;
|
||||
|
||||
public static BundleContext getContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
|
||||
*/
|
||||
public void start(BundleContext bundleContext) throws Exception {
|
||||
Activator.context = bundleContext;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
|
||||
*/
|
||||
public void stop(BundleContext bundleContext) throws Exception {
|
||||
Activator.context = null;
|
||||
}
|
||||
|
||||
public static IStatus errorStatus(String message, Throwable cause) {
|
||||
return new Status(IStatus.ERROR, PLUGIN_ID, message, cause);
|
||||
}
|
||||
|
||||
public static <T> T getService(Class<T> service) {
|
||||
ServiceReference<T> ref = context.getServiceReference(service);
|
||||
return ref != null ? context.getService(ref) : null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
SUBDIRS = src
|
||||
dist_doc_DATA = README
|
|
@ -0,0 +1 @@
|
|||
Autotools project README file
|
|
@ -0,0 +1,8 @@
|
|||
AC_INIT([main)], [1.0])
|
||||
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
|
||||
AC_PROG_CC
|
||||
AC_CONFIG_FILES([
|
||||
Makefile
|
||||
src/Makefile
|
||||
])
|
||||
AC_OUTPUT
|
|
@ -0,0 +1,13 @@
|
|||
<templateManifest>
|
||||
<file src="/templates/autotools/README"
|
||||
dest="/${projectName}/README"/>
|
||||
<file src="/templates/autotools/configure.ac"
|
||||
dest="/${projectName}/configure.ac"/>
|
||||
<file src="/templates/autotools/Makefile.am"
|
||||
dest="/${projectName}/Makefile.am"/>
|
||||
<file src="/templates/autotools/src/main.c"
|
||||
dest="/${projectName}/src/main.c"
|
||||
open="true"/>
|
||||
<file src="/templates/autotools/src/Makefile.am"
|
||||
dest="/${projectName}/src/Makefile.am"/>
|
||||
</templateManifest>
|
|
@ -0,0 +1,2 @@
|
|||
bin_PROGRAMS = hello
|
||||
hello_SOURCES = main.c
|
|
@ -0,0 +1,8 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main(void) {
|
||||
|
||||
printf("Hello from autotools!\n");
|
||||
return 0;
|
||||
|
||||
}
|
7
build/org.eclipse.cdt.core.autotools.ui/.classpath
Normal file
7
build/org.eclipse.cdt.core.autotools.ui/.classpath
Normal 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.8"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
28
build/org.eclipse.cdt.core.autotools.ui/.project
Normal file
28
build/org.eclipse.cdt.core.autotools.ui/.project
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>org.eclipse.cdt.core.autotools.ui</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>
|
|
@ -0,0 +1,7 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
16
build/org.eclipse.cdt.core.autotools.ui/META-INF/MANIFEST.MF
Normal file
16
build/org.eclipse.cdt.core.autotools.ui/META-INF/MANIFEST.MF
Normal file
|
@ -0,0 +1,16 @@
|
|||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: %pluginName
|
||||
Bundle-SymbolicName: org.eclipse.cdt.core.autotools.ui;singleton:=true
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Bundle-Activator: org.eclipse.cdt.core.autotools.ui.internal.Activator
|
||||
Bundle-Vendor: %providerName
|
||||
Require-Bundle: org.eclipse.ui,
|
||||
org.eclipse.core.runtime,
|
||||
org.eclipse.tools.templates.ui;bundle-version="1.1.1",
|
||||
org.eclipse.ui.ide;bundle-version="3.13.0",
|
||||
org.eclipse.cdt.core.autotools.core;bundle-version="1.0.0",
|
||||
org.eclipse.tools.templates.freemarker;bundle-version="1.0.0"
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Bundle-Localization: plugin
|
24
build/org.eclipse.cdt.core.autotools.ui/about.html
Normal file
24
build/org.eclipse.cdt.core.autotools.ui/about.html
Normal file
|
@ -0,0 +1,24 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>About</title></head>
|
||||
|
||||
<body lang="EN-US">
|
||||
<h2>About This Content</h2>
|
||||
|
||||
<p>June 22, 2007</p>
|
||||
<h3>License</h3>
|
||||
|
||||
<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise
|
||||
indicated below, the Content is provided to you under the terms and conditions of the
|
||||
Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available
|
||||
at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
|
||||
For purposes of the EPL, "Program" will mean the Content.</p>
|
||||
|
||||
<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
|
||||
being redistributed by another party ("Redistributor") and different terms and conditions may
|
||||
apply to your use of any object code in the Content. Check the Redistributor's license that was
|
||||
provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
|
||||
indicated below, the terms and conditions of the EPL still apply to any source code in the Content
|
||||
and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
|
||||
|
||||
</body></html>
|
7
build/org.eclipse.cdt.core.autotools.ui/build.properties
Normal file
7
build/org.eclipse.cdt.core.autotools.ui/build.properties
Normal file
|
@ -0,0 +1,7 @@
|
|||
source.. = src/
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.,\
|
||||
plugin.xml,\
|
||||
about.html,\
|
||||
plugin.properties
|
12
build/org.eclipse.cdt.core.autotools.ui/plugin.properties
Normal file
12
build/org.eclipse.cdt.core.autotools.ui/plugin.properties
Normal file
|
@ -0,0 +1,12 @@
|
|||
###############################################################################
|
||||
# Copyright (c) 2017 Intel 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
|
||||
###############################################################################
|
||||
|
||||
pluginName=CDT Autotools UI
|
||||
providerName=Eclipse CDT
|
||||
autotoolsTemplate.label=Autotools Project
|
||||
autotoolsTemplate.description=An Autotools project with a Hello World executable build using the CDT's core build system. Can be built using toolchain containers.
|
19
build/org.eclipse.cdt.core.autotools.ui/plugin.xml
Normal file
19
build/org.eclipse.cdt.core.autotools.ui/plugin.xml
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?eclipse version="3.4"?>
|
||||
<plugin>
|
||||
<extension
|
||||
point="org.eclipse.tools.templates.ui.templates">
|
||||
<template
|
||||
id="org.eclipse.cdt.core.autotools.ui.template1"
|
||||
label="%autotoolsTemplate.label"
|
||||
wizard="org.eclipse.cdt.core.autotools.ui.internal.NewAutotoolsProjectWizard">
|
||||
<tagReference
|
||||
id="org.eclipse.cdt.ui.cdtTag">
|
||||
</tagReference>
|
||||
<description>
|
||||
%autotoolsTemplate.description
|
||||
</description>
|
||||
</template>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
|
@ -0,0 +1,61 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2017 Intel 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:
|
||||
* Intel Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.core.autotools.ui.internal;
|
||||
|
||||
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
||||
import org.osgi.framework.BundleContext;
|
||||
|
||||
/**
|
||||
* The activator class controls the plug-in life cycle
|
||||
*/
|
||||
public class Activator extends AbstractUIPlugin {
|
||||
|
||||
// The plug-in ID
|
||||
public static final String PLUGIN_ID = "org.eclipse.cdt.core.autotools.ui"; //$NON-NLS-1$
|
||||
|
||||
// The shared instance
|
||||
private static Activator plugin;
|
||||
|
||||
/**
|
||||
* The constructor
|
||||
*/
|
||||
public Activator() {
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
|
||||
*/
|
||||
public void start(BundleContext context) throws Exception {
|
||||
super.start(context);
|
||||
plugin = this;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.eclipse.ui.plugin.AbstractUIPlugin#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;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2017 Intel 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:
|
||||
* Intel Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.core.autotools.ui.internal;
|
||||
|
||||
import org.eclipse.osgi.util.NLS;
|
||||
|
||||
public class Messages extends NLS {
|
||||
private static final String BUNDLE_NAME = "org.eclipse.cdt.core.autotools.ui.internal.messages"; //$NON-NLS-1$
|
||||
public static String NewAutotoolsProjectWizard_Description;
|
||||
public static String NewAutotoolsProjectWizard_Title;
|
||||
static {
|
||||
// initialize resource bundle
|
||||
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
|
||||
}
|
||||
|
||||
private Messages() {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2017 Intel 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:
|
||||
* Intel Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.core.autotools.ui.internal;
|
||||
|
||||
import org.eclipse.cdt.core.autotools.core.AutotoolsProjectGenerator;
|
||||
import org.eclipse.jface.dialogs.Dialog;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.tools.templates.core.IGenerator;
|
||||
import org.eclipse.tools.templates.ui.TemplateWizard;
|
||||
import org.eclipse.ui.dialogs.WizardNewProjectCreationPage;
|
||||
|
||||
public class NewAutotoolsProjectWizard extends TemplateWizard {
|
||||
|
||||
private WizardNewProjectCreationPage mainPage;
|
||||
|
||||
@Override
|
||||
public void addPages() {
|
||||
mainPage = new WizardNewProjectCreationPage("basicNewProjectPage") { //$NON-NLS-1$
|
||||
@Override
|
||||
public void createControl(Composite parent) {
|
||||
super.createControl(parent);
|
||||
createWorkingSetGroup((Composite) getControl(), getSelection(),
|
||||
new String[] { "org.eclipse.ui.resourceWorkingSetPage" }); //$NON-NLS-1$
|
||||
Dialog.applyDialogFont(getControl());
|
||||
}
|
||||
};
|
||||
mainPage.setTitle(Messages.NewAutotoolsProjectWizard_Title);
|
||||
mainPage.setDescription(Messages.NewAutotoolsProjectWizard_Description);
|
||||
this.addPage(mainPage);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IGenerator getGenerator() {
|
||||
AutotoolsProjectGenerator generator = new AutotoolsProjectGenerator("templates/autotools/manifest.xml"); //$NON-NLS-1$
|
||||
generator.setProjectName(mainPage.getProjectName());
|
||||
if (!mainPage.useDefaults()) {
|
||||
generator.setLocationURI(mainPage.getLocationURI());
|
||||
}
|
||||
return generator;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
###############################################################################
|
||||
# Copyright (c) 2017 Intel 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
|
||||
###############################################################################
|
||||
NewAutotoolsProjectWizard_Description=Specify properties of new Autotools project.
|
||||
NewAutotoolsProjectWizard_Title=New Autotools Project
|
4
pom.xml
4
pom.xml
|
@ -73,6 +73,10 @@
|
|||
<module>build/org.eclipse.cdt.cmake.ui</module>
|
||||
<module>build/org.eclipse.cdt.cmake-feature</module>
|
||||
|
||||
<module>build/org.eclipse.cdt.core.autotools.core</module>
|
||||
<module>build/org.eclipse.cdt.core.autotools.ui</module>
|
||||
<module>build/org.eclipse.cdt.core.autotools-feature</module>
|
||||
|
||||
<module>codan/org.eclipse.cdt.codan.core</module>
|
||||
<module>codan/org.eclipse.cdt.codan.ui</module>
|
||||
<module>codan/org.eclipse.cdt.codan.core.cxx</module>
|
||||
|
|
|
@ -149,6 +149,12 @@
|
|||
<feature url="features/org.eclipse.cdt.cmake.source_0.0.0.qualifier.jar" id="org.eclipse.cdt.cmake.source" version="0.0.0">
|
||||
<category name="extra"/>
|
||||
</feature>
|
||||
<feature url="features/org.eclipse.cdt.core.autotools_0.0.0.qualifier.jar" id="org.eclipse.cdt.core.autotools" version="0.0.0">
|
||||
<category name="extra"/>
|
||||
</feature>
|
||||
<feature url="features/org.eclipse.cdt.core.autotools.source_0.0.0.qualifier.jar" id="org.eclipse.cdt.core.autotools.source" version="0.0.0">
|
||||
<category name="extra"/>
|
||||
</feature>
|
||||
<feature url="features/org.eclipse.cdt.llvm.dsf.lldb_0.0.0.qualifier.jar" id="org.eclipse.cdt.llvm.dsf.lldb" version="0.0.0">
|
||||
<category name="extra"/>
|
||||
</feature>
|
||||
|
|
Loading…
Add table
Reference in a new issue