mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-07-30 07:18:37 -09:00
GP-0: The Visual Studio Code Integration options can now accept 2
optional arguments, allowing a Flatpak installation of VSCode to be launched by Ghidra (Closes #8442)
This commit is contained in:
@@ -37,10 +37,26 @@
|
|||||||
<TD valign="top" align="left">Path to a Visual Studio Code executable file. It defaults
|
<TD valign="top" align="left">Path to a Visual Studio Code executable file. It defaults
|
||||||
to the most commonly used location on your specific platform.</TD>
|
to the most commonly used location on your specific platform.</TD>
|
||||||
</TR>
|
</TR>
|
||||||
|
<TR valign="middle">
|
||||||
|
<TD valign="top" width="200" align="left">Visual Studio Code Argument 1 (optional)</TD>
|
||||||
|
<TD valign="top" align="left">An optional argument to pass to the Visual Studio Code
|
||||||
|
executable.</TD>
|
||||||
|
</TR>
|
||||||
|
<TR valign="middle">
|
||||||
|
<TD valign="top" width="200" align="left">Visual Studio Code Argument 2 (optional)</TD>
|
||||||
|
<TD valign="top" align="left">An optional argument to pass to the Visual Studio Code
|
||||||
|
executable.</TD>
|
||||||
|
</TR>
|
||||||
</TBODY>
|
</TBODY>
|
||||||
</TABLE>
|
</TABLE>
|
||||||
</CENTER>
|
</CENTER>
|
||||||
|
|
||||||
|
<P>
|
||||||
|
<IMG src="help/shared/note.yellow.png" alt="">One use of the optional argument fields is to
|
||||||
|
launch a Flatpak installation of Visual Studio Code. In this case, the executable path might be
|
||||||
|
"/usr/bin/flatpak", and the two optional arguments might be "run" and "com.visualstudio.code".
|
||||||
|
</P>
|
||||||
|
|
||||||
<H2><A name="VSCodeModuleProject"></A>Create Visual Studio Code Module Project</H2>
|
<H2><A name="VSCodeModuleProject"></A>Create Visual Studio Code Module Project</H2>
|
||||||
<P>This action creates a new Visual Studio Code project folder which can be used as a convenient
|
<P>This action creates a new Visual Studio Code project folder which can be used as a convenient
|
||||||
starting point to develop a new Ghidra module. The new project will be linked against the
|
starting point to develop a new Ghidra module. The new project will be linked against the
|
||||||
|
|||||||
@@ -44,9 +44,21 @@ public class VSCodeIntegrationOptionsPlugin extends Plugin implements Applicatio
|
|||||||
public static final String PLUGIN_OPTIONS_NAME = "Visual Studio Code Integration";
|
public static final String PLUGIN_OPTIONS_NAME = "Visual Studio Code Integration";
|
||||||
|
|
||||||
public static final String VSCODE_EXE_PATH_OPTION = "Visual Studio Code Executable Path";
|
public static final String VSCODE_EXE_PATH_OPTION = "Visual Studio Code Executable Path";
|
||||||
private static final String VSCODE_EXE_PATH_DESC = "Path to Visual Studio Code executable";
|
private static final String VSCODE_EXE_PATH_DESC = "Full path to Visual Studio Code executable";
|
||||||
private static final File VSCODE_EXE_PATH_DEFAULT = getDefaultVSCodeExecutable();
|
private static final File VSCODE_EXE_PATH_DEFAULT = getDefaultVSCodeExecutable();
|
||||||
|
|
||||||
|
public static final String VSCODE_ARG1_OPTION =
|
||||||
|
"Visual Studio Code Launch Argument 1 (optional)";
|
||||||
|
private static final String VSCODE_ARG1_DESC =
|
||||||
|
"Optional argument 1 for Visual Studio Code executable";
|
||||||
|
private static final String VSCODE_ARG1_DEFAULT = null;
|
||||||
|
|
||||||
|
public static final String VSCODE_ARG2_OPTION =
|
||||||
|
"Visual Studio Code Launch Argument 2 (optional)";
|
||||||
|
private static final String VSCODE_ARG2_DESC =
|
||||||
|
"Optional argument 2 for Visual Studio Code executable";
|
||||||
|
private static final String VSCODE_ARG2_DEFAULT = null;
|
||||||
|
|
||||||
public VSCodeIntegrationOptionsPlugin(PluginTool tool) {
|
public VSCodeIntegrationOptionsPlugin(PluginTool tool) {
|
||||||
super(tool);
|
super(tool);
|
||||||
}
|
}
|
||||||
@@ -57,6 +69,10 @@ public class VSCodeIntegrationOptionsPlugin extends Plugin implements Applicatio
|
|||||||
ToolOptions options = tool.getOptions(PLUGIN_OPTIONS_NAME);
|
ToolOptions options = tool.getOptions(PLUGIN_OPTIONS_NAME);
|
||||||
options.registerOption(VSCODE_EXE_PATH_OPTION, OptionType.FILE_TYPE,
|
options.registerOption(VSCODE_EXE_PATH_OPTION, OptionType.FILE_TYPE,
|
||||||
VSCODE_EXE_PATH_DEFAULT, null, VSCODE_EXE_PATH_DESC);
|
VSCODE_EXE_PATH_DEFAULT, null, VSCODE_EXE_PATH_DESC);
|
||||||
|
options.registerOption(VSCODE_ARG1_OPTION, OptionType.STRING_TYPE,
|
||||||
|
VSCODE_ARG1_DEFAULT, null, VSCODE_ARG1_DESC);
|
||||||
|
options.registerOption(VSCODE_ARG2_OPTION, OptionType.STRING_TYPE,
|
||||||
|
VSCODE_ARG2_DEFAULT, null, VSCODE_ARG2_DESC);
|
||||||
options.setOptionsHelpLocation(
|
options.setOptionsHelpLocation(
|
||||||
new HelpLocation("VSCodeIntegration", "VSCodeIntegrationOptions"));
|
new HelpLocation("VSCodeIntegration", "VSCodeIntegrationOptions"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import java.io.*;
|
|||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.apache.commons.io.*;
|
import org.apache.commons.io.*;
|
||||||
|
|
||||||
import com.google.gson.*;
|
import com.google.gson.*;
|
||||||
@@ -153,6 +154,16 @@ public class VSCodeIntegrationPlugin extends ProgramPlugin implements VSCodeInte
|
|||||||
return vscodeExecutableFile;
|
return vscodeExecutableFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getVSCodeArguments() {
|
||||||
|
List<String> args = new ArrayList<>();
|
||||||
|
CollectionUtils.addIgnoreNull(args,
|
||||||
|
options.getString(VSCodeIntegrationOptionsPlugin.VSCODE_ARG1_OPTION, null));
|
||||||
|
CollectionUtils.addIgnoreNull(args,
|
||||||
|
options.getString(VSCodeIntegrationOptionsPlugin.VSCODE_ARG2_OPTION, null));
|
||||||
|
return args;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void launchVSCode(File file) {
|
public void launchVSCode(File file) {
|
||||||
TaskLauncher.launch(new VSCodeLauncherTask(this, file));
|
TaskLauncher.launch(new VSCodeLauncherTask(this, file));
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ class VSCodeLauncherTask extends Task {
|
|||||||
// location present the user with the options window, and when they close that window, try
|
// location present the user with the options window, and when they close that window, try
|
||||||
// again.
|
// again.
|
||||||
File vscodeExecutableFile;
|
File vscodeExecutableFile;
|
||||||
|
List<String> vscodeArgs = vscodeService.getVSCodeArguments();
|
||||||
try {
|
try {
|
||||||
vscodeExecutableFile = vscodeService.getVSCodeExecutableFile();
|
vscodeExecutableFile = vscodeService.getVSCodeExecutableFile();
|
||||||
}
|
}
|
||||||
@@ -93,6 +94,7 @@ class VSCodeLauncherTask extends Task {
|
|||||||
try {
|
try {
|
||||||
List<String> args = new ArrayList<>();
|
List<String> args = new ArrayList<>();
|
||||||
args.add(vscodeExecutableFile.getAbsolutePath());
|
args.add(vscodeExecutableFile.getAbsolutePath());
|
||||||
|
args.addAll(vscodeArgs);
|
||||||
args.add("-a");
|
args.add("-a");
|
||||||
args.add(workspaceFile.getAbsolutePath());
|
args.add(workspaceFile.getAbsolutePath());
|
||||||
args.add(file.getAbsolutePath());
|
args.add(file.getAbsolutePath());
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
package ghidra.app.services;
|
package ghidra.app.services;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import ghidra.framework.options.ToolOptions;
|
import ghidra.framework.options.ToolOptions;
|
||||||
|
|
||||||
@@ -36,6 +37,11 @@ public interface VSCodeIntegrationService {
|
|||||||
*/
|
*/
|
||||||
public File getVSCodeExecutableFile() throws FileNotFoundException;
|
public File getVSCodeExecutableFile() throws FileNotFoundException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@return the Visual Studio Code executable arguments}
|
||||||
|
*/
|
||||||
|
public List<String> getVSCodeArguments();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Launches Visual Studio Code
|
* Launches Visual Studio Code
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user