Skip to content

#1163 create project the cdt way #1201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Jul 7, 2020
12 changes: 7 additions & 5 deletions io.sloeber.core/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@
<!-- It is also used for the base of the Debug configuration (for use with a JTAG/DragonAVR etc). -->
<!-- TODO: Consider renaming as base. -->
<configuration
artifactExtension="hex"
cleanCommand="rm -f"
id="io.sloeber.core.configuration.release"
languageSettingsProviders="io.sloeber.languageSettingsProvider"
Expand Down Expand Up @@ -400,22 +399,25 @@
command="${JANTJE.SIZE.SWITCH} "
commandLinePattern="${COMMAND}"
id="io.sloeber.tool.size"
isAbstract="false"
name="%tool.printsize.name">
<inputType
buildVariable="HEX"
dependencyExtensions="hex"
id="io.sloeber.tool.size.input"
multipleOfType="true"
primaryInput="true"
sourceContentType="io.sloeber.tool.objcopy.output">
sourceContentType="io.sloeber.tool.objcopy.output"
sources="hex">
</inputType>
<outputType
buildVariable="SIZEDUMMY"
id="io.sloeber.tool.size.output"
multipleOfType="false"
outputNames="sizedummy"
outputs="${project}.size"
primaryOutput="true">
name="size info"
outputNames="${ProjName}.size"
outputs="size"
primaryOutput="false">
</outputType>
</tool>
</toolChain>
Expand Down
2,003 changes: 1,012 additions & 991 deletions io.sloeber.core/src/io/sloeber/core/api/BoardDescriptor.java

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion io.sloeber.core/src/io/sloeber/core/common/Common.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,15 @@ public class Common extends Const {
* filenames containing spaces in Windows, see Note 1 < less than used to
* redirect input, allowed in Unix filenames, see Note 1 > greater than used
* to redirect output, allowed in Unix filenames, see Note 1 . period or dot
*
* # is excluded as it is seen as a special character by make
*
* @param name
* the string that needs to be checked
* @return a name safe to create files or folders
*/
public static String MakeNameCompileSafe(String name) {
char[] badChars = { ' ', '/', '.',':', '\\', '(', ')', '*', '?', '%', '|', '<', '>', ',', '-' };
char[] badChars = { ' ', '/', '.',':', '\\', '(', ')', '*', '?', '%', '|', '<', '>', ',', '-','#' };

String ret = name.trim();
for (char curchar : badChars) {
Expand Down
41 changes: 11 additions & 30 deletions io.sloeber.core/src/io/sloeber/core/tools/Helpers.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
Expand Down Expand Up @@ -103,8 +102,10 @@ public class Helpers extends Common {
* @param configurationDescription
* @param IncludePath
*/
public static void addIncludeFolder(ICConfigurationDescription configurationDescription, IPath IncludePath) {
addIncludeFolder(configurationDescription, IncludePath, true);

public static void addIncludeFolder(ICFolderDescription folderDescription, IPath IncludePath)
{
addIncludeFolder( folderDescription, IncludePath,true) ;
}

/**
Expand All @@ -116,10 +117,7 @@ public static void addIncludeFolder(ICConfigurationDescription configurationDesc
* @param IncludePath The path to add to the include folders
* @see addLibraryDependency {@link #addLibraryDependency(IProject, IProject)}
*/
public static void addIncludeFolder(ICConfigurationDescription configurationDescription, IPath IncludePath,
boolean isWorkspacePath) {
// find all languages
ICFolderDescription folderDescription = configurationDescription.getRootFolderDescription();
public static void addIncludeFolder(ICFolderDescription folderDescription, IPath IncludePath,boolean isWorkspacePath) {
ICLanguageSetting[] languageSettings = folderDescription.getLanguageSettings();
int pathSetting = ICSettingEntry.VALUE_WORKSPACE_PATH;
if (!isWorkspacePath) {
Expand Down Expand Up @@ -247,6 +245,7 @@ public static void LinkFolderToFolder(IProject project, IPath source, IPath targ
public static void addCodeFolder(IProject project, IPath toLinkFolder, String LinkName,
ICConfigurationDescription configurationDescription, boolean forceRoot) throws CoreException {
IFolder link = project.getFolder(LinkName);
ICFolderDescription folderDescription = configurationDescription.getRootFolderDescription();

LinkFolderToFolder(project, toLinkFolder, new Path(LinkName));

Expand All @@ -256,27 +255,27 @@ public static void addCodeFolder(IProject project, IPath toLinkFolder, String Li
String possibleIncludeFolder = "utility";
File file = toLinkFolder.append(possibleIncludeFolder).toFile();
if (file.exists()) {
addIncludeFolder(configurationDescription, link.getFullPath().append(possibleIncludeFolder));
addIncludeFolder(folderDescription, link.getFullPath().append(possibleIncludeFolder));
}

if (forceRoot) {
addIncludeFolder(configurationDescription, link.getFullPath());
addIncludeFolder(folderDescription, link.getFullPath());
} else {
// add src or root give priority to src
possibleIncludeFolder = Library.LIBRARY_SOURCE_FODER;
file = toLinkFolder.append(possibleIncludeFolder).toFile();
if (file.exists()) {
addIncludeFolder(configurationDescription, link.getFullPath().append(possibleIncludeFolder));
addIncludeFolder(folderDescription, link.getFullPath().append(possibleIncludeFolder));
} else {
addIncludeFolder(configurationDescription, link.getFullPath());
addIncludeFolder(folderDescription, link.getFullPath());
}
}

possibleIncludeFolder = "arch";
file = toLinkFolder.append(possibleIncludeFolder).toFile();
if (file.exists()) {
InternalBoardDescriptor boardDescriptor = new InternalBoardDescriptor(configurationDescription);
addIncludeFolder(configurationDescription,
addIncludeFolder(folderDescription,
link.getFullPath().append(possibleIncludeFolder).append(boardDescriptor.getArchitecture()));
}
}
Expand Down Expand Up @@ -316,24 +315,6 @@ public static void addCodeFolder(IProject project, Path Path, ICConfigurationDes
addCodeFolder(project, Path, NiceName, configurationDescription, forceRoot);
}

/**
* addTheNatures replaces all existing natures by the natures needed for a
* arduino project
*
* @param project The project where the natures need to be added to
* @throws CoreException
*/
public static void addTheNatures(IProjectDescription description) throws CoreException {

String[] newnatures = new String[5];
newnatures[0] = "org.eclipse.cdt.core.cnature";
newnatures[1] = "org.eclipse.cdt.core.ccnature";
newnatures[2] = "org.eclipse.cdt.managedbuilder.core.managedBuildNature";
newnatures[3] = "org.eclipse.cdt.managedbuilder.core.ScannerConfigNature";
newnatures[4] = Const.ARDUINO_NATURE_ID;
description.setNatureIds(newnatures);

}

/**
* This method adds the content of a content stream to a file If the file
Expand Down
136 changes: 0 additions & 136 deletions io.sloeber.core/src/io/sloeber/core/tools/ShouldHaveBeenInCDT.java

This file was deleted.

5 changes: 1 addition & 4 deletions io.sloeber.tests/src/io/sloeber/core/CompileAndUpload.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@

import io.sloeber.core.api.CodeDescriptor;
import io.sloeber.core.api.CompileOptions;
import io.sloeber.core.api.ConfigurationDescriptor;
import io.sloeber.core.api.PackageManager;
import io.sloeber.core.api.Preferences;
import io.sloeber.core.api.Sketch;
Expand Down Expand Up @@ -155,9 +154,7 @@ public void Build_Verify_upload(CodeDescriptor codeDescriptor,
try {

theTestProject = this.myBoard.getBoardDescriptor().createProject(
projectName, null,
ConfigurationDescriptor.getDefaultDescriptors(),
codeDescriptor, compileOptions, monitor);
projectName, null, codeDescriptor, compileOptions, monitor);
Shared.waitForAllJobsToFinish(); // for the indexer
} catch (Exception e) {
e.printStackTrace();
Expand Down
Loading