Fixed bug in creating remote debug launcher
cover Fixed bug in creating remote debug launcher
From: Atanas Gegov <[email protected]>
Hi,
this patch series fixes a bug where the remote debug launcher is not correctly created because not all Yocto natures are added to the project at the point where the method is being called. The path to the binary was in some cases (by new CMake project) not correctly set.
This fix required some code refactoring. Some further refactoring was also done in order to reduce the complexity of the very large YoctoSDKUtils class.
Cheers,
Atanas
P.S: This patch series apply on the current master "Add remote.utils plugin to sdk features" (ff4ccb4d65243f2a28eb89c72e9b425702b6c3aa).
Atanas Gegov (7):
plugins/sdk.ide: Extracted a private method plugins/sdk.ide: Extracted launchers creation plugins/sdk.ide: Decoupled launcher creation from environment setting plugins/sdk.ide: Moved a locally used method plugins/sdk.ide: Changed access level modifiers for some methods plugins/sdk.ide: Removed unused methods
plugins/sdk.ide: Moved more locally used methods
.../managedbuilder/job/ExecuteConfigureJob.java | 29 +- .../src/org/yocto/sdk/ide/YoctoSDKChecker.java | 26 +- .../natures/YoctoSDKAutotoolsProjectNature.java | 21 +- .../ide/preferences/YoctoSDKPreferencePage.java | 25 +- .../preferences/YoctoSDKProjectPropertyPage.java | 119 +++++- .../src/org/yocto/sdk/ide/utils/YoctoSDKUtils.java | 388 +++++--------------- .../sdk/ide/utils/YoctoSDKUtilsConstants.java | 2 +- .../ide/wizard/NewYoctoProjectTemplateProcess.java | 2 + 8 files changed, 306 insertions(+), 306 deletions(-)
Signature · 1 line
1.7.9.5
PATCH 1/7 plugins/sdk.ide: Extracted a private method
From: Atanas Gegov <[email protected]>
Extracted a method that gets the full path of the
environment-setup-* file.
--- .../src/org/yocto/sdk/ide/utils/YoctoSDKUtils.java | 22 ++++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-)
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/utils/YoctoSDKUtils.java +13 -9
@@ -210,21 +210,25 @@ public class YoctoSDKUtils { } - public static void setEnvironmentVariables(IProject project, YoctoUIElement elem) throws YoctoGeneralException{ - String sFileName; - ICProjectDescription cpdesc = CoreModel.getDefault().getProjectDescription(project, true); - + private static String getEnvironmentSetupFileFullPath(YoctoUIElement elem) { + String envSetupFile = ""; if (elem.getEnumPokyMode() == YoctoUIElement.PokyMode.POKY_SDK_MODE) { - sFileName = elem.getStrToolChainRoot()+"/" + YoctoSDKUtilsConstants.DEFAULT_ENV_FILE_PREFIX + elem.getStrTarget(); - } - else { + envSetupFile = elem.getStrToolChainRoot() + "/"; + } else { //POKY TREE Mode - sFileName = elem.getStrToolChainRoot() + YoctoSDKUtilsConstants.DEFAULT_TMP_PREFIX + - YoctoSDKUtilsConstants.DEFAULT_ENV_FILE_PREFIX + elem.getStrTarget(); + envSetupFile = elem.getStrToolChainRoot() + YoctoSDKUtilsConstants.DEFAULT_TMP_PREFIX; } + envSetupFile += YoctoSDKUtilsConstants.DEFAULT_ENV_FILE_PREFIX + elem.getStrTarget(); + return envSetupFile; + } + + public static void setEnvironmentVariables(IProject project, YoctoUIElement elem) throws YoctoGeneralException { + ICProjectDescription cpdesc = CoreModel.getDefault().getProjectDescription(project, true); + String sFileName = getEnvironmentSetupFileFullPath(elem); HashMap<String, String> envMap = parseEnvScript(sFileName); + setEnvVars(cpdesc, elem, envMap); try {
Signature · 1 line
1.7.9.5
PATCH 2/7 plugins/sdk.ide: Extracted launchers creation
In reply to Atanas GegovFrom: Atanas Gegov <[email protected]>
The creation of the RemoteDebug launcher and the Qemu launcher is extracted in an own method. The creation of both launchers should be decoupled from the setting of the project environment. This is done in the next patch.
--- .../src/org/yocto/sdk/ide/utils/YoctoSDKUtils.java | 44 ++++++++++++-------- 1 file changed, 26 insertions(+), 18 deletions(-)
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/utils/YoctoSDKUtils.java +26 -18
@@ -231,30 +231,38 @@ public class YoctoSDKUtils { setEnvVars(cpdesc, elem, envMap); + createRemoteDebugAndQemuLaunchers(project, elem); try { - ILaunchManager lManager = DebugPlugin.getDefault().getLaunchManager(); - ILaunchConfigurationType configType = - lManager.getLaunchConfigurationType("org.eclipse.ui.externaltools.ProgramLaunchConfigurationType"); - ILaunchConfigurationType debug_configType = - lManager.getLaunchConfigurationType("org.eclipse.cdt.launch.remoteApplicationLaunchType"); - - String sPath = envMap.get("PATH"); - String sDebugName = envMap.get("GDB"); - String sysroot_str = elem.getStrSysrootLoc(); - if (configType == null || debug_configType == null) - throw new YoctoGeneralException("Failed to get program or remote debug launcher!"); - createRemoteDebugLauncher(project, lManager, debug_configType, elem.getStrTarget(), sPath, sDebugName, sysroot_str); - - ArrayList<String> listValue = new ArrayList<String>(); - listValue.add(new String("org.eclipse.ui.externaltools.launchGroup")); - if (elem.getEnumDeviceMode() == YoctoUIElement.DeviceMode.QEMU_MODE) { - createQemuLauncher(project, configType, listValue, sFileName, elem); - } CoreModel.getDefault().setProjectDescription(project,cpdesc); } catch (CoreException e) { e.printStackTrace(); } } + + public static void createRemoteDebugAndQemuLaunchers(IProject project, YoctoUIElement elem) throws YoctoGeneralException { + ILaunchManager lManager = DebugPlugin.getDefault().getLaunchManager(); + ILaunchConfigurationType configType = + lManager.getLaunchConfigurationType("org.eclipse.ui.externaltools.ProgramLaunchConfigurationType"); + ILaunchConfigurationType debug_configType = + lManager.getLaunchConfigurationType("org.eclipse.cdt.launch.remoteApplicationLaunchType"); + + String sPath = getEnvValue(project, "PATH"); + String sDebugName = getEnvValue(project, "GDB"); + String sysroot_str = elem.getStrSysrootLoc(); + + if (configType == null || debug_configType == null) { + throw new YoctoGeneralException("Failed to get program or remote debug launcher!"); + } + createRemoteDebugLauncher(project, lManager, debug_configType, elem.getStrTarget(), sPath, sDebugName, sysroot_str); + + ArrayList<String> listValue = new ArrayList<String>(); + listValue.add(new String("org.eclipse.ui.externaltools.launchGroup")); + + if (elem.getEnumDeviceMode() == YoctoUIElement.DeviceMode.QEMU_MODE) { + String sFileName = getEnvironmentSetupFileFullPath(elem); + createQemuLauncher(project, configType, listValue, sFileName, elem); + } + } protected static void createRemoteDebugLauncher(IProject project, ILaunchManager lManager, ILaunchConfigurationType configType,
Signature · 1 line
1.7.9.5
PATCH 3/7 plugins/sdk.ide: Decoupled launcher creation from environment setting
In reply to Atanas GegovFrom: Atanas Gegov <[email protected]>
The creation of the remote debug and qemu launchers is now decoupled from the method setEnvironmentVariables(...). This also fixes a bug where the remote debug launcher is not correctly created because at the time of the call not all relevant Yocto natures are added to the project.
--- .../src/org/yocto/sdk/ide/utils/YoctoSDKUtils.java | 5 ++--- .../ide/wizard/NewYoctoProjectTemplateProcess.java | 2 ++ 2 files changed, 4 insertions(+), 3 deletions(-)
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/utils/YoctoSDKUtils.java +2 -3
@@ -223,15 +223,13 @@ public class YoctoSDKUtils { return envSetupFile; } - public static void setEnvironmentVariables(IProject project, YoctoUIElement elem) throws YoctoGeneralException { + public static void setEnvironmentVariables(IProject project, YoctoUIElement elem) { ICProjectDescription cpdesc = CoreModel.getDefault().getProjectDescription(project, true); String sFileName = getEnvironmentSetupFileFullPath(elem); HashMap<String, String> envMap = parseEnvScript(sFileName); setEnvVars(cpdesc, elem, envMap); - - createRemoteDebugAndQemuLaunchers(project, elem); try { CoreModel.getDefault().setProjectDescription(project,cpdesc); } catch (CoreException e) {
@@ -461,6 +459,7 @@ public class YoctoSDKUtils { try { setEnvironmentVariables(project, elem); + createRemoteDebugAndQemuLaunchers(project, elem); if (project.hasNature(YoctoSDKAutotoolsProjectNature.YoctoSDK_AUTOTOOLS_NATURE_ID)) { YoctoSDKAutotoolsProjectNature.configureAutotoolsOptions(project);
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/wizard/NewYoctoProjectTemplateProcess.java +2 -0
@@ -232,6 +232,8 @@ public class NewYoctoProjectTemplateProcess extends ProcessRunner { YoctoSDKNatureUtils.addNature(project, YoctoSDKCMakeProjectNature.YoctoSDK_CMAKE_NATURE_ID, monitor); YoctoSDKCMakeProjectNature.extendProjectEnvironmentForCMake(project); } + + YoctoSDKUtils.createRemoteDebugAndQemuLaunchers(project, elem); } protected final void turnOffAutoBuild(IWorkspace workspace) throws CoreException {
Signature · 1 line
1.7.9.5
PATCH 4/7 plugins/sdk.ide: Moved a locally used method
In reply to Atanas GegovFrom: Atanas Gegov <[email protected]>
The method splitString(...) is used only locally.
Removed from the YoctoSDKUtils in order to
simplify the overpopulated YoctoSDKUtils
class.
--- .../natures/YoctoSDKAutotoolsProjectNature.java | 21 +++++++++++++++++--- .../src/org/yocto/sdk/ide/utils/YoctoSDKUtils.java | 12 ----------- 2 files changed, 18 insertions(+), 15 deletions(-)
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKAutotoolsProjectNature.java +18 -3
@@ -51,13 +51,28 @@ public class YoctoSDKAutotoolsProjectNature extends YoctoSDKProjectNature { String strConfigure = YoctoSDKUtils.getEnvValue(project, "CONFIGURE_FLAGS"); cfg.setOption(DEFAULT_CONFIGURE_STR, configure_setting); - cfg.setOption(DEFAULT_BUILD_STR, YoctoSDKUtils.splitString(strConfigure, "--build=")); - cfg.setOption(DEFAULT_HOST_STR, YoctoSDKUtils.splitString(strConfigure, "--host=")); - cfg.setOption(DEFAULT_TARGET_STR, YoctoSDKUtils.splitString(strConfigure, "--target=")); + cfg.setOption(DEFAULT_BUILD_STR, splitString(strConfigure, "--build=")); + cfg.setOption(DEFAULT_HOST_STR, splitString(strConfigure, "--host=")); + cfg.setOption(DEFAULT_TARGET_STR, splitString(strConfigure, "--target=")); cfg.setOption(DEFAULT_AUTOGEN_STR, autogen_setting); cfg.setOption(DEFAULT_AUTOGEN_OPT_STR, strConfigure); AutotoolsConfigurationManager.getInstance().addConfiguration(project, cfg); AutotoolsConfigurationManager.getInstance().saveConfigs(project); } + + private static String splitString(String strValue, String strDelim) { + int iBeginIndex = strValue.indexOf(strDelim); + + if (iBeginIndex < 0) { + return ""; + } + int iEndIndex = strValue.indexOf(' ', iBeginIndex + 1); + + if (iEndIndex < 0) { + return strValue.substring(iBeginIndex + strDelim.length()); + } else { + return strValue.substring(iBeginIndex + strDelim.length(), iEndIndex); + } + } }
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/utils/YoctoSDKUtils.java +0 -12
@@ -592,18 +592,6 @@ public class YoctoSDKUtils { qemu_target = "qemuppc"; return qemu_target; } - public static String splitString(String strValue, String strDelim) - { - int iBeginIndex = strValue.indexOf(strDelim); - if (iBeginIndex < 0) - return ""; - int iEndIndex = strValue.indexOf(' ', iBeginIndex + 1); - - if (iEndIndex < 0) - return strValue.substring(iBeginIndex + strDelim.length()); - else - return strValue.substring(iBeginIndex + strDelim.length(), iEndIndex); - } public static HashMap<String, String> parseEnvScript(String sFileName) {
Signature · 1 line
1.7.9.5
PATCH 5/7 plugins/sdk.ide: Changed access level modifiers for some methods
In reply to Atanas GegovFrom: Atanas Gegov <[email protected]>
Declared some methods, that are only privately
used, as private. This simplifies the public API
of the YoctoSDKUtils class.
--- .../src/org/yocto/sdk/ide/utils/YoctoSDKUtils.java | 132 +++++++++----------- 1 file changed, 61 insertions(+), 71 deletions(-)
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/utils/YoctoSDKUtils.java +61 -71
@@ -106,7 +106,7 @@ public class YoctoSDKUtils { /* Save project wide settings into ENV VARs including POKY preference settings * and Environment Script File export VARs */ - public static void setEnvVars(ICProjectDescription cpdesc, + private static void setEnvVars(ICProjectDescription cpdesc, YoctoUIElement elem, HashMap<String, String> envMap) { ICConfigurationDescription ccdesc = cpdesc.getActiveConfiguration(); IEnvironmentVariableManager manager = CCorePlugin.getDefault().getBuildEnvironmentManager();
@@ -223,6 +223,46 @@ public class YoctoSDKUtils { return envSetupFile; } + private static HashMap<String, String> parseEnvScript(String sFileName) { + try { + HashMap<String, String> envMap = new HashMap<String, String>(); + File file = new File(sFileName); + + if (file.exists()) { + BufferedReader input = new BufferedReader(new FileReader(file)); + + try { + String line = null; + + while ((line = input.readLine()) != null) { + if (!line.startsWith("export")) { + continue; + } + String sKey = line.substring("export".length() + 1, line.indexOf('=')); + String sValue = line.substring(line.indexOf('=') + 1); + if (sValue.startsWith("\"") && sValue.endsWith("\"")) + sValue = sValue.substring(sValue.indexOf('"') + 1, sValue.lastIndexOf('"')); + /* If PATH ending with $PATH, we need to join with current system path */ + if (sKey.equalsIgnoreCase("PATH")) { + if (sValue.lastIndexOf("$PATH") >= 0) + sValue = sValue.substring(0, sValue.lastIndexOf("$PATH")) + System.getenv("PATH"); + } + envMap.put(sKey, sValue); + System.out.printf("get env key %s value %s\n", sKey, sValue); + } + } finally { + input.close(); + } + } + + return envMap; + + } catch (IOException e) { + e.printStackTrace(); + return null; + } + } + public static void setEnvironmentVariables(IProject project, YoctoUIElement elem) { ICProjectDescription cpdesc = CoreModel.getDefault().getProjectDescription(project, true);
@@ -236,7 +276,7 @@ public class YoctoSDKUtils { e.printStackTrace(); } } - + public static void createRemoteDebugAndQemuLaunchers(IProject project, YoctoUIElement elem) throws YoctoGeneralException { ILaunchManager lManager = DebugPlugin.getDefault().getLaunchManager(); ILaunchConfigurationType configType =
@@ -348,7 +388,7 @@ public class YoctoSDKUtils { w_copy.setAttribute("org.eclipse.debug.ui.favoriteGroups", listValue); w_copy.setAttribute("org.eclipse.ui.externaltools.ATTR_LOCATION", "/usr/bin/xterm"); - String argument = "-e \"source " + sScriptFile + ";runqemu " + YoctoSDKUtils.qemuTargetTranslate(elem.getStrTarget()) + " "+ + String argument = "-e \"source " + sScriptFile + ";runqemu " + qemuTargetTranslate(elem.getStrTarget()) + " " + elem.getStrQemuKernelLoc() + " " + elem.getStrSysrootLoc() + " " + elem.getStrQemuOption() + ";bash\""; w_copy.setAttribute("org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS", argument);
@@ -358,6 +398,22 @@ public class YoctoSDKUtils { } + private static String qemuTargetTranslate(String strTargetArch) { + String qemu_target = ""; + if (strTargetArch.indexOf("i586") != -1) { + qemu_target = "qemux86"; + } else if (strTargetArch.indexOf("x86_64") != -1) { + qemu_target = "qemux86-64"; + } else if (strTargetArch.indexOf("arm") != -1) { + qemu_target = "qemuarm"; + } else if (strTargetArch.indexOf("mips") != -1) { + qemu_target = "qemumips"; + } else if (strTargetArch.indexOf("ppc") != -1) { + qemu_target = "qemuppc"; + } + return qemu_target; + } + /* Get POKY Preference settings from project's preference store */ public static YoctoUIElement getElemFromProjectPreferences(IProject project) {
@@ -577,70 +633,6 @@ public class YoctoSDKUtils { return elem; } - public static String qemuTargetTranslate(String strTargetArch) - { - String qemu_target = ""; - if (strTargetArch.indexOf("i586") != -1) - qemu_target = "qemux86"; - else if (strTargetArch.indexOf("x86_64") != -1) - qemu_target = "qemux86-64"; - else if (strTargetArch.indexOf("arm") != -1) - qemu_target = "qemuarm"; - else if (strTargetArch.indexOf("mips") != -1) - qemu_target = "qemumips"; - else if (strTargetArch.indexOf("ppc") != -1) - qemu_target = "qemuppc"; - return qemu_target; - } - - public static HashMap<String, String> parseEnvScript(String sFileName) - { - try - { - HashMap<String, String> envMap = new HashMap<String, String>(); - File file = new File(sFileName); - - if (file.exists()) { - BufferedReader input = new BufferedReader(new FileReader(file)); - - try - { - String line = null; - - while ((line = input.readLine()) != null) - { - if (!line.startsWith("export")) - continue; - String sKey = line.substring("export".length() + 1, line.indexOf('=')); - String sValue = line.substring(line.indexOf('=') + 1); - if (sValue.startsWith("\"") && sValue.endsWith("\"")) - sValue = sValue.substring(sValue.indexOf('"') + 1, sValue.lastIndexOf('"')); - /* If PATH ending with $PATH, we need to join with current system path */ - if (sKey.equalsIgnoreCase("PATH")) { - if (sValue.lastIndexOf("$PATH") >= 0) - sValue = sValue.substring(0, sValue.lastIndexOf("$PATH")) + System.getenv("PATH"); - } - envMap.put(sKey, sValue); - System.out.printf("get env key %s value %s\n", sKey, sValue); - } - - } - finally { - input.close(); - } - } - - return envMap; - - } - catch (IOException e) - { - e.printStackTrace(); - return null; - } - - } - public static String getPlatformArch() { String value = null;
@@ -692,8 +684,7 @@ public class YoctoSDKUtils { } /* Save profiles and selected profile to a specific preference store */ - public static void saveProfilesToStore(YoctoProfileElement profileElement, IPreferenceStore store) - { + private static void saveProfilesToStore(YoctoProfileElement profileElement, IPreferenceStore store) { store.setValue(PreferenceConstants.PROFILES, profileElement.getProfilesAsString()); store.setValue(PreferenceConstants.SELECTED_PROFILE, profileElement.getSelectedProfile()); }
@@ -705,8 +696,7 @@ public class YoctoSDKUtils { } /* Get profiles and selected profile from a specific preference store */ - public static YoctoProfileElement getProfilesFromStore(IPreferenceStore store) - { + private static YoctoProfileElement getProfilesFromStore(IPreferenceStore store) { String profiles = store.getString(PreferenceConstants.PROFILES); String selectedProfile = store.getString(PreferenceConstants.SELECTED_PROFILE);
Signature · 1 line
1.7.9.5
PATCH 6/7 plugins/sdk.ide: Removed unused methods
In reply to Atanas GegovFrom: Atanas Gegov <[email protected]>
Removed methods from the YoctoSDKUtils class that
are not used.
--- .../src/org/yocto/sdk/ide/utils/YoctoSDKUtils.java | 12 ------------ 1 file changed, 12 deletions(-)
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/utils/YoctoSDKUtils.java +0 -12
@@ -554,12 +554,6 @@ public class YoctoSDKUtils { } } - /* Save IDE wide POKY Preference settings to the default preference store */ - public static void saveElemToDefaultStore(YoctoUIElement elem) - { - saveElemToStore(elem, YoctoSDKPlugin.getDefault().getPreferenceStore()); - } - /* Save IDE wide POKY Preference settings to a specific preference store */ public static void saveElemToStore(YoctoUIElement elem, IPreferenceStore store) {
@@ -579,12 +573,6 @@ public class YoctoSDKUtils { store.setValue(PreferenceConstants.TOOLCHAIN_TRIPLET, elem.getStrTarget()); } - /* Get IDE wide POKY Preference settings from the default preference store */ - public static YoctoUIElement getElemFromDefaultStore() - { - return getElemFromStore(YoctoSDKPlugin.getDefault().getPreferenceStore()); - } - /* Get IDE wide POKY Preference settings from a specific preference store */ public static YoctoUIElement getElemFromStore(IPreferenceStore store) { YoctoUIElement elem = new YoctoUIElement();
Signature · 1 line
1.7.9.5
PATCH 7/7 plugins/sdk.ide: Moved more locally used methods
In reply to Atanas GegovFrom: Atanas Gegov <[email protected]>
Moved public methods from the YoctoSDKUtils class that are used locally in just one other class. This should reduce the complexity of the YoctoSDKUtils class and decrease unneeded coupling between classes.
--- .../managedbuilder/job/ExecuteConfigureJob.java | 29 +++- .../src/org/yocto/sdk/ide/YoctoSDKChecker.java | 26 ++- .../ide/preferences/YoctoSDKPreferencePage.java | 25 ++- .../preferences/YoctoSDKProjectPropertyPage.java | 119 +++++++++++++- .../src/org/yocto/sdk/ide/utils/YoctoSDKUtils.java | 173 +------------------- .../sdk/ide/utils/YoctoSDKUtilsConstants.java | 2 +- 6 files changed, 190 insertions(+), 184 deletions(-)
plugins/org.yocto.cmake.managedbuilder/src/org/yocto/cmake/managedbuilder/job/ExecuteConfigureJob.java +26 -3
@@ -12,8 +12,17 @@ package org.yocto.cmake.managedbuilder.job; import java.io.IOException; import java.util.Arrays; +import java.util.HashMap; import java.util.LinkedList; - +import java.util.Map; + +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.envvar.IContributedEnvironment; +import org.eclipse.cdt.core.envvar.IEnvironmentVariable; +import org.eclipse.cdt.core.envvar.IEnvironmentVariableManager; +import org.eclipse.cdt.core.model.CoreModel; +import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; +import org.eclipse.cdt.core.settings.model.ICProjectDescription; import org.eclipse.cdt.managedbuilder.core.BuildException; import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.ITool;
@@ -28,7 +37,6 @@ import org.yocto.cmake.managedbuilder.Activator; import org.yocto.cmake.managedbuilder.YoctoCMakeMessages; import org.yocto.cmake.managedbuilder.util.ConsoleUtility; import org.yocto.cmake.managedbuilder.util.SystemProcess; -import org.yocto.sdk.ide.utils.YoctoSDKUtils; public class ExecuteConfigureJob extends Job {
@@ -84,7 +92,22 @@ public class ExecuteConfigureJob extends Job { protected void createProcesses() { configureProcess = - new SystemProcess(configureCommand, location.toFile(), YoctoSDKUtils.getEnvVariablesAsMap(project)); + new SystemProcess(configureCommand, location.toFile(), getEnvVariablesAsMap(project)); + } + + private 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; } /* (non-Javadoc)
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKChecker.java +25 -1
@@ -18,6 +18,8 @@ import java.io.File; import java.io.FileReader; import java.io.FilenameFilter; import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; import org.eclipse.jface.preference.IPreferenceStore; import org.yocto.sdk.ide.natures.YoctoSDKProjectNature;
@@ -130,7 +132,7 @@ public class YoctoSDKChecker { if (elem.getEnumPokyMode() == YoctoUIElement.PokyMode.POKY_SDK_MODE) { //Check for SDK compatible with the host arch - String platform = YoctoSDKUtils.getPlatformArch(); + String platform = getPlatformArch(); String sysroot_dir_str = elem.getStrToolChainRoot() + "/" + SYSROOTS_DIR; File sysroot_dir = new File(sysroot_dir_str); if (!sysroot_dir.exists())
@@ -238,6 +240,28 @@ public class YoctoSDKChecker { return strErrorMsg; } + private static String getPlatformArch() { + String value = null; + try + { + Runtime rt = Runtime.getRuntime(); + Process proc = rt.exec("uname -m"); + InputStream stdin = proc.getInputStream(); + InputStreamReader isr = new InputStreamReader(stdin); + BufferedReader br = new BufferedReader(isr); + String line = null; + + while ( (line = br.readLine()) != null) { + value = line; + } + proc.waitFor(); + + } catch (Throwable t) { + t.printStackTrace(); + } + return value; + } + private static String findHostArch(File sysroot_dir) { FilenameFilter nativeFilter = new FilenameFilter() { public boolean accept(File dir, String name) {
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/preferences/YoctoSDKPreferencePage.java +23 -2
@@ -141,7 +141,7 @@ public class YoctoSDKPreferencePage extends PreferencePage implements IWorkbench } } - YoctoSDKUtils.saveElemToStore(modifiedElement, getPreferenceStore()); + saveElemToStore(modifiedElement, getPreferenceStore()); YoctoSDKUtils.saveProfilesToDefaultStore(profileElement); updateProjects(yoctoProjects, modifiedElement);
@@ -201,7 +201,7 @@ public class YoctoSDKPreferencePage extends PreferencePage implements IWorkbench public void renameProfile(String oldProfileName, String newProfileName) { YoctoUIElement oldProfileElement = YoctoSDKUtils.getElemFromStore(YoctoSDKPlugin.getProfilePreferenceStore(oldProfileName)); - YoctoSDKUtils.saveElemToStore(oldProfileElement, YoctoSDKPlugin.getProfilePreferenceStore(newProfileName)); + saveElemToStore(oldProfileElement, YoctoSDKPlugin.getProfilePreferenceStore(newProfileName)); renameProfileInAffectedProjects(oldProfileName, newProfileName); }
@@ -211,6 +211,27 @@ public class YoctoSDKPreferencePage extends PreferencePage implements IWorkbench resetProfileInAffectedProjects(selectedProfile); } + /* Save IDE wide POKY Preference settings to a specific preference store */ + private void saveElemToStore(YoctoUIElement elem, IPreferenceStore store) { + store.setValue(PreferenceConstants.TARGET_ARCH_INDEX, elem.getIntTargetIndex()); + + if (elem.getEnumPokyMode() == YoctoUIElement.PokyMode.POKY_SDK_MODE) { + store.setValue(PreferenceConstants.SDK_MODE, IPreferenceStore.TRUE); + } else { + store.setValue(PreferenceConstants.SDK_MODE, IPreferenceStore.FALSE); + } + store.setValue(PreferenceConstants.QEMU_KERNEL, elem.getStrQemuKernelLoc()); + store.setValue(PreferenceConstants.QEMU_OPTION, elem.getStrQemuOption()); + store.setValue(PreferenceConstants.SYSROOT, elem.getStrSysrootLoc()); + if (elem.getEnumDeviceMode() == YoctoUIElement.DeviceMode.QEMU_MODE) { + store.setValue(PreferenceConstants.TARGET_MODE, IPreferenceStore.TRUE); + } else { + store.setValue(PreferenceConstants.TARGET_MODE, IPreferenceStore.FALSE); + } + store.setValue(PreferenceConstants.TOOLCHAIN_ROOT, elem.getStrToolChainRoot()); + store.setValue(PreferenceConstants.TOOLCHAIN_TRIPLET, elem.getStrTarget()); + } + private void resetProfileInAffectedProjects(String usedProfile) { HashSet<IProject> yoctoProjects = getAffectedProjects(usedProfile);
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/preferences/YoctoSDKProjectPropertyPage.java +113 -6
167 lines not on this page · raw message
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/utils/YoctoSDKUtils.java +2 -171
229 lines not on this page · raw message
plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/utils/YoctoSDKUtilsConstants.java +1 -1
@@ -14,5 +14,5 @@ public class YoctoSDKUtilsConstants { public static final String DEFAULT_ENV_FILE_PREFIX = "environment-setup-"; public static final String DEFAULT_TMP_PREFIX = "/tmp/"; - + public static final String PROJECT_SCOPE = "org.yocto.sdk.ide"; }
Signature · 1 line
1.7.9.5
Zhang, Jessica
AppliedMerged to eclipse-poky master.
Thanks,
Jessica
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Atanas Gegov
Sent: Monday, June 03, 2013 1:30 AM
To: [email protected]
Subject: [yocto] [eclipse-poky][PATCH 0/7] Fixed bug in creating remote debug launcher
From: Atanas Gegov <[email protected]>
Hi,
this patch series fixes a bug where the remote debug launcher is not correctly created because not all Yocto natures are added to the project at the point where the method is being called. The path to the binary was in some cases (by new CMake project) not correctly set.
This fix required some code refactoring. Some further refactoring was also done in order to reduce the complexity of the very large YoctoSDKUtils class.
Cheers,
Atanas
P.S: This patch series apply on the current master "Add remote.utils plugin to sdk features" (ff4ccb4d65243f2a28eb89c72e9b425702b6c3aa).
Atanas Gegov (7):
plugins/sdk.ide: Extracted a private method plugins/sdk.ide: Extracted launchers creation plugins/sdk.ide: Decoupled launcher creation from environment setting plugins/sdk.ide: Moved a locally used method plugins/sdk.ide: Changed access level modifiers for some methods plugins/sdk.ide: Removed unused methods
plugins/sdk.ide: Moved more locally used methods
.../managedbuilder/job/ExecuteConfigureJob.java | 29 +- .../src/org/yocto/sdk/ide/YoctoSDKChecker.java | 26 +- .../natures/YoctoSDKAutotoolsProjectNature.java | 21 +- .../ide/preferences/YoctoSDKPreferencePage.java | 25 +- .../preferences/YoctoSDKProjectPropertyPage.java | 119 +++++- .../src/org/yocto/sdk/ide/utils/YoctoSDKUtils.java | 388 +++++--------------- .../sdk/ide/utils/YoctoSDKUtilsConstants.java | 2 +- .../ide/wizard/NewYoctoProjectTemplateProcess.java | 2 + 8 files changed, 306 insertions(+), 306 deletions(-)
--
1.7.9.5
_______________________________________________
yocto mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/yocto