1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-22 06:02:11 +02:00

Cherry picking changes from the CDT 9 branch for Qt and Arduino.

Change-Id: I85eca2b8bb0447d4dd703030c41d90c1f9bcdf89
This commit is contained in:
Doug Schaefer 2016-05-25 11:21:22 -04:00 committed by Gerrit Code Review @ Eclipse.org
parent de37ec61db
commit 5d2cbaaa1c
46 changed files with 1252 additions and 527 deletions

View file

@ -55,6 +55,7 @@ public class GCCToolChain extends PlatformObject implements IToolChain {
private final String prefix; private final String prefix;
private final IEnvironmentVariable pathVar; private final IEnvironmentVariable pathVar;
private final IEnvironmentVariable[] envVars; private final IEnvironmentVariable[] envVars;
private final Map<String, String> properties = new HashMap<>();
protected String[] compileCommands; protected String[] compileCommands;
@ -113,16 +114,27 @@ public class GCCToolChain extends PlatformObject implements IToolChain {
@Override @Override
public String getProperty(String key) { public String getProperty(String key) {
// this class represents a local toolchain String value = properties.get(key);
if (value != null) {
return value;
}
// By default, we're a local GCC
switch (key) { switch (key) {
case ATTR_OS: case ATTR_OS:
return Platform.getOS(); return Platform.getOS();
case ATTR_ARCH: case ATTR_ARCH:
return Platform.getOSArch(); return Platform.getOSArch();
} }
return null; return null;
} }
@Override
public void setProperty(String key, String value) {
properties.put(key, value);
}
@Override @Override
public String getBinaryParserId() { public String getBinaryParserId() {
// Assume local builds // Assume local builds

View file

@ -18,8 +18,10 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.eclipse.cdt.build.gcc.core.GCCToolChain; import org.eclipse.cdt.build.gcc.core.GCCToolChain;
import org.eclipse.cdt.core.build.IToolChain;
import org.eclipse.cdt.core.build.IToolChainManager; import org.eclipse.cdt.core.build.IToolChainManager;
import org.eclipse.cdt.core.build.IToolChainProvider; import org.eclipse.cdt.core.build.IToolChainProvider;
import org.eclipse.core.runtime.Platform;
/** /**
* Finds gcc and clang on the path. * Finds gcc and clang on the path.
@ -74,8 +76,32 @@ public class GCCPathToolChainProvider implements IToolChainProvider {
String name = target + " - " + version; //$NON-NLS-1$ String name = target + " - " + version; //$NON-NLS-1$
if (!names.contains(name)) { if (!names.contains(name)) {
names.add(name); names.add(name);
manager.addToolChain(new GCCToolChain(this, target, version, GCCToolChain toolChain = new GCCToolChain(this, target, version,
new Path[] { dir.toPath() }, prefix)); new Path[] { dir.toPath() }, prefix);
String[] tuple = target.split("-"); //$NON-NLS-1$
if (tuple.length > 2) {
// Arch
if ("x86_64".equals(tuple[0])) {
toolChain.setProperty(IToolChain.ATTR_ARCH, tuple[0]);
} else {
toolChain.setProperty(IToolChain.ATTR_ARCH, "x86"); // default
}
// OS
switch (tuple[1]) {
case "w64":
toolChain.setProperty(IToolChain.ATTR_OS, Platform.OS_WIN32);
break;
case "linux":
toolChain.setProperty(IToolChain.ATTR_OS, Platform.OS_LINUX);
break;
case "apple":
toolChain.setProperty(IToolChain.ATTR_OS, Platform.OS_MACOSX);
break;
}
}
toolChain.setProperty(IToolChain.ATTR_PACKAGE, "system");
manager.addToolChain(toolChain);
} }
} }
} catch (IOException e) { } catch (IOException e) {

View file

@ -11,6 +11,7 @@ import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import org.eclipse.cdt.build.gcc.core.GCCToolChain; import org.eclipse.cdt.build.gcc.core.GCCToolChain;
import org.eclipse.cdt.core.build.IToolChain;
import org.eclipse.cdt.core.build.IToolChainManager; import org.eclipse.cdt.core.build.IToolChainManager;
import org.eclipse.cdt.core.build.IToolChainProvider; import org.eclipse.cdt.core.build.IToolChainProvider;
import org.eclipse.cdt.utils.WindowsRegistry; import org.eclipse.cdt.utils.WindowsRegistry;
@ -65,8 +66,10 @@ public class Msys2ToolChainProvider implements IToolChainProvider {
Path msysPath = Paths.get(installLocation); Path msysPath = Paths.get(installLocation);
Path gccPath = msysPath.resolve("mingw64\\bin\\gcc.exe"); //$NON-NLS-1$ Path gccPath = msysPath.resolve("mingw64\\bin\\gcc.exe"); //$NON-NLS-1$
if (Files.exists(gccPath)) { if (Files.exists(gccPath)) {
manager.addToolChain(new GCCToolChain(this, "x86_64-w64-mingw32", "msys2.x86_64", new Path[] { //$NON-NLS-1$ //$NON-NLS-2$ GCCToolChain toolChain = new GCCToolChain(this, "x86_64-w64-mingw32", "msys2.x86_64", new Path[] { //$NON-NLS-1$ //$NON-NLS-2$
gccPath.getParent(), msysPath.resolve("bin"), msysPath.resolve("usr\\bin") })); //$NON-NLS-1$ //$NON-NLS-2$ gccPath.getParent(), msysPath.resolve("bin"), msysPath.resolve("usr\\bin") }); //$NON-NLS-1$ //$NON-NLS-2$
toolChain.setProperty(IToolChain.ATTR_PACKAGE, "msys2"); //$NON-NLS-1$
manager.addToolChain(toolChain);
return true; return true;
} else { } else {
return addToolChain32(manager, registry, key); return addToolChain32(manager, registry, key);
@ -78,8 +81,10 @@ public class Msys2ToolChainProvider implements IToolChainProvider {
Path msysPath = Paths.get(installLocation); Path msysPath = Paths.get(installLocation);
Path gccPath = msysPath.resolve("mingw32\\bin\\gcc.exe"); //$NON-NLS-1$ Path gccPath = msysPath.resolve("mingw32\\bin\\gcc.exe"); //$NON-NLS-1$
if (Files.exists(gccPath)) { if (Files.exists(gccPath)) {
manager.addToolChain(new GCCToolChain(this, "i686-w64-mingw32", "msys2.i686", new Path[] { //$NON-NLS-1$ //$NON-NLS-2$ GCCToolChain toolChain = new GCCToolChain(this, "i686-w64-mingw32", "msys2.i686", new Path[] { //$NON-NLS-1$ //$NON-NLS-2$
gccPath.getParent(), msysPath.resolve("bin"), msysPath.resolve("usr\\bin") })); //$NON-NLS-1$ //$NON-NLS-2$ gccPath.getParent(), msysPath.resolve("bin"), msysPath.resolve("usr\\bin") }); //$NON-NLS-1$ //$NON-NLS-2$
toolChain.setProperty(IToolChain.ATTR_PACKAGE, "msys2"); //$NON-NLS-1$
manager.addToolChain(toolChain);
return true; return true;
} else { } else {
return false; return false;

View file

@ -611,11 +611,9 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
// Check for new style build configs first // Check for new style build configs first
Set<String> parserIds = new HashSet<>(); Set<String> parserIds = new HashSet<>();
for (IBuildConfiguration config : project.getBuildConfigs()) { for (IBuildConfiguration config : project.getBuildConfigs()) {
if (!IBuildConfiguration.DEFAULT_CONFIG_NAME.equals(config.getName())) { ICBuildConfiguration cconfig = config.getAdapter(ICBuildConfiguration.class);
ICBuildConfiguration cconfig = config.getAdapter(ICBuildConfiguration.class); if (cconfig != null) {
if (cconfig != null) { parserIds.add(cconfig.getBinaryParserId());
parserIds.add(cconfig.getBinaryParserId());
}
} }
} }
if (!parserIds.isEmpty()) { if (!parserIds.isEmpty()) {

View file

@ -1147,10 +1147,7 @@ public class CCorePlugin extends Plugin {
// If we are new style build configurations, get the provider there // If we are new style build configurations, get the provider there
IBuildConfiguration activeConfig = project.getActiveBuildConfig(); IBuildConfiguration activeConfig = project.getActiveBuildConfig();
ICBuildConfiguration cconfig = buildConfigManager.getBuildConfiguration(activeConfig); ICBuildConfiguration cconfig = activeConfig.getAdapter(ICBuildConfiguration.class);
if (cconfig == null) {
cconfig = buildConfigManager.getDefaultBuildConfiguration(project);
}
if (cconfig != null) { if (cconfig != null) {
return cconfig; return cconfig;
} }

View file

@ -102,7 +102,7 @@ public abstract class CBuildConfiguration extends PlatformObject
toolChain = tc; toolChain = tc;
} }
public CBuildConfiguration(IBuildConfiguration config, String name, IToolChain toolChain) { protected CBuildConfiguration(IBuildConfiguration config, String name, IToolChain toolChain) {
this.config = config; this.config = config;
this.name = name; this.name = name;
this.toolChain = toolChain; this.toolChain = toolChain;
@ -118,6 +118,10 @@ public abstract class CBuildConfiguration extends PlatformObject
} }
} }
protected CBuildConfiguration(IBuildConfiguration config, IToolChain toolChain) {
this(config, DEFAULT_NAME, toolChain);
}
@Override @Override
public IBuildConfiguration getBuildConfiguration() { public IBuildConfiguration getBuildConfiguration() {
return config; return config;

View file

@ -28,6 +28,12 @@ import org.eclipse.core.runtime.IProgressMonitor;
*/ */
public interface ICBuildConfiguration extends IAdaptable, IScannerInfoProvider { public interface ICBuildConfiguration extends IAdaptable, IScannerInfoProvider {
/**
* CDT doesn't like that the Platform default config name is an empty string.
* It needs a real name for the name of the build directory, for example.
*/
public static String DEFAULT_NAME = "default";
/** /**
* Returns the resources build configuration that this CDT build * Returns the resources build configuration that this CDT build
* configuration is associated with. * configuration is associated with.

View file

@ -20,6 +20,12 @@ import org.eclipse.core.runtime.IProgressMonitor;
*/ */
public interface ICBuildConfigurationManager { public interface ICBuildConfigurationManager {
/**
* Return the build configuration provider with the given id.
*
* @param id
* @return build configuration provider
*/
ICBuildConfigurationProvider getProvider(String id); ICBuildConfigurationProvider getProvider(String id);
/** /**
@ -35,8 +41,6 @@ public interface ICBuildConfigurationManager {
IBuildConfiguration createBuildConfiguration(ICBuildConfigurationProvider provider, IProject project, IBuildConfiguration createBuildConfiguration(ICBuildConfigurationProvider provider, IProject project,
String configName, IProgressMonitor monitor) throws CoreException; String configName, IProgressMonitor monitor) throws CoreException;
IBuildConfiguration getBuildConfiguration(ICBuildConfigurationProvider provider, IProject project, String configName) throws CoreException;
/** /**
* Called by providers to add new build configurations as they are created. * Called by providers to add new build configurations as they are created.
* *
@ -56,6 +60,4 @@ public interface ICBuildConfigurationManager {
*/ */
ICBuildConfiguration getBuildConfiguration(IBuildConfiguration buildConfig) throws CoreException; ICBuildConfiguration getBuildConfiguration(IBuildConfiguration buildConfig) throws CoreException;
ICBuildConfiguration getDefaultBuildConfiguration(IProject project) throws CoreException;
} }

View file

@ -8,7 +8,6 @@
package org.eclipse.cdt.core.build; package org.eclipse.cdt.core.build;
import org.eclipse.core.resources.IBuildConfiguration; import org.eclipse.core.resources.IBuildConfiguration;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
/** /**
@ -33,12 +32,4 @@ public interface ICBuildConfigurationProvider {
*/ */
ICBuildConfiguration getCBuildConfiguration(IBuildConfiguration config, String name) throws CoreException; ICBuildConfiguration getCBuildConfiguration(IBuildConfiguration config, String name) throws CoreException;
/**
* Returns a default C build configuration for a given project if any.
*
* @param project
* @return default C build configuration for the project
*/
ICBuildConfiguration getDefaultCBuildConfiguration(IProject project) throws CoreException;
} }

View file

@ -27,6 +27,7 @@ public interface IToolChain extends IAdaptable {
// Standard attributes // Standard attributes
static final String ATTR_OS = "os"; //$NON-NLS-1$ static final String ATTR_OS = "os"; //$NON-NLS-1$
static final String ATTR_ARCH = "arch"; //$NON-NLS-1$ static final String ATTR_ARCH = "arch"; //$NON-NLS-1$
static final String ATTR_PACKAGE = "package"; //$NON-NLS-1$
IToolChainProvider getProvider(); IToolChainProvider getProvider();
@ -47,6 +48,8 @@ public interface IToolChain extends IAdaptable {
*/ */
String getProperty(String key); String getProperty(String key);
void setProperty(String key, String value);
IEnvironmentVariable getVariable(String name); IEnvironmentVariable getVariable(String name);
IEnvironmentVariable[] getVariables(); IEnvironmentVariable[] getVariables();

View file

@ -72,16 +72,19 @@ public class CBuildConfigurationManager implements ICBuildConfigurationManager,
public boolean supports(IProject project) { public boolean supports(IProject project) {
try { try {
return project.hasNature(natureId); if (natureId != null) {
return project.hasNature(natureId);
}
} catch (CoreException e) { } catch (CoreException e) {
CCorePlugin.log(e.getStatus()); CCorePlugin.log(e.getStatus());
return false;
} }
return false;
} }
} }
private Map<String, Provider> providers; private Map<String, Provider> providers;
private Map<IBuildConfiguration, ICBuildConfiguration> configs = new HashMap<>(); private Map<IBuildConfiguration, ICBuildConfiguration> configs = new HashMap<>();
private Set<IBuildConfiguration> noConfigs = new HashSet<>();
public CBuildConfigurationManager() { public CBuildConfigurationManager() {
ResourcesPlugin.getWorkspace().addResourceChangeListener(this); ResourcesPlugin.getWorkspace().addResourceChangeListener(this);
@ -105,13 +108,33 @@ public class CBuildConfigurationManager implements ICBuildConfigurationManager,
} }
private Provider getProviderDelegate(String id) { private Provider getProviderDelegate(String id) {
initProviders();
return providers.get(id); return providers.get(id);
} }
@Override @Override
public ICBuildConfigurationProvider getProvider(String id) { public ICBuildConfigurationProvider getProvider(String id) {
return getProviderDelegate(id).getProvider(); initProviders();
Provider provider = providers.get(id);
return provider != null ? provider.getProvider() : null;
}
public ICBuildConfigurationProvider getProvider(String id, IProject project) {
initProviders();
Provider provider = getProviderDelegate(id);
if (provider != null && provider.supports(project)) {
return provider.getProvider();
}
return null;
}
public ICBuildConfigurationProvider getProvider(IProject project) throws CoreException {
initProviders();
for (Provider provider : providers.values()) {
if (provider.supports(project)) {
return provider.getProvider();
}
}
return null;
} }
@Override @Override
@ -143,47 +166,51 @@ public class CBuildConfigurationManager implements ICBuildConfigurationManager,
public ICBuildConfiguration getBuildConfiguration(IBuildConfiguration buildConfig) throws CoreException { public ICBuildConfiguration getBuildConfiguration(IBuildConfiguration buildConfig) throws CoreException {
initProviders(); initProviders();
synchronized (configs) { synchronized (configs) {
ICBuildConfiguration config = configs.get(buildConfig); if (noConfigs.contains(buildConfig)) {
if (config == null) { return null;
String[] segments = buildConfig.getName().split("/"); //$NON-NLS-1$ } else {
if (segments.length == 2) { ICBuildConfiguration config = configs.get(buildConfig);
String providerId = segments[0];
String configName = segments[1];
Provider provider = getProviderDelegate(providerId);
if (provider != null && provider.supports(buildConfig.getProject())) {
config = provider.getProvider().getCBuildConfiguration(buildConfig, configName);
configs.put(buildConfig, config);
// Also make sure we reset the binary parser cache for the new config
CModelManager.getDefault().resetBinaryParser(buildConfig.getProject());
}
}
}
return config;
}
}
@Override
public IBuildConfiguration getBuildConfiguration(ICBuildConfigurationProvider provider, IProject project,
String configName) throws CoreException {
String name = provider.getId() + '/' + configName;
return project.getBuildConfig(name);
}
@Override
public ICBuildConfiguration getDefaultBuildConfiguration(IProject project) throws CoreException {
initProviders();
for (Provider provider : providers.values()) {
if (provider.supports(project)) {
ICBuildConfiguration config = provider.getProvider().getDefaultCBuildConfiguration(project);
if (config != null) { if (config != null) {
configs.put(config.getBuildConfiguration(), config);
return config; return config;
} else {
String configName;
ICBuildConfigurationProvider provider;
if (IBuildConfiguration.DEFAULT_CONFIG_NAME.equals(buildConfig.getName())) {
configName = ICBuildConfiguration.DEFAULT_NAME;
provider = getProvider(buildConfig.getProject());
} else {
String[] segments = buildConfig.getName().split("/"); //$NON-NLS-1$
if (segments.length == 2) {
String providerId = segments[0];
configName = segments[1];
Provider delegate = getProviderDelegate(providerId);
if (delegate != null && delegate.supports(buildConfig.getProject())) {
provider = delegate.getProvider();
} else {
return null;
}
} else {
// Not ours
return null;
}
}
if (provider != null) {
config = provider.getCBuildConfiguration(buildConfig, configName);
if (config != null) {
configs.put(buildConfig, config);
// Also make sure we reset the binary parser cache for the new config
CModelManager.getDefault().resetBinaryParser(buildConfig.getProject());
return config;
}
}
noConfigs.add(buildConfig);
return null;
} }
} }
} }
return null;
} }
@Override @Override

View file

@ -133,6 +133,15 @@ public class ToolChainManager implements IToolChainManager {
tcs.add(toolChain); tcs.add(toolChain);
} }
} }
// Allow 32-bit compilers on 64-bit machines
// TODO is there a cleaner way to do this?
if ("x86_64".equals(properties.get(IToolChain.ATTR_ARCH))) { //$NON-NLS-1$
Map<String, String> properties32 = new HashMap<>(properties);
properties32.put(IToolChain.ATTR_ARCH, "x86"); //$NON-NLS-1$
tcs.addAll(getToolChainsMatching(properties32));
}
return tcs; return tcs;
} }

