Introducing a YoctoSDKAutotoolsProjectNature
cover Introducing a YoctoSDKAutotoolsProjectNature
From: Atanas Gegov <[email protected]>
Hi,
this patch series does a refactoring in the project natures. It does not add new functionality. In detail, this means the following:
Initially, the org.yocto.sdk.ide plugin defined 2 natures:
1/ YoctoSDKProjectNature (every template project has this nature, strongly coupled with Autotools)
2/ YoctoSDKEmptyProjectNature (additional nature for empty projects)
With this change there are now 3 natures available:
1/ YoctoSDKProjectNature (the "basic" nature,
every Yocto IDE project has this nature)
2/ YoctoSDKAutotoolsProjectNature (requires YoctoSDKProjectNature, strongly coupled with Autotools, all existing template projects get it) 3/ YoctoSDKEmptyProjectNature (additional nature for empty projects, requires YoctoSDKProjectNature)
Now it is possible to introduce new type of Yocto projects that for example use CMake instead of Autotools. These projects still have the YoctoSDKProjectNature which provides the right environment, the cross-development profiles, etc.
Cheers,
Atanas
P.S: This patch series apply on the current master "Remove clutter project templates" (5e20d3c32072ddd91dceb8b2b793ef13f25b915e). However, it should be updated if the patch currently discussed on the mailing list "[yocto][PATCH v2][eclipse-poky][master] Add more comprehensive error message for invalid project name" is applied before this patch series.
Atanas Gegov (7):
plugins/sdk.ide: Prepared templates for autotools nature plugins/sdk.ide: Added a new YoctoSDKAutotoolsProjectNature plugins/sdk.ide: Added a check method for the global target profie plugins/sdk.ide: Switch to YoctoSDKAutotoolsProjectNature plugins/sdk.ide: Renamed the NewYoctoProjectPostProcess plugins/sdk.ide: Improved usage of strings in class plugins/sdk.ide: Extracted error message to YoctoSDKMessages
.../OSGI-INF/l10n/bundle.properties | 1 + plugins/org.yocto.sdk.ide/plugin.xml | 28 ++++++- .../src/org/yocto/sdk/ide/YoctoSDKChecker.java | 13 +++ .../org/yocto/sdk/ide/YoctoSDKMessages.properties | 3 +- .../natures/YoctoSDKAutotoolsProjectNature.java | 86 ++++++++++++++++++++ .../sdk/ide/natures/YoctoSDKProjectNature.java | 70 ---------------- .../src/org/yocto/sdk/ide/utils/YoctoSDKUtils.java | 6 +- .../NewYoctoAutotoolsProjectPostProcess.java | 81 ++++++++++++++++++ .../sdk/ide/wizard/NewYoctoCProjectTemplate.java | 84 +++++++++++-------- .../sdk/ide/wizard/NewYoctoProjectPostProcess.java | 73 ----------------- .../projecttemplates/EmptyCPPProject/template.xml | 1 + .../projecttemplates/EmptyCProject/template.xml | 1 + .../HelloWorldCAutotoolsProject/template.xml | 3 +- .../HelloWorldCGTKProject/template.xml | 3 +- .../HelloWorldCPPAutotoolsProject/template.xml | 3 +- 15 files changed, 268 insertions(+), 188 deletions(-) create mode 100644 plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKAutotoolsProjectNature.java create mode 100644 plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoAutotoolsProjectPostProcess.java delete mode 100644 plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoProjectPostProcess.java
Signature · 1 line
1.7.9.5
PATCH 1/7 plugins/sdk.ide: Prepared templates for autotools nature
From: Atanas Gegov <[email protected]>
Added an extra variable to the templates and the
creating process. They are now prepared for a new
autotools nature.
--- plugins/org.yocto.sdk.ide/plugin.xml | 4 ++++ .../sdk/ide/wizard/NewYoctoCProjectTemplate.java | 3 +++ .../projecttemplates/EmptyCPPProject/template.xml | 1 + .../projecttemplates/EmptyCProject/template.xml | 1 + .../HelloWorldCAutotoolsProject/template.xml | 1 + .../HelloWorldCGTKProject/template.xml | 1 + .../HelloWorldCPPAutotoolsProject/template.xml | 1 + 7 files changed, 12 insertions(+)
plugins/org.yocto.sdk.ide/plugin.xml +4 -0
@@ -142,6 +142,10 @@ external="true" name="isEmptyProject"> </simple> + <simple + external="true" + name="isAutotoolsProject"> + </simple> </processType> <processType name="NewYoctoProjectPostProcess"
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoCProjectTemplate.java +3 -0
@@ -70,8 +70,11 @@ public class NewYoctoCProjectTemplate extends ProcessRunner { String artifactExtension = args[2].getSimpleValue(); String isCProjectValue = args[3].getSimpleValue(); String isEmptyProjetValue = args[4].getSimpleValue(); + String isAutotoolsProjectValue = args[5].getSimpleValue(); boolean isCProject = Boolean.valueOf(isCProjectValue).booleanValue(); boolean isEmptryProject = Boolean.valueOf(isEmptyProjetValue).booleanValue(); + boolean isAutotoolsProject = Boolean.valueOf(isAutotoolsProjectValue).booleanValue(); + IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); try { if (projectName.contains(" ")) {
plugins/org.yocto.sdk.ide/templates/projecttemplates/EmptyCPPProject/template.xml +1 -0
@@ -9,6 +9,7 @@ <simple name="artifactExtension" value="exe" /> <simple name="isCProject" value="false" /> <simple name="isEmptyProject" value="true" /> + <simple name="isAutotoolsProject" value="true" /> </process> </template>
plugins/org.yocto.sdk.ide/templates/projecttemplates/EmptyCProject/template.xml +1 -0
@@ -10,6 +10,7 @@ <simple name="artifactExtension" value="exe" /> <simple name="isCProject" value="true" /> <simple name="isEmptyProject" value="true" /> + <simple name="isAutotoolsProject" value="true" /> </process> </template>
plugins/org.yocto.sdk.ide/templates/projecttemplates/HelloWorldCAutotoolsProject/template.xml +1 -0
@@ -55,6 +55,7 @@ <simple name="artifactExtension" value="exe" /> <simple name="isCProject" value="true" /> <simple name="isEmptyProject" value="false" /> + <simple name="isAutotoolsProject" value="true" /> </process> <process type="org.eclipse.cdt.core.CreateSourceFolder">
plugins/org.yocto.sdk.ide/templates/projecttemplates/HelloWorldCGTKProject/template.xml +1 -0
@@ -55,6 +55,7 @@ <simple name="artifactExtension" value="exe" /> <simple name="isCProject" value="true" /> <simple name="isEmptyProject" value="false" /> + <simple name="isAutotoolsProject" value="true" /> </process> <process type="org.eclipse.cdt.core.CreateSourceFolder">
plugins/org.yocto.sdk.ide/templates/projecttemplates/HelloWorldCPPAutotoolsProject/template.xml +1 -0
@@ -55,6 +55,7 @@ <simple name="artifactExtension" value="exe" /> <simple name="isCProject" value="false" /> <simple name="isEmptyProject" value="false" /> + <simple name="isAutotoolsProject" value="true" /> </process> <process type="org.eclipse.cdt.core.CreateSourceFolder">
Signature · 1 line
1.7.9.5
PATCH 2/7 plugins/sdk.ide: Added a new YoctoSDKAutotoolsProjectNature
In reply to Atanas GegovFrom: Atanas Gegov <[email protected]>
This nature is intended for Yocto projects that use Autotools as a build system. It requires the YoctoSDKProjectNature and will be used by the existing templates.
--- .../OSGI-INF/l10n/bundle.properties | 1 + plugins/org.yocto.sdk.ide/plugin.xml | 18 ++++++++- .../natures/YoctoSDKAutotoolsProjectNature.java | 41 ++++++++++++++++++++ 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKAutotoolsProjectNature.java
plugins/org.yocto.sdk.ide/OSGI-INF/l10n/bundle.properties +1 -0
@@ -1,6 +1,7 @@ #Properties file for org.Yocto.sdk.ide page.name.0 = Yocto Project ADT extension.name.0 = YoctoSDKNature +extension.name.1 = YoctoSDKAutotoolsNature command.name = ReconfigureYoctoProject command.label.0 = Change Yocto Project Settings command.mnemonic = C
plugins/org.yocto.sdk.ide/plugin.xml +17 -1
@@ -19,12 +19,25 @@ id="YoctoSDKNature" name="%extension.name.0" point="org.eclipse.core.resources.natures"> + <runtime> + <run + class="org.yocto.sdk.ide.natures.YoctoSDKProjectNature"> + </run> + </runtime> + </extension> + <extension + id="YoctoSDKAutotoolsNature" + name="%extension.name.1" + point="org.eclipse.core.resources.natures"> + <requires-nature + id="org.yocto.sdk.ide.YoctoSDKNature"> + </requires-nature> <requires-nature id="org.eclipse.cdt.autotools.core.autotoolsNatureV2"> </requires-nature> <runtime> <run - class="org.yocto.sdk.ide.natures.YoctoSDKProjectNature"> + class="org.yocto.sdk.ide.natures.YoctoSDKAutotoolsProjectNature"> </run> </runtime> <builder
@@ -34,6 +47,9 @@ <extension id="YoctoSDKEmptyNature" point="org.eclipse.core.resources.natures"> + <requires-nature + id="org.yocto.sdk.ide.YoctoSDKNature"> + </requires-nature> <runtime> <run class="org.yocto.sdk.ide.natures.YoctoSDKEmptyProjectNature">
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKAutotoolsProjectNature.java new file +41 -0
41 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH 3/7 plugins/sdk.ide: Added a check method for the global target profie
In reply to Atanas GegovFrom: Atanas Gegov <[email protected]>
Added an own method (copied code) in YoctoSDKChecker that checks the validity of the globally selected profile. This method will be used in the next patch and will replace duplicated code.
--- .../src/org/yocto/sdk/ide/YoctoSDKChecker.java | 13 +++++++++++++ 1 file changed, 13 insertions(+)
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKChecker.java +13 -0
@@ -19,6 +19,7 @@ import java.io.FileReader; import java.io.FilenameFilter; import java.io.IOException; +import org.eclipse.jface.preference.IPreferenceStore; import org.yocto.sdk.ide.natures.YoctoSDKProjectNature; import org.yocto.sdk.ide.utils.YoctoSDKUtils; import org.yocto.sdk.ide.utils.YoctoSDKUtilsConstants;
@@ -98,6 +99,18 @@ public class YoctoSDKChecker { } }; + public static void checkIfGloballySelectedYoctoProfileIsValid() throws YoctoGeneralException { + YoctoProfileElement profileElement = YoctoSDKUtils.getProfilesFromDefaultStore(); + IPreferenceStore selectedProfileStore = YoctoSDKPlugin.getProfilePreferenceStore(profileElement.getSelectedProfile()); + YoctoUIElement elem = YoctoSDKUtils.getElemFromStore(selectedProfileStore); + + SDKCheckResults result = checkYoctoSDK(elem); + if (result != SDKCheckResults.SDK_PASS){ + String strErrorMsg = getErrorMessage(result, SDKCheckRequestFrom.Wizard); + throw new YoctoGeneralException(strErrorMsg); + } + } + public static SDKCheckResults checkYoctoSDK(YoctoUIElement elem) { if (elem.getStrToolChainRoot().isEmpty()) return SDKCheckResults.TOOLCHAIN_LOCATION_EMPTY;
Signature · 1 line
1.7.9.5
PATCH 4/7 plugins/sdk.ide: Switch to YoctoSDKAutotoolsProjectNature
In reply to Atanas GegovFrom: Atanas Gegov <[email protected]>
The YoctoSDKProjectNature remains the basic nature for all Yocto projects in the IDE. The projects using Autotools (all templates) get the YoctoSDKProjectNature and additionally the YoctoSDKAutotoolsProjectNature. The process NewYoctoCProjectTemplate is adapted accordingly.
--- plugins/org.yocto.sdk.ide/plugin.xml | 2 +- .../natures/YoctoSDKAutotoolsProjectNature.java | 45 +++++++++++ .../sdk/ide/natures/YoctoSDKProjectNature.java | 70 ----------------- .../src/org/yocto/sdk/ide/utils/YoctoSDKUtils.java | 6 +- .../sdk/ide/wizard/NewYoctoCProjectTemplate.java | 81 +++++++++++--------- 5 files changed, 96 insertions(+), 108 deletions(-)
plugins/org.yocto.sdk.ide/plugin.xml +1 -1
@@ -91,7 +91,7 @@ type="org.eclipse.core.resources.IResource"> <test property="org.eclipse.core.resources.projectNature" - value="org.yocto.sdk.ide.YoctoSDKNature"> + value="org.yocto.sdk.ide.YoctoSDKAutotoolsNature"> </test> </adapt> </iterate>
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKAutotoolsProjectNature.java +45 -0
64 lines not on this page · raw message
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKProjectNature.java +0 -70
89 lines not on this page · raw message
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/utils/YoctoSDKUtils.java +4 -2
@@ -54,8 +54,8 @@ import org.yocto.sdk.ide.YoctoProfileElement; import org.yocto.sdk.ide.YoctoSDKMessages; import org.yocto.sdk.ide.YoctoSDKPlugin; import org.yocto.sdk.ide.YoctoUIElement; +import org.yocto.sdk.ide.natures.YoctoSDKAutotoolsProjectNature; import org.yocto.sdk.ide.natures.YoctoSDKEmptyProjectNature; -import org.yocto.sdk.ide.natures.YoctoSDKProjectNature; import org.yocto.sdk.ide.preferences.PreferenceConstants; public class YoctoSDKUtils {
@@ -427,7 +427,9 @@ public class YoctoSDKUtils { try { setEnvironmentVariables(project, elem); - YoctoSDKProjectNature.configureAutotoolsOptions(project); + if(project.hasNature(YoctoSDKAutotoolsProjectNature.YoctoSDK_AUTOTOOLS_NATURE_ID)) { + YoctoSDKAutotoolsProjectNature.configureAutotoolsOptions(project); + } IConsole console = CCorePlugin.getDefault().getConsole("org.yocto.sdk.ide.YoctoConsole"); console.start(project); consoleOutStream = console.getOutputStream();
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoCProjectTemplate.java +46 -35
123 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH 5/7 plugins/sdk.ide: Renamed the NewYoctoProjectPostProcess
In reply to Atanas GegovFrom: Atanas Gegov <[email protected]>
Renamed the NewYoctoProjectPostProcess to NewYoctoAutotoolsProjectPostProcess as it is actually relevant for Autotools-based projects. Added a check for the apropriate project nature in the the "process" method of NewYoctoAutotoolsProjectPostProcess.
--- plugins/org.yocto.sdk.ide/plugin.xml | 4 +- .../org/yocto/sdk/ide/YoctoSDKMessages.properties | 2 +- .../NewYoctoAutotoolsProjectPostProcess.java | 77 ++++++++++++++++++++ .../sdk/ide/wizard/NewYoctoProjectPostProcess.java | 73 ------------------- .../HelloWorldCAutotoolsProject/template.xml | 2 +- .../HelloWorldCGTKProject/template.xml | 2 +- .../HelloWorldCPPAutotoolsProject/template.xml | 2 +- 7 files changed, 83 insertions(+), 79 deletions(-) create mode 100644 plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoAutotoolsProjectPostProcess.java delete mode 100644 plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoProjectPostProcess.java
plugins/org.yocto.sdk.ide/plugin.xml +2 -2
@@ -164,8 +164,8 @@ </simple> </processType> <processType - name="NewYoctoProjectPostProcess" - processRunner="org.yocto.sdk.ide.wizard.NewYoctoProjectPostProcess"> + name="NewYoctoAutotoolsProjectPostProcess" + processRunner="org.yocto.sdk.ide.wizard.NewYoctoAutotoolsProjectPostProcess"> <simple name="projectName"> </simple>
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKMessages.properties +1 -1
@@ -98,5 +98,5 @@ LaunchConfig.BuildScope.Value = ${projects:} LaunchConfig.Location.Attr = org.eclipse.ui.externaltools.ATTR_LOCATION LaunchConfig.Arguments.Attr = org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS; - +AutotoolsProjectPostProcess.WrongProjectNature = {0} is not an Autotools project
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoAutotoolsProjectPostProcess.java new file +77 -0
77 lines not on this page · raw message
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoProjectPostProcess.java deleted +0 -73
73 lines not on this page · raw message
plugins/org.yocto.sdk.ide/templates/projecttemplates/HelloWorldCAutotoolsProject/template.xml +1 -1
@@ -135,7 +135,7 @@ </complex-array> </process> - <process type="org.yocto.sdk.ide.NewYoctoProjectPostProcess"> + <process type="org.yocto.sdk.ide.NewYoctoAutotoolsProjectPostProcess"> <simple name="projectName" value="$(projectName)" /> </process>
plugins/org.yocto.sdk.ide/templates/projecttemplates/HelloWorldCGTKProject/template.xml +1 -1
@@ -135,7 +135,7 @@ </complex-array> </process> - <process type="org.yocto.sdk.ide.NewYoctoProjectPostProcess"> + <process type="org.yocto.sdk.ide.NewYoctoAutotoolsProjectPostProcess"> <simple name="projectName" value="$(projectName)" /> </process> </template>
plugins/org.yocto.sdk.ide/templates/projecttemplates/HelloWorldCPPAutotoolsProject/template.xml +1 -1
@@ -135,7 +135,7 @@ </complex-array> </process> - <process type="org.yocto.sdk.ide.NewYoctoProjectPostProcess"> + <process type="org.yocto.sdk.ide.NewYoctoAutotoolsProjectPostProcess"> <simple name="projectName" value="$(projectName)" /> </process> </template>
Signature · 1 line
1.7.9.5
PATCH 6/7 plugins/sdk.ide: Improved usage of strings in class
In reply to Atanas GegovFrom: Atanas Gegov <[email protected]>
Extracted string constants. Added missing
NON-NLS-1 declarations.
--- .../NewYoctoAutotoolsProjectPostProcess.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoAutotoolsProjectPostProcess.java +7 -3
@@ -11,6 +11,7 @@ package org.yocto.sdk.ide.wizard; import java.io.BufferedReader; +import java.io.File; import java.io.InputStream; import java.io.InputStreamReader;
@@ -28,6 +29,9 @@ import org.yocto.sdk.ide.natures.YoctoSDKAutotoolsProjectNature; public class NewYoctoAutotoolsProjectPostProcess extends ProcessRunner { + public static final String CHMOD_COMMAND = "chmod +x "; //$NON-NLS-1$ + public static final String AUTOGEN_SCRIPT_NAME = "autogen.sh"; //$NON-NLS-1$ + public NewYoctoAutotoolsProjectPostProcess() {} public void process(TemplateCore template, ProcessArgument[] args, String processId, IProgressMonitor monitor) throws ProcessFailureException {
@@ -45,7 +49,7 @@ public class NewYoctoAutotoolsProjectPostProcess extends ProcessRunner { } else { IPath path = project.getLocation(); String path_str = path.toString(); - String autogen_cmd = "chmod +x " + path_str + "/autogen.sh"; + String autogen_cmd = CHMOD_COMMAND + path_str + File.separator + AUTOGEN_SCRIPT_NAME; try { Runtime rt = Runtime.getRuntime(); Process proc = rt.exec(autogen_cmd);
@@ -53,7 +57,7 @@ public class NewYoctoAutotoolsProjectPostProcess extends ProcessRunner { InputStreamReader isr = new InputStreamReader(stdin); BufferedReader br = new BufferedReader(isr); String line = null; - String error_message = ""; + String error_message = ""; //$NON-NLS-1$ while ( (line = br.readLine()) != null) { error_message = error_message + line;
@@ -61,7 +65,7 @@ public class NewYoctoAutotoolsProjectPostProcess extends ProcessRunner { int exitVal = proc.waitFor(); if (exitVal != 0) { - throw new ProcessFailureException("Failed to make autogen.sh executable for project: " + projectName); + throw new ProcessFailureException("Failed to make autogen.sh executable for project: " + projectName); //$NON-NLS-1$ } } catch (Throwable t) { t.printStackTrace();
Signature · 1 line
1.7.9.5
PATCH 7/7 plugins/sdk.ide: Extracted error message to YoctoSDKMessages
In reply to Atanas GegovFrom: Atanas Gegov <[email protected]>
Improved the i18n ability.
--- .../org/yocto/sdk/ide/YoctoSDKMessages.properties | 1 + .../NewYoctoAutotoolsProjectPostProcess.java | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-)
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKMessages.properties +1 -0
@@ -99,4 +99,5 @@ LaunchConfig.Location.Attr = org.eclipse.ui.externaltools.ATTR_LOCATION LaunchConfig.Arguments.Attr = org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS; AutotoolsProjectPostProcess.WrongProjectNature = {0} is not an Autotools project +AutotoolsProjectPostProcess.ChmodFailure = Failed to make autogen.sh executable for project: {0}
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoAutotoolsProjectPostProcess.java +4 -4
@@ -65,16 +65,16 @@ public class NewYoctoAutotoolsProjectPostProcess extends ProcessRunner { int exitVal = proc.waitFor(); if (exitVal != 0) { - throw new ProcessFailureException("Failed to make autogen.sh executable for project: " + projectName); //$NON-NLS-1$ + throw new ProcessFailureException( + YoctoSDKMessages.getFormattedString("AutotoolsProjectPostProcess.ChmodFailure", //$NON-NLS-1$ + projectName)); } } catch (Throwable t) { t.printStackTrace(); } } - } - catch (Exception e) - { + } catch (Exception e) { throw new ProcessFailureException(Messages.getString("NewManagedProject.3") + e.getMessage(), e); //$NON-NLS-1$ } }
Signature · 1 line
1.7.9.5