Skip to content

Commit

Permalink
#580: fix preferXpacksBin not in workspace
Browse files Browse the repository at this point in the history
  • Loading branch information
ilg-ul committed Jul 25, 2023
1 parent ed5cd58 commit 2eea055
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,14 @@ public static String getGdbServerCommand(ILaunchConfiguration configuration, Str
}

if (project != null) {
IPath projectPath = project.getWorkspace().getRoot().getLocation()
.append(project.getFullPath());
IPath serverPath = projectPath.append("xpacks").append(".bin").append(name);
IPath xpackBinPath = project.getFolder("xpacks").getFolder(".bin").getLocation();
IPath serverPath = xpackBinPath.append(name);

if (serverPath.toFile().exists()) {
executable = serverPath.toString();
} else {
if (EclipseUtils.isWindows()) {
serverPath = projectPath.append("xpacks").append(".bin").append(name + ".cmd");
serverPath = xpackBinPath.append(name + ".cmd");
if (serverPath.toFile().exists()) {
executable = serverPath.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Platform;
import org.eclipse.embedcdt.internal.managedbuild.cross.arm.core.Activator;
import org.eclipse.embedcdt.managedbuild.cross.core.preferences.PersistentPreferences;
Expand Down Expand Up @@ -94,10 +93,8 @@ public static PathEnvironmentVariable create(IConfiguration configuration) {

List<String> path = new ArrayList<>();
if (preferXpacksBin) {
IPath projectPath = project.getWorkspace().getRoot().getLocation().append(project.getFullPath());
IPath xpackBinPath = projectPath.append("xpacks").append(".bin");

path.add(xpackBinPath.toOSString());
String xpackBinPath = project.getFolder("xpacks").getFolder(".bin").getLocation().toOSString();
path.add(xpackBinPath);
}

// Get the build tools path from the common store.
Expand All @@ -117,28 +114,31 @@ public static PathEnvironmentVariable create(IConfiguration configuration) {
path.add(buildToolsPath);
}

IOption optionId;
optionId = toolchain.getOptionBySuperClassId(Option.OPTION_TOOLCHAIN_ID); // $NON-NLS-1$
String toolchainId = (String) optionId.getValue();

IOption optionName;
optionName = toolchain.getOptionBySuperClassId(Option.OPTION_TOOLCHAIN_NAME); // $NON-NLS-1$
String toolchainName = (String) optionName.getValue();

String toolchainPath = "";

// Get the toolchain path from this plug-in store.
PersistentPreferences persistentPreferences = Activator.getInstance().getPersistentPreferences();
// Get the most specific toolchain path (project, workspace,
// Eclipse, defaults).
toolchainPath = persistentPreferences.getToolchainPath(toolchainId, toolchainName, project);
if (toolchainPath.isEmpty()) {
// Try to get from original gnuarmeclipse store.
toolchainPath = deprecatedPersistentPreferences.getToolchainPath(toolchainId, toolchainName, project);
}
if (!preferXpacksBin) {
IOption optionId;
optionId = toolchain.getOptionBySuperClassId(Option.OPTION_TOOLCHAIN_ID); // $NON-NLS-1$
String toolchainId = (String) optionId.getValue();

IOption optionName;
optionName = toolchain.getOptionBySuperClassId(Option.OPTION_TOOLCHAIN_NAME); // $NON-NLS-1$
String toolchainName = (String) optionName.getValue();

String toolchainPath = "";

// Get the toolchain path from this plug-in store.
PersistentPreferences persistentPreferences = Activator.getInstance().getPersistentPreferences();
// Get the most specific toolchain path (project, workspace,
// Eclipse, defaults).
toolchainPath = persistentPreferences.getToolchainPath(toolchainId, toolchainName, project);
if (toolchainPath.isEmpty()) {
// Try to get from original gnuarmeclipse store.
toolchainPath = deprecatedPersistentPreferences.getToolchainPath(toolchainId, toolchainName,
project);
}

if (!toolchainPath.isEmpty()) {
path.add(toolchainPath);
if (!toolchainPath.isEmpty()) {
path.add(toolchainPath);
}
}

if (!path.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import org.eclipse.cdt.managedbuilder.envvar.IEnvironmentVariableProvider;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Platform;
import org.eclipse.embedcdt.internal.managedbuild.cross.riscv.core.Activator;
import org.eclipse.embedcdt.managedbuild.cross.core.preferences.PersistentPreferences;
Expand Down Expand Up @@ -95,10 +94,8 @@ public static PathEnvironmentVariable create(IConfiguration configuration) {

List<String> path = new ArrayList<>();
if (preferXpacksBin) {
IPath projectPath = project.getWorkspace().getRoot().getLocation().append(project.getFullPath());
IPath xpackBinPath = projectPath.append("xpacks").append(".bin");

path.add(xpackBinPath.toOSString());
String xpackBinPath = project.getFolder("xpacks").getFolder(".bin").getLocation().toOSString();
path.add(xpackBinPath);
}

// Get the build tools path from the common store.
Expand All @@ -112,24 +109,26 @@ public static PathEnvironmentVariable create(IConfiguration configuration) {
path.add(buildToolsPath);
}

IOption optionId;
optionId = toolchain.getOptionBySuperClassId(Option.OPTION_TOOLCHAIN_ID); // $NON-NLS-1$
String toolchainId = (String) optionId.getValue();
if (!preferXpacksBin) {
IOption optionId;
optionId = toolchain.getOptionBySuperClassId(Option.OPTION_TOOLCHAIN_ID); // $NON-NLS-1$
String toolchainId = (String) optionId.getValue();

IOption optionName;
optionName = toolchain.getOptionBySuperClassId(Option.OPTION_TOOLCHAIN_NAME); // $NON-NLS-1$
String toolchainName = (String) optionName.getValue();
IOption optionName;
optionName = toolchain.getOptionBySuperClassId(Option.OPTION_TOOLCHAIN_NAME); // $NON-NLS-1$
String toolchainName = (String) optionName.getValue();

String toolchainPath = "";
String toolchainPath = "";

// Get the toolchain path from this plug-in store.
PersistentPreferences persistentPreferences = Activator.getInstance().getPersistentPreferences();
// Get the most specific toolchain path (project, workspace,
// Eclipse, defaults).
toolchainPath = persistentPreferences.getToolchainPath(toolchainId, toolchainName, project);
// Get the toolchain path from this plug-in store.
PersistentPreferences persistentPreferences = Activator.getInstance().getPersistentPreferences();
// Get the most specific toolchain path (project, workspace,
// Eclipse, defaults).
toolchainPath = persistentPreferences.getToolchainPath(toolchainId, toolchainName, project);

if (!toolchainPath.isEmpty()) {
path.add(toolchainPath);
if (!toolchainPath.isEmpty()) {
path.add(toolchainPath);
}
}

if (!path.isEmpty()) {
Expand Down

0 comments on commit 2eea055

Please sign in to comment.