Skip to content

Commit ba74365

Browse files
author
zhangzegang
committed
profiling: add tool path settings in project properity for profiling
tools
1 parent 2c9fc6f commit ba74365

File tree

8 files changed

+97
-7
lines changed

8 files changed

+97
-7
lines changed

profiling/org.eclipse.linuxtools.tools.launch.core/META-INF/MANIFEST.MF

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ Require-Bundle: org.eclipse.core.runtime,
1111
org.eclipse.ui;bundle-version="3.7.0",
1212
org.eclipse.linuxtools.profiling.launch;bundle-version="0.10.0",
1313
org.eclipse.core.filesystem;bundle-version="1.3.100",
14-
com.jcraft.jsch
14+
com.jcraft.jsch,
15+
org.eclipse.core.variables;bundle-version="3.5.100"
1516
Bundle-RequiredExecutionEnvironment: JavaSE-17
1617
Bundle-ActivationPolicy: lazy
1718
Export-Package: org.eclipse.linuxtools.tools.launch.core,org.eclipse.l

profiling/org.eclipse.linuxtools.tools.launch.core/src/org/eclipse/linuxtools/tools/launch/core/LaunchCoreConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@
2121
public interface LaunchCoreConstants {
2222
String PLUGIN_ID = "org.eclipse.linuxtools.tools.launch.core"; //$NON-NLS-1$
2323
String LINUXTOOLS_PATH_NAME = LaunchCoreConstants.PLUGIN_ID + ".LinuxtoolsPath"; //$NON-NLS-1$
24+
String LINUXTOOLS_PREFIX_NAME = LaunchCoreConstants.PLUGIN_ID + ".LinuxtoolsPrefix"; //$NON-NLS-1$
2425
String LINUXTOOLS_PATH_SYSTEM_NAME = LaunchCoreConstants.PLUGIN_ID + ".LinuxtoolsSystemEnvPath"; //$NON-NLS-1$
2526
}

profiling/org.eclipse.linuxtools.tools.launch.core/src/org/eclipse/linuxtools/tools/launch/core/factory/LinuxtoolsProcessFactory.java

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323

2424
import org.eclipse.core.resources.IProject;
2525
import org.eclipse.core.runtime.CoreException;
26+
import org.eclipse.core.runtime.Platform;
27+
import org.eclipse.core.variables.IStringVariableManager;
28+
import org.eclipse.core.variables.VariablesPlugin;
2629
import org.eclipse.linuxtools.profiling.launch.RemoteEnvProxyManager;
2730
import org.eclipse.linuxtools.tools.launch.core.properties.LinuxtoolsPathProperty;
2831