View file

@ -32,6 +32,7 @@ import java.util.concurrent.RejectedExecutionException;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.cdtvariables.CdtVariableException; import org.eclipse.cdt.core.cdtvariables.CdtVariableException;
import org.eclipse.cdt.core.cdtvariables.ICdtVariable; import org.eclipse.cdt.core.cdtvariables.ICdtVariable;
import org.eclipse.cdt.core.cdtvariables.ICdtVariableManager;
import org.eclipse.cdt.core.envvar.IEnvironmentVariable; import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ICProject;
@ -660,19 +661,17 @@ public class GdbLaunch extends DsfLaunch implements ITerminate, IDisconnect, ITr
} }
// Add variables from build info // Add variables from build info
ICdtVariable[] buildVars = CCorePlugin.getDefault().getCdtVariableManager().getVariables(cfg); ICdtVariableManager manager = CCorePlugin.getDefault().getCdtVariableManager();
ICdtVariable[] buildVars = manager.getVariables(cfg);
for (ICdtVariable var : buildVars) { for (ICdtVariable var : buildVars) {
try { try {
// The project_classpath variable contributed by JDT is // The project_classpath variable contributed by JDT is
// useless // useless for running C/C++ binaries, but it can be lethal
// for running C/C++ // if it has a very large value that exceeds shell limit. See
// binaries, but it can be lethal if it has a very large
// value
// that exceeds shell
// limit. See
// http://bugs.eclipse.org/bugs/show_bug.cgi?id=408522 // http://bugs.eclipse.org/bugs/show_bug.cgi?id=408522
if (!"project_classpath".equals(var.getName())) {//$NON-NLS-1$ if (!"project_classpath".equals(var.getName())) {//$NON-NLS-1$
envMap.put(var.getName(), var.getStringValue()); String value = manager.resolveValue(var.getStringValue(), "", File.pathSeparator, cfg); //$NON-NLS-1$
envMap.put(var.getName(), value);
} }
} catch (CdtVariableException e) { } catch (CdtVariableException e) {
// Some Eclipse dynamic variables can't be resolved // Some Eclipse dynamic variables can't be resolved

View file

@ -139,7 +139,7 @@ public class GdbLaunchDelegate extends AbstractCLaunchDelegate2
monitor.worked(1); monitor.worked(1);
String gdbVersion = getGDBVersion(config); String gdbVersion = launch.getGDBVersion();
// First make sure non-stop is supported, if the user want to use this mode // First make sure non-stop is supported, if the user want to use this mode
if (LaunchUtils.getIsNonStopMode(config) && !isNonStopSupportedInGdbVersion(gdbVersion)) { if (LaunchUtils.getIsNonStopMode(config) && !isNonStopSupportedInGdbVersion(gdbVersion)) {

View file

@ -18,9 +18,19 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.cdtvariables.CdtVariableException;
import org.eclipse.cdt.core.cdtvariables.ICdtVariable;
import org.eclipse.cdt.core.cdtvariables.ICdtVariableManager;
import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
import org.eclipse.cdt.launch.AbstractCLaunchDelegate2; import org.eclipse.cdt.launch.AbstractCLaunchDelegate2;
import org.eclipse.cdt.launch.internal.ui.LaunchMessages; import org.eclipse.cdt.launch.internal.ui.LaunchMessages;
@ -28,6 +38,9 @@ import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
import org.eclipse.cdt.utils.CommandLineUtil; import org.eclipse.cdt.utils.CommandLineUtil;
import org.eclipse.cdt.utils.pty.PTY; import org.eclipse.cdt.utils.pty.PTY;
import org.eclipse.cdt.utils.spawner.ProcessFactory; import org.eclipse.cdt.utils.spawner.ProcessFactory;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
@ -44,27 +57,28 @@ import com.ibm.icu.text.DateFormat;
/** /**
* The launch delegate for Run mode. * The launch delegate for Run mode.
*/ */
public class LocalRunLaunchDelegate extends AbstractCLaunchDelegate2 public class LocalRunLaunchDelegate extends AbstractCLaunchDelegate2 {
{
public LocalRunLaunchDelegate() { public LocalRunLaunchDelegate() {
// We support project-less run // We support project-less run
super(false); super(false);
} }
@Override @Override
public void launch( ILaunchConfiguration config, String mode, ILaunch launch, IProgressMonitor monitor ) throws CoreException { public void launch(ILaunchConfiguration config, String mode, ILaunch launch, IProgressMonitor monitor)
throws CoreException {
// This delegate is only for Run mode // This delegate is only for Run mode
assert mode.equals(ILaunchManager.RUN_MODE); assert mode.equals(ILaunchManager.RUN_MODE);
if ( monitor == null ) { if (monitor == null) {
monitor = new NullProgressMonitor(); monitor = new NullProgressMonitor();
} }
if ( mode.equals(ILaunchManager.RUN_MODE ) ) { if (mode.equals(ILaunchManager.RUN_MODE)) {
runLocalApplication( config, launch, monitor ); runLocalApplication(config, launch, monitor);
} }
} }
private void runLocalApplication(ILaunchConfiguration config, ILaunch launch, IProgressMonitor monitor) throws CoreException { private void runLocalApplication(ILaunchConfiguration config, ILaunch launch, IProgressMonitor monitor)
throws CoreException {
monitor.beginTask(LaunchMessages.LocalCDILaunchDelegate_0, 10); monitor.beginTask(LaunchMessages.LocalCDILaunchDelegate_0, 10);
if (monitor.isCanceled()) { if (monitor.isCanceled()) {
return; return;
@ -90,7 +104,7 @@ public class LocalRunLaunchDelegate extends AbstractCLaunchDelegate2
monitor.worked(2); monitor.worked(2);
String[] commandArray = command.toArray(new String[command.size()]); String[] commandArray = command.toArray(new String[command.size()]);
String[] environment = DebugPlugin.getDefault().getLaunchManager().getEnvironment(config); String[] environment = getLaunchEnvironment(config);
Process process = exec(commandArray, environment, wd); Process process = exec(commandArray, environment, wd);
monitor.worked(6); monitor.worked(6);
@ -103,24 +117,147 @@ public class LocalRunLaunchDelegate extends AbstractCLaunchDelegate2
} }
} }
/**
* Gets the CDT environment from the CDT project's configuration referenced
* by the launch
*/
protected String[] getLaunchEnvironment(ILaunchConfiguration config) throws CoreException {
// Get the project
String projectName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String) null);
IProject project = null;
if (projectName == null) {
IResource[] resources = config.getMappedResources();
if (resources != null && resources.length > 0 && resources[0] instanceof IProject) {
project = (IProject) resources[0];
}
} else {
projectName = projectName.trim();
if (projectName.length() == 0) {
return null;
}
project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
}
HashMap<String, String> envMap = new HashMap<String, String>();
// Add in from the config
String[] debugEnv = DebugPlugin.getDefault().getLaunchManager().getEnvironment(config);
if (debugEnv != null) {
for (String env : debugEnv) {
String[] parts = env.split("=", 2); //$NON-NLS-1$
if (parts.length == 2) {
envMap.put(parts[0], parts[1]);
}
}
}
if (project != null && project.isAccessible()) {
ICProjectDescription projDesc = CoreModel.getDefault().getProjectDescription(project, false);
if (projDesc != null) {
String buildConfigID = config
.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_ID, ""); //$NON-NLS-1$
ICConfigurationDescription cfg = null;
if (buildConfigID.length() != 0) {
cfg = projDesc.getConfigurationById(buildConfigID);
}
// if configuration is null fall-back to active
if (cfg == null) {
cfg = projDesc.getActiveConfiguration();
}
// Environment variables and inherited vars
IEnvironmentVariable[] vars = CCorePlugin.getDefault().getBuildEnvironmentManager().getVariables(cfg,
true);
for (IEnvironmentVariable var : vars) {
String value;
switch (var.getOperation()) {
case IEnvironmentVariable.ENVVAR_REPLACE:
value = var.getValue();
break;
case IEnvironmentVariable.ENVVAR_APPEND:
value = envMap.get(var.getName());
if (value != null) {
value += var.getDelimiter() + var.getValue();
} else {
value = var.getValue();
}
break;
case IEnvironmentVariable.ENVVAR_PREPEND:
value = envMap.get(var.getName());
if (value != null) {
value = var.getValue() + var.getDelimiter() + value;
} else {
value = var.getValue();
}
break;
case IEnvironmentVariable.ENVVAR_REMOVE:
envMap.remove(var.getName());
value = null;
break;
default:
value = null;
}
if (value != null) {
envMap.put(var.getName(), value);
}
}
// Add variables from build info
ICdtVariableManager manager = CCorePlugin.getDefault().getCdtVariableManager();
ICdtVariable[] buildVars = manager.getVariables(cfg);
for (ICdtVariable var : buildVars) {
try {
// The project_classpath variable contributed by JDT is
// useless for running C/C++ binaries, but it can be
// lethal if it has a very large value that exceeds
// shell limit. See
// http://bugs.eclipse.org/bugs/show_bug.cgi?id=408522
if (!"project_classpath".equals(var.getName())) {//$NON-NLS-1$
String value = manager.resolveValue(var.getStringValue(), "", File.pathSeparator, cfg); //$NON-NLS-1$
envMap.put(var.getName(), value);
}
} catch (CdtVariableException e) {
// Some Eclipse dynamic variables can't be resolved
// dynamically... we don't care.
}
}
}
}
// Turn it into an envp format
List<String> strings = new ArrayList<String>(envMap.size());
for (Entry<String, String> entry : envMap.entrySet()) {
StringBuilder buffer = new StringBuilder(entry.getKey());
buffer.append('=').append(entry.getValue());
strings.add(buffer.toString());
}
return strings.toArray(new String[strings.size()]);
}
protected Map<String, String> createProcessAttributes() { protected Map<String, String> createProcessAttributes() {
Map<String, String> attributes = new HashMap<>(); Map<String, String> attributes = new HashMap<>();
// Specify that the process factory (GdbProcessFactory) should use InferiorRuntimeProcess to wrap // Specify that the process factory (GdbProcessFactory) should use
// InferiorRuntimeProcess to wrap
// the process that we are about to run. // the process that we are about to run.
// Note that GdbProcessFactory is only used for launches created using DSF-GDB not CDI // Note that GdbProcessFactory is only used for launches created using
attributes.put("org.eclipse.cdt.dsf.gdb.createProcessType" /* IGdbDebugConstants.PROCESS_TYPE_CREATION_ATTR */, //$NON-NLS-1$ // DSF-GDB not CDI
"org.eclipse.cdt.dsf.gdb.inferiorProcess" /* IGdbDebugConstants.INFERIOR_PROCESS_CREATION_VALUE */); //$NON-NLS-1$ attributes.put("org.eclipse.cdt.dsf.gdb.createProcessType" /* IGdbDebugConstants.PROCESS_TYPE_CREATION_ATTR */, //$NON-NLS-1$
"org.eclipse.cdt.dsf.gdb.inferiorProcess" /* IGdbDebugConstants.INFERIOR_PROCESS_CREATION_VALUE */); //$NON-NLS-1$
// Show the exit code of the process in the console title once it has terminated // Show the exit code of the process in the console title once it has
attributes.put("org.eclipse.cdt.dsf.gdb.inferiorExited" /* IGdbDebugConstants.INFERIOR_EXITED_ATTR */, //$NON-NLS-1$ // terminated
""); //$NON-NLS-1$ attributes.put("org.eclipse.cdt.dsf.gdb.inferiorExited" /* IGdbDebugConstants.INFERIOR_EXITED_ATTR */, //$NON-NLS-1$
""); //$NON-NLS-1$
return attributes; return attributes;
} }
/** /**
* Method used to check that the project and program are correct. * Method used to check that the project and program are correct. Can be
* Can be overridden to avoid checking certain things. * overridden to avoid checking certain things.
*/ */
protected IPath checkBinaryDetails(final ILaunchConfiguration config) throws CoreException { protected IPath checkBinaryDetails(final ILaunchConfiguration config) throws CoreException {
// First verify we are dealing with a proper project. // First verify we are dealing with a proper project.
@ -139,7 +276,8 @@ public class LocalRunLaunchDelegate extends AbstractCLaunchDelegate2
* @param environ * @param environ
* @param workingDirectory * @param workingDirectory
* the working directory, or <code>null</code> * the working directory, or <code>null</code>
* @return the resulting process or <code>null</code> if the exec is cancelled * @return the resulting process or <code>null</code> if the exec is
* cancelled
* @see Runtime * @see Runtime
* @since 4.7 * @since 4.7
*/ */
@ -156,33 +294,35 @@ public class LocalRunLaunchDelegate extends AbstractCLaunchDelegate2
return null; return null;
} }
@Override @Override
public boolean preLaunchCheck(ILaunchConfiguration config, String mode, IProgressMonitor monitor) throws CoreException { public boolean preLaunchCheck(ILaunchConfiguration config, String mode, IProgressMonitor monitor)
// Setup default Process Factory throws CoreException {
// Setup default Process Factory
setDefaultProcessFactory(config); setDefaultProcessFactory(config);
return super.preLaunchCheck(config, mode, monitor); return super.preLaunchCheck(config, mode, monitor);
} }
/** /**
* Modify the ILaunchConfiguration to set the DebugPlugin.ATTR_PROCESS_FACTORY_ID attribute, * Modify the ILaunchConfiguration to set the
* so as to specify the process factory to use. * DebugPlugin.ATTR_PROCESS_FACTORY_ID attribute, so as to specify the
* * process factory to use.
* This attribute should only be set if it is not part of the configuration already, to allow *
* other code to set it to something else. * This attribute should only be set if it is not part of the configuration
* already, to allow other code to set it to something else.
*/ */
protected void setDefaultProcessFactory(ILaunchConfiguration config) throws CoreException { protected void setDefaultProcessFactory(ILaunchConfiguration config) throws CoreException {
if (!config.hasAttribute(DebugPlugin.ATTR_PROCESS_FACTORY_ID)) { if (!config.hasAttribute(DebugPlugin.ATTR_PROCESS_FACTORY_ID)) {
ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy(); ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
// Use the debug process factory as it provides extra features for the program // Use the debug process factory as it provides extra features for
// that is being debugged or in this case run. // the program
// Effectively, we want to use InferiorRuntimeProcess when doing this Run launch. // that is being debugged or in this case run.
wc.setAttribute(DebugPlugin.ATTR_PROCESS_FACTORY_ID, // Effectively, we want to use InferiorRuntimeProcess when doing
"org.eclipse.cdt.dsf.gdb.GdbProcessFactory"); //$NON-NLS-1$ // this Run launch.
wc.doSave(); wc.setAttribute(DebugPlugin.ATTR_PROCESS_FACTORY_ID, "org.eclipse.cdt.dsf.gdb.GdbProcessFactory"); //$NON-NLS-1$
} wc.doSave();
} }
}
@Override @Override
protected String getPluginID() { protected String getPluginID() {

View file

@ -19,6 +19,10 @@
%license %license
</license> </license>
<requires>
<import feature="org.eclipse.launchbar" version="2.0.0" match="compatible"/>
</requires>
<plugin <plugin
id="org.eclipse.cdt.qt.core" id="org.eclipse.cdt.qt.core"
download-size="0" download-size="0"

View file

@ -185,6 +185,9 @@
<provider <provider
class="org.eclipse.cdt.internal.qt.core.provider.QtInstallProvider"> class="org.eclipse.cdt.internal.qt.core.provider.QtInstallProvider">
</provider> </provider>
<provider
class="org.eclipse.cdt.internal.qt.core.provider.LinuxQtInstallProvider">
</provider>
</extension> </extension>
<extension <extension
point="org.eclipse.cdt.qt.core.qtToolChainMapper"> point="org.eclipse.cdt.qt.core.qtToolChainMapper">
@ -210,5 +213,16 @@
value="x86_64"> value="x86_64">
</property> </property>
</mapping> </mapping>
<mapping
spec="linux-g++-64">
<property
key="os"
value="linux">
</property>
<property
key="arch"
value="x86_64">
</property>
</mapping>
</extension> </extension>
</plugin> </plugin>

View file

@ -10,7 +10,11 @@ package org.eclipse.cdt.internal.qt.core;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.cdt.qt.core.IQtInstall; import org.eclipse.cdt.qt.core.IQtInstall;
@ -18,6 +22,7 @@ public class QtInstall implements IQtInstall {
private final Path qmakePath; private final Path qmakePath;
private String spec; private String spec;
private Map<String, String> properties = new HashMap<>();
public QtInstall(Path qmakePath) { public QtInstall(Path qmakePath) {
this.qmakePath = qmakePath; this.qmakePath = qmakePath;
@ -38,14 +43,16 @@ public class QtInstall implements IQtInstall {
return qmakePath.resolve("../../qml"); //$NON-NLS-1$ return qmakePath.resolve("../../qml"); //$NON-NLS-1$
} }
public static String getSpec(String qmakePath) throws IOException { public static String getSpec(Path qmakePath) throws IOException {
Process proc = new ProcessBuilder(qmakePath, "-query", "QMAKE_XSPEC").start(); //$NON-NLS-1$ //$NON-NLS-2$ if (Files.exists(qmakePath)) {
Process proc = new ProcessBuilder(qmakePath.toString(), "-query", "QMAKE_XSPEC").start(); //$NON-NLS-1$ //$NON-NLS-2$
try (BufferedReader reader = new BufferedReader(new InputStreamReader(proc.getInputStream()))) { try (BufferedReader reader = new BufferedReader(new InputStreamReader(proc.getInputStream()))) {
String line = reader.readLine(); String line = reader.readLine();
if (line != null) { if (line != null) {
return line.trim(); return line.trim();
} }
} }
}
return null; return null;
} }
@ -53,7 +60,7 @@ public class QtInstall implements IQtInstall {
public String getSpec() { public String getSpec() {
if (spec == null) { if (spec == null) {
try { try {
spec = getSpec(getQmakePath().toString()); spec = getSpec(getQmakePath());
} catch (IOException e) { } catch (IOException e) {
Activator.log(e); Activator.log(e);
} }
@ -61,4 +68,14 @@ public class QtInstall implements IQtInstall {
return spec; return spec;
} }
@Override
public void setProperty(String key, String value) {
properties.put(key, value);
}
@Override
public Map<String, String> getProperties() {
return Collections.unmodifiableMap(properties);
}
} }

View file

@ -13,6 +13,7 @@ import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import org.eclipse.cdt.core.build.IToolChain; import org.eclipse.cdt.core.build.IToolChain;
import org.eclipse.cdt.qt.core.IQtInstall; import org.eclipse.cdt.qt.core.IQtInstall;
@ -78,7 +79,7 @@ public class QtInstallManager implements IQtInstallManager {
for (Path path : installs.keySet()) { for (Path path : installs.keySet()) {
String key = path.toString(); String key = path.toString();
if (prefs.get(key, null) == null) { if (prefs.get(key, null) == null) {
prefs.put(key, installs.get(key).getQmakePath().toString()); prefs.put(key, installs.get(path).getQmakePath().toString());
} }
} }
@ -135,6 +136,13 @@ public class QtInstallManager implements IQtInstallManager {
return false; return false;
} }
} }
for (Entry<String, String> property : install.getProperties().entrySet()) {
if (!property.getValue().equals(toolChain.getProperty(property.getKey()))) {
return false;
}
}
return true; return true;
} else { } else {
// Don't know so returning false // Don't know so returning false

View file

@ -68,19 +68,20 @@ public class QtBuildConfiguration extends CBuildConfiguration implements ICBuild
qtInstall = null; qtInstall = null;
} }
launchMode = settings.get(LAUNCH_MODE, ""); //$NON-NLS-1$ launchMode = settings.get(LAUNCH_MODE, null); // $NON-NLS-1$
} }
QtBuildConfiguration(IBuildConfiguration config, String name, IToolChain toolChain, IQtInstall qtInstall, QtBuildConfiguration(IBuildConfiguration config, String name, IToolChain toolChain, IQtInstall qtInstall,
String launchMode) String launchMode) throws CoreException {
throws CoreException {
super(config, name, toolChain); super(config, name, toolChain);
this.qtInstall = qtInstall; this.qtInstall = qtInstall;
this.launchMode = launchMode; this.launchMode = launchMode;
Preferences settings = getSettings(); Preferences settings = getSettings();
settings.put(QTINSTALL_NAME, qtInstall.getQmakePath().toString()); settings.put(QTINSTALL_NAME, qtInstall.getQmakePath().toString());
settings.put(LAUNCH_MODE, launchMode); if (launchMode != null) {
settings.put(LAUNCH_MODE, launchMode);
}
try { try {
settings.flush(); settings.flush();
} catch (BackingStoreException e) { } catch (BackingStoreException e) {
@ -108,16 +109,18 @@ public class QtBuildConfiguration extends CBuildConfiguration implements ICBuild
} }
@Override @Override
public String getQmakeConfig() { public String[] getQmakeConfig() {
switch (launchMode) { if (launchMode != null) {
case "run": //$NON-NLS-1$ switch (launchMode) {
return "CONFIG+=release"; //$NON-NLS-1$ case "run": //$NON-NLS-1$
case "debug": //$NON-NLS-1$ return new String[] { "CONFIG-=debug_and_release", "CONFIG+=release" }; //$NON-NLS-1$ //$NON-NLS-2$
return "CONFIG+=debug"; //$NON-NLS-1$ case "debug": //$NON-NLS-1$
default: return new String[] { "CONFIG-=debug_and_release", "CONFIG+=debug" }; //$NON-NLS-1$ //$NON-NLS-2$
// TODO probably need an extension point for guidance default:
return null; return new String[] { "CONFIG-=debug_and_release", "CONFIG+=launch_mode_" + launchMode }; //$NON-NLS-1$ //$NON-NLS-2$
}
} }
return new String[] { "CONFIG+=debug_and_release", "CONFIG+=launch_modeall" }; //$NON-NLS-1$ //$NON-NLS-2$
} }
public Path getProjectFile() { public Path getProjectFile() {
@ -133,21 +136,18 @@ public class QtBuildConfiguration extends CBuildConfiguration implements ICBuild
@Override @Override
public Path getProgramPath() throws CoreException { public Path getProgramPath() throws CoreException {
// TODO get the app name from the .pro file.
String projectName = getProject().getName(); String projectName = getProject().getName();
switch (Platform.getOS()) { switch (Platform.getOS()) {
case Platform.OS_MACOSX: case Platform.OS_MACOSX:
// TODO this is mac local specific and really should be
// in the config
// TODO also need to pull the app name out of the pro
// file name
Path appFolder = getBuildDirectory().resolve(projectName + ".app"); //$NON-NLS-1$ Path appFolder = getBuildDirectory().resolve(projectName + ".app"); //$NON-NLS-1$
Path contentsFolder = appFolder.resolve("Contents"); //$NON-NLS-1$ Path contentsFolder = appFolder.resolve("Contents"); //$NON-NLS-1$
Path macosFolder = contentsFolder.resolve("MacOS"); //$NON-NLS-1$ Path macosFolder = contentsFolder.resolve("MacOS"); //$NON-NLS-1$
return macosFolder.resolve(projectName); return macosFolder.resolve(projectName);
case Platform.OS_WIN32: { case Platform.OS_WIN32:
String subdir = "run".equals(launchMode) ? "release" : "debug"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ return getBuildDirectory().resolve(projectName + ".exe"); //$NON-NLS-1$
return getBuildDirectory().resolve(subdir).resolve(projectName + ".exe"); //$NON-NLS-1$ case Platform.OS_LINUX:
} return getBuildDirectory().resolve(projectName); //$NON-NLS-1$
default: default:
Path releaseFolder = getBuildDirectory().resolve("release"); //$NON-NLS-1$ Path releaseFolder = getBuildDirectory().resolve("release"); //$NON-NLS-1$
return releaseFolder.resolve(projectName); return releaseFolder.resolve(projectName);
@ -160,9 +160,11 @@ public class QtBuildConfiguration extends CBuildConfiguration implements ICBuild
cmd.add(getQmakeCommand().toString()); cmd.add(getQmakeCommand().toString());
cmd.add("-E"); //$NON-NLS-1$ cmd.add("-E"); //$NON-NLS-1$
String config = getQmakeConfig(); String[] config = getQmakeConfig();
if (config != null) { if (config != null) {
cmd.add(config); for (String str : config) {
cmd.add(str);
}
} }
cmd.add(getProjectFile().toString()); cmd.add(getProjectFile().toString());
@ -280,16 +282,17 @@ public class QtBuildConfiguration extends CBuildConfiguration implements ICBuild
List<String> command = new ArrayList<>(); List<String> command = new ArrayList<>();
command.add(getQmakeCommand().toString()); command.add(getQmakeCommand().toString());
String config = getQmakeConfig(); String[] config = getQmakeConfig();
if (config != null) { if (config != null) {
command.add(config); for (String str : config) {
command.add(str);
}
} }
IFile projectFile = project.getFile(project.getName() + ".pro"); //$NON-NLS-1$ IFile projectFile = project.getFile(project.getName() + ".pro"); //$NON-NLS-1$
command.add(projectFile.getLocation().toOSString()); command.add(projectFile.getLocation().toOSString());
ProcessBuilder processBuilder = new ProcessBuilder(command) ProcessBuilder processBuilder = new ProcessBuilder(command).directory(getBuildDirectory().toFile());
.directory(getBuildDirectory().toFile());
setBuildEnvironment(processBuilder.environment()); setBuildEnvironment(processBuilder.environment());
Process process = processBuilder.start(); Process process = processBuilder.start();
@ -305,7 +308,7 @@ public class QtBuildConfiguration extends CBuildConfiguration implements ICBuild
} }
// run make // run make
ProcessBuilder processBuilder = new ProcessBuilder(makeCommand.toString()).directory(buildDir.toFile()); ProcessBuilder processBuilder = new ProcessBuilder(makeCommand.toString(), "all").directory(buildDir.toFile());
setBuildEnvironment(processBuilder.environment()); setBuildEnvironment(processBuilder.environment());
Process process = processBuilder.start(); Process process = processBuilder.start();
outStream.write(makeCommand.toString() + '\n'); outStream.write(makeCommand.toString() + '\n');

View file

@ -7,6 +7,7 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.qt.core.build; package org.eclipse.cdt.internal.qt.core.build;
import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -16,15 +17,14 @@ import org.eclipse.cdt.core.build.ICBuildConfigurationProvider;
import org.eclipse.cdt.core.build.IToolChain; import org.eclipse.cdt.core.build.IToolChain;
import org.eclipse.cdt.core.build.IToolChainManager; import org.eclipse.cdt.core.build.IToolChainManager;
import org.eclipse.cdt.internal.qt.core.Activator; import org.eclipse.cdt.internal.qt.core.Activator;
import org.eclipse.cdt.internal.qt.core.QtNature;
import org.eclipse.cdt.qt.core.IQtBuildConfiguration; import org.eclipse.cdt.qt.core.IQtBuildConfiguration;
import org.eclipse.cdt.qt.core.IQtInstall; import org.eclipse.cdt.qt.core.IQtInstall;
import org.eclipse.cdt.qt.core.IQtInstallManager; import org.eclipse.cdt.qt.core.IQtInstallManager;
import org.eclipse.cdt.qt.core.QtMinGWToolChainProvider;
import org.eclipse.core.resources.IBuildConfiguration; import org.eclipse.core.resources.IBuildConfiguration;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
public class QtBuildConfigurationProvider implements ICBuildConfigurationProvider { public class QtBuildConfigurationProvider implements ICBuildConfigurationProvider {
@ -43,83 +43,71 @@ public class QtBuildConfigurationProvider implements ICBuildConfigurationProvide
@Override @Override
public ICBuildConfiguration getCBuildConfiguration(IBuildConfiguration config, String name) { public ICBuildConfiguration getCBuildConfiguration(IBuildConfiguration config, String name) {
try { try {
// Double check to make sure this config is ours if (config.getName().equals(IBuildConfiguration.DEFAULT_CONFIG_NAME)) {
if (!config.getProject().hasNature(QtNature.ID)) { // try the toolchain for the local target
return null; Map<String, String> properties = new HashMap<>();
} properties.put(IToolChain.ATTR_OS, Platform.getOS());
properties.put(IToolChain.ATTR_ARCH, Platform.getOSArch());
for (IToolChain toolChain : toolChainManager.getToolChainsMatching(properties)) {
for (IQtInstall qtInstall : qtInstallManager.getInstalls()) {
if (qtInstallManager.supports(qtInstall, toolChain)) {
return new QtBuildConfiguration(config, name, toolChain, qtInstall, null);
}
}
}
return new QtBuildConfiguration(config, name); // local didn't work, try and find one that does
for (IToolChain toolChain : toolChainManager.getToolChainsMatching(new HashMap<>())) {
for (IQtInstall qtInstall : qtInstallManager.getInstalls()) {
if (qtInstallManager.supports(qtInstall, toolChain)) {
return new QtBuildConfiguration(config, name, toolChain, qtInstall, null);
}
}
}
// No valid combinations
return null;
} else {
return new QtBuildConfiguration(config, name);
}
} catch (CoreException e) { } catch (CoreException e) {
// Failed to create the build config. Return null so it gets recreated. // Failed to create the build config. Return null so it gets
// recreated.
Activator.log(e); Activator.log(e);
return null; return null;
} }
} }
@Override public IQtBuildConfiguration getConfiguration(IProject project, Map<String, String> properties, String launchMode,
public ICBuildConfiguration getDefaultCBuildConfiguration(IProject project) {
try {
if (!project.hasNature(QtNature.ID)) {
return null;
}
// try the local target as the default
Map<String, String> properties = new HashMap<>();
properties.put(IToolChain.ATTR_OS, Platform.getOS());
properties.put(IToolChain.ATTR_ARCH, Platform.getOSArch());
for (IToolChain toolChain : toolChainManager.getToolChainsMatching(properties)) {
IQtBuildConfiguration qtConfig = getConfiguration(project, toolChain, "run", new NullProgressMonitor()); //$NON-NLS-1$
if (qtConfig == null) {
qtConfig = createConfiguration(project, toolChain, "run", new NullProgressMonitor()); //$NON-NLS-1$
if (qtConfig != null) {
return qtConfig;
}
}
}
// local didn't work, try and find one that does
for (IToolChain toolChain : toolChainManager.getToolChainsMatching(new HashMap<>())) {
IQtBuildConfiguration qtConfig = getConfiguration(project, toolChain, "run", new NullProgressMonitor()); //$NON-NLS-1$
if (qtConfig == null) {
qtConfig = createConfiguration(project, toolChain, "run", new NullProgressMonitor()); //$NON-NLS-1$
if (qtConfig != null) {
return qtConfig;
}
}
}
} catch (CoreException e) {
Activator.log(e);
}
return null;
}
public IQtBuildConfiguration getConfiguration(IProject project, IToolChain toolChain, String launchMode,
IProgressMonitor monitor) throws CoreException { IProgressMonitor monitor) throws CoreException {
Collection<IToolChain> toolChains = toolChainManager.getToolChainsMatching(properties);
for (IBuildConfiguration config : project.getBuildConfigs()) { for (IBuildConfiguration config : project.getBuildConfigs()) {
ICBuildConfiguration cconfig = config.getAdapter(ICBuildConfiguration.class); ICBuildConfiguration cconfig = config.getAdapter(ICBuildConfiguration.class);
if (cconfig != null) { if (cconfig != null) {
IQtBuildConfiguration qtConfig = cconfig.getAdapter(IQtBuildConfiguration.class); IQtBuildConfiguration qtConfig = cconfig.getAdapter(IQtBuildConfiguration.class);
if (qtConfig != null && qtConfig.getLaunchMode().equals(launchMode) if (qtConfig != null && launchMode.equals(qtConfig.getLaunchMode())) {
&& qtConfig.getToolChain().equals(toolChain)) { for (IToolChain toolChain : toolChains) {
return qtConfig; if (qtConfig.getToolChain().equals(toolChain)) {
return qtConfig;
}
}
} }
} }
} }
return null;
}
public QtBuildConfiguration createConfiguration(IProject project, IToolChain toolChain, String launchMode, // Not found, create one
IProgressMonitor monitor) throws CoreException { for (IToolChain toolChain : toolChains) {
for (IQtInstall qtInstall : qtInstallManager.getInstalls()) { for (IQtInstall qtInstall : qtInstallManager.getInstalls()) {
if (qtInstallManager.supports(qtInstall, toolChain)) { if (qtInstallManager.supports(qtInstall, toolChain)) {
// TODO what if multiple matches // TODO what if multiple matches, this returns first match
String configName = "qt." + qtInstall.getSpec() + "." + launchMode; //$NON-NLS-1$ //$NON-NLS-2$ String configName = "qt." + qtInstall.getSpec() + "." + launchMode; //$NON-NLS-1$ //$NON-NLS-2$
IBuildConfiguration config = configManager.createBuildConfiguration(this, project, configName, IBuildConfiguration config = configManager.createBuildConfiguration(this, project, configName,
monitor); monitor);
QtBuildConfiguration qtConfig = new QtBuildConfiguration(config, configName, toolChain, qtInstall, QtBuildConfiguration qtConfig = new QtBuildConfiguration(config, configName, toolChain, qtInstall,
launchMode); launchMode);
configManager.addBuildConfiguration(config, qtConfig); configManager.addBuildConfiguration(config, qtConfig);
return qtConfig; return qtConfig;
}
} }
} }

View file

@ -0,0 +1,41 @@
/*******************************************************************************
* Copyright (c) 2016 QNX Software Systems 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
*******************************************************************************/
package org.eclipse.cdt.internal.qt.core.provider;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import org.eclipse.cdt.core.build.IToolChain;
import org.eclipse.cdt.internal.qt.core.QtInstall;
import org.eclipse.cdt.qt.core.IQtInstall;
import org.eclipse.cdt.qt.core.IQtInstallProvider;
import org.eclipse.core.runtime.Platform;
/**
* Qt install provider that looks for qmake on /usr/bin
*/
public class LinuxQtInstallProvider implements IQtInstallProvider {
@Override
public Collection<IQtInstall> getInstalls() {
if (Platform.getOS().equals(Platform.OS_LINUX)) {
Path qmakePath = Paths.get("/usr/bin/qmake"); //$NON-NLS-1$
if (Files.exists(qmakePath)) {
QtInstall install = new QtInstall(qmakePath);
install.setProperty(IToolChain.ATTR_PACKAGE, "system");
return Arrays.asList(install);
}
}
return Collections.emptyList();
}
}

View file

@ -14,6 +14,7 @@ import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import org.eclipse.cdt.core.build.IToolChain;
import org.eclipse.cdt.internal.qt.core.QtInstall; import org.eclipse.cdt.internal.qt.core.QtInstall;
import org.eclipse.cdt.qt.core.IQtInstall; import org.eclipse.cdt.qt.core.IQtInstall;
import org.eclipse.cdt.qt.core.IQtInstallProvider; import org.eclipse.cdt.qt.core.IQtInstallProvider;
@ -40,7 +41,9 @@ public class Msys2QtInstallProvider implements IQtInstallProvider {
if ("MSYS2 64bit".equals(displayName)) { //$NON-NLS-1$ if ("MSYS2 64bit".equals(displayName)) { //$NON-NLS-1$
String installLocation = registry.getCurrentUserValue(compKey, "InstallLocation"); //$NON-NLS-1$ String installLocation = registry.getCurrentUserValue(compKey, "InstallLocation"); //$NON-NLS-1$
Path qmakePath = Paths.get(installLocation + "\\mingw64\\bin\\qmake.exe"); //$NON-NLS-1$ Path qmakePath = Paths.get(installLocation + "\\mingw64\\bin\\qmake.exe"); //$NON-NLS-1$
installs.add(new QtInstall(qmakePath)); QtInstall install = new QtInstall(qmakePath);
install.setProperty(IToolChain.ATTR_PACKAGE, "msys2"); //$NON-NLS-1$
installs.add(install);
} }
} }
return installs; return installs;

View file

@ -16,6 +16,7 @@ import java.util.Collections;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.eclipse.cdt.codan.core.cxx.Activator; import org.eclipse.cdt.codan.core.cxx.Activator;
import org.eclipse.cdt.core.build.IToolChain;
import org.eclipse.cdt.internal.qt.core.QtInstall; import org.eclipse.cdt.internal.qt.core.QtInstall;
import org.eclipse.cdt.qt.core.IQtInstall; import org.eclipse.cdt.qt.core.IQtInstall;
import org.eclipse.cdt.qt.core.IQtInstallProvider; import org.eclipse.cdt.qt.core.IQtInstallProvider;
@ -27,14 +28,22 @@ import org.eclipse.core.runtime.Platform;
*/ */
public class QtInstallProvider implements IQtInstallProvider { public class QtInstallProvider implements IQtInstallProvider {
private static boolean isWin32 = Platform.getOS().equals(Platform.OS_WIN32);
@Override @Override
public Collection<IQtInstall> getInstalls() { public Collection<IQtInstall> getInstalls() {
Path root = getQtRoot(); Path root = getQtRoot();
Path qmake = Paths.get(Platform.getOS().equals(Platform.OS_WIN32) ? "bin/qmake.exe" : "bin/qmake"); //$NON-NLS-1$ //$NON-NLS-2$ Path qmake = Paths.get(isWin32 ? "bin/qmake.exe" : "bin/qmake"); //$NON-NLS-1$ //$NON-NLS-2$
if (root != null) { if (root != null && Files.exists(root)) {
try { try {
return Files.walk(root, 2).filter((path) -> Files.exists(path.resolve(qmake))) return Files.walk(root, 2).filter((path) -> Files.exists(path.resolve(qmake)))
.map((path) -> new QtInstall(path.resolve(qmake))).collect(Collectors.toList()); .map((path) -> {
QtInstall install = new QtInstall(path.resolve(qmake));
if (isWin32 && "win32-g++".equals(install.getSpec())) { //$NON-NLS-1$
install.setProperty(IToolChain.ATTR_PACKAGE, "qt"); //$NON-NLS-1$ //$NON-NLS-2$
}
return install;
}).collect(Collectors.toList());
} catch (IOException e) { } catch (IOException e) {
Activator.log(e); Activator.log(e);
} }
@ -43,14 +52,13 @@ public class QtInstallProvider implements IQtInstallProvider {
} }
private Path getQtRoot() { private Path getQtRoot() {
if (Platform.getOS().equals(Platform.OS_WIN32)) { if (isWin32) {
WindowsRegistry registry = WindowsRegistry.getRegistry(); WindowsRegistry registry = WindowsRegistry.getRegistry();
String uninstallKey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"; //$NON-NLS-1$ String uninstallKey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"; //$NON-NLS-1$
String subkey; String subkey;
for (int i = 0; (subkey = registry.getCurrentUserKeyName(uninstallKey, i)) != null; i++) { for (int i = 0; (subkey = registry.getCurrentUserKeyName(uninstallKey, i)) != null; i++) {
String compKey = uninstallKey + '\\' + subkey; String compKey = uninstallKey + '\\' + subkey;
String displayName = registry.getCurrentUserValue(compKey, "DisplayName"); //$NON-NLS-1$ String displayName = registry.getCurrentUserValue(compKey, "DisplayName"); //$NON-NLS-1$
// On Windows, look for MSYS2, MinGW 64/32 locations
if ("Qt".equals(displayName)) { //$NON-NLS-1$ if ("Qt".equals(displayName)) { //$NON-NLS-1$
String installLocation = registry.getCurrentUserValue(compKey, "InstallLocation"); //$NON-NLS-1$ String installLocation = registry.getCurrentUserValue(compKey, "InstallLocation"); //$NON-NLS-1$
return Paths.get(installLocation); return Paths.get(installLocation);

View file

@ -18,7 +18,7 @@ public interface IQtBuildConfiguration extends ICBuildConfiguration {
Path getQmakeCommand(); Path getQmakeCommand();
String getQmakeConfig(); String[] getQmakeConfig();
Path getProgramPath() throws CoreException; Path getProgramPath() throws CoreException;

View file

@ -8,6 +8,7 @@
package org.eclipse.cdt.qt.core; package org.eclipse.cdt.qt.core;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.Map;
/** /**
* Represents an installation of the Qt SDK. Qt installs are defined by the path * Represents an installation of the Qt SDK. Qt installs are defined by the path
@ -25,4 +26,8 @@ public interface IQtInstall {
Path getQmlPath(); Path getQmlPath();
void setProperty(String key, String value);
Map<String, String> getProperties();
} }

View file

@ -12,7 +12,6 @@ import java.util.Map;
import org.eclipse.cdt.core.build.ICBuildConfigurationManager; import org.eclipse.cdt.core.build.ICBuildConfigurationManager;
import org.eclipse.cdt.core.build.IToolChain; import org.eclipse.cdt.core.build.IToolChain;
import org.eclipse.cdt.core.build.IToolChainManager;
import org.eclipse.cdt.internal.qt.core.Activator; import org.eclipse.cdt.internal.qt.core.Activator;
import org.eclipse.cdt.internal.qt.core.build.QtBuildConfigurationProvider; import org.eclipse.cdt.internal.qt.core.build.QtBuildConfigurationProvider;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
@ -71,19 +70,12 @@ public abstract class QtLaunchConfigurationDelegate extends LaunchConfigurationT
.getProvider(QtBuildConfigurationProvider.ID); .getProvider(QtBuildConfigurationProvider.ID);
IProject project = configuration.getMappedResources()[0].getProject(); IProject project = configuration.getMappedResources()[0].getProject();
// Find the toolchains that support this target
Map<String, String> properties = new HashMap<>(); Map<String, String> properties = new HashMap<>();
populateToolChainProperties(target, properties); populateToolChainProperties(target, properties);
IToolChainManager toolChainManager = Activator.getService(IToolChainManager.class); IQtBuildConfiguration qtConfig = provider.getConfiguration(project, properties, mode, monitor);
for (IToolChain toolChain : toolChainManager.getToolChainsMatching(properties)) { if (qtConfig != null) {
IQtBuildConfiguration qtConfig = provider.getConfiguration(project, toolChain, mode, monitor); return qtConfig;
if (qtConfig == null) {
qtConfig = provider.createConfiguration(project, toolChain, mode, monitor);
}
if (qtConfig != null) {
return qtConfig;
}
} }
// Couldn't find any // Couldn't find any

View file

@ -13,6 +13,7 @@ import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import org.eclipse.cdt.build.gcc.core.GCCToolChain; import org.eclipse.cdt.build.gcc.core.GCCToolChain;
import org.eclipse.cdt.core.build.IToolChain;
import org.eclipse.cdt.core.build.IToolChainManager; import org.eclipse.cdt.core.build.IToolChainManager;
import org.eclipse.cdt.core.build.IToolChainProvider; import org.eclipse.cdt.core.build.IToolChainProvider;
import org.eclipse.cdt.internal.qt.core.Activator; import org.eclipse.cdt.internal.qt.core.Activator;
@ -22,7 +23,8 @@ import org.eclipse.core.runtime.Platform;
public class QtMinGWToolChainProvider implements IToolChainProvider { public class QtMinGWToolChainProvider implements IToolChainProvider {
private static final String ID = "org.eclipse.cdt.qt.core.qtMinGWProvider"; //$NON-NLS-1$ public static final String ID = "org.eclipse.cdt.qt.core.qtMinGWProvider"; //$NON-NLS-1$
public static final String TOOLCHAIN_ID = "qt.mingw"; //$NON-NLS-1$
@Override @Override
public String getId() { public String getId() {
@ -39,15 +41,20 @@ public class QtMinGWToolChainProvider implements IToolChainProvider {
String compKey = uninstallKey + '\\' + subkey; String compKey = uninstallKey + '\\' + subkey;
String displayName = registry.getCurrentUserValue(compKey, "DisplayName"); //$NON-NLS-1$ String displayName = registry.getCurrentUserValue(compKey, "DisplayName"); //$NON-NLS-1$
if ("Qt".equals(displayName)) { //$NON-NLS-1$ if ("Qt".equals(displayName)) { //$NON-NLS-1$
String installLocation = registry.getCurrentUserValue(compKey, "InstallLocation"); //$NON-NLS-1$ Path installLocation = Paths.get(registry.getCurrentUserValue(compKey, "InstallLocation")); //$NON-NLS-1$
Path gcc = Paths.get("\\bin\\gcc.exe"); //$NON-NLS-1$ if (Files.exists(installLocation)) {
try { Path gcc = Paths.get("bin\\gcc.exe"); //$NON-NLS-1$
Files.walk(Paths.get(installLocation).resolve("Tools"), 1) //$NON-NLS-1$ try {
.filter((path) -> Files.exists(path.resolve(gcc))) Files.walk(installLocation.resolve("Tools"), 1) //$NON-NLS-1$
.map((path) -> new GCCToolChain(this, "qt.mingw", "", new Path[] { path.resolve("bin") })) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ .filter(path -> Files.exists(path.resolve(gcc))).map(path -> {
.forEach(toolChain -> manager.addToolChain(toolChain)); GCCToolChain toolChain = new GCCToolChain(this, TOOLCHAIN_ID, "", //$NON-NLS-1$
} catch (IOException e) { new Path[] { path.resolve("bin") }); //$NON-NLS-1$
Activator.log(e); toolChain.setProperty(IToolChain.ATTR_PACKAGE, "qt"); //$NON-NLS-1$
return toolChain;
}).forEach(toolChain -> manager.addToolChain(toolChain));
} catch (IOException e) {
Activator.log(e);
}
} }
} }
} }

View file

@ -6,3 +6,11 @@ CONFIG += c++11
RESOURCES += ${projectName}.qrc RESOURCES += ${projectName}.qrc
qml.files = src/${projectName}.qml qml.files = src/${projectName}.qml
launch_modeall {
CONFIG(debug, debug|release) {
DESTDIR = debug
} else {
DESTDIR = release
}
}

View file

@ -81,7 +81,7 @@ public class NewQtInstallWizardPage extends WizardPage {
@Override @Override
protected IStatus run(IProgressMonitor monitor) { protected IStatus run(IProgressMonitor monitor) {
try { try {
String spec = QtInstall.getSpec(selected); String spec = QtInstall.getSpec(Paths.get(selected));
getControl().getDisplay().asyncExec(() -> { getControl().getDisplay().asyncExec(() -> {
specText.setText(spec); specText.setText(spec);
}); });

View file

@ -26,7 +26,7 @@
<import feature="org.eclipse.remote" version="2.0.0"/> <import feature="org.eclipse.remote" version="2.0.0"/>
<import feature="org.eclipse.remote.console" version="2.0.0"/> <import feature="org.eclipse.remote.console" version="2.0.0"/>
<import feature="org.eclipse.cdt" version="9.0.0"/> <import feature="org.eclipse.cdt" version="9.0.0"/>
<import feature="org.eclipse.launchbar.remote" version="1.0.0.qualifier"/> <import feature="org.eclipse.launchbar.remote" version="1.0.0"/>
</requires> </requires>
<plugin <plugin

View file

@ -0,0 +1,205 @@
/*******************************************************************************
* Copyright (c) 2015, 2016 QNX Software Systems 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
*******************************************************************************/
package org.eclipse.cdt.arduino.core.tests;
import java.net.URL;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
import org.eclipse.cdt.arduino.core.internal.Activator;
import org.eclipse.cdt.arduino.core.internal.ArduinoPreferences;
import org.eclipse.cdt.arduino.core.internal.ArduinoProjectGenerator;
import org.eclipse.cdt.arduino.core.internal.board.ArduinoBoard;
import org.eclipse.cdt.arduino.core.internal.board.ArduinoManager;
import org.eclipse.cdt.arduino.core.internal.board.ArduinoPlatform;
import org.eclipse.cdt.arduino.core.internal.build.ArduinoBuildConfiguration;
import org.eclipse.cdt.arduino.core.internal.build.ArduinoBuildConfigurationProvider;
import org.eclipse.cdt.arduino.core.internal.remote.ArduinoRemoteConnection;
import org.eclipse.cdt.core.build.ICBuildConfigurationManager;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.remote.core.IRemoteConnection;
import org.eclipse.remote.core.IRemoteConnectionType;
import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
import org.eclipse.remote.core.IRemoteServicesManager;
import org.junit.Test;
@SuppressWarnings("nls")
public class FullIntegration {
private static final ArduinoManager arduinoManager = Activator.getService(ArduinoManager.class);
private static final IRemoteServicesManager remoteManager = Activator.getService(IRemoteServicesManager.class);
private static final ICBuildConfigurationManager buildConfigManager = Activator
.getService(ICBuildConfigurationManager.class);
private void setBoardUrls() throws Exception {
URL[] urls = new URL[] { new URL("http://downloads.arduino.cc/packages/package_index.json"),
new URL("https://adafruit.github.io/arduino-board-index/package_adafruit_index.json") };
ArduinoPreferences.setBoardUrlList(urls);
}
private Set<ArduinoBoard> getSkipBuild() throws Exception {
Set<ArduinoBoard> boards = new HashSet<>();
// Fails in arduino too
boards.add(arduinoManager.getBoard("arduino", "avr", "robotControl"));
boards.add(arduinoManager.getBoard("arduino", "avr", "robotMotor"));
boards.add(arduinoManager.getBoard("adafruit", "avr", "adafruit32u4"));
// TODO Need to add support for menu specific build properties
boards.add(arduinoManager.getBoard("arduino", "avr", "mini"));
boards.add(arduinoManager.getBoard("arduino", "avr", "lilypad"));
boards.add(arduinoManager.getBoard("arduino", "avr", "diecimila"));
boards.add(arduinoManager.getBoard("arduino", "avr", "pro"));
boards.add(arduinoManager.getBoard("arduino", "avr", "atmegang"));
boards.add(arduinoManager.getBoard("arduino", "avr", "bt"));
boards.add(arduinoManager.getBoard("arduino", "avr", "mega"));
boards.add(arduinoManager.getBoard("arduino", "avr", "nano"));
boards.add(arduinoManager.getBoard("TeeOnArdu", "avr", "CirPlayTeensyCore"));
boards.add(arduinoManager.getBoard("TeeOnArdu", "avr", "FloraTeensyCore"));
boards.add(arduinoManager.getBoard("TeeOnArdu", "avr", "TeeOnArdu"));
// TODO build.system.path missing
boards.add(arduinoManager.getBoard("arduino", "sam", "arduino_due_x"));
boards.add(arduinoManager.getBoard("arduino", "sam", "arduino_due_x_dbg"));
boards.add(arduinoManager.getBoard("Intel", "arc32", "arduino_101"));
if (Platform.getOS().equals(Platform.OS_WIN32)) {
// i586/i686 link missing
boards.add(arduinoManager.getBoard("Intel", "i586", "izmir_fd"));
boards.add(arduinoManager.getBoard("Intel", "i586", "izmir_fg"));
boards.add(arduinoManager.getBoard("Intel", "i686", "izmir_ec"));
}
return boards;
}
private Set<ArduinoBoard> getSkipUpload() throws Exception {
Set<ArduinoBoard> boards = new HashSet<>();
// missing upload.protocol
boards.add(arduinoManager.getBoard("arduino", "avr", "gemma"));
boards.add(arduinoManager.getBoard("adafruit", "avr", "gemma"));
boards.add(arduinoManager.getBoard("adafruit", "avr", "trinket5"));
boards.add(arduinoManager.getBoard("adafruit", "avr", "trinket3"));
// usbtiny missing
boards.add(arduinoManager.getBoard("adafruit", "avr", "protrinket3"));
boards.add(arduinoManager.getBoard("adafruit", "avr", "protrinket5"));
return boards;
}
@Test
public void runTest() throws Exception {
IProgressMonitor monitor = new SysoutProgressMonitor();
setArduinoHome();
setBoardUrls();
loadPlatforms(monitor);
Set<ArduinoBoard> skipBuild = getSkipBuild();
Set<ArduinoBoard> skipUpload = getSkipUpload();
IProject project = createProject(monitor);
for (ArduinoBoard board : arduinoManager.getInstalledBoards()) {
if (!skipBuild.contains(board)) {
buildBoard(project, board, !skipUpload.contains(board), monitor);
}
}
}
private void setArduinoHome() throws Exception {
Path workspace = Paths.get(ResourcesPlugin.getWorkspace().getRoot().getLocationURI());
ArduinoPreferences.setArduinoHome(workspace.resolve(".arduinocdt"));
}
private void loadPlatforms(IProgressMonitor monitor) throws Exception {
Collection<ArduinoPlatform> plats = arduinoManager.getAvailablePlatforms(monitor);
arduinoManager.installPlatforms(plats, monitor);
}
private IProject createProject(IProgressMonitor monitor) throws Exception {
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
String projectName = "ArduinoTest";
ArduinoProjectGenerator generator = new ArduinoProjectGenerator("templates/cppsketch/manifest.xml"); //$NON-NLS-1$
Job job = new Job("Create") {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
IProject project = root.getProject(projectName);
if (project.exists()) {
project.delete(true, monitor);
}
generator.setProjectName(projectName);
generator.generate(new HashMap<String, Object>(), monitor);
return Status.OK_STATUS;
} catch (CoreException e) {
return e.getStatus();
}
}
};
job.setRule(root);
job.schedule();
job.join();
return generator.getProject();
}
private void buildBoard(IProject project, ArduinoBoard board, boolean upload, IProgressMonitor monitor) throws Exception {
ArduinoRemoteConnection arduinoTarget = createTarget(board);
ArduinoBuildConfigurationProvider provider = (ArduinoBuildConfigurationProvider) buildConfigManager
.getProvider(ArduinoBuildConfigurationProvider.ID);
ArduinoBuildConfiguration config = provider.createConfiguration(project, arduinoTarget, "run", monitor);
System.out.println(String.format("Building board: %s\n %s - %s", board.getName(), board.getId(),
board.getPlatform().getInstallPath()));
config.generateMakeFile(monitor);
ProcessBuilder processBuilder = new ProcessBuilder().command(config.getBuildCommand())
.directory(config.getBuildDirectory().toFile()).inheritIO();
config.setBuildEnvironment(processBuilder.environment());
Process process = processBuilder.start();
int rc = process.waitFor();
if (rc != 0) {
throw new Exception("Build failed");
}
// Test to make sure we can get the upload command cleanly
if (upload) {
System.out.println(String.join(" ", config.getUploadCommand("port1")));
}
}
private ArduinoRemoteConnection createTarget(ArduinoBoard board) throws Exception {
IRemoteConnectionType type = remoteManager.getConnectionType(ArduinoRemoteConnection.TYPE_ID);
IRemoteConnection connection = type.getConnection(board.getName());
if (connection != null) {
type.removeConnection(connection);
}
IRemoteConnectionWorkingCopy workingCopy = type.newConnection(board.getName());
ArduinoRemoteConnection.setBoardId(workingCopy, board);
ArduinoRemoteConnection.setPortName(workingCopy, "port1");
connection = workingCopy.save();
return connection.getService(ArduinoRemoteConnection.class);
}
}

View file

@ -0,0 +1,38 @@
/*******************************************************************************
* Copyright (c) 2015, 2016 QNX Software Systems 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
*******************************************************************************/
package org.eclipse.cdt.arduino.core.tests;
import org.eclipse.core.runtime.NullProgressMonitor;
public class SysoutProgressMonitor extends NullProgressMonitor {
@Override
public void beginTask(String name, int totalWork) {
if (name.length() > 0) {
System.out.println(name);
System.out.flush();
}
}
@Override
public void subTask(String name) {
if (name.length() > 0) {
System.out.println(name);
System.out.flush();
}
}
@Override
public void setTaskName(String name) {
if (name.length() > 0) {
System.out.println(name);
System.out.flush();
}
}
}

View file

@ -38,11 +38,15 @@ public class ArduinoPreferences {
return Paths.get(getPrefs().get(ARDUINO_HOME, defaultHome)); return Paths.get(getPrefs().get(ARDUINO_HOME, defaultHome));
} }
public static void setArduinoHome(Path home) {
getPrefs().put(ARDUINO_HOME, home.toString());
}
public static String getBoardUrls() { public static String getBoardUrls() {
return getPrefs().get(BOARD_URLS, defaultBoardUrls); return getPrefs().get(BOARD_URLS, defaultBoardUrls);
} }
public static Collection<URL> getBoardUrlList() throws CoreException { public static URL[] getBoardUrlList() throws CoreException {
List<URL> urlList = new ArrayList<>(); List<URL> urlList = new ArrayList<>();
for (String url : getBoardUrls().split("\n")) { //$NON-NLS-1$ for (String url : getBoardUrls().split("\n")) { //$NON-NLS-1$
try { try {
@ -51,7 +55,7 @@ public class ArduinoPreferences {
throw Activator.coreException(e); throw Activator.coreException(e);
} }
} }
return urlList; return urlList.toArray(new URL[urlList.size()]);
} }
public static void setBoardUrls(String boardUrls) { public static void setBoardUrls(String boardUrls) {
@ -64,6 +68,22 @@ public class ArduinoPreferences {
} }
} }
public static void setBoardUrlList(URL[] urls) {
StringBuilder str = new StringBuilder();
for (int i = 0; i < urls.length - 1; ++i) {
str.append(urls[i].toString());
str.append('\n');
}
if (urls.length > 0) {
str.append(urls[urls.length - 1].toString());
}
setBoardUrls(str.toString());
}
public static String getDefaultArduinoHome() {
return defaultHome;
}
public static String getDefaultBoardUrls() { public static String getDefaultBoardUrls() {
return defaultBoardUrls; return defaultBoardUrls;
} }

View file

@ -13,8 +13,6 @@ import org.eclipse.cdt.arduino.core.internal.HierarchicalProperties;
public class ArduinoBoard { public class ArduinoBoard {
public static final String MENU_QUALIFIER = "menu_"; //$NON-NLS-1$
private String name; private String name;
private String id; private String id;

View file

@ -90,7 +90,7 @@ public class ArduinoManager {
return ArduinoPreferences.getArduinoHome().resolve(".version"); //$NON-NLS-1$ return ArduinoPreferences.getArduinoHome().resolve(".version"); //$NON-NLS-1$
} }
private void init() throws CoreException { private synchronized void init() throws CoreException {
if (props == null) { if (props == null) {
if (!Files.exists(ArduinoPreferences.getArduinoHome())) { if (!Files.exists(ArduinoPreferences.getArduinoHome())) {
try { try {
@ -219,12 +219,12 @@ public class ArduinoManager {
return pkg != null ? pkg.getInstalledPlatform(architecture) : null; return pkg != null ? pkg.getInstalledPlatform(architecture) : null;
} }
public Collection<ArduinoPlatform> getAvailablePlatforms(IProgressMonitor monitor) throws CoreException { public synchronized Collection<ArduinoPlatform> getAvailablePlatforms(IProgressMonitor monitor) throws CoreException {
List<ArduinoPlatform> platforms = new ArrayList<>(); List<ArduinoPlatform> platforms = new ArrayList<>();
Collection<URL> urls = ArduinoPreferences.getBoardUrlList(); URL[] urls = ArduinoPreferences.getBoardUrlList();
SubMonitor sub = SubMonitor.convert(monitor, urls.size() + 1); SubMonitor sub = SubMonitor.convert(monitor, urls.length + 1);
sub.beginTask("Downloading package descriptions", urls.size()); //$NON-NLS-1$ sub.beginTask("Downloading package descriptions", urls.length); //$NON-NLS-1$
for (URL url : urls) { for (URL url : urls) {
Path packagePath = ArduinoPreferences.getArduinoHome() Path packagePath = ArduinoPreferences.getArduinoHome()
.resolve(Paths.get(url.getPath()).getFileName()); .resolve(Paths.get(url.getPath()).getFileName());
@ -252,7 +252,7 @@ public class ArduinoManager {
public void installPlatforms(Collection<ArduinoPlatform> platforms, IProgressMonitor monitor) throws CoreException { public void installPlatforms(Collection<ArduinoPlatform> platforms, IProgressMonitor monitor) throws CoreException {
SubMonitor sub = SubMonitor.convert(monitor, platforms.size()); SubMonitor sub = SubMonitor.convert(monitor, platforms.size());
for (ArduinoPlatform platform : platforms) { for (ArduinoPlatform platform : platforms) {
sub.setTaskName(String.format("Installing %s", platform.getName())); //$NON-NLS-1$ sub.setTaskName(String.format("Installing %s %s", platform.getName(), platform.getVersion())); //$NON-NLS-1$
platform.install(sub); platform.install(sub);
sub.worked(1); sub.worked(1);
} }
@ -292,7 +292,7 @@ public class ArduinoManager {
return result; return result;
} }
private void initPackages() throws CoreException { private synchronized void initPackages() throws CoreException {
if (packages == null) { if (packages == null) {
init(); init();
packages = new HashMap<>(); packages = new HashMap<>();
@ -326,7 +326,7 @@ public class ArduinoManager {
packages = null; packages = null;
} }
private ArduinoPackage getPackage(String packageName) throws CoreException { public ArduinoPackage getPackage(String packageName) throws CoreException {
if (packageName == null) { if (packageName == null) {
return null; return null;
} else { } else {

View file

@ -92,24 +92,27 @@ public class ArduinoPackage {
if (Files.isDirectory(getInstallPath())) { if (Files.isDirectory(getInstallPath())) {
Path platformTxt = Paths.get("platform.txt"); //$NON-NLS-1$ Path platformTxt = Paths.get("platform.txt"); //$NON-NLS-1$
try { try {
Files.find(getInstallPath().resolve("hardware"), 2, //$NON-NLS-1$ Path hardware = getInstallPath().resolve("hardware");
(path, attrs) -> path.getFileName().equals(platformTxt)) if (Files.exists(hardware)) {
.forEach(path -> { Files.find(hardware, 2, // $NON-NLS-1$
try (FileReader reader = new FileReader(path.toFile())) { (path, attrs) -> path.getFileName().equals(platformTxt)).forEach(path -> {
Properties platformProperties = new Properties(); try (FileReader reader = new FileReader(path.toFile())) {
platformProperties.load(reader); Properties platformProperties = new Properties();
String arch = path.getName(path.getNameCount() - 2).toString(); platformProperties.load(reader);
String version = platformProperties.getProperty("version"); //$NON-NLS-1$ String arch = path.getName(path.getNameCount() - 2).toString();
String version = platformProperties.getProperty("version"); //$NON-NLS-1$
ArduinoPlatform platform = getPlatform(arch, version); ArduinoPlatform platform = getPlatform(arch, version);
if (platform != null) { if (platform != null) {
platform.setPlatformProperties(platformProperties); platform.setPlatformProperties(platformProperties);
installedPlatforms.put(arch, platform); installedPlatforms.put(arch, platform);
} // TODO manually add it if was removed from index } // TODO manually add it if was removed
} catch (IOException e) { // from index
throw new RuntimeException(e); } catch (IOException e) {
} throw new RuntimeException(e);
}); }
});
}
} catch (IOException e) { } catch (IOException e) {
throw Activator.coreException(e); throw Activator.coreException(e);
} }
@ -166,6 +169,18 @@ public class ArduinoPackage {
return null; return null;
} }
public ArduinoTool getLatestTool(String toolName) {
ArduinoTool latest = null;
for (ArduinoTool tool : tools) {
if (tool.getName().equals(toolName) && tool.isInstalled()) {
if (latest == null || ArduinoManager.compareVersions(tool.getVersion(), latest.getVersion()) > 0) {
latest = tool;
}
}
}
return latest;
}
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj instanceof ArduinoPackage) { if (obj instanceof ArduinoPackage) {

View file

@ -20,7 +20,6 @@ import java.net.URL;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -31,7 +30,6 @@ import org.eclipse.cdt.arduino.core.internal.Activator;
import org.eclipse.cdt.arduino.core.internal.ArduinoPreferences; import org.eclipse.cdt.arduino.core.internal.ArduinoPreferences;
import org.eclipse.cdt.arduino.core.internal.HierarchicalProperties; import org.eclipse.cdt.arduino.core.internal.HierarchicalProperties;
import org.eclipse.cdt.arduino.core.internal.Messages; import org.eclipse.cdt.arduino.core.internal.Messages;
import org.eclipse.cdt.arduino.core.internal.build.ArduinoBuildConfiguration;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
@ -209,39 +207,6 @@ public class ArduinoPlatform {
return getPackage().getInstallPath().resolve("hardware").resolve(architecture); //$NON-NLS-1$ return getPackage().getInstallPath().resolve("hardware").resolve(architecture); //$NON-NLS-1$
} }
public List<Path> getIncludePath() {
Path installPath = getInstallPath();
return Arrays.asList(installPath.resolve("cores/{build.core}"), //$NON-NLS-1$
installPath.resolve("variants/{build.variant}")); //$NON-NLS-1$
}
private void getSources(Collection<String> sources, Path dir, boolean recurse) {
for (File file : dir.toFile().listFiles()) {
if (file.isDirectory()) {
if (recurse) {
getSources(sources, file.toPath(), recurse);
}
} else {
if (ArduinoBuildConfiguration.isSource(file.getName())) {
sources.add(ArduinoBuildConfiguration.pathString(file.toPath()));
}
}
}
}
public Collection<String> getSources(String core, String variant) {
List<String> sources = new ArrayList<>();
Path srcPath = getInstallPath().resolve("cores").resolve(core); //$NON-NLS-1$
if (srcPath.toFile().isDirectory()) {
getSources(sources, srcPath, true);
}
Path variantPath = getInstallPath().resolve("variants").resolve(variant); //$NON-NLS-1$
if (variantPath.toFile().isDirectory()) {
getSources(sources, variantPath, true);
}
return sources;
}
private void initLibraries() throws CoreException { private void initLibraries() throws CoreException {
if (libraries == null) { if (libraries == null) {
libraries = new HashMap<>(); libraries = new HashMap<>();

View file

@ -87,6 +87,7 @@ public class ArduinoTool {
for (ArduinoToolSystem system : systems) { for (ArduinoToolSystem system : systems) {
if (system.isApplicable()) { if (system.isApplicable()) {
system.install(monitor); system.install(monitor);
return;
} }
} }

View file

@ -23,8 +23,10 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties; import java.util.Properties;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -38,6 +40,7 @@ import org.eclipse.cdt.arduino.core.internal.board.ArduinoLibrary;
import org.eclipse.cdt.arduino.core.internal.board.ArduinoManager; import org.eclipse.cdt.arduino.core.internal.board.ArduinoManager;
import org.eclipse.cdt.arduino.core.internal.board.ArduinoPackage; import org.eclipse.cdt.arduino.core.internal.board.ArduinoPackage;
import org.eclipse.cdt.arduino.core.internal.board.ArduinoPlatform; import org.eclipse.cdt.arduino.core.internal.board.ArduinoPlatform;
import org.eclipse.cdt.arduino.core.internal.board.ArduinoTool;
import org.eclipse.cdt.arduino.core.internal.board.ToolDependency; import org.eclipse.cdt.arduino.core.internal.board.ToolDependency;
import org.eclipse.cdt.arduino.core.internal.remote.ArduinoRemoteConnection; import org.eclipse.cdt.arduino.core.internal.remote.ArduinoRemoteConnection;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
@ -79,6 +82,7 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration implements Te
private static final String PACKAGE_NAME = "packageName"; //$NON-NLS-1$ private static final String PACKAGE_NAME = "packageName"; //$NON-NLS-1$
private static final String PLATFORM_NAME = "platformName"; //$NON-NLS-1$ private static final String PLATFORM_NAME = "platformName"; //$NON-NLS-1$
private static final String BOARD_NAME = "boardName"; //$NON-NLS-1$ private static final String BOARD_NAME = "boardName"; //$NON-NLS-1$
private static final String MENU_QUALIFIER = "menu_"; //$NON-NLS-1$
private static ArduinoManager manager = Activator.getService(ArduinoManager.class); private static ArduinoManager manager = Activator.getService(ArduinoManager.class);
@ -117,8 +121,7 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration implements Te
} }
ArduinoBuildConfiguration(IBuildConfiguration config, String name, ArduinoBoard board, String launchMode, ArduinoBuildConfiguration(IBuildConfiguration config, String name, ArduinoBoard board, String launchMode,
IToolChain toolChain) IToolChain toolChain) throws CoreException {
throws CoreException {
super(config, name, toolChain); super(config, name, toolChain);
this.board = board; this.board = board;
this.launchMode = launchMode; this.launchMode = launchMode;
@ -148,10 +151,9 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration implements Te
if (menus != null) { if (menus != null) {
Preferences settings = getSettings(); Preferences settings = getSettings();
for (String id : menus.getChildren().keySet()) { for (String id : menus.getChildren().keySet()) {
String key = ArduinoBoard.MENU_QUALIFIER + id; String value = target.getMenuValue(id);
String value = target.getRemoteConnection().getAttribute(key);
if (value != null) { if (value != null) {
settings.put(key, value); settings.put(MENU_QUALIFIER + id, value);
} }
} }
@ -164,7 +166,9 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration implements Te
} }
static String generateName(ArduinoBoard board, String launchMode) { static String generateName(ArduinoBoard board, String launchMode) {
return "arduino." + board.getId() + '.' + launchMode; //$NON-NLS-1$ ArduinoPlatform platform = board.getPlatform();
ArduinoPackage pkg = platform.getPackage();
return pkg.getName() + '.' + platform.getArchitecture() + '.' + board.getId() + '.' + launchMode;
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -190,8 +194,7 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration implements Te
HierarchicalProperties menus = board.getMenus(); HierarchicalProperties menus = board.getMenus();
if (menus != null) { if (menus != null) {
for (String id : menus.getChildren().keySet()) { for (String id : menus.getChildren().keySet()) {
String key = ArduinoBoard.MENU_QUALIFIER + id; if (!settings.get(MENU_QUALIFIER + id, "").equals(target.getMenuValue(id))) { //$NON-NLS-1$
if (!settings.get(key, "").equals(target.getRemoteConnection().getAttribute(key))) { //$NON-NLS-1$
return false; return false;
} }
} }
@ -211,19 +214,43 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration implements Te
// IDE generated properties // IDE generated properties
properties = new Properties(); properties = new Properties();
properties.put("runtime.platform.path", platform.getInstallPath().toString()); //$NON-NLS-1$ properties.put("runtime.platform.path", platform.getInstallPath().toString()); //$NON-NLS-1$
properties.put("runtime.ide.version", "10607"); //$NON-NLS-1$ //$NON-NLS-2$ properties.put("runtime.ide.version", "10608"); //$NON-NLS-1$ //$NON-NLS-2$
properties.put("software", "ARDUINO"); //$NON-NLS-1$ //$NON-NLS-2$ properties.put("software", "ARDUINO"); //$NON-NLS-1$ //$NON-NLS-2$
properties.put("build.arch", platform.getArchitecture().toUpperCase()); //$NON-NLS-1$ properties.put("build.arch", platform.getArchitecture().toUpperCase()); //$NON-NLS-1$
String configName = getBuildConfiguration().getName(); String configName = getBuildConfiguration().getName();
if (configName.equals(IBuildConfiguration.DEFAULT_CONFIG_NAME)) { if (configName.equals(IBuildConfiguration.DEFAULT_CONFIG_NAME)) {
configName = "default"; //$NON-NLS-1$ configName = "default"; //$NON-NLS-1$
} }
properties.put("build.path", configName); //$NON-NLS-1$ properties.put("build.path", "."); //$NON-NLS-1$ //$NON-NLS-2$
properties.put("build.variant.path", //$NON-NLS-1$ properties.put("build.variant.path", //$NON-NLS-1$
platform.getInstallPath().resolve("variants").resolve("{build.variant}").toString()); //$NON-NLS-1$ //$NON-NLS-2$ platform.getInstallPath().resolve("variants").resolve("{build.variant}").toString()); //$NON-NLS-1$ //$NON-NLS-2$
// Everyone seems to want to use the avr-gcc and avrdude tools
ArduinoPackage arduinoPackage = manager.getPackage("arduino"); //$NON-NLS-1$
ArduinoTool avrgcc = arduinoPackage.getLatestTool("avr-gcc"); //$NON-NLS-1$
if (avrgcc != null) {
properties.put("runtime.tools.avr-gcc.path", avrgcc.getInstallPath().toString()); //$NON-NLS-1$
}
ArduinoTool avrdude = arduinoPackage.getLatestTool("avrdude"); //$NON-NLS-1$
if (avrdude != null) {
properties.put("runtime.tools.avrdude.path", avrdude.getInstallPath().toString()); //$NON-NLS-1$
}
// Super Platform
String core = board.getBoardProperties().getProperty("build.core"); //$NON-NLS-1$
if (core.contains(":")) { //$NON-NLS-1$
String[] segments = core.split(":"); //$NON-NLS-1$
if (segments.length == 2) {
ArduinoPlatform superPlatform = manager.getInstalledPlatform(segments[0],
platform.getArchitecture());
if (superPlatform != null) {
properties.putAll(superPlatform.getPlatformProperties());
}
}
}
// Platform // Platform
properties.putAll(board.getPlatform().getPlatformProperties()); properties.putAll(platform.getPlatformProperties());
// Tools // Tools
for (ToolDependency toolDep : platform.getToolsDependencies()) { for (ToolDependency toolDep : platform.getToolsDependencies()) {
@ -238,10 +265,18 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration implements Te
Preferences settings = getSettings(); Preferences settings = getSettings();
HierarchicalProperties menus = board.getMenus(); HierarchicalProperties menus = board.getMenus();
if (menus != null) { if (menus != null) {
for (String menuId : menus.getChildren().keySet()) { for (Entry<String, HierarchicalProperties> menuEntry : menus.getChildren().entrySet()) {
String value = settings.get(ArduinoBoard.MENU_QUALIFIER + menuId, ""); //$NON-NLS-1$ String key = menuEntry.getKey();
String defaultValue;
Iterator<HierarchicalProperties> i = menuEntry.getValue().getChildren().values().iterator();
if (i.hasNext()) {
defaultValue = i.next().getValue();
} else {
defaultValue = ""; //$NON-NLS-1$
}
String value = settings.get(MENU_QUALIFIER + key, defaultValue);
if (!value.isEmpty()) { if (!value.isEmpty()) {
properties.putAll(board.getMenuProperties(menuId, value)); properties.putAll(board.getMenuProperties(key, value));
} }
} }
} }
@ -252,13 +287,6 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration implements Te
return properties; return properties;
} }
public IFile getMakeFile() throws CoreException {
IFolder buildFolder = (IFolder) getBuildContainer();
ArduinoBoard board = getBoard();
String makeFileName = board.getId() + ".mk"; //$NON-NLS-1$
return buildFolder.getFile(makeFileName);
}
public Map<String, Object> getBuildModel() throws CoreException { public Map<String, Object> getBuildModel() throws CoreException {
IProject project = getProject(); IProject project = getProject();
ArduinoBoard board = getBoard(); ArduinoBoard board = getBoard();
@ -301,7 +329,7 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration implements Te
buildModel.put("project_name", project.getName()); //$NON-NLS-1$ buildModel.put("project_name", project.getName()); //$NON-NLS-1$
String includes = null; String includes = null;
for (Path include : platform.getIncludePath()) { for (Path include : getIncludePath(platform, properties)) {
if (includes == null) { if (includes == null) {
includes = "-I"; //$NON-NLS-1$ includes = "-I"; //$NON-NLS-1$
} else { } else {
@ -316,10 +344,35 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration implements Te
} }
properties.put("includes", includes); //$NON-NLS-1$ properties.put("includes", includes); //$NON-NLS-1$
Path platformPath = platform.getInstallPath(); ArduinoPlatform corePlatform = platform;
buildModel.put("platform_path", pathString(platformPath).replace("+", "\\+")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ String core = properties.getProperty("build.core"); //$NON-NLS-1$
buildModel.put("platform_srcs", //$NON-NLS-1$ if (core.contains(":")) { //$NON-NLS-1$
platform.getSources(properties.getProperty("build.core"), properties.getProperty("build.variant"))); //$NON-NLS-1$ //$NON-NLS-2$ String[] segments = core.split(":"); //$NON-NLS-1$
if (segments.length == 2) {
corePlatform = manager.getInstalledPlatform(segments[0], platform.getArchitecture());
core = segments[1];
}
}
Path corePath = corePlatform.getInstallPath().resolve("cores").resolve(core); //$NON-NLS-1$
buildModel.put("platform_core_path", pathString(corePath)); //$NON-NLS-1$
List<String> coreSources = new ArrayList<>();
getSources(coreSources, corePath, true);
buildModel.put("platform_core_srcs", coreSources); //$NON-NLS-1$
ArduinoPlatform variantPlatform = platform;
String variant = properties.getProperty("build.variant"); //$NON-NLS-1$
if (variant.contains(":")) { //$NON-NLS-1$
String[] segments = variant.split(":"); //$NON-NLS-1$
if (segments.length == 2) {
variantPlatform = manager.getInstalledPlatform(segments[0], platform.getArchitecture());
variant = segments[1];
}
}
Path variantPath = variantPlatform.getInstallPath().resolve("variants").resolve(variant); //$NON-NLS-1$
buildModel.put("platform_variant_path", pathString(variantPath)); //$NON-NLS-1$
List<String> variantSources = new ArrayList<>();
getSources(variantSources, variantPath, true);
buildModel.put("platform_variant_srcs", variantSources); //$NON-NLS-1$
properties.put("object_file", "$@"); //$NON-NLS-1$ //$NON-NLS-2$ properties.put("object_file", "$@"); //$NON-NLS-1$ //$NON-NLS-2$
properties.put("source_file", "$<"); //$NON-NLS-1$ //$NON-NLS-2$ properties.put("source_file", "$<"); //$NON-NLS-1$ //$NON-NLS-2$
@ -340,13 +393,27 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration implements Te
return buildModel; return buildModel;
} }
private static void getSources(Collection<String> sources, Path dir, boolean recurse) {
for (File file : dir.toFile().listFiles()) {
if (file.isDirectory()) {
if (recurse) {
getSources(sources, file.toPath(), recurse);
}
} else {
if (ArduinoBuildConfiguration.isSource(file.getName())) {
sources.add(ArduinoBuildConfiguration.pathString(file.toPath()));
}
}
}
}
public IFile generateMakeFile(IProgressMonitor monitor) throws CoreException { public IFile generateMakeFile(IProgressMonitor monitor) throws CoreException {
IFolder buildFolder = (IFolder) getBuildContainer(); IFolder buildFolder = (IFolder) getBuildContainer();
if (!buildFolder.exists()) { if (!buildFolder.exists()) {
buildFolder.create(true, true, monitor); buildFolder.create(true, true, monitor);
} }
IFile makefile = getMakeFile(); IFile makefile = buildFolder.getFile("Makefile"); //$NON-NLS-1$
Map<String, Object> buildModel = getBuildModel(); Map<String, Object> buildModel = getBuildModel();
@ -402,28 +469,35 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration implements Te
} }
} }
private String resolvePropertyValue(String value, Properties dict) { private String resolvePropertyValue(String value, Properties dict) throws CoreException {
String last; String last;
do { do {
last = value; last = value;
for (int i = value.indexOf('{'); i >= 0; i = value.indexOf('{', i)) { for (int i = value.indexOf('{'); i >= 0; i = value.indexOf('{', i)) {
i++; i++;
if (value.charAt(i) == '{') {
i++;
continue;
}
int n = value.indexOf('}', i); int n = value.indexOf('}', i);
if (n >= 0) { if (n >= 0) {
String p2 = value.substring(i, n); String p2 = value.substring(i, n);
String r2 = dict.getProperty(p2); String r2 = dict.getProperty(p2);
if (r2 != null) { if (r2 != null) {
value = value.replace('{' + p2 + '}', r2); value = value.replace('{' + p2 + '}', r2);
} else {
throw Activator.coreException(String.format("Undefined key %s", p2), null);
} }
} }
i = n; i = n;
} }
} while (!value.equals(last)); } while (!value.equals(last));
return value; return value.replace("}}", "}").replace("{{", "{"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
} }
private String resolveProperty(String property, Properties dict) { private String resolveProperty(String property, Properties dict) throws CoreException {
String value = dict.getProperty(property); String value = dict.getProperty(property);
return value != null ? resolvePropertyValue(value, dict) : null; return value != null ? resolvePropertyValue(value, dict) : null;
} }
@ -433,17 +507,17 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration implements Te
} }
public String[] getBuildCommand() throws CoreException { public String[] getBuildCommand() throws CoreException {
return new String[] { getMakeCommand(), "-f", getMakeFile().getName() }; //$NON-NLS-1$ return new String[] { getMakeCommand() };
} }
public String[] getCleanCommand() throws CoreException { public String[] getCleanCommand() throws CoreException {
return new String[] { getMakeCommand(), "-f", getMakeFile().getName(), "clean" }; //$NON-NLS-1$ //$NON-NLS-2$ return new String[] { getMakeCommand(), "clean" }; //$NON-NLS-1$
} }
public String[] getSizeCommand() throws CoreException { public String[] getSizeCommand() throws CoreException {
// TODO this shouldn't be in the makefile // TODO this shouldn't be in the makefile
// should be like the upload command // should be like the upload command
return new String[] { getMakeCommand(), "-f", getMakeFile().getName(), "size" }; //$NON-NLS-1$ //$NON-NLS-2$ return new String[] { getMakeCommand(), "size" }; //$NON-NLS-1$
} }
public String getCodeSizeRegex() throws CoreException { public String getCodeSizeRegex() throws CoreException {
@ -466,9 +540,22 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration implements Te
public String[] getUploadCommand(String serialPort) throws CoreException { public String[] getUploadCommand(String serialPort) throws CoreException {
String toolName = getProperties().getProperty("upload.tool"); //$NON-NLS-1$ String toolName = getProperties().getProperty("upload.tool"); //$NON-NLS-1$
ArduinoPlatform platform = getBoard().getPlatform();
if (toolName.contains(":")) { //$NON-NLS-1$
String[] segments = toolName.split(":"); //$NON-NLS-1$
if (segments.length == 2) {
platform = manager.getInstalledPlatform(segments[0], platform.getArchitecture());
toolName = segments[1];
}
}
Properties properties = getProperties(); Properties properties = getProperties();
ArduinoTool uploadTool = platform.getPackage().getLatestTool(toolName);
if (uploadTool != null) {
properties.putAll(uploadTool.getToolProperties());
}
properties.put("serial.port", serialPort); //$NON-NLS-1$ properties.put("serial.port", serialPort); //$NON-NLS-1$
// Little bit of weirdness needed for the bossac tool // Little bit of weirdness needed for the bossac tool
if (serialPort.startsWith("/dev/")) { //$NON-NLS-1$ if (serialPort.startsWith("/dev/")) { //$NON-NLS-1$
@ -482,7 +569,7 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration implements Te
properties.put("config.path", "{tools." + toolName + ".config.path}"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ properties.put("config.path", "{tools." + toolName + ".config.path}"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
// properties for the tool flattened // properties for the tool flattened
HierarchicalProperties toolsProps = new HierarchicalProperties(getBoard().getPlatform().getPlatformProperties()) HierarchicalProperties toolsProps = new HierarchicalProperties(platform.getPlatformProperties())
.getChild("tools"); //$NON-NLS-1$ .getChild("tools"); //$NON-NLS-1$
if (toolsProps != null) { if (toolsProps != null) {
HierarchicalProperties toolProps = toolsProps.getChild(toolName); HierarchicalProperties toolProps = toolsProps.getChild(toolName);
@ -493,13 +580,14 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration implements Te
// TODO make this a preference // TODO make this a preference
properties.put("upload.verbose", properties.getProperty("upload.params.verbose", "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ properties.put("upload.verbose", properties.getProperty("upload.params.verbose", "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
properties.put("upload.verify", properties.getProperty("upload.params.verify", "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
// TODO needed this for esptool // TODO needed this for esptool
properties.put("upload.resetmethod", "ck"); //$NON-NLS-1$ //$NON-NLS-2$ properties.put("upload.resetmethod", "ck"); //$NON-NLS-1$ //$NON-NLS-2$
String command = resolveProperty("upload.pattern", properties); //$NON-NLS-1$ String command = resolveProperty("upload.pattern", properties); //$NON-NLS-1$
if (command == null) { if (command == null) {
return new String[] { "command not specified" }; //$NON-NLS-1$ throw Activator.coreException("Upload command not specified", null);
} }
if (isWindows) { if (isWindows) {
return splitCommand(command); return splitCommand(command);
@ -508,6 +596,31 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration implements Te
} }
} }
private Collection<Path> getIncludePath(ArduinoPlatform platform, Properties properties) throws CoreException {
ArduinoPlatform corePlatform = platform;
String core = properties.getProperty("build.core"); //$NON-NLS-1$
if (core.contains(":")) { //$NON-NLS-1$
String[] segments = core.split(":"); //$NON-NLS-1$
if (segments.length == 2) {
corePlatform = manager.getInstalledPlatform(segments[0], platform.getArchitecture());
core = segments[1];
}
}
ArduinoPlatform variantPlatform = platform;
String variant = properties.getProperty("build.variant"); //$NON-NLS-1$
if (variant.contains(":")) { //$NON-NLS-1$
String[] segments = variant.split(":"); //$NON-NLS-1$
if (segments.length == 2) {
variantPlatform = manager.getInstalledPlatform(segments[0], platform.getArchitecture());
variant = segments[1];
}
}
return Arrays.asList(corePlatform.getInstallPath().resolve("cores").resolve(core), //$NON-NLS-1$
variantPlatform.getInstallPath().resolve("variants").resolve(variant)); //$NON-NLS-1$
}
// Scanner Info Cache // Scanner Info Cache
private String[] cachedIncludePath; private String[] cachedIncludePath;
private String cachedInfoCommand; private String cachedInfoCommand;
@ -537,14 +650,27 @@ public class ArduinoBuildConfiguration extends CBuildConfiguration implements Te
String commandString = resolveProperty(recipe, properties); String commandString = resolveProperty(recipe, properties);
List<Path> includePath = new ArrayList<>(); List<Path> includePath = new ArrayList<>();
includePath.addAll(platform.getIncludePath()); includePath.addAll(getIncludePath(platform, properties));
Collection<ArduinoLibrary> libs = manager.getLibraries(getProject()); Collection<ArduinoLibrary> libs = manager.getLibraries(getProject());
for (ArduinoLibrary lib : libs) { for (ArduinoLibrary lib : libs) {
includePath.addAll(lib.getIncludePath()); includePath.addAll(lib.getIncludePath());
} }
String[] includes = includePath.stream() String[] includes = null;
.map(path -> resolvePropertyValue(path.toString(), properties)).collect(Collectors.toList()) try {
.toArray(new String[includePath.size()]); includes = includePath.stream().map(path -> {
try {
return resolvePropertyValue(path.toString(), properties);
} catch (CoreException e) {
throw new RuntimeException(e);
}
}).collect(Collectors.toList()).toArray(new String[includePath.size()]);
} catch (RuntimeException e) {
if (e.getCause() != null && e.getCause() instanceof CoreException) {
throw (CoreException) e.getCause();
} else {
throw e;
}
}
// Use cache if we can // Use cache if we can
if (cachedScannerInfo != null && cachedInfoCommand.equals(commandString) if (cachedScannerInfo != null && cachedInfoCommand.equals(commandString)

View file

@ -39,49 +39,28 @@ public class ArduinoBuildConfigurationProvider implements ICBuildConfigurationPr
@Override @Override
public ICBuildConfiguration getCBuildConfiguration(IBuildConfiguration config, String name) throws CoreException { public ICBuildConfiguration getCBuildConfiguration(IBuildConfiguration config, String name) throws CoreException {
return new ArduinoBuildConfiguration(config, name); if (config.getName().equals(IBuildConfiguration.DEFAULT_CONFIG_NAME)) {
} // Use the good ol' Uno as the default
ArduinoBoard board = arduinoManager.getBoard("arduino", "avr", "uno"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
@Override if (board == null) {
public ICBuildConfiguration getDefaultCBuildConfiguration(IProject project) throws CoreException { Collection<ArduinoBoard> boards = arduinoManager.getInstalledBoards();
ArduinoBoard board = arduinoManager.getBoard("arduino", "avr", "Arduino/Genuino Uno"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ if (!boards.isEmpty()) {
if (board == null) { board = boards.iterator().next();
Collection<ArduinoBoard> boards = arduinoManager.getInstalledBoards();
if (!boards.isEmpty()) {
board = boards.iterator().next();
}
}
if (board != null) {
String launchMode = "run"; //$NON-NLS-1$
for (IBuildConfiguration config : project.getBuildConfigs()) {
ICBuildConfiguration cconfig = config.getAdapter(ICBuildConfiguration.class);
if (cconfig != null) {
ArduinoBuildConfiguration arduinoConfig = cconfig.getAdapter(ArduinoBuildConfiguration.class);
if (arduinoConfig != null && arduinoConfig.getLaunchMode().equals(launchMode)
&& arduinoConfig.getBoard().equals(board)) {
return arduinoConfig;
}
} }
} }
if (board != null) {
// Create the toolChain
IToolChainManager toolChainManager = Activator.getService(IToolChainManager.class);
IToolChainProvider provider = toolChainManager.getProvider(ArduinoToolChainProvider.ID);
IToolChain toolChain = new ArduinoToolChain(provider, config);
toolChainManager.addToolChain(toolChain);
// not found, create one return new ArduinoBuildConfiguration(config, name, board, "run", toolChain); //$NON-NLS-1$
String configName = ArduinoBuildConfiguration.generateName(board, launchMode); }
IBuildConfiguration config = configManager.createBuildConfiguration(this, project, configName, return null;
null); } else {
return new ArduinoBuildConfiguration(config, name);
// Create the toolChain
IToolChainManager toolChainManager = Activator.getService(IToolChainManager.class);
IToolChainProvider provider = toolChainManager.getProvider(ArduinoToolChainProvider.ID);
IToolChain toolChain = new ArduinoToolChain(provider, config);
toolChainManager.addToolChain(toolChain);
ArduinoBuildConfiguration arduinoConfig = new ArduinoBuildConfiguration(config, configName, board,
launchMode, toolChain);
arduinoConfig.setActive(null);
configManager.addBuildConfiguration(config, arduinoConfig);
return arduinoConfig;
} }
return null;
} }
public ArduinoBuildConfiguration getConfiguration(IProject project, ArduinoRemoteConnection target, public ArduinoBuildConfiguration getConfiguration(IProject project, ArduinoRemoteConnection target,

View file

@ -17,12 +17,15 @@ import java.util.Map;
import org.eclipse.cdt.arduino.core.internal.Activator; import org.eclipse.cdt.arduino.core.internal.Activator;
import org.eclipse.cdt.arduino.core.internal.board.ArduinoBoard; import org.eclipse.cdt.arduino.core.internal.board.ArduinoBoard;
import org.eclipse.cdt.arduino.core.internal.board.ArduinoManager; import org.eclipse.cdt.arduino.core.internal.board.ArduinoManager;
import org.eclipse.cdt.arduino.core.internal.board.ArduinoPackage;
import org.eclipse.cdt.arduino.core.internal.board.ArduinoPlatform;
import org.eclipse.cdt.serial.SerialPort; import org.eclipse.cdt.serial.SerialPort;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.remote.core.IRemoteCommandShellService; import org.eclipse.remote.core.IRemoteCommandShellService;
import org.eclipse.remote.core.IRemoteConnection; import org.eclipse.remote.core.IRemoteConnection;
import org.eclipse.remote.core.IRemoteConnectionChangeListener; import org.eclipse.remote.core.IRemoteConnectionChangeListener;
import org.eclipse.remote.core.IRemoteConnectionPropertyService; import org.eclipse.remote.core.IRemoteConnectionPropertyService;
import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
import org.eclipse.remote.core.IRemoteProcess; import org.eclipse.remote.core.IRemoteProcess;
import org.eclipse.remote.core.RemoteConnectionChangeEvent; import org.eclipse.remote.core.RemoteConnectionChangeEvent;
import org.eclipse.remote.serial.core.SerialPortCommandShell; import org.eclipse.remote.serial.core.SerialPortCommandShell;
@ -31,10 +34,12 @@ public class ArduinoRemoteConnection
implements IRemoteConnectionPropertyService, IRemoteCommandShellService, IRemoteConnectionChangeListener { implements IRemoteConnectionPropertyService, IRemoteCommandShellService, IRemoteConnectionChangeListener {
public static final String TYPE_ID = "org.eclipse.cdt.arduino.core.connectionType"; //$NON-NLS-1$ public static final String TYPE_ID = "org.eclipse.cdt.arduino.core.connectionType"; //$NON-NLS-1$
public static final String PORT_NAME = "arduinoPortName"; //$NON-NLS-1$
public static final String PACKAGE_NAME = "arduinoPackageName"; //$NON-NLS-1$ private static final String PORT_NAME = "arduinoPortName"; //$NON-NLS-1$
public static final String PLATFORM_NAME = "arduinoPlatformName"; //$NON-NLS-1$ private static final String PACKAGE_NAME = "arduinoPackageName"; //$NON-NLS-1$
public static final String BOARD_NAME = "arduinoBoardName"; //$NON-NLS-1$ private static final String PLATFORM_NAME = "arduinoPlatformName"; //$NON-NLS-1$
private static final String BOARD_NAME = "arduinoBoardName"; //$NON-NLS-1$
private static final String MENU_QUALIFIER = "menu_"; //$NON-NLS-1$
private final IRemoteConnection remoteConnection; private final IRemoteConnection remoteConnection;
private SerialPort serialPort; private SerialPort serialPort;
@ -47,6 +52,28 @@ public class ArduinoRemoteConnection
remoteConnection.addConnectionChangeListener(this); remoteConnection.addConnectionChangeListener(this);
} }
public static void setBoardId(IRemoteConnectionWorkingCopy workingCopy, ArduinoBoard board) {
workingCopy.setAttribute(BOARD_NAME, board.getId());
ArduinoPlatform platform = board.getPlatform();
workingCopy.setAttribute(PLATFORM_NAME, platform.getArchitecture());
ArduinoPackage pkg = platform.getPackage();
workingCopy.setAttribute(PACKAGE_NAME, pkg.getName());
}
public static void setPortName(IRemoteConnectionWorkingCopy workingCopy, String portName) {
workingCopy.setAttribute(PORT_NAME, portName);
}
public static void setMenuValue(IRemoteConnectionWorkingCopy workingCopy, String key, String value) {
workingCopy.setAttribute(MENU_QUALIFIER + key, value);
}
public String getMenuValue(String key) {
return remoteConnection.getAttribute(MENU_QUALIFIER + key);
}
@Override @Override
public void connectionChanged(RemoteConnectionChangeEvent event) { public void connectionChanged(RemoteConnectionChangeEvent event) {
if (event.getType() == RemoteConnectionChangeEvent.CONNECTION_REMOVED) { if (event.getType() == RemoteConnectionChangeEvent.CONNECTION_REMOVED) {

View file

@ -15,19 +15,35 @@ PROJECT_OBJS = \
</#if> </#if>
</#list> </#list>
PLATFORM_OBJS = \ PLATFORM_CORE_OBJS = \
<#list platform_srcs as file> <#list platform_core_srcs as file>
<#assign cpp = file?matches("${platform_path}/(.*)\\.cpp")> <#assign cpp = file?matches("${platform_core_path}/(.*)\\.cpp")>
<#if cpp> <#if cpp>
${build_path}/platform/${cpp?groups[1]}.cpp.o \ ${build_path}/core/${cpp?groups[1]}.cpp.o \
</#if> </#if>
<#assign c = file?matches("${platform_path}/(.*)\\.c")> <#assign c = file?matches("${platform_core_path}/(.*)\\.c")>
<#if c> <#if c>
${build_path}/platform/${c?groups[1]}.c.o \ ${build_path}/core/${c?groups[1]}.c.o \
</#if> </#if>
<#assign S = file?matches("${platform_path}/(.*)\\.S")> <#assign S = file?matches("${platform_core_path}/(.*)\\.S")>
<#if S> <#if S>
${build_path}/platform/${S?groups[1]}.S.o \ ${build_path}/core/${S?groups[1]}.S.o \
</#if>
</#list>
PLATFORM_VARIANT_OBJS = \
<#list platform_variant_srcs as file>
<#assign cpp = file?matches("${platform_variant_path}/(.*)\\.cpp")>
<#if cpp>
${build_path}/variant/${cpp?groups[1]}.cpp.o \
</#if>
<#assign c = file?matches("${platform_variant_path}/(.*)\\.c")>
<#if c>
${build_path}/variant/${c?groups[1]}.c.o \
</#if>
<#assign S = file?matches("${platform_variant_path}/(.*)\\.S")>
<#if S>
${build_path}/variant/${S?groups[1]}.S.o \
</#if> </#if>
</#list> </#list>
@ -80,7 +96,7 @@ ${build_path}/${project_name}.bin: ${build_path}/${project_name}.elf
${build_path}/${project_name}.elf: $(PROJECT_OBJS) $(LIBRARIES_OBJS) ${build_path}/core.a ${build_path}/${project_name}.elf: $(PROJECT_OBJS) $(LIBRARIES_OBJS) ${build_path}/core.a
${recipe_c_combine_pattern} ${recipe_c_combine_pattern}
${build_path}/core.a: $(PLATFORM_OBJS) ${build_path}/core.a: $(PLATFORM_CORE_OBJS) $(PLATFORM_VARIANT_OBJS)
clean: clean:
$(RMDIR) ${build_path} $(RMDIR) ${build_path}
@ -102,34 +118,69 @@ ${build_path}/project/${cpp?groups[1]}.cpp.d: ;
</#if> </#if>
</#list> </#list>
<#list platform_srcs as file> <#list platform_core_srcs as file>
<#assign cpp = file?matches("${platform_path}/(.*)\\.cpp")> <#assign cpp = file?matches("${platform_core_path}/(.*)\\.cpp")>
<#if cpp> <#if cpp>
${build_path}/platform/${cpp?groups[1]}.cpp.o: ${file} ${build_path}/platform/${cpp?groups[1]}.cpp.d ${build_path}/core/${cpp?groups[1]}.cpp.o: ${file} ${build_path}/core/${cpp?groups[1]}.cpp.d
@$(call mymkdir,$(dir $@)) @$(call mymkdir,$(dir $@))
${recipe_cpp_o_pattern} ${recipe_cpp_o_pattern}
${recipe_ar_pattern} ${recipe_ar_pattern}
${build_path}/platform/${cpp?groups[1]}.cpp.d: ; ${build_path}/core/${cpp?groups[1]}.cpp.d: ;
-include ${build_path}/platform/${cpp?groups[1]}.cpp.d -include ${build_path}/core/${cpp?groups[1]}.cpp.d
</#if> </#if>
<#assign c = file?matches("${platform_path}/(.*)\\.c")> <#assign c = file?matches("${platform_core_path}/(.*)\\.c")>
<#if c> <#if c>
${build_path}/platform/${c?groups[1]}.c.o: ${file} ${build_path}/platform/${c?groups[1]}.c.d ${build_path}/core/${c?groups[1]}.c.o: ${file} ${build_path}/core/${c?groups[1]}.c.d
@$(call mymkdir,$(dir $@)) @$(call mymkdir,$(dir $@))
${recipe_c_o_pattern} ${recipe_c_o_pattern}
${recipe_ar_pattern} ${recipe_ar_pattern}
${build_path}/platform/${c?groups[1]}.c.d: ; ${build_path}/core/${c?groups[1]}.c.d: ;
-include ${build_path}/platform/${c?groups[1]}.c.d -include ${build_path}/core/${c?groups[1]}.c.d
</#if> </#if>
<#assign S = file?matches("${platform_path}/(.*)\\.S")> <#assign S = file?matches("${platform_core_path}/(.*)\\.S")>
<#if S> <#if S>
${build_path}/platform/${S?groups[1]}.S.o: ${file} ${build_path}/core/${S?groups[1]}.S.o: ${file}
@$(call mymkdir,$(dir $@))
${recipe_S_o_pattern}
${recipe_ar_pattern}
</#if>
</#list>
<#list platform_variant_srcs as file>
<#assign cpp = file?matches("${platform_variant_path}/(.*)\\.cpp")>
<#if cpp>
${build_path}/variant/${cpp?groups[1]}.cpp.o: ${file} ${build_path}/variant/${cpp?groups[1]}.cpp.d
@$(call mymkdir,$(dir $@))
${recipe_cpp_o_pattern}
${recipe_ar_pattern}
${build_path}/variant/${cpp?groups[1]}.cpp.d: ;
-include ${build_path}/variant/${cpp?groups[1]}.cpp.d
</#if>
<#assign c = file?matches("${platform_variant_path}/(.*)\\.c")>
<#if c>
${build_path}/variant/${c?groups[1]}.c.o: ${file} ${build_path}/variant/${c?groups[1]}.c.d
@$(call mymkdir,$(dir $@))
${recipe_c_o_pattern}
${recipe_ar_pattern}
${build_path}/variant/${c?groups[1]}.c.d: ;
-include ${build_path}/variant/${c?groups[1]}.c.d
</#if>
<#assign S = file?matches("${platform_variant_path}/(.*)\\.S")>
<#if S>
${build_path}/variant/${S?groups[1]}.S.o: ${file}
@$(call mymkdir,$(dir $@)) @$(call mymkdir,$(dir $@))
${recipe_S_o_pattern} ${recipe_S_o_pattern}
${recipe_ar_pattern} ${recipe_ar_pattern}

View file

@ -86,12 +86,6 @@
id="org.eclipse.cdt.arduino.preference.page" id="org.eclipse.cdt.arduino.preference.page"
name="%preferencePage.name"> name="%preferencePage.name">
</page> </page>
<page
category="org.eclipse.cdt.arduino.preference.page"
class="org.eclipse.cdt.arduino.ui.internal.preferences.ArduinoPlatformsPreferencePage"
id="org.eclipse.cdt.arduino.ui.page.platforms"
name="Platforms">
</page>
</extension> </extension>
<extension <extension
point="org.eclipse.ui.perspectiveExtensions"> point="org.eclipse.ui.perspectiveExtensions">

View file

@ -96,15 +96,11 @@ public class ArduinoTargetPropertyPage extends PropertyPage implements IWorkbenc
IRemoteConnection remoteConnection = getElement().getAdapter(IRemoteConnection.class); IRemoteConnection remoteConnection = getElement().getAdapter(IRemoteConnection.class);
IRemoteConnectionWorkingCopy workingCopy = remoteConnection.getWorkingCopy(); IRemoteConnectionWorkingCopy workingCopy = remoteConnection.getWorkingCopy();
String portName = portSelector.getItem(portSelector.getSelectionIndex());
workingCopy.setAttribute(ArduinoRemoteConnection.PORT_NAME, portName);
ArduinoBoard board = boards[boardSelector.getSelectionIndex()]; ArduinoBoard board = boards[boardSelector.getSelectionIndex()];
workingCopy.setAttribute(ArduinoRemoteConnection.BOARD_NAME, board.getId()); ArduinoRemoteConnection.setBoardId(workingCopy, board);
ArduinoPlatform platform = board.getPlatform();
workingCopy.setAttribute(ArduinoRemoteConnection.PLATFORM_NAME, platform.getArchitecture()); String portName = portSelector.getItem(portSelector.getSelectionIndex());
ArduinoPackage pkg = platform.getPackage(); ArduinoRemoteConnection.setPortName(workingCopy, portName);
workingCopy.setAttribute(ArduinoRemoteConnection.PACKAGE_NAME, pkg.getName());
try { try {
workingCopy.save(); workingCopy.save();

View file

@ -188,15 +188,8 @@ public class BoardPropertyControl extends Composite {
} }
public void apply(IRemoteConnectionWorkingCopy workingCopy) { public void apply(IRemoteConnectionWorkingCopy workingCopy) {
workingCopy.setAttribute(ArduinoRemoteConnection.PORT_NAME, portName); ArduinoRemoteConnection.setBoardId(workingCopy, board);
ArduinoRemoteConnection.setPortName(workingCopy, portName);
workingCopy.setAttribute(ArduinoRemoteConnection.BOARD_NAME, board.getId());
ArduinoPlatform platform = board.getPlatform();
workingCopy.setAttribute(ArduinoRemoteConnection.PLATFORM_NAME, platform.getArchitecture());
ArduinoPackage pkg = platform.getPackage();
workingCopy.setAttribute(ArduinoRemoteConnection.PACKAGE_NAME, pkg.getName());
String key = null; String key = null;
for (Control control : menuControls) { for (Control control : menuControls) {
@ -208,7 +201,7 @@ public class BoardPropertyControl extends Composite {
String value = ((List<String>) combo.getData()).get(combo.getSelectionIndex()); String value = ((List<String>) combo.getData()).get(combo.getSelectionIndex());
if (key != null) { if (key != null) {
workingCopy.setAttribute(ArduinoBoard.MENU_QUALIFIER + key, value); ArduinoRemoteConnection.setMenuValue(workingCopy, key, value);
} }
} }
} }