diff options
author | Adrian Dudau <adrian.dudau@enea.com> | 2014-06-26 13:23:09 +0200 |
---|---|---|
committer | Adrian Dudau <adrian.dudau@enea.com> | 2014-06-26 13:24:09 +0200 |
commit | c7da892cb23d50d4d85746c9a0b6b14bf570989d (patch) | |
tree | e7136073f386d6156f51766c498c52c30c8df85f /plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKCMakeProjectNature.java | |
download | eclipse-poky-kepler-c7da892cb23d50d4d85746c9a0b6b14bf570989d.tar.gz |
initial commit for Enea Linux 4.0daisy
Migrated from the internal git server on the daisy-enea branch
Signed-off-by: Adrian Dudau <adrian.dudau@enea.com>
Diffstat (limited to 'plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKCMakeProjectNature.java')
-rw-r--r-- | plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKCMakeProjectNature.java | 92 |
1 files changed, 92 insertions, 0 deletions
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 | *******************************************************************************/ | ||
11 | package org.yocto.sdk.ide.natures; | ||
12 | |||
13 | import org.eclipse.cdt.core.CCorePlugin; | ||
14 | import org.eclipse.cdt.core.envvar.IContributedEnvironment; | ||
15 | import org.eclipse.cdt.core.envvar.IEnvironmentVariable; | ||
16 | import org.eclipse.cdt.core.envvar.IEnvironmentVariableManager; | ||
17 | import org.eclipse.cdt.core.model.CoreModel; | ||
18 | import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; | ||
19 | import org.eclipse.cdt.core.settings.model.ICProjectDescription; | ||
20 | import org.eclipse.core.resources.IProject; | ||
21 | import org.eclipse.core.runtime.CoreException; | ||
22 | import org.yocto.sdk.ide.YoctoSDKPlugin; | ||
23 | import org.yocto.sdk.ide.utils.YoctoSDKUtils; | ||
24 | |||
25 | public 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 | } | ||