Skip to content

Commit 91614c7

Browse files
committed
#572: add isEmbeddedCdt property tester
1 parent fd62f0b commit 91614c7

File tree

10 files changed

+109
-7
lines changed

10 files changed

+109
-7
lines changed

plugins/org.eclipse.embedcdt.core/META-INF/MANIFEST.MF

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,8 @@ Require-Bundle: org.eclipse.cdt.core;bundle-version="7.0.0",
600600
org.eclipse.cdt.managedbuilder.core;bundle-version="9.0.0",
601601
org.eclipse.core.runtime;bundle-version="3.19.0",
602602
org.eclipse.core.variables;bundle-version="3.4.800",
603-
org.eclipse.debug.core;bundle-version="3.16.0"
603+
org.eclipse.debug.core;bundle-version="3.16.0",
604+
org.eclipse.core.expressions;bundle-version="3.7.0"
604605
Bundle-ClassPath: lib/antlr-runtime-3.5.2.jar,
605606
lib/jackson-annotations-2.9.9.jar,
606607
lib/jackson-core-2.9.9.jar,

plugins/org.eclipse.embedcdt.core/plugin.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,14 @@
1515

1616
<plugin>
1717

18+
<extension point="org.eclipse.core.expressions.propertyTesters">
19+
<propertyTester
20+
class="org.eclipse.embedcdt.core.EmbeddedCdtPropertyTester"
21+
id="org.eclipse.embedcdt.core.propertyTester"
22+
namespace="org.eclipse.embedcdt.core"
23+
properties="isEmbeddedCdt"
24+
type="java.lang.Object">
25+
</propertyTester>
26+
</extension>
27+
1828
</plugin>
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2015 Liviu Ionescu.
3+
*
4+
* This program and the accompanying materials
5+
* are made available under the terms of the Eclipse Public License 2.0
6+
* which accompanies this distribution, and is available at
7+
* https://www.eclipse.org/legal/epl-2.0/
8+
*
9+
* SPDX-License-Identifier: EPL-2.0
10+
*
11+
* Contributors:
12+
* Liviu Ionescu - initial version
13+
*******************************************************************************/
14+
15+
package org.eclipse.embedcdt.core;
16+
17+
import org.eclipse.cdt.managedbuilder.core.BuildException;
18+
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
19+
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
20+
import org.eclipse.cdt.managedbuilder.core.IManagedProject;
21+
import org.eclipse.cdt.managedbuilder.core.IOption;
22+
import org.eclipse.cdt.managedbuilder.core.IToolChain;
23+
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
24+
import org.eclipse.core.expressions.PropertyTester;
25+
import org.eclipse.core.resources.IProject;
26+
27+
/**
28+
* Property tester for the Tools Paths page.
29+
*
30+
* The project must be managed and have an options with the toolchain name.
31+
*
32+
* This class deprecates org.eclipse.embedcdt.managedbuild.cross.core.GnuMcuPropertyTester.
33+
*/
34+
public class EmbeddedCdtPropertyTester extends PropertyTester {
35+
36+
@Override
37+
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
38+
39+
if ("isEmbeddedCdt".equals(property)) {
40+
if (receiver instanceof IProject) {
41+
42+
IProject project = (IProject) receiver;
43+
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
44+
if (info == null) {
45+
return false; // Not managed build
46+
}
47+
48+
IManagedProject managedProject = info.getManagedProject();
49+
IConfiguration[] cfgs = managedProject.getConfigurations();
50+
for (int i = 0; i < cfgs.length; ++i) {
51+
IToolChain toolchain = cfgs[i].getToolChain();
52+
if (toolchain == null) {
53+
continue;
54+
}
55+
56+
IOption options[] = toolchain.getOptions();
57+
for (IOption opt : options) {
58+
String id = opt.getId();
59+
// System.out.println(opt.getId());
60+
if (id.indexOf(".managedbuild.cross.") >= 0 && id.indexOf(".toolchain.name.") >= 0) {
61+
try {
62+
String name = opt.getStringValue();
63+
// Might be empty
64+
if (name != null) {
65+
return true;
66+
}
67+
} catch (BuildException e) {
68+
69+
}
70+
}
71+
}
72+
73+
}
74+
75+
return false;
76+
77+
// IProjectType projectType = managedProject.getProjectType();
78+
//
79+
// if (projectType == null
80+
// || !projectType.getId().startsWith(TYPE_PREFIX)) {
81+
// return false;
82+
// }
83+
// return true;
84+
}
85+
}
86+
return false;
87+
}
88+
89+
}