@@ -41,7 +44,9 @@ public abstract class LinuxtoolsProcessFactory {
4144

4245
private static final String PATH = "PATH"; //$NON-NLS-1$
4346
private static final String PATH_EQUAL = "PATH="; //$NON-NLS-1$
44-
private static final String SEPARATOR = ":"; //$NON-NLS-1$
47+
private static final String SEPARATOR_WIN32 = ";"; //$NON-NLS-1$
48+
private static final String SEPARATOR_LINUX = ":"; //$NON-NLS-1$
49+
private static final String SEPARATOR = ":"; //$NON-NLS-1$
4550

4651
private String getEnvpPath(String[] envp) {
4752
if (envp == null) {
@@ -66,7 +71,14 @@ private String getEnvpPath(String[] envp) {
6671
* will be updated.
6772
* @return The new environment.
6873
*/
69-
protected String[] updateEnvironment(String[] envp, IProject project) {
74+
protected String[] updateEnvironment(String[] envp, IProject project) {
75+
String separator;
76+
if (Platform.OS_WIN32.equals(Platform.getOS())) {
77+
separator = SEPARATOR_WIN32;
78+
} else {
79+
separator = SEPARATOR_LINUX;
80+
}
81+
7082
String ltPath = LinuxtoolsPathProperty.getInstance().getLinuxtoolsPath(project);
7183
String envpPath = getEnvpPath(envp);
7284

@@ -96,13 +108,28 @@ protected String[] updateEnvironment(String[] envp, IProject project) {
96108
StringBuilder newPath = new StringBuilder();
97109
newPath.append(PATH_EQUAL);
98110

111+
IStringVariableManager varManager = VariablesPlugin.getDefault().getStringVariableManager();
112+
113+
99114
if (ltPath != null && !ltPath.isEmpty()) {
115+
try {
116+
ltPath = varManager.performStringSubstitution(ltPath);
117+
} catch (CoreException e) {
118+
// TODO Auto-generated catch block
119+
e.printStackTrace();
120+
}
100121
newPath.append(ltPath);
101-
newPath.append(SEPARATOR);
122+
newPath.append(separator);
102123
}
103124
if (envpPath != null && !envpPath.isEmpty()) {
125+
try {
126+
envpPath = varManager.performStringSubstitution(envpPath);
127+
} catch (CoreException e) {
128+
// TODO Auto-generated catch block
129+
e.printStackTrace();
130+
}
104131
newPath.append(envpPath);
105-
newPath.append(SEPARATOR);
132+
newPath.append(separator);
106133
}
107134
if (systemPath != null && !systemPath.isEmpty()) {
108135
newPath.append(systemPath);

profiling/org.eclipse.linuxtools.tools.launch.core/src/org/eclipse/linuxtools/tools/launch/core/factory/RuntimeProcessFactory.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.eclipse.linuxtools.profiling.launch.IRemoteCommandLauncher;
3434
import org.eclipse.linuxtools.profiling.launch.IRemoteFileProxy;
3535
import org.eclipse.linuxtools.profiling.launch.RemoteProxyManager;
36+
import org.eclipse.linuxtools.tools.launch.core.properties.LinuxtoolsPathProperty;
3637

3738
/*
3839
* Create process using Runtime.getRuntime().exec and prepends the
@@ -81,8 +82,15 @@ private String[] fillPathSudoCommand(String[] cmdarray, IProject project) throws
8182
*
8283
* @since 1.1
8384
*/
84-
public String whichCommand(String command, IProject project) throws IOException {
85+
public String whichCommand(String command, IProject project) throws IOException {
8586
String[] envp = updateEnvironment(null, project);
87+
88+
String ltPrefix = LinuxtoolsPathProperty.getInstance().getLinuxtoolsPrefix(project);
89+
90+
if (!ltPrefix.isEmpty()) {
91+
command = ltPrefix + command;
92+
}
93+
8694
try {
8795
IRemoteFileProxy proxy = RemoteProxyManager.getInstance().getFileProxy(project);
8896
URI whichUri;
@@ -107,7 +115,7 @@ public String whichCommand(String command, IProject project) throws IOException
107115
}
108116
}
109117
if (!lines.isEmpty()) {
110-
if (project != null && project.getLocationURI() != null) {
118+
if (project != null && project.getLocationURI() != null) {
111119
if (project.getLocationURI().toString()
112120
.startsWith("rse:")) { //$NON-NLS-1$
113121
// RSE output

profiling/org.eclipse.linuxtools.tools.launch.core/src/org/eclipse/linuxtools/tools/launch/core/properties/LinuxtoolsPathProperty.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public class LinuxtoolsPathProperty {
3131
private static final String LINUXTOOLS_PATH_OPTION_PATH = "path"; //$NON-NLS-1$
3232
private static final String LINUXTOOLS_PATH_OPTION_DEFAULT = "default"; //$NON-NLS-1$
3333
private String linuxtoolsPathDefault = ""; //$NON-NLS-1$
34+
private String linuxtoolsPrefixDefault = ""; //$NON-NLS-1$
3435
private boolean linuxtoolsPathSystemDefault = true;
3536
private static LinuxtoolsPathProperty instance = null;
3637

@@ -109,10 +110,33 @@ public String getLinuxtoolsPath(IProject project) {
109110
return path;
110111
}
111112

113+
public String getLinuxtoolsPrefix(IProject project) {
114+
if (project == null) {
115+
return ""; //$NON-NLS-1$
116+
}
117+
118+
ScopedPreferenceStore store = new ScopedPreferenceStore(new ProjectScope(project),
119+
LaunchCoreConstants.PLUGIN_ID);
120+
121+
String prefix = null;
122+
if (store.contains(LaunchCoreConstants.LINUXTOOLS_PREFIX_NAME)) {
123+
prefix = store.getString(LaunchCoreConstants.LINUXTOOLS_PREFIX_NAME);
124+
}
125+
126+
if (prefix == null) {
127+
return getLinuxtoolsPrefixDefault();
128+
}
129+
return prefix;
130+
}
131+
112132
public String getLinuxtoolsPathDefault() {
113133
return linuxtoolsPathDefault;
114134
}
115135

136+
public String getLinuxtoolsPrefixDefault() {
137+
return linuxtoolsPrefixDefault;
138+
}
139+
116140
public boolean getLinuxtoolsPathSystemDefault() {
117141
return linuxtoolsPathSystemDefault;
118142
}

profiling/org.eclipse.linuxtools.tools.launch.ui/src/org/eclipse/linuxtools/internal/tools/launch/ui/properties/LinuxtoolsPathPropertyPage.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ public class LinuxtoolsPathPropertyPage extends PropertyPage {
6262
{"Custom", ""}, //$NON-NLS-1$ //$NON-NLS-2$
6363
};
6464
private StringFieldEditor linuxtoolsPath;
65+
private StringFieldEditor linuxtoolsPrefix;
6566
private CustomComboFieldEditor linuxtoolsPathCombo;
6667
private IAdaptable element = null;
6768
private Composite result;
@@ -150,6 +151,17 @@ protected Control createContents(Composite parent) {
150151
linuxtoolsPath.setPage(this);
151152
linuxtoolsPath.setPreferenceStore(getPreferenceStore());
152153
linuxtoolsPath.getTextControl(result).setToolTipText(Messages.LINUXTOOLS_PATH_TOOLTIP);
154+
155+
156+
157+
//Add textbox
158+
linuxtoolsPrefix = new StringFieldEditor(LaunchCoreConstants.LINUXTOOLS_PREFIX_NAME,Messages.LINUXTOOLS_PREFIX_COMBO, result);
159+
linuxtoolsPrefix.setPage(this);
160+
linuxtoolsPrefix.setPreferenceStore(getPreferenceStore());
161+
linuxtoolsPrefix.getTextControl(result).setToolTipText(Messages.LINUXTOOLS_PREFIX_TOOLTIP);
162+
163+
getPreferenceStore().setDefault(LaunchCoreConstants.LINUXTOOLS_PREFIX_NAME, LinuxtoolsPathProperty.getInstance().getLinuxtoolsPrefixDefault());
164+
linuxtoolsPrefix.load();
153165

154166
String selected = getPreferenceStore().getString(LINUXTOOLS_PATH_COMBO_NAME);
155167
customSelected = selected.equals(""); //$NON-NLS-1$
@@ -176,6 +188,7 @@ private void updateOptionsEnable() {
176188
protected void performDefaults() {
177189
if (initialized) {
178190
linuxtoolsPath.loadDefault();
191+
linuxtoolsPrefix.loadDefault();
179192
linuxtoolsPathCombo.loadDefault();
180193
customButton.setSelection(!LinuxtoolsPathProperty.getInstance().getLinuxtoolsPathSystemDefault());
181194
systemEnvButton.setSelection(LinuxtoolsPathProperty.getInstance().getLinuxtoolsPathSystemDefault());
@@ -187,6 +200,7 @@ protected void performDefaults() {
187200
public boolean performOk() {
188201
if (initialized) {
189202
linuxtoolsPath.store();
203+
linuxtoolsPrefix.store();
190204
linuxtoolsPathCombo.store();
191205
getPreferenceStore().setValue(LaunchCoreConstants.LINUXTOOLS_PATH_SYSTEM_NAME, systemEnvButton.getSelection());
192206
}
@@ -197,6 +211,7 @@ public boolean performOk() {
197211
protected void performApply() {
198212
if (initialized) {
199213
linuxtoolsPath.store();
214+
linuxtoolsPrefix.store();
200215
linuxtoolsPathCombo.store();
201216
getPreferenceStore().setValue(LaunchCoreConstants.LINUXTOOLS_PATH_SYSTEM_NAME, systemEnvButton.getSelection());
202217
}

profiling/org.eclipse.linuxtools.tools.launch.ui/src/org/eclipse/linuxtools/internal/tools/launch/ui/properties/Messages.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ public class Messages extends NLS {
2323
public static String LINUXTOOLS_PATH_CUSTOM_TOOLTIP;
2424
public static String LINUXTOOLS_PATH_SYSTEM_ENV;
2525
public static String LINUXTOOLS_PATH_TOOLTIP;
26+
public static String LINUXTOOLS_PREFIX;
27+
public static String LINUXTOOLS_PREFIX_COMBO;
28+
public static String LINUXTOOLS_PREFIX_TOOLTIP;
29+
public static String LINUXTOOLS_PREFIX_CUSTOM;
30+
public static String LINUXTOOLS_PREFIX_SYSTEM_ENV;
31+
public static String LINUXTOOLS_PREFIX_CUSTOM_TOOLTIP;
32+
33+
2634
static {
2735
// initialize resource bundle
2836
NLS.initializeMessages(BUNDLE_NAME, Messages.class);

profiling/org.eclipse.linuxtools.tools.launch.ui/src/org/eclipse/linuxtools/internal/tools/launch/ui/properties/messages.properties

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,9 @@ LINUXTOOLS_PATH_TOOLTIP=Use ':' as Path separator
1818
LINUXTOOLS_PATH_CUSTOM=Prepend string to PATH
1919
LINUXTOOLS_PATH_SYSTEM_ENV=Use the System Environment PATH
2020
LINUXTOOLS_PATH_CUSTOM_TOOLTIP=Append the selected string to the beginning of the current system Path
21+
LINUXTOOLS_PREFIX=
22+
LINUXTOOLS_PREFIX_COMBO=Prefix:
23+
LINUXTOOLS_PREFIX_TOOLTIP=Add extra prefix to command such as gcov addr2line nm c++filt strings gprof, eg, prefix riscv-nuclei-elf-, command, strings will be riscv-nuclei-elf-strings
24+
LINUXTOOLS_PREFIX_CUSTOM=
25+
LINUXTOOLS_PREFIX_SYSTEM_ENV=
26+
LINUXTOOLS_PREFIX_CUSTOM_TOOLTIP=

0 commit comments

Comments
 (0)