[yocto] [PATCH 03/13] plugins/sdk.ide: Added a method to get project environment

Atanas Gegov atanas.gegov.oss at gmail.com
Thu May 23 01:39:42 PDT 2013


From: Atanas Gegov <atanas.gegov at bmw-carit.de>

This methods creates a key-value map from the
project environment. It can be used to provide
this environment to new processes.
---
 .../src/org/yocto/sdk/ide/utils/YoctoSDKUtils.java |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/utils/YoctoSDKUtils.java b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/utils/YoctoSDKUtils.java
index f27fad7..669157b 100644
--- a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/utils/YoctoSDKUtils.java
+++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/utils/YoctoSDKUtils.java
@@ -8,6 +8,7 @@
  * Contributors:
  * Intel - initial API and implementation
  * BMW Car IT - add methods to use different preference stores
+ * Atanas Gegov (BMW Car IT) - add method to get the project environment
  *******************************************************************************/
 package org.yocto.sdk.ide.utils;
 
@@ -87,6 +88,21 @@ public class YoctoSDKUtils {
 			return var.getValue();
 	}
 
+	public static Map<String,String> getEnvVariablesAsMap (IProject project) {
+		Map<String, String> result = new HashMap<String, String>();
+
+		ICProjectDescription cpdesc = CoreModel.getDefault().getProjectDescription(project, true);
+		ICConfigurationDescription ccdesc = cpdesc.getActiveConfiguration();
+		IEnvironmentVariableManager manager = CCorePlugin.getDefault().getBuildEnvironmentManager();
+		IContributedEnvironment env = manager.getContributedEnvironment();
+
+		for(IEnvironmentVariable var : env.getVariables(ccdesc)) {
+			result.put(var.getName(), var.getValue());
+		}
+
+		return result;
+	}
+
 	/* Save project wide settings into ENV VARs including POKY preference settings
 	 * and Environment Script File export VARs
 	 */
-- 
1.7.9.5




More information about the yocto mailing list