Skip to content

Commit 0cf43ce

Browse files
committed
Merge remote-tracking branch 'upstream/master' into mueller/explicit-no-file-option
2 parents af1a6f1 + ee0383b commit 0cf43ce

File tree

25 files changed

+203
-342
lines changed

25 files changed

+203
-342
lines changed

io.sloeber.core/config/pre_processing_platform_default.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ A.build.system.path={A.referenced.core.path}{DirectoryDelimiter}system
99
A.serial.port={JANTJE.com_port}
1010
A.build.project_name={ProjName}
1111
A.packages={eclipse_home}{DirectoryDelimiter}arduinoPlugin{DirectoryDelimiter}packages
12-
A.build.source.path={ProjDirPath}
12+
1313

1414

1515
#quick fix for issue #810

io.sloeber.core/src/io/sloeber/core/Activator.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import java.io.InputStream;
77
import java.net.MalformedURLException;
88
import java.net.URL;
9+
910
import org.eclipse.cdt.core.CCorePlugin;
1011
import org.eclipse.cdt.core.model.CoreModel;
1112
import org.eclipse.cdt.core.settings.model.CProjectDescriptionEvent;
@@ -132,7 +133,7 @@ private static void testKnownIssues() {
132133
errorString += "Alternatively use the environment var " +Const.SLOEBER_HOME + ".";
133134
addString = "\nand\n";
134135
}
135-
if (installPath.toOSString().contains(" ")) {
136+
if (installPath.toString().contains(" ")) {
136137
errorString += addString + "The installpath can not contain spaces " + installPath.toString();
137138
addString = "\nand\n";
138139
}

io.sloeber.core/src/io/sloeber/core/InternalBoardDescriptor.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public InternalBoardDescriptor(ICConfigurationDescription confdesc) {
2424

2525
}
2626

27-
public InternalBoardDescriptor(File boardsFile, String boardID, Map<String, String> options) {
27+
public InternalBoardDescriptor(File boardsFile, String boardID, Map<String, String> options) {
2828
super(boardsFile, boardID, options);
2929

3030
}

io.sloeber.core/src/io/sloeber/core/api/BoardDescriptor.java

+44-63
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ public class BoardDescriptor {
127127
*/
128128
private String myProjectName = emptyString;
129129
private String myOSName = Platform.getOS();
130-
private String myWorkSpaceLocation = Common.getWorkspaceRoot().toString();
131-
private String myWorkEclipseLocation = ConfigurationPreferences.getEclipseHome().toString();
130+
private IPath myWorkSpaceLocation = Common.getWorkspaceRoot();
131+
private IPath myWorkEclipseLocation = ConfigurationPreferences.getEclipseHome();
132132

133133
/*
134134
* Stuff to make things work
@@ -428,8 +428,8 @@ protected BoardDescriptor(ICConfigurationDescription confdesc) {
428428
this.myProjectName = getFromBuildEnv(confdesc, ENV_KEY_JANTJE_PROJECT_NAME);
429429
this.myTxtFile = new TxtFile(this.myreferencingBoardsFile, true);
430430
this.myOSName = getFromBuildEnv(confdesc, ENV_KEY_JANTJE_OS);
431-
this.myWorkSpaceLocation = getFromBuildEnv(confdesc, ENV_KEY_JANTJE_WORKSPACE_LOCATION);
432-
this.myWorkEclipseLocation = getFromBuildEnv(confdesc, ENV_KEY_JANTJE_ECLIPSE_LOCATION);
431+
this.myWorkSpaceLocation = new Path(getFromBuildEnv(confdesc, ENV_KEY_JANTJE_WORKSPACE_LOCATION));
432+
this.myWorkEclipseLocation = new Path(getFromBuildEnv(confdesc, ENV_KEY_JANTJE_ECLIPSE_LOCATION));
433433
String optinconcat = getFromBuildEnv(confdesc, ENV_KEY_JANTJE_MENU_SELECTION);
434434
this.myOptions = KeyValue.makeMap(optinconcat);
435435
}
@@ -575,7 +575,7 @@ public boolean configureProject(IProject project, IProgressMonitor monitor) {
575575
* Method to create a project based on the board
576576
*/
577577
public IProject createProject(String projectName, URI projectURI, CodeDescriptor codeDescription,
578-
CompileOptions compileOptions, IProgressMonitor monitor) {
578+
CompileOptions compileOptions, IProgressMonitor monitor) {
579579

580580
String realProjectName = Common.MakeNameCompileSafe(projectName);
581581

@@ -584,70 +584,73 @@ public IProject createProject(String projectName, URI projectURI, CodeDescriptor
584584
final IWorkspace workspace = ResourcesPlugin.getWorkspace();
585585
ICoreRunnable runnable = new ICoreRunnable() {
586586
@Override
587-
public void run(IProgressMonitor internalMonitor) throws CoreException {
587+
public void run(IProgressMonitor internalMonitor) throws CoreException {
588588
try {
589-
// Create the base project
590589
IWorkspaceDescription workspaceDesc = workspace.getDescription();
591590
workspaceDesc.setAutoBuilding(false);
592591
workspace.setDescription(workspaceDesc);
592+
IProjectType sloeberProjType = ManagedBuildManager.getProjectType("io.sloeber.core.sketch"); //$NON-NLS-1$
593593

594+
// create a eclipse project
594595
IProjectDescription description = workspace.newProjectDescription(newProjectHandle.getName());
595596
if (projectURI != null) {
596597
description.setLocationURI(projectURI);
597598
}
598599

600+
// make the eclipse project a cdt project
599601
CCorePlugin.getDefault().createCProject(description, newProjectHandle, new NullProgressMonitor(),
600602
ManagedBuilderCorePlugin.MANAGED_MAKE_PROJECT_ID);
601-
// Add the managed build nature and builder
602-
addManagedBuildNature(newProjectHandle);
603603

604-
// Find the base project type definition
605-
IProjectType projType = ManagedBuildManager.getProjectType("io.sloeber.core.sketch"); //$NON-NLS-1$
604+
// add the required natures
605+
ManagedCProjectNature.addManagedNature(newProjectHandle, internalMonitor);
606+
ManagedCProjectNature.addManagedBuilder(newProjectHandle, internalMonitor);
607+
ManagedCProjectNature.addNature(newProjectHandle, "org.eclipse.cdt.core.ccnature", internalMonitor); //$NON-NLS-1$
608+
ManagedCProjectNature.addNature(newProjectHandle, Const.ARDUINO_NATURE_ID, internalMonitor);
609+
606610

607-
// Create the managed-project (.cdtbuild) for our project that builds an
608-
// executable.
609-
IManagedProject newProject = null;
610-
newProject = ManagedBuildManager.createManagedProject(newProjectHandle, projType);
611+
612+
// make the cdt project a managed build project
613+
ManagedBuildManager.createBuildInfo(newProjectHandle);
614+
IManagedProject newProject = ManagedBuildManager.createManagedProject(newProjectHandle,
615+
sloeberProjType);
611616
ManagedBuildManager.setNewProjectVersion(newProjectHandle);
612-
// Copy over the configs
617+
// Copy over the Sloeber configs
613618
IConfiguration defaultConfig = null;
614-
IConfiguration[] configs = projType.getConfigurations();
619+
IConfiguration[] configs = sloeberProjType.getConfigurations();
615620
for (int i = 0; i < configs.length; ++i) {
621+
IConfiguration curConfig = newProject.createConfiguration(configs[i],
622+
sloeberProjType.getId() + "." + i); //$NON-NLS-1$
623+
curConfig.setArtifactName(newProject.getDefaultArtifactName());
616624
// Make the first configuration the default
617625
if (i == 0) {
618-
defaultConfig = newProject.createConfiguration(configs[i], projType.getId() + "." + i); //$NON-NLS-1$
619-
} else {
620-
newProject.createConfiguration(configs[i], projType.getId() + "." + i); //$NON-NLS-1$
626+
defaultConfig = curConfig;
621627
}
622628
}
623-
ManagedBuildManager.setDefaultConfiguration(newProjectHandle, defaultConfig);
624629

625-
IConfiguration cfgs[] = newProject.getConfigurations();
626-
for (int i = 0; i < cfgs.length; i++) {
627-
cfgs[i].setArtifactName(newProject.getDefaultArtifactName());
628-
}
630+
ManagedBuildManager.setDefaultConfiguration(newProjectHandle, defaultConfig);
629631
Map<String, IPath> librariesToAdd = codeDescription.createFiles(newProjectHandle,
630632
new NullProgressMonitor());
631633

632-
ManagedCProjectNature.addNature(newProjectHandle, "org.eclipse.cdt.core.ccnature", internalMonitor); //$NON-NLS-1$
633-
ManagedCProjectNature.addNature(newProjectHandle, Const.ARDUINO_NATURE_ID, internalMonitor);
634-
635634
CCorePlugin cCorePlugin = CCorePlugin.getDefault();
636635
ICProjectDescription prjCDesc = cCorePlugin.getProjectDescription(newProjectHandle);
637-
Libraries.addLibrariesToProject(newProjectHandle, prjCDesc.getActiveConfiguration(), librariesToAdd);
636+
638637
for (ICConfigurationDescription curConfig : prjCDesc.getConfigurations()) {
639638
compileOptions.save(curConfig);
640639
save(curConfig);
640+
Libraries.addLibrariesToProject(newProjectHandle, curConfig, librariesToAdd);
641641
}
642+
642643
SubMonitor refreshMonitor = SubMonitor.convert(internalMonitor, 3);
643644
newProjectHandle.open(refreshMonitor);
644645
newProjectHandle.refreshLocal(IResource.DEPTH_INFINITE, refreshMonitor);
645646
cCorePlugin.setProjectDescription(newProjectHandle, prjCDesc, true, null);
647+
646648
} catch (Exception e) {
647649
Common.log(new Status(IStatus.INFO, io.sloeber.core.Activator.getId(),
648650
"Project creation failed: " + newProjectHandle.getName(), e)); //$NON-NLS-1$
649651
}
650-
Common.log(new Status(Const.SLOEBER_STATUS_DEBUG, Activator.getId(),"internal creation of project is done: "+newProjectHandle.getName())); //$NON-NLS-1$
652+
Common.log(new Status(Const.SLOEBER_STATUS_DEBUG, Activator.getId(),
653+
"internal creation of project is done: " + newProjectHandle.getName())); //$NON-NLS-1$
651654
}
652655
};
653656

@@ -656,7 +659,7 @@ public void run(IProgressMonitor internalMonitor) throws CoreException {
656659
workspace.run(runnable, root, IWorkspace.AVOID_UPDATE, monitor);
657660
} catch (Exception e) {
658661
Common.log(new Status(IStatus.INFO, io.sloeber.core.Activator.getId(),
659-
"Project creation failed: " + newProjectHandle.getName(),e)); //$NON-NLS-1$
662+
"Project creation failed: " + newProjectHandle.getName(), e)); //$NON-NLS-1$
660663
}
661664

662665
monitor.done();
@@ -705,7 +708,7 @@ public boolean saveConfiguration(ICConfigurationDescription confDesc, IContribut
705708

706709
Common.setBuildEnvironmentVariable(contribEnv, confDesc, ENV_KEY_JANTJE_BOARD_NAME, getBoardName());
707710
Common.setBuildEnvironmentVariable(contribEnv, confDesc, ENV_KEY_JANTJE_BOARDS_FILE,
708-
getReferencingBoardsFile().toString());
711+
getReferencingBoardsFile());
709712
Common.setBuildEnvironmentVariable(contribEnv, confDesc, ENV_KEY_JANTJE_BOARD_ID, this.myBoardID);
710713
Common.setBuildEnvironmentVariable(contribEnv, confDesc, ENV_KEY_JANTJE_ARCITECTURE_ID, getArchitecture());
711714
Common.setBuildEnvironmentVariable(contribEnv, confDesc, ENV_KEY_JANTJE_PACKAGE_ID, getPackage());
@@ -725,11 +728,10 @@ public boolean saveConfiguration(ICConfigurationDescription confDesc, IContribut
725728
Common.setBuildEnvironmentVariable(contribEnv, confDesc, ENV_KEY_SERIAL_PORT_FILE,
726729
getActualUploadPort().replace("/dev/", emptyString)); //$NON-NLS-1$
727730
Common.setBuildEnvironmentVariable(contribEnv, confDesc, ENV_KEY_BUILD_ACTUAL_CORE_PATH,
728-
getActualCoreCodePath().toOSString());
731+
getActualCoreCodePath());
729732
IPath variantPath = getActualVariantPath();
730733
if (variantPath != null) {
731-
Common.setBuildEnvironmentVariable(contribEnv, confDesc, ENV_KEY_BUILD_VARIANT_PATH,
732-
variantPath.toOSString());
734+
Common.setBuildEnvironmentVariable(contribEnv, confDesc, ENV_KEY_BUILD_VARIANT_PATH, variantPath);
733735
} else {// teensy does not use variants
734736
Common.setBuildEnvironmentVariable(contribEnv, confDesc, ENV_KEY_BUILD_VARIANT_PATH, emptyString);
735737
}
@@ -738,11 +740,11 @@ public boolean saveConfiguration(ICConfigurationDescription confDesc, IContribut
738740
// referencing such as jantjes hardware
739741

740742
Common.setBuildEnvironmentVariable(contribEnv, confDesc, ENV_KEY_REFERENCED_CORE_PLATFORM_PATH,
741-
getReferencedCorePlatformPath().toOSString());
743+
getReferencedCorePlatformPath());
742744
Common.setBuildEnvironmentVariable(contribEnv, confDesc, ENV_KEY_REFERENCED_VARIANT_PLATFORM_PATH,
743-
getReferencedVariantPlatformPath().toOSString());
745+
getReferencedVariantPlatformPath());
744746
Common.setBuildEnvironmentVariable(contribEnv, confDesc, ENV_KEY_REFERENCED_UPLOAD_PLATFORM_PATH,
745-
getReferencedUploadPlatformPath().toOSString());
747+
getReferencedUploadPlatformPath());
746748

747749
}
748750

@@ -919,11 +921,11 @@ private String getMyOSName() {
919921
return this.myOSName;
920922
}
921923

922-
private String getMyWorkSpaceLocation() {
924+
private IPath getMyWorkSpaceLocation() {
923925
return this.myWorkSpaceLocation;
924926
}
925927

926-
private String getMyWorkEclipseLocation() {
928+
private IPath getMyWorkEclipseLocation() {
927929
return this.myWorkEclipseLocation;
928930
}
929931

@@ -1031,9 +1033,9 @@ public String getUploadCommand(ICConfigurationDescription confdesc) {
10311033
}
10321034
String networkPrefix = empty;
10331035
if (isNetworkUpload()) {
1034-
networkPrefix = Const.NETWORK_PREFIX;
1036+
networkPrefix = DOT + Const.NETWORK_PREFIX;
10351037
}
1036-
String key = Const.A_TOOLS + upLoadTool + DOT + action + DOT + networkPrefix + DOT + Const.PATTERN;
1038+
String key = Const.A_TOOLS + upLoadTool + DOT + action + networkPrefix + DOT + Const.PATTERN;
10371039
String ret = Common.getBuildEnvironmentVariable(confdesc, key, empty);
10381040
if (ret.isEmpty()) {
10391041
Common.log(new Status(IStatus.ERROR, Const.CORE_PLUGIN_ID, key + " : not found in the platform.txt file")); //$NON-NLS-1$
@@ -1100,26 +1102,5 @@ public boolean isNetworkUpload() {
11001102
return getHost() != null;
11011103
}
11021104

1103-
static private void addManagedBuildNature(IProject project) throws Exception {
1104-
// Create the buildinformation object for the project
1105-
ManagedBuildManager.createBuildInfo(project);
1106-
1107-
// Add the managed build nature
1108-
ManagedCProjectNature.addManagedNature(project, new NullProgressMonitor());
1109-
ManagedCProjectNature.addManagedBuilder(project, new NullProgressMonitor());
1110-
1111-
// Associate the project with the managed builder so the clients can get proper
1112-
// information
11131105

1114-
CCorePlugin cCorePlugin = CCorePlugin.getDefault();
1115-
ICProjectDescription projDesc = cCorePlugin.getProjectDescription(project, true);
1116-
1117-
for (ICConfigurationDescription curConfig : projDesc.getConfigurations()) {
1118-
curConfig.remove(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID);
1119-
curConfig.create(CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID, ManagedBuildManager.INTERFACE_IDENTITY);
1120-
}
1121-
1122-
cCorePlugin.setProjectDescription(project, projDesc, true, null);
1123-
1124-
}
11251106
}

io.sloeber.core/src/io/sloeber/core/builder/inoToCpp.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ protected IProject[] build(int kind, @SuppressWarnings("rawtypes") Map args, IPr
6060

6161
@Override
6262
protected void clean(IProgressMonitor monitor) throws CoreException {
63-
// delete markers set and files created
64-
63+
PdePreprocessor.deleteSloeberInoCPPFile(getProject());
6564
}
6665

6766
@SuppressWarnings("unused")

io.sloeber.core/src/io/sloeber/core/common/Common.java

+18-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import org.eclipse.core.resources.IWorkspaceRoot;
1717
import org.eclipse.core.resources.ResourcesPlugin;
1818
import org.eclipse.core.runtime.CoreException;
19+
import org.eclipse.core.runtime.IPath;
1920
import org.eclipse.core.runtime.IStatus;
2021
import org.eclipse.core.runtime.QualifiedName;
2122
import org.eclipse.core.runtime.Status;
@@ -252,9 +253,9 @@ static public String getBuildEnvironmentVariable(ICConfigurationDescription conf
252253
return defaultvalue;
253254
}
254255

255-
public static File getWorkspaceRoot() {
256+
public static IPath getWorkspaceRoot() {
256257
IWorkspaceRoot myWorkspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
257-
return myWorkspaceRoot.getLocation().toFile();
258+
return myWorkspaceRoot.getLocation();
258259
}
259260

260261
static {
@@ -283,6 +284,21 @@ private static String makePathEnvironmentString(String path) {
283284
return path.replace(eclipseHomeValue, makeEnvironmentVar(ECLIPSE_HOME));
284285
}
285286

287+
public static void setBuildEnvironmentVariable(IContributedEnvironment contribEnv,
288+
ICConfigurationDescription confDesc, String envKeyBuildPath, IPath buildPath) {
289+
// setBuildEnvironmentVariable(contribEnv, confDesc, envKeyBuildPath,
290+
// buildPath.toString());
291+
setBuildEnvironmentVariable(contribEnv, confDesc, envKeyBuildPath, buildPath.toOSString());
292+
293+
}
294+
295+
public static void setBuildEnvironmentVariable(IContributedEnvironment contribEnv,
296+
ICConfigurationDescription confDesc, String envKeyBuildPath, File file) {
297+
// String toSave = new Path(file.toString()).toString();
298+
String toSave = file.toString();
299+
setBuildEnvironmentVariable(contribEnv, confDesc, envKeyBuildPath, toSave);
300+
301+
}
286302
public static void setBuildEnvironmentVariable(IContributedEnvironment contribEnv,
287303
ICConfigurationDescription confdesc, String key, String value) {
288304

io.sloeber.core/src/io/sloeber/core/communication/ArduinoSerial.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ public static String makeArduinoUploadready(MessageConsoleStream console, IProje
232232
*/
233233
List<String> originalPorts = Serial.list();
234234
if (!originalPorts.contains(comPort) && !use_1200bps_touch && !bWaitForUploadPort) {
235-
console.println(Messages.ArduinoSerial_comport_not_found);
235+
console.println(Messages.ArduinoSerial_comport_not_found + ' ' + comPort);
236236
return comPort;
237237
}
238238
if (use_1200bps_touch) {

io.sloeber.core/src/io/sloeber/core/managers/ArduinoPlatform.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ public String getID() {
214214
String ID=new String();
215215

216216
if (myParent==null) {
217-
ID=getInstallPath().toOSString();
217+
ID = getInstallPath().toString();
218218
}
219219
else {
220220
ID=myParent.getName();

io.sloeber.core/src/io/sloeber/core/toolchain/ArduinoGnuMakefileGenerator.java

+6-4
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@
103103
import org.eclipse.core.runtime.MultiStatus;
104104
import org.eclipse.core.runtime.OperationCanceledException;
105105
import org.eclipse.core.runtime.Path;
106-
import org.eclipse.core.runtime.Platform;
107106
import org.eclipse.core.runtime.Status;
108107
import org.eclipse.core.runtime.SubProgressMonitor;
109108

@@ -1134,7 +1133,8 @@ private StringBuffer addTargets(List<String> outputVarsAdditionsList, boolean re
11341133
String prebuildStep = config.getPrebuildStep();
11351134
//JABA issue927 adding recipe.hooks.sketch.prebuild.NUMBER.pattern as cdt prebuild command if needed
11361135
ICConfigurationDescription confDesc = ManagedBuildManager.getDescriptionForConfiguration(config);
1137-
String sketchPrebuild= io.sloeber.core.common.Common.getBuildEnvironmentVariable(confDesc, "A.JANTJE.PREBUILD", new String(), false);
1136+
String sketchPrebuild = io.sloeber.core.common.Common.getBuildEnvironmentVariable(confDesc, "A.JANTJE.prebuild",
1137+
new String(), false);
11381138
if (!sketchPrebuild.isEmpty()) {
11391139
String separator = new String();
11401140
if (!prebuildStep.isEmpty()) {
@@ -2397,8 +2397,10 @@ protected void addRuleForSource(String relativePath, StringBuffer buffer, IResou
23972397
//JABA add sketch.prebuild and postbouild if needed
23982398
if("sloeber.ino".equals(fileName)) {
23992399
ICConfigurationDescription confDesc = ManagedBuildManager.getDescriptionForConfiguration(config);
2400-
String sketchPrebuild=io.sloeber.core.common.Common.getBuildEnvironmentVariable(confDesc, "A.JANTJE.SKETCH.PREBUILD", new String(), true);
2401-
String sketchPostBuild=io.sloeber.core.common.Common.getBuildEnvironmentVariable(confDesc, "A.JANTJE.SKETCH.POSTBUILD", new String(), true);
2400+
String sketchPrebuild = io.sloeber.core.common.Common.getBuildEnvironmentVariable(confDesc,
2401+
"A.JANTJE.sketch.prebuild", new String(), true);
2402+
String sketchPostBuild = io.sloeber.core.common.Common.getBuildEnvironmentVariable(confDesc,
2403+
"A.JANTJE.sketch.postbuild", new String(), true);
24022404
if(!sketchPrebuild.isEmpty()) {
24032405
buffer.append(TAB).append(sketchPrebuild);
24042406
}

0 commit comments

Comments
 (0)