summaryrefslogtreecommitdiffstats
path: root/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures')
-rw-r--r--plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKAutotoolsProjectNature.java79
-rw-r--r--plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKCMakeProjectNature.java92
-rw-r--r--plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKEmptyProjectNature.java8
-rw-r--r--plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKNatureUtils.java39
-rw-r--r--plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKProjectNature.java36
5 files changed, 254 insertions, 0 deletions
diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKAutotoolsProjectNature.java b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKAutotoolsProjectNature.java
new file mode 100644
index 0000000..ce80d77
--- /dev/null
+++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKAutotoolsProjectNature.java
@@ -0,0 +1,79 @@
1/*******************************************************************************
2 * Copyright (c) 2010 Intel Corporation.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * Intel - initial API and implementation
10 *******************************************************************************/
11package org.yocto.sdk.ide.natures;
12
13import org.eclipse.cdt.internal.autotools.core.configure.AutotoolsConfigurationManager;
14import org.eclipse.cdt.internal.autotools.core.configure.IAConfiguration;
15import org.eclipse.cdt.managedbuilder.core.IConfiguration;
16import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
17import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
18import org.eclipse.core.resources.IProject;
19import org.yocto.sdk.ide.YoctoSDKPlugin;
20import org.yocto.sdk.ide.YoctoUIElement;
21import org.yocto.sdk.ide.utils.ProjectPreferenceUtils;
22import org.yocto.sdk.ide.utils.YoctoSDKUtils;
23
24public class YoctoSDKAutotoolsProjectNature extends YoctoSDKProjectNature {
25 public static final String YoctoSDK_AUTOTOOLS_NATURE_ID = YoctoSDKPlugin.getUniqueIdentifier() + ".YoctoSDKAutotoolsNature";
26
27 private static final String DEFAULT_HOST_STR = "host";
28 private static final String DEFAULT_TARGET_STR = "target";
29 private static final String DEFAULT_BUILD_STR = "build";
30 private static final String DEFAULT_AUTOGEN_OPT_STR = "autogenOpts";
31
32 private static final String DEFAULT_CONFIGURE_STR = "configure";
33 private static final String DEFAULT_AUTOGEN_STR = "autogen";
34 private static final String DEFAULT_LIBTOOL_SYSROOT_PREFIX = " --with-libtool-sysroot=";
35
36 public static void configureAutotoolsOptions(IProject project) {
37 IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
38 IConfiguration icfg = info.getDefaultConfiguration();
39 YoctoUIElement elem = ProjectPreferenceUtils.getElemFromProjectEnv(project);
40 String sysroot_str = elem.getStrSysrootLoc();
41 String id = icfg.getId();
42 String CFLAGS_str = YoctoSDKUtils.getEnvValue(project, "CFLAGS");
43 String CXXFLAGS_str = YoctoSDKUtils.getEnvValue(project, "CXXFLAGS");
44 String CPPFLAGS_str = YoctoSDKUtils.getEnvValue(project, "CPPFLAGS");
45 String LDFLAGS_str = YoctoSDKUtils.getEnvValue(project, "LDFLAGS");
46
47 String command_prefix = "CFLAGS=\" -g -O0 " + CFLAGS_str + "\" CXXFLAGS=\" -g -O0 "
48 + CXXFLAGS_str + "\" LDFLAGS=\"" + LDFLAGS_str + "\" CPPFLAGS=\"" + CPPFLAGS_str + "\"";
49 String autogen_setting = command_prefix+" autogen.sh" + DEFAULT_LIBTOOL_SYSROOT_PREFIX + sysroot_str;
50 String configure_setting = command_prefix + " configure" + DEFAULT_LIBTOOL_SYSROOT_PREFIX + sysroot_str;
51 IAConfiguration cfg = AutotoolsConfigurationManager.getInstance().getConfiguration(project, id);
52 String strConfigure = YoctoSDKUtils.getEnvValue(project, "CONFIGURE_FLAGS");
53
54 cfg.setOption(DEFAULT_CONFIGURE_STR, configure_setting);
55 cfg.setOption(DEFAULT_BUILD_STR, splitString(strConfigure, "--build="));
56 cfg.setOption(DEFAULT_HOST_STR, splitString(strConfigure, "--host="));
57 cfg.setOption(DEFAULT_TARGET_STR, splitString(strConfigure, "--target="));
58 cfg.setOption(DEFAULT_AUTOGEN_STR, autogen_setting);
59 cfg.setOption(DEFAULT_AUTOGEN_OPT_STR, strConfigure);
60
61 AutotoolsConfigurationManager.getInstance().addConfiguration(project, cfg);
62 AutotoolsConfigurationManager.getInstance().saveConfigs(project);
63 }
64
65 private static String splitString(String strValue, String strDelim) {
66 int iBeginIndex = strValue.indexOf(strDelim);
67
68 if (iBeginIndex < 0) {
69 return "";
70 }
71 int iEndIndex = strValue.indexOf(' ', iBeginIndex + 1);
72
73 if (iEndIndex < 0) {
74 return strValue.substring(iBeginIndex + strDelim.length());
75 } else {
76 return strValue.substring(iBeginIndex + strDelim.length(), iEndIndex);
77 }
78 }
79}
diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKCMakeProjectNature.java b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKCMakeProjectNature.java
new file mode 100644
index 0000000..b3d0f2c
--- /dev/null
+++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKCMakeProjectNature.java
@@ -0,0 +1,92 @@
1/*******************************************************************************
2 * Copyright (c) 2013 BMW Car IT GmbH.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * BMW Car IT - initial API and implementation
10 *******************************************************************************/
11package org.yocto.sdk.ide.natures;
12
13import org.eclipse.cdt.core.CCorePlugin;
14import org.eclipse.cdt.core.envvar.IContributedEnvironment;
15import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
16import org.eclipse.cdt.core.envvar.IEnvironmentVariableManager;
17import org.eclipse.cdt.core.model.CoreModel;
18import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
19import org.eclipse.cdt.core.settings.model.ICProjectDescription;
20import org.eclipse.core.resources.IProject;
21import org.eclipse.core.runtime.CoreException;
22import org.yocto.sdk.ide.YoctoSDKPlugin;
23import org.yocto.sdk.ide.utils.YoctoSDKUtils;
24
25public class YoctoSDKCMakeProjectNature extends YoctoSDKProjectNature {
26 public static final String YoctoSDK_CMAKE_NATURE_ID = YoctoSDKPlugin.getUniqueIdentifier() + ".YoctoSDKCMakeNature";
27
28 // Considered poky's cmake.bbclass for this method
29 public static void extendProjectEnvironmentForCMake(IProject project) {
30 ICProjectDescription cpdesc = CoreModel.getDefault().getProjectDescription(project, true);
31 ICConfigurationDescription ccdesc = cpdesc.getActiveConfiguration();
32 IEnvironmentVariableManager manager = CCorePlugin.getDefault().getBuildEnvironmentManager();
33 IContributedEnvironment env = manager.getContributedEnvironment();
34 String delimiter = manager.getDefaultDelimiter();
35
36 env.addVariable("CCACHE", "", IEnvironmentVariable.ENVVAR_REPLACE, delimiter, ccdesc);
37
38 env.addVariable("OECMAKE_SOURCEPATH", "..",
39 IEnvironmentVariable.ENVVAR_REPLACE, delimiter, ccdesc);
40
41 String oecmakeBuildPathString = "";
42 env.addVariable("OECMAKE_BUILDPATH", oecmakeBuildPathString,
43 IEnvironmentVariable.ENVVAR_REPLACE, delimiter, ccdesc);
44 env.addVariable("EXTRA_OEMAKE", "-C " + oecmakeBuildPathString,
45 IEnvironmentVariable.ENVVAR_REPLACE, delimiter, ccdesc);
46
47 String ccString = YoctoSDKUtils.getEnvValue(project, "CC");
48
49 if (!ccString.equals("") && !ccString.equals(" ")) {
50 ccString.trim();
51 ccString = ccString.split(" ")[0];
52 }
53
54 env.addVariable("OECMAKE_C_COMPILER", ccString,
55 IEnvironmentVariable.ENVVAR_REPLACE, delimiter, ccdesc);
56 String cxxString = YoctoSDKUtils.getEnvValue(project, "CXX");
57
58 if (!cxxString.equals("") && !cxxString.equals(" ")) {
59 cxxString.trim();
60 cxxString = cxxString.split(" ")[0];
61 }
62
63 env.addVariable("OECMAKE_CXX_COMPILER", cxxString,
64 IEnvironmentVariable.ENVVAR_REPLACE, delimiter, ccdesc);
65
66 String hostCCArchString = YoctoSDKUtils.getEnvValue(project, "HOST_CC_ARCH");
67 String toolchainOptionsString = YoctoSDKUtils.getEnvValue(project, "TOOLCHAIN_OPTIONS");
68 String cppFlagsString = YoctoSDKUtils.getEnvValue(project, "CPPFLAGS");
69 String cxxFlagsString = YoctoSDKUtils.getEnvValue(project, "CXXFLAGS");
70 String selectedOptimizationString = YoctoSDKUtils.getEnvValue(project, "SELECTED_OPTIMIZATION");
71 env.addVariable("OECMAKE_C_FLAGS", hostCCArchString + " " + toolchainOptionsString + " " + cppFlagsString,
72 IEnvironmentVariable.ENVVAR_REPLACE, delimiter, ccdesc);
73 env.addVariable("OECMAKE_CXX_FLAGS", hostCCArchString + " " + toolchainOptionsString + " " + cxxFlagsString
74 + " -fpermissive",
75 IEnvironmentVariable.ENVVAR_REPLACE, delimiter, ccdesc);
76 env.addVariable("OECMAKE_C_FLAGS_RELEASE", selectedOptimizationString + " " + cppFlagsString + " -DNDEBUG",
77 IEnvironmentVariable.ENVVAR_REPLACE, delimiter, ccdesc);
78 env.addVariable("OECMAKE_CXX_FLAGS_RELEASE", selectedOptimizationString + " " + cxxFlagsString + " -DNDEBUG",
79 IEnvironmentVariable.ENVVAR_REPLACE, delimiter, ccdesc);
80
81 env.addVariable("OECMAKE_RPATH", "",
82 IEnvironmentVariable.ENVVAR_REPLACE, delimiter, ccdesc);
83 env.addVariable("OECMAKE_PERLNATIVE_DIR", "",
84 IEnvironmentVariable.ENVVAR_REPLACE, delimiter, ccdesc);
85
86 try {
87 CoreModel.getDefault().setProjectDescription(project, cpdesc);
88 } catch (CoreException e) {
89 e.printStackTrace();
90 }
91 }
92}
diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKEmptyProjectNature.java b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKEmptyProjectNature.java
new file mode 100644
index 0000000..e1b847a
--- /dev/null
+++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKEmptyProjectNature.java
@@ -0,0 +1,8 @@
1package org.yocto.sdk.ide.natures;
2
3import org.yocto.sdk.ide.YoctoSDKPlugin;
4
5public class YoctoSDKEmptyProjectNature extends YoctoSDKProjectNature {
6
7 public static final String YoctoSDK_EMPTY_NATURE_ID = YoctoSDKPlugin.getUniqueIdentifier() + ".YoctoSDKEmptyNature";
8}
diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKNatureUtils.java b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKNatureUtils.java
new file mode 100644
index 0000000..5a2a6b1
--- /dev/null
+++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKNatureUtils.java
@@ -0,0 +1,39 @@
1/*******************************************************************************
2 * Copyright (c) 2010 Intel Corporation.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * Intel - initial API and implementation
10 * BMW Car IT - extracted in an own class
11 *******************************************************************************/
12package org.yocto.sdk.ide.natures;
13
14import org.eclipse.core.resources.IProject;
15import org.eclipse.core.resources.IProjectDescription;
16import org.eclipse.core.runtime.CoreException;
17import org.eclipse.core.runtime.IProgressMonitor;
18
19public class YoctoSDKNatureUtils {
20
21 public static void addNature(IProject project, String natureId, IProgressMonitor monitor) throws CoreException
22 {
23 IProjectDescription description = project.getDescription();
24 String[] natures = description.getNatureIds();
25
26 for (int i = 0; i < natures.length; ++i) {
27 if (natureId.equals(natures[i]))
28 return;
29 }
30
31 String[] newNatures = new String[natures.length + 1];
32 System.arraycopy(natures, 0, newNatures, 0, natures.length);
33 newNatures[natures.length] = natureId;
34 description.setNatureIds(newNatures);
35 project.setDescription(description, monitor);
36
37 }
38
39}
diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKProjectNature.java b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKProjectNature.java
new file mode 100644
index 0000000..e3f6a35
--- /dev/null
+++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKProjectNature.java
@@ -0,0 +1,36 @@
1/*******************************************************************************
2 * Copyright (c) 2010 Intel Corporation.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * Intel - initial API and implementation
10 *******************************************************************************/
11package org.yocto.sdk.ide.natures;
12
13import org.eclipse.core.resources.IProject;
14import org.eclipse.core.resources.IProjectNature;
15import org.eclipse.core.runtime.CoreException;
16import org.yocto.sdk.ide.YoctoSDKPlugin;
17
18public class YoctoSDKProjectNature implements IProjectNature {
19 public static final String YoctoSDK_NATURE_ID = YoctoSDKPlugin.getUniqueIdentifier() + ".YoctoSDKNature";
20
21 private IProject proj;
22
23 public void configure() throws CoreException {
24 }
25
26 public void deconfigure() throws CoreException {
27 }
28
29 public IProject getProject() {
30 return proj;
31 }
32
33 public void setProject(IProject project) {
34 this.proj = project;
35 }
36}