plugins/org.eclipse.embedcdt.debug.gdbjtag.jlink.ui/plugin.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
<and>
5959
<instanceof value="org.eclipse.core.resources.IProject">
6060
</instanceof>
61-
<test forcePluginActivation="true" property="org.eclipse.embedcdt.managedbuild.cross.core.isGnuMcu">
61+
<test forcePluginActivation="true" property="org.eclipse.embedcdt.core.isEmbeddedCdt">
6262
</test>
6363
</and>
6464
</enabledWhen>

plugins/org.eclipse.embedcdt.debug.gdbjtag.openocd.ui/plugin.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
<and>
5858
<instanceof value="org.eclipse.core.resources.IProject">
5959
</instanceof>
60-
<test forcePluginActivation="true" property="org.eclipse.embedcdt.managedbuild.cross.core.isGnuMcu">
60+
<test forcePluginActivation="true" property="org.eclipse.embedcdt.core.isEmbeddedCdt">
6161
</test>
6262
</and>
6363
</enabledWhen>

plugins/org.eclipse.embedcdt.debug.gdbjtag.pyocd.ui/plugin.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
<and>
5858
<instanceof value="org.eclipse.core.resources.IProject">
5959
</instanceof>
60-
<test forcePluginActivation="true" property="org.eclipse.embedcdt.managedbuild.cross.core.isGnuMcu">
60+
<test forcePluginActivation="true" property="org.eclipse.embedcdt.core.isEmbeddedCdt">
6161
</test>
6262
</and>
6363
</enabledWhen>

plugins/org.eclipse.embedcdt.debug.gdbjtag.qemu.ui/plugin.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
<and>
9090
<instanceof value="org.eclipse.core.resources.IProject">
9191
</instanceof>
92-
<test forcePluginActivation="true" property="org.eclipse.embedcdt.managedbuild.cross.core.isGnuMcu">
92+
<test forcePluginActivation="true" property="org.eclipse.embedcdt.core.isEmbeddedCdt">
9393
</test>
9494
</and>
9595
</enabledWhen>

plugins/org.eclipse.embedcdt.managedbuild.cross.core/src/org/eclipse/embedcdt/managedbuild/cross/core/GnuMcuPropertyTester.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
* Property tester for the Tools Paths page.
2929
*
3030
* The project must be managed and have an options with the toolchain name.
31+
* @deprecated See org.eclipse.embedcdt.core.EmbeddedCdtPropertyTester.
3132
*/
33+
@Deprecated
3234
public class GnuMcuPropertyTester extends PropertyTester {
3335

3436
@Override

plugins/org.eclipse.embedcdt.managedbuild.cross.ui/plugin.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
<and>
4646
<instanceof value="org.eclipse.core.resources.IProject">
4747
</instanceof>
48-
<test forcePluginActivation="true" property="org.eclipse.embedcdt.managedbuild.cross.core.isGnuMcu">
48+
<test forcePluginActivation="true" property="org.eclipse.embedcdt.core.isEmbeddedCdt">
4949
</test>
5050
</and>
5151
</enabledWhen>

plugins/org.eclipse.embedcdt.ui/plugin.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<and>
3535
<instanceof value="org.eclipse.core.resources.IProject">
3636
</instanceof>
37-
<test forcePluginActivation="true" property="org.eclipse.embedcdt.managedbuild.cross.core.isGnuMcu">
37+
<test forcePluginActivation="true" property="org.eclipse.embedcdt.core.isEmbeddedCdt">
3838
</test>
3939
</and>
4040
</enabledWhen>

0 commit comments

Comments
 (0)