mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-22 07:43:56 +02:00
Change the way default configs are handled.
Provide support for new build configs using the default config. Previously, we used it to represent old style configs. But if you're not using the launch bar, you end up building with the default config. Adds support for Qt to build debug_and_release, and for Arduino to just build normally for run. Users are then responsible for creating their own launch config, just like the old days. Change-Id: I54305fa27e7eac198ac50d800e0c175143215516
This commit is contained in:
parent
bf1f4c93ff
commit
9e0d307cdf
12 changed files with 172 additions and 172 deletions
|
@ -611,11 +611,9 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
|
|||
// Check for new style build configs first
|
||||
Set<String> parserIds = new HashSet<>();
|
||||
for (IBuildConfiguration config : project.getBuildConfigs()) {
|
||||
if (!IBuildConfiguration.DEFAULT_CONFIG_NAME.equals(config.getName())) {
|
||||
ICBuildConfiguration cconfig = config.getAdapter(ICBuildConfiguration.class);
|
||||
if (cconfig != null) {
|
||||
parserIds.add(cconfig.getBinaryParserId());
|
||||
}
|
||||
ICBuildConfiguration cconfig = config.getAdapter(ICBuildConfiguration.class);
|
||||
if (cconfig != null) {
|
||||
parserIds.add(cconfig.getBinaryParserId());
|
||||
}
|
||||
}
|
||||
if (!parserIds.isEmpty()) {
|
||||
|
|
|
@ -1147,10 +1147,7 @@ public class CCorePlugin extends Plugin {
|
|||
|
||||
// If we are new style build configurations, get the provider there
|
||||
IBuildConfiguration activeConfig = project.getActiveBuildConfig();
|
||||
ICBuildConfiguration cconfig = buildConfigManager.getBuildConfiguration(activeConfig);
|
||||
if (cconfig == null) {
|
||||
cconfig = buildConfigManager.getDefaultBuildConfiguration(project);
|
||||
}
|
||||
ICBuildConfiguration cconfig = activeConfig.getAdapter(ICBuildConfiguration.class);
|
||||
if (cconfig != null) {
|
||||
return cconfig;
|
||||
}
|
||||
|
|
|
@ -101,8 +101,8 @@ public abstract class CBuildConfiguration extends PlatformObject
|
|||
|
||||
toolChain = tc;
|
||||
}
|
||||
|
||||
public CBuildConfiguration(IBuildConfiguration config, String name, IToolChain toolChain) {
|
||||
|
||||
protected CBuildConfiguration(IBuildConfiguration config, String name, IToolChain toolChain) {
|
||||
this.config = config;
|
||||
this.name = name;
|
||||
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
|
||||
public IBuildConfiguration getBuildConfiguration() {
|
||||
return config;
|
||||
|
|
|
@ -28,6 +28,12 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
|||
*/
|
||||
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
|
||||
* configuration is associated with.
|
||||
|
|
|
@ -20,6 +20,12 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
|||
*/
|
||||
public interface ICBuildConfigurationManager {
|
||||
|
||||
/**
|
||||
* Return the build configuration provider with the given id.
|
||||
*
|
||||
* @param id
|
||||
* @return build configuration provider
|
||||
*/
|
||||
ICBuildConfigurationProvider getProvider(String id);
|
||||
|
||||
/**
|
||||
|
@ -35,8 +41,6 @@ public interface ICBuildConfigurationManager {
|
|||
IBuildConfiguration createBuildConfiguration(ICBuildConfigurationProvider provider, IProject project,
|
||||
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.
|
||||
*
|
||||
|
@ -56,6 +60,4 @@ public interface ICBuildConfigurationManager {
|
|||
*/
|
||||
ICBuildConfiguration getBuildConfiguration(IBuildConfiguration buildConfig) throws CoreException;
|
||||
|
||||
ICBuildConfiguration getDefaultBuildConfiguration(IProject project) throws CoreException;
|
||||
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
package org.eclipse.cdt.core.build;
|
||||
|
||||
import org.eclipse.core.resources.IBuildConfiguration;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
|
@ -33,12 +32,4 @@ public interface ICBuildConfigurationProvider {
|
|||
*/
|
||||
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;
|
||||
|
||||
}
|
||||
|
|
|
@ -72,16 +72,19 @@ public class CBuildConfigurationManager implements ICBuildConfigurationManager,
|
|||
|
||||
public boolean supports(IProject project) {
|
||||
try {
|
||||
return project.hasNature(natureId);
|
||||
if (natureId != null) {
|
||||
return project.hasNature(natureId);
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e.getStatus());
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, Provider> providers;
|
||||
private Map<IBuildConfiguration, ICBuildConfiguration> configs = new HashMap<>();
|
||||
private Set<IBuildConfiguration> noConfigs = new HashSet<>();
|
||||
|
||||
public CBuildConfigurationManager() {
|
||||
ResourcesPlugin.getWorkspace().addResourceChangeListener(this);
|
||||
|
@ -105,13 +108,33 @@ public class CBuildConfigurationManager implements ICBuildConfigurationManager,
|
|||
}
|
||||
|
||||
private Provider getProviderDelegate(String id) {
|
||||
initProviders();
|
||||
return providers.get(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
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
|
||||
|
@ -143,47 +166,51 @@ public class CBuildConfigurationManager implements ICBuildConfigurationManager,
|
|||
public ICBuildConfiguration getBuildConfiguration(IBuildConfiguration buildConfig) throws CoreException {
|
||||
initProviders();
|
||||
synchronized (configs) {
|
||||
ICBuildConfiguration config = configs.get(buildConfig);
|
||||
if (config == null) {
|
||||
String[] segments = buildConfig.getName().split("/"); //$NON-NLS-1$
|
||||
if (segments.length == 2) {
|
||||
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 (noConfigs.contains(buildConfig)) {
|
||||
return null;
|
||||
} else {
|
||||
ICBuildConfiguration config = configs.get(buildConfig);
|
||||
if (config != null) {
|
||||
configs.put(config.getBuildConfiguration(), 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
|
||||
|
|
|
@ -68,19 +68,20 @@ public class QtBuildConfiguration extends CBuildConfiguration implements ICBuild
|
|||
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,
|
||||
String launchMode)
|
||||
throws CoreException {
|
||||
String launchMode) throws CoreException {
|
||||
super(config, name, toolChain);
|
||||
this.qtInstall = qtInstall;
|
||||
this.launchMode = launchMode;
|
||||
|
||||
Preferences settings = getSettings();
|
||||
settings.put(QTINSTALL_NAME, qtInstall.getQmakePath().toString());
|
||||
settings.put(LAUNCH_MODE, launchMode);
|
||||
if (launchMode != null) {
|
||||
settings.put(LAUNCH_MODE, launchMode);
|
||||
}
|
||||
try {
|
||||
settings.flush();
|
||||
} catch (BackingStoreException e) {
|
||||
|
@ -108,16 +109,18 @@ public class QtBuildConfiguration extends CBuildConfiguration implements ICBuild
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getQmakeConfig() {
|
||||
switch (launchMode) {
|
||||
case "run": //$NON-NLS-1$
|
||||
return "CONFIG+=release"; //$NON-NLS-1$
|
||||
case "debug": //$NON-NLS-1$
|
||||
return "CONFIG+=debug"; //$NON-NLS-1$
|
||||
default:
|
||||
// TODO probably need an extension point for guidance
|
||||
return null;
|
||||
public String[] getQmakeConfig() {
|
||||
if (launchMode != null) {
|
||||
switch (launchMode) {
|
||||
case "run": //$NON-NLS-1$
|
||||
return new String[] { "CONFIG+=release" }; //$NON-NLS-1$
|
||||
case "debug": //$NON-NLS-1$
|
||||
return new String[] { "CONFIG+=debug" }; //$NON-NLS-1$
|
||||
default:
|
||||
return new String[] { "CONFIG+=launch_mode_" + launchMode }; //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
return new String[] { "CONFIG+=debug_and_release", "CONFIG+=launch_modeall" }; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
|
||||
public Path getProjectFile() {
|
||||
|
@ -160,9 +163,11 @@ public class QtBuildConfiguration extends CBuildConfiguration implements ICBuild
|
|||
cmd.add(getQmakeCommand().toString());
|
||||
cmd.add("-E"); //$NON-NLS-1$
|
||||
|
||||
String config = getQmakeConfig();
|
||||
String[] config = getQmakeConfig();
|
||||
if (config != null) {
|
||||
cmd.add(config);
|
||||
for (String str : config) {
|
||||
cmd.add(str);
|
||||
}
|
||||
}
|
||||
|
||||
cmd.add(getProjectFile().toString());
|
||||
|
@ -280,16 +285,17 @@ public class QtBuildConfiguration extends CBuildConfiguration implements ICBuild
|
|||
List<String> command = new ArrayList<>();
|
||||
command.add(getQmakeCommand().toString());
|
||||
|
||||
String config = getQmakeConfig();
|
||||
String[] config = getQmakeConfig();
|
||||
if (config != null) {
|
||||
command.add(config);
|
||||
for (String str : config) {
|
||||
command.add(str);
|
||||
}
|
||||
}
|
||||
|
||||
IFile projectFile = project.getFile(project.getName() + ".pro"); //$NON-NLS-1$
|
||||
command.add(projectFile.getLocation().toOSString());
|
||||
|
||||
ProcessBuilder processBuilder = new ProcessBuilder(command)
|
||||
.directory(getBuildDirectory().toFile());
|
||||
ProcessBuilder processBuilder = new ProcessBuilder(command).directory(getBuildDirectory().toFile());
|
||||
setBuildEnvironment(processBuilder.environment());
|
||||
Process process = processBuilder.start();
|
||||
|
||||
|
@ -305,7 +311,7 @@ public class QtBuildConfiguration extends CBuildConfiguration implements ICBuild
|
|||
}
|
||||
|
||||
// run make
|
||||
ProcessBuilder processBuilder = new ProcessBuilder(makeCommand.toString()).directory(buildDir.toFile());
|
||||
ProcessBuilder processBuilder = new ProcessBuilder(makeCommand.toString(), "all").directory(buildDir.toFile());
|
||||
setBuildEnvironment(processBuilder.environment());
|
||||
Process process = processBuilder.start();
|
||||
outStream.write(makeCommand.toString() + '\n');
|
||||
|
|
|
@ -16,7 +16,6 @@ import org.eclipse.cdt.core.build.ICBuildConfigurationProvider;
|
|||
import org.eclipse.cdt.core.build.IToolChain;
|
||||
import org.eclipse.cdt.core.build.IToolChainManager;
|
||||
import org.eclipse.cdt.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.IQtInstall;
|
||||
import org.eclipse.cdt.qt.core.IQtInstallManager;
|
||||
|
@ -24,7 +23,6 @@ import org.eclipse.core.resources.IBuildConfiguration;
|
|||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
|
||||
public class QtBuildConfigurationProvider implements ICBuildConfigurationProvider {
|
||||
|
@ -43,63 +41,48 @@ public class QtBuildConfigurationProvider implements ICBuildConfigurationProvide
|
|||
@Override
|
||||
public ICBuildConfiguration getCBuildConfiguration(IBuildConfiguration config, String name) {
|
||||
try {
|
||||
// Double check to make sure this config is ours
|
||||
if (!config.getProject().hasNature(QtNature.ID)) {
|
||||
return null;
|
||||
}
|
||||
if (config.getName().equals(IBuildConfiguration.DEFAULT_CONFIG_NAME)) {
|
||||
// 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)) {
|
||||
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) {
|
||||
// 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);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
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 {
|
||||
for (IBuildConfiguration config : project.getBuildConfigs()) {
|
||||
ICBuildConfiguration cconfig = config.getAdapter(ICBuildConfiguration.class);
|
||||
if (cconfig != null) {
|
||||
IQtBuildConfiguration qtConfig = cconfig.getAdapter(IQtBuildConfiguration.class);
|
||||
if (qtConfig != null && qtConfig.getLaunchMode().equals(launchMode)
|
||||
if (qtConfig != null && launchMode.equals(qtConfig.getLaunchMode())
|
||||
&& qtConfig.getToolChain().equals(toolChain)) {
|
||||
return qtConfig;
|
||||
}
|
||||
|
@ -114,8 +97,7 @@ public class QtBuildConfigurationProvider implements ICBuildConfigurationProvide
|
|||
if (qtInstallManager.supports(qtInstall, toolChain)) {
|
||||
// TODO what if multiple matches
|
||||
String configName = "qt." + qtInstall.getSpec() + "." + launchMode; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
IBuildConfiguration config = configManager.createBuildConfiguration(this, project, configName,
|
||||
monitor);
|
||||
IBuildConfiguration config = configManager.createBuildConfiguration(this, project, configName, monitor);
|
||||
QtBuildConfiguration qtConfig = new QtBuildConfiguration(config, configName, toolChain, qtInstall,
|
||||
launchMode);
|
||||
configManager.addBuildConfiguration(config, qtConfig);
|
||||
|
|
|
@ -18,7 +18,7 @@ public interface IQtBuildConfiguration extends ICBuildConfiguration {
|
|||
|
||||
Path getQmakeCommand();
|
||||
|
||||
String getQmakeConfig();
|
||||
String[] getQmakeConfig();
|
||||
|
||||
Path getProgramPath() throws CoreException;
|
||||
|
||||
|
|
|
@ -6,3 +6,11 @@ CONFIG += c++11
|
|||
RESOURCES += ${projectName}.qrc
|
||||
|
||||
qml.files = src/${projectName}.qml
|
||||
|
||||
launch_modeall {
|
||||
CONFIG(debug, debug|release) {
|
||||
DESTDIR = debug
|
||||
} else {
|
||||
DESTDIR = release
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,49 +39,28 @@ public class ArduinoBuildConfigurationProvider implements ICBuildConfigurationPr
|
|||
|
||||
@Override
|
||||
public ICBuildConfiguration getCBuildConfiguration(IBuildConfiguration config, String name) throws CoreException {
|
||||
return new ArduinoBuildConfiguration(config, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICBuildConfiguration getDefaultCBuildConfiguration(IProject project) throws CoreException {
|
||||
ArduinoBoard board = arduinoManager.getBoard("arduino", "avr", "Arduino/Genuino Uno"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
if (board == null) {
|
||||
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 (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$
|
||||
if (board == null) {
|
||||
Collection<ArduinoBoard> boards = arduinoManager.getInstalledBoards();
|
||||
if (!boards.isEmpty()) {
|
||||
board = boards.iterator().next();
|
||||
}
|
||||
}
|
||||
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
|
||||
String configName = ArduinoBuildConfiguration.generateName(board, launchMode);
|
||||
IBuildConfiguration config = configManager.createBuildConfiguration(this, project, configName,
|
||||
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);
|
||||
|
||||
ArduinoBuildConfiguration arduinoConfig = new ArduinoBuildConfiguration(config, configName, board,
|
||||
launchMode, toolChain);
|
||||
arduinoConfig.setActive(null);
|
||||
configManager.addBuildConfiguration(config, arduinoConfig);
|
||||
return arduinoConfig;
|
||||
return new ArduinoBuildConfiguration(config, name, board, "run", toolChain);
|
||||
}
|
||||
return null;
|
||||
} else {
|
||||
return new ArduinoBuildConfiguration(config, name);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ArduinoBuildConfiguration getConfiguration(IProject project, ArduinoRemoteConnection target,
|
||||
|
|
Loading…
Add table
Reference in a new issue