summaryrefslogtreecommitdiffstats
path: root/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/utils/YoctoSDKUtils.java
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/utils/YoctoSDKUtils.java')
-rw-r--r--plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/utils/YoctoSDKUtils.java463
1 files changed, 463 insertions, 0 deletions
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
new file mode 100644
index 0000000..cd27a61
--- /dev/null
+++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/utils/YoctoSDKUtils.java
@@ -0,0 +1,463 @@
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 - add methods to use different preference stores
11 * Atanas Gegov (BMW Car IT) - add method to get the project environment
12 *******************************************************************************/
13package org.yocto.sdk.ide.utils;
14
15import java.io.BufferedReader;
16import java.io.File;
17import java.io.FileReader;
18import java.io.FileWriter;
19import java.io.IOException;
20import java.util.ArrayList;
21import java.util.HashMap;
22import java.util.HashSet;
23import java.util.Iterator;
24import java.util.Set;
25import java.util.StringTokenizer;
26
27import org.eclipse.cdt.core.CCorePlugin;
28import org.eclipse.cdt.core.envvar.IContributedEnvironment;
29import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
30import org.eclipse.cdt.core.envvar.IEnvironmentVariableManager;
31import org.eclipse.cdt.core.model.CoreModel;
32import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
33import org.eclipse.cdt.core.settings.model.ICProjectDescription;
34import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
35import org.eclipse.cdt.debug.mi.core.IMILaunchConfigurationConstants;
36import org.eclipse.core.resources.IProject;
37import org.eclipse.core.runtime.CoreException;
38import org.eclipse.debug.core.DebugPlugin;
39import org.eclipse.debug.core.ILaunchConfiguration;
40import org.eclipse.debug.core.ILaunchConfigurationType;
41import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
42import org.eclipse.debug.core.ILaunchManager;
43import org.eclipse.jface.preference.IPreferenceStore;
44import org.yocto.sdk.ide.YoctoGeneralException;
45import org.yocto.sdk.ide.YoctoProfileElement;
46import org.yocto.sdk.ide.YoctoSDKPlugin;
47import org.yocto.sdk.ide.YoctoUIElement;
48import org.yocto.sdk.ide.natures.YoctoSDKCMakeProjectNature;
49import org.yocto.sdk.ide.natures.YoctoSDKEmptyProjectNature;
50import org.yocto.sdk.ide.preferences.PreferenceConstants;
51
52public class YoctoSDKUtils {
53
54 private static final String DEFAULT_SYSROOT_PREFIX = "--sysroot=";
55 private static final String LIBTOOL_SYSROOT_PREFIX = "--with-libtool-sysroot=";
56
57 private static final String DEFAULT_USR_BIN = "/usr/bin/";
58 private static final String NATIVE_SYSROOT = "OECORE_NATIVE_SYSROOT";
59
60 public static String getEnvValue(IProject project, String strKey)
61 {
62 ICProjectDescription cpdesc = CoreModel.getDefault().getProjectDescription(project, true);
63 ICConfigurationDescription ccdesc = cpdesc.getActiveConfiguration();
64 IEnvironmentVariableManager manager = CCorePlugin.getDefault().getBuildEnvironmentManager();
65 IContributedEnvironment env = manager.getContributedEnvironment();
66 IEnvironmentVariable var = env.getVariable(strKey, ccdesc);
67
68 if (var == null)
69 {
70 System.out.printf("ENV key %s is NULL\n", strKey);
71 return "";
72 }
73
74 else
75 return var.getValue();
76 }
77
78 /* Save project wide settings into ENV VARs including POKY preference settings
79 * and Environment Script File export VARs
80 */
81 private static void setEnvVars(ICProjectDescription cpdesc,
82 YoctoUIElement elem, HashMap<String, String> envMap) {
83 ICConfigurationDescription ccdesc = cpdesc.getActiveConfiguration();
84 IEnvironmentVariableManager manager = CCorePlugin.getDefault().getBuildEnvironmentManager();
85 IContributedEnvironment env = manager.getContributedEnvironment();
86 String delimiter = manager.getDefaultDelimiter();
87
88 if (elem.getEnumPokyMode() == YoctoUIElement.PokyMode.POKY_SDK_MODE)
89 env.addVariable(PreferenceConstants.SDK_MODE, IPreferenceStore.TRUE,
90 IEnvironmentVariable.ENVVAR_REPLACE, delimiter, ccdesc);
91 else
92 env.addVariable(PreferenceConstants.SDK_MODE, IPreferenceStore.FALSE,
93 IEnvironmentVariable.ENVVAR_REPLACE, delimiter, ccdesc);
94
95 env.addVariable(PreferenceConstants.TOOLCHAIN_ROOT, elem.getStrToolChainRoot(),
96 IEnvironmentVariable.ENVVAR_REPLACE, delimiter, ccdesc);
97 env.addVariable(PreferenceConstants.TOOLCHAIN_TRIPLET, elem.getStrTarget(),
98 IEnvironmentVariable.ENVVAR_REPLACE, delimiter, ccdesc);
99 env.addVariable(PreferenceConstants.TARGET_ARCH_INDEX, String.valueOf(elem.getIntTargetIndex()),
100 IEnvironmentVariable.ENVVAR_REPLACE, delimiter, ccdesc);
101
102 if (elem.getEnumDeviceMode() == YoctoUIElement.DeviceMode.QEMU_MODE)
103 env.addVariable(PreferenceConstants.TARGET_MODE, IPreferenceStore.TRUE,
104 IEnvironmentVariable.ENVVAR_REPLACE, delimiter, ccdesc);
105 else
106 env.addVariable(PreferenceConstants.TARGET_MODE, IPreferenceStore.FALSE,
107 IEnvironmentVariable.ENVVAR_REPLACE, delimiter, ccdesc);
108
109 env.addVariable(PreferenceConstants.QEMU_KERNEL, elem.getStrQemuKernelLoc(),
110 IEnvironmentVariable.ENVVAR_REPLACE, delimiter, ccdesc);
111 env.addVariable(PreferenceConstants.QEMU_OPTION, elem.getStrQemuOption(),
112 IEnvironmentVariable.ENVVAR_REPLACE, delimiter, ccdesc);
113 env.addVariable(PreferenceConstants.SYSROOT, elem.getStrSysrootLoc(),
114 IEnvironmentVariable.ENVVAR_REPLACE, delimiter, ccdesc);
115
116 if (envMap == null)
117 {
118 System.out.println("ENV var hasmap is NULL, Please check ENV script File!");
119 return;
120 }
121 Iterator<String> iter = envMap.keySet().iterator();
122 while (iter.hasNext())
123 {
124 String sKey = (String)iter.next();
125 String sValue = (String)envMap.get(sKey);
126 String targetFilePath;
127 File targetFile;
128 //replace --sysroot
129 if (sKey.matches("CFLAGS") || sKey.matches("CXXFLAGS") || sKey.matches("CXXFLAGS") || sKey.matches("LDFLAGS") ||
130 sKey.matches("CPPFLAGS")) {
131
132 int SYSROOT_idx = sValue.lastIndexOf(DEFAULT_SYSROOT_PREFIX);
133 if (SYSROOT_idx >=0 )
134 sValue = sValue.substring(0, SYSROOT_idx) + DEFAULT_SYSROOT_PREFIX + elem.getStrSysrootLoc();
135 else
136 sValue = " " + DEFAULT_SYSROOT_PREFIX + elem.getStrSysrootLoc();
137 targetFilePath = elem.getStrSysrootLoc() + "/" + elem.getStrTarget();
138 targetFile = new File(targetFilePath);
139 if (targetFile.exists())
140 sValue = sValue + "/" + elem.getStrTarget();
141 } else if (sKey.matches("CONFIGURE_FLAGS")) {
142 int LIBTOOL_idx = sValue.lastIndexOf(LIBTOOL_SYSROOT_PREFIX);
143 if (LIBTOOL_idx >= 0)
144 sValue = sValue.substring(0, LIBTOOL_idx) + LIBTOOL_SYSROOT_PREFIX + elem.getStrSysrootLoc();
145 else
146 sValue = " " + LIBTOOL_SYSROOT_PREFIX + elem.getStrSysrootLoc();
147 targetFilePath = elem.getStrSysrootLoc() + "/" + elem.getStrTarget();
148 targetFile = new File(targetFilePath);
149 if (targetFile.exists())
150 sValue = sValue + "/" + elem.getStrTarget();
151 } else if(sKey.matches("PKG_CONFIG_SYSROOT_DIR") || sKey.matches("OECORE_TARGET_SYSROOT")) {
152 sValue = elem.getStrSysrootLoc();
153 targetFilePath = elem.getStrSysrootLoc() + "/" + elem.getStrTarget();
154 targetFile = new File(targetFilePath);
155 if (targetFile.exists())
156 sValue = sValue + "/" + elem.getStrTarget();
157 } else if (sKey.matches("PKG_CONFIG_PATH")) {
158 sValue = elem.getStrSysrootLoc();
159 targetFilePath = elem.getStrSysrootLoc() + "/" + elem.getStrTarget();
160 targetFile = new File(targetFilePath);
161 if (targetFile.exists())
162 sValue = sValue + "/" + elem.getStrTarget();
163 sValue = sValue + "/usr/lib/pkgconfig";
164 }
165 // env.addVariable(sKey, elem.getStrSysrootLoc(), IEnvironmentVariable.ENVVAR_REPLACE, delimiter, ccdesc);
166 /*
167 else if (sKey.matches("PKG_CONFIG_PATH"))
168 env.addVariable(sKey, elem.getStrSysrootLoc()+"/"+elem.getStrTarget()+"/usr/lib/pkgconfig", IEnvironmentVariable.ENVVAR_REPLACE, delimiter, ccdesc);
169 //env.addVariable(sKey, sValue, IEnvironmentVariable.ENVVAR_REPLACE, delimiter, ccdesc);
170 else if (sKey.matches("PKG_CONFIG_SYSROOT_DIR"))
171 env.addVariable(sKey, elem.getStrSysrootLoc()+"/"+elem.getStrTarget(), IEnvironmentVariable.ENVVAR_REPLACE, delimiter, ccdesc);
172 */
173 env.addVariable(sKey, sValue, IEnvironmentVariable.ENVVAR_REPLACE, delimiter, ccdesc);
174 }
175 //add ACLOCAL OPTS for libtool 2.4 support
176 env.addVariable("OECORE_ACLOCAL_OPTS",
177 "-I " + env.getVariable(NATIVE_SYSROOT, ccdesc).getValue() + "/usr/share/aclocal",
178 IEnvironmentVariable.ENVVAR_REPLACE,
179 delimiter,
180 ccdesc);
181 return;
182
183 }
184
185 private static String getEnvironmentSetupFileFullPath(YoctoUIElement elem) {
186 String envSetupFile = "";
187
188 if (elem.getEnumPokyMode() == YoctoUIElement.PokyMode.POKY_SDK_MODE) {
189 envSetupFile = elem.getStrToolChainRoot() + "/";
190 } else {
191 //POKY TREE Mode
192 envSetupFile = elem.getStrToolChainRoot() + YoctoSDKUtilsConstants.DEFAULT_TMP_PREFIX;
193 }
194 envSetupFile += YoctoSDKUtilsConstants.DEFAULT_ENV_FILE_PREFIX + elem.getStrTarget();
195 return envSetupFile;
196 }
197
198 private static HashMap<String, String> parseEnvScript(String sFileName) {
199 try {
200 HashMap<String, String> envMap = new HashMap<String, String>();
201 File file = new File(sFileName);
202
203 if (file.exists()) {
204 BufferedReader input = new BufferedReader(new FileReader(file));
205
206 try {
207 String line = null;
208
209 while ((line = input.readLine()) != null) {
210 if (!line.startsWith("export")) {
211 continue;
212 }
213 String sKey = line.substring("export".length() + 1, line.indexOf('='));
214 String sValue = line.substring(line.indexOf('=') + 1);
215 if (sValue.startsWith("\"") && sValue.endsWith("\""))
216 sValue = sValue.substring(sValue.indexOf('"') + 1, sValue.lastIndexOf('"'));
217 /* If PATH ending with $PATH, we need to join with current system path */
218 if (sKey.equalsIgnoreCase("PATH")) {
219 if (sValue.lastIndexOf("$PATH") >= 0)
220 sValue = sValue.substring(0, sValue.lastIndexOf("$PATH")) + System.getenv("PATH");
221 }
222 envMap.put(sKey, sValue);
223 System.out.printf("get env key %s value %s\n", sKey, sValue);
224 }
225 } finally {
226 input.close();
227 }
228 }
229
230 return envMap;
231
232 } catch (IOException e) {
233 e.printStackTrace();
234 return null;
235 }
236 }
237
238 public static void setEnvironmentVariables(IProject project, YoctoUIElement elem) {
239 ICProjectDescription cpdesc = CoreModel.getDefault().getProjectDescription(project, true);
240
241 String sFileName = getEnvironmentSetupFileFullPath(elem);
242 HashMap<String, String> envMap = parseEnvScript(sFileName);
243
244 setEnvVars(cpdesc, elem, envMap);
245 try {
246 CoreModel.getDefault().setProjectDescription(project,cpdesc);
247 } catch (CoreException e) {
248 e.printStackTrace();
249 }
250 }
251
252 public static void createRemoteDebugAndQemuLaunchers(IProject project, YoctoUIElement elem) throws YoctoGeneralException {
253 ILaunchManager lManager = DebugPlugin.getDefault().getLaunchManager();
254 ILaunchConfigurationType configType =
255 lManager.getLaunchConfigurationType("org.eclipse.ui.externaltools.ProgramLaunchConfigurationType");
256 ILaunchConfigurationType debug_configType =
257 lManager.getLaunchConfigurationType("org.eclipse.cdt.launch.remoteApplicationLaunchType");
258
259 String sPath = getEnvValue(project, "PATH");
260 String sDebugName = getEnvValue(project, "GDB");
261 String sysroot_str = elem.getStrSysrootLoc();
262 String target_prefix_str = getEnvValue(project,"TARGET_PREFIX");
263 String target_str = target_prefix_str.substring(0, target_prefix_str.length() - 1);
264
265 if (configType == null || debug_configType == null) {
266 throw new YoctoGeneralException("Failed to get program or remote debug launcher!");
267 }
268
269 createRemoteDebugLauncher(project, lManager, debug_configType, target_str, sPath, sDebugName, sysroot_str);
270 ArrayList<String> listValue = new ArrayList<String>();
271 listValue.add(new String("org.eclipse.ui.externaltools.launchGroup"));
272
273 if (elem.getEnumDeviceMode() == YoctoUIElement.DeviceMode.QEMU_MODE) {
274 String sFileName = getEnvironmentSetupFileFullPath(elem);
275 createQemuLauncher(project, configType, listValue, sFileName, elem);
276 }
277 }
278
279 protected static void createRemoteDebugLauncher(IProject project,
280 ILaunchManager lManager, ILaunchConfigurationType configType,
281 String sTargetTriplet, String strPath, String sDebugName, String sSysroot) {
282 try {
283
284 String sDebugSubDir = DEFAULT_USR_BIN + sTargetTriplet;
285 StringTokenizer token = new StringTokenizer(strPath, ":");
286 String strDebugger = "";
287 while (token.hasMoreTokens())
288 {
289 String sTemp = token.nextToken();
290 if (sTemp.endsWith(sDebugSubDir)) {
291 strDebugger = sTemp + "/" + sDebugName;
292 break;
293 }
294 }
295 if (strDebugger.isEmpty())
296 return;
297 //If get default Debugger successfully, go ahead!
298
299 //create the gdbinit file
300 String sDebugInitFile = project.getLocation().toString() + "/.gdbinit";
301 FileWriter out = new FileWriter(new File(sDebugInitFile));
302 out.write("set sysroot " + sSysroot);
303 out.flush();
304 out.close();
305
306 //set the launch configuration
307 String projectName = project.getName();
308 String configName = projectName+"_gdb_"+sTargetTriplet;
309 int i;
310 ILaunchConfiguration[] configs=lManager.getLaunchConfigurations(configType);
311 for(i=0; i<configs.length; i++)
312 { //delete the old configuration
313 ILaunchConfiguration config=configs[i];
314 if(config.getName().equals(configName)) {
315 config.delete();
316 break;
317 }
318 }
319 ILaunchConfigurationWorkingCopy w_copy = configType.newInstance(project, configName);
320 Set<String> modes=new HashSet<String>();
321 modes.add("debug");
322 w_copy.setPreferredLaunchDelegate(modes, "org.eclipse.rse.remotecdt.launch");
323 w_copy.setAttribute(IMILaunchConfigurationConstants.ATTR_GDB_INIT, sDebugInitFile);
324 w_copy.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_AUTO_SOLIB, false);
325 w_copy.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUG_NAME, strDebugger);
326 w_copy.setAttribute(IMILaunchConfigurationConstants.ATTR_DEBUGGER_PROTOCOL, "mi");
327 //TWEAK avoid loading default values in org.eclipse.cdt.launch.remote.tabs.RemoteCDebuggerTab
328 w_copy.setAttribute("org.eclipse.cdt.launch.remote.RemoteCDSFDebuggerTab.DEFAULTS_SET",true);
329 w_copy.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, projectName);
330 if (!project.hasNature(YoctoSDKEmptyProjectNature.YoctoSDK_EMPTY_NATURE_ID)) {
331 String pathToCompiledBinary = "";
332 if (project.hasNature(YoctoSDKCMakeProjectNature.YoctoSDK_CMAKE_NATURE_ID)) {
333 pathToCompiledBinary = "Debug/";
334 } else {
335 pathToCompiledBinary = "src/";
336 }
337 pathToCompiledBinary += projectName;
338 w_copy.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, pathToCompiledBinary);
339 }
340
341 w_copy.doSave();
342 }
343 catch (CoreException e)
344 {
345 System.out.println(e.getMessage());
346 }
347 catch (IOException e)
348 {
349 System.out.println("Failed to generate debug init file!");
350 System.out.println(e.getMessage());
351 }
352 }
353
354 protected static void createQemuLauncher(IProject project,
355 ILaunchConfigurationType configType,
356 ArrayList<String> listValue, String sScriptFile,
357 YoctoUIElement elem) {
358 try {
359
360 ILaunchConfigurationWorkingCopy w_copy = configType.newInstance(null, "qemu_"+elem.getStrTarget());
361
362 w_copy.setAttribute("org.eclipse.debug.ui.favoriteGroups", listValue);
363 w_copy.setAttribute("org.eclipse.ui.externaltools.ATTR_LOCATION", "/usr/bin/xterm");
364
365 String argument = "-e \"source " + sScriptFile + ";runqemu " + qemuTargetTranslate(elem.getStrTarget()) + " " +
366 elem.getStrQemuKernelLoc() + " " + elem.getStrSysrootLoc() + " " + elem.getStrQemuOption() + ";bash\"";
367
368 w_copy.setAttribute("org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS", argument);
369 w_copy.doSave();
370 } catch (CoreException e) {
371 }
372
373 }
374
375 private static String qemuTargetTranslate(String strTargetArch) {
376 String qemu_target = "";
377 if (strTargetArch.indexOf("i586") != -1) {
378 qemu_target = "qemux86";
379 } else if (strTargetArch.indexOf("x86_64") != -1) {
380 qemu_target = "qemux86-64";
381 } else if (strTargetArch.indexOf("arm") != -1) {
382 qemu_target = "qemuarm";
383 } else if (strTargetArch.indexOf("mips") != -1) {
384 qemu_target = "qemumips";
385 } else if (strTargetArch.indexOf("ppc") != -1) {
386 qemu_target = "qemuppc";
387 }
388 return qemu_target;
389 }
390
391 /* Get IDE wide POKY Preference settings from a specific preference store */
392 public static YoctoUIElement getElemFromStore(IPreferenceStore store) {
393 YoctoUIElement elem = new YoctoUIElement();
394 if (store.getString(PreferenceConstants.SDK_MODE).equals(IPreferenceStore.TRUE))
395 elem.setEnumPokyMode(YoctoUIElement.PokyMode.POKY_SDK_MODE);
396 else
397 elem.setEnumPokyMode(YoctoUIElement.PokyMode.POKY_TREE_MODE);
398
399 elem.setStrToolChainRoot(store.getString(PreferenceConstants.TOOLCHAIN_ROOT));
400 elem.setStrTarget(store.getString(PreferenceConstants.TOOLCHAIN_TRIPLET));
401 elem.setIntTargetIndex(store.getInt(PreferenceConstants.TARGET_ARCH_INDEX));
402 elem.setStrQemuKernelLoc(store.getString(PreferenceConstants.QEMU_KERNEL));
403 elem.setStrQemuOption(store.getString(PreferenceConstants.QEMU_OPTION));
404 elem.setStrSysrootLoc(store.getString(PreferenceConstants.SYSROOT));
405
406 if (store.getString(PreferenceConstants.TARGET_MODE).equals(IPreferenceStore.TRUE))
407 elem.setEnumDeviceMode(YoctoUIElement.DeviceMode.QEMU_MODE);
408 else
409 elem.setEnumDeviceMode(YoctoUIElement.DeviceMode.DEVICE_MODE);
410
411 return elem;
412 }
413
414 /* Get default POKY Preference settings from the default preference store */
415 public static YoctoUIElement getDefaultElemFromDefaultStore()
416 {
417 IPreferenceStore store = YoctoSDKPlugin.getDefault().getPreferenceStore();
418 YoctoUIElement elem = new YoctoUIElement();
419 if (store.getDefaultString(PreferenceConstants.SDK_MODE).equals(IPreferenceStore.TRUE))
420 elem.setEnumPokyMode(YoctoUIElement.PokyMode.POKY_SDK_MODE);
421 else
422 elem.setEnumPokyMode(YoctoUIElement.PokyMode.POKY_TREE_MODE);
423
424 elem.setStrToolChainRoot(store.getDefaultString(PreferenceConstants.TOOLCHAIN_ROOT));
425 elem.setStrTarget(store.getDefaultString(PreferenceConstants.TOOLCHAIN_TRIPLET));
426 elem.setIntTargetIndex(store.getDefaultInt(PreferenceConstants.TARGET_ARCH_INDEX));
427 elem.setStrQemuKernelLoc(store.getDefaultString(PreferenceConstants.QEMU_KERNEL));
428 elem.setStrQemuOption(store.getDefaultString(PreferenceConstants.QEMU_OPTION));
429 elem.setStrSysrootLoc(store.getDefaultString(PreferenceConstants.SYSROOT));
430
431 if (store.getDefaultString(PreferenceConstants.TARGET_MODE).equals(IPreferenceStore.TRUE))
432 elem.setEnumDeviceMode(YoctoUIElement.DeviceMode.QEMU_MODE);
433 else
434 elem.setEnumDeviceMode(YoctoUIElement.DeviceMode.DEVICE_MODE);
435
436 return elem;
437 }
438
439 /* Save profiles and selected profile to the default preference store */
440 public static void saveProfilesToDefaultStore(YoctoProfileElement profileElement) {
441 saveProfilesToStore(profileElement, YoctoSDKPlugin.getDefault().getPreferenceStore());
442 }
443
444 /* Save profiles and selected profile to a specific preference store */
445 private static void saveProfilesToStore(YoctoProfileElement profileElement, IPreferenceStore store) {
446 store.setValue(PreferenceConstants.PROFILES, profileElement.getProfilesAsString());
447 store.setValue(PreferenceConstants.SELECTED_PROFILE, profileElement.getSelectedProfile());
448 }
449
450 /* Get profiles and selected profile from the default preference store */
451 public static YoctoProfileElement getProfilesFromDefaultStore()
452 {
453 return getProfilesFromStore(YoctoSDKPlugin.getDefault().getPreferenceStore());
454 }
455
456 /* Get profiles and selected profile from a specific preference store */
457 private static YoctoProfileElement getProfilesFromStore(IPreferenceStore store) {
458 String profiles = store.getString(PreferenceConstants.PROFILES);
459 String selectedProfile = store.getString(PreferenceConstants.SELECTED_PROFILE);
460
461 return new YoctoProfileElement(profiles, selectedProfile);
462 }
463}