1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 17:35:35 +02:00

Hack in Windows support for Qt build and launch.

Only supports Qt 5.5 and mingw492_32 and only if installed into
C:/Qt or %HOME%/Qt.

Change-Id: I10e293fe5c7a72430a624dcf74fd8fc9a806c34c
This commit is contained in:
Doug Schaefer 2015-09-28 14:46:38 -04:00
parent 64bf3c4f69
commit 34378cb163
4 changed files with 58 additions and 15 deletions

View file

@ -24,6 +24,7 @@ import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
public class QtBuilder extends IncrementalProjectBuilder {
@ -65,7 +66,18 @@ public class QtBuilder extends IncrementalProjectBuilder {
}
// run make
Process process = new ProcessBuilder("make").directory(new File(buildFolder.getLocationURI())).start(); //$NON-NLS-1$
// TODO obviously hardcoding here
boolean isWin = Platform.getOS().equals(Platform.OS_WIN32);
String make = isWin ? "C:/Qt/Tools/mingw492_32/bin/mingw32-make" : "make";
ProcessBuilder procBuilder = new ProcessBuilder(make).directory(new File(buildFolder.getLocationURI())); //$NON-NLS-1$
if (isWin) {
// Need to put the toolchain into env
Map<String, String> env = procBuilder.environment();
String path = env.get("PATH");
path = "C:/Qt/Tools/mingw492_32/bin;" + path;
env.put("PATH", path);
}
Process process = procBuilder.start();
console.writeOutput("make\n"); //$NON-NLS-1$
console.monitor(process, null, buildFolder);

View file

@ -36,6 +36,8 @@ public class QtInstall {
switch (getSpec()) {
case "macx-clang": //$NON-NLS-1$
return Platform.OS_MACOSX.equals(os) && Platform.ARCH_X86_64.equals(arch);
case "win32-g++": //$NON-NLS-1$
return Platform.OS_WIN32.equals(os);
}
return false;
}

View file

@ -12,20 +12,27 @@ import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.runtime.Platform;
public class QtInstallManager {
public static final QtInstallManager instance = new QtInstallManager();
private List<QtInstall> installs;
private static boolean isWin = Platform.getOS().equals(Platform.OS_WIN32);
public List<QtInstall> getInstalls() {
if (installs == null) {
installs = new ArrayList<>();
// TODO hack to get going
File qtDir = new File(System.getProperty("user.home"), "Qt/5.5");
if (!qtDir.isDirectory() && isWin) {
qtDir = new File("C:/Qt/5.5");
}
if (qtDir.isDirectory()) {
for (File dir : qtDir.listFiles()) {
Path qmakePath = dir.toPath().resolve("bin/qmake");
Path qmakePath = dir.toPath().resolve(isWin ? "bin/qmake.exe" : "bin/qmake");
if (qmakePath.toFile().canExecute()) {
installs.add(new QtInstall(qmakePath));
}

View file

@ -44,29 +44,51 @@ public class QtLocalRunLaunchConfigDelegate extends LaunchConfigurationDelegate
// get the executable
IFolder buildFolder = qtBuildConfig.getBuildFolder();
// TODO this is mac local specific and really should be in the config
// TODO also need to pull the app name out of the pro file name
IFolder appFolder = buildFolder.getFolder("main.app");
IFolder contentsFolder = appFolder.getFolder("Contents");
IFolder macosFolder = contentsFolder.getFolder("MacOS");
IFile exeFile = macosFolder.getFile("main");
IFile exeFile;
switch (Platform.getOS()) {
case Platform.OS_MACOSX:
// TODO this is mac local specific and really should be in the config
// TODO also need to pull the app name out of the pro file name
IFolder appFolder = buildFolder.getFolder("main.app");
IFolder contentsFolder = appFolder.getFolder("Contents");
IFolder macosFolder = contentsFolder.getFolder("MacOS");
exeFile = macosFolder.getFile("main");
break;
case Platform.OS_WIN32:
IFolder releaseFolder = buildFolder.getFolder("release");
exeFile = releaseFolder.getFile("main.exe");
break;
default:
return new Status(IStatus.ERROR, QtPlugin.ID, "platform not supported: " + Platform.getOS());
}
ProcessBuilder builder = new ProcessBuilder(exeFile.getLocation().toFile().getAbsolutePath())
.directory(qtBuildConfig.getProject().getLocation().toFile());
// need to add the Qt libraries to the env
Map<String, String> env = builder.environment();
String libPathEnv = env.get("DYLD_LIBRARY_PATH");
Path libPath = qtBuildConfig.getQtInstall().getLibPath();
if (libPathEnv == null) {
libPathEnv = libPath.toString();
} else {
libPathEnv = libPath.toString() + File.pathSeparator + libPathEnv;
switch (Platform.getOS()) {
case Platform.OS_MACOSX:
String libPathEnv = env.get("DYLD_LIBRARY_PATH");
if (libPathEnv == null) {
libPathEnv = libPath.toString();
} else {
libPathEnv = libPath.toString() + File.pathSeparator + libPathEnv;
}
env.put("DYLD_LIBRARY_PATH", libPathEnv);
break;
case Platform.OS_WIN32:
String path = env.get("PATH");
// TODO really need a bin path
// and resolve doesn't work properly on Windows
path = "C:/Qt/5.5/mingw492_32/bin;" + path;
env.put("PATH", path);
break;
}
env.put("DYLD_LIBRARY_PATH", libPathEnv);
Process process = builder.start();
DebugPlugin.newProcess(launch, process, "main.app");
DebugPlugin.newProcess(launch, process, "main");
} catch (IOException e) {
return new Status(IStatus.ERROR, QtPlugin.ID, "running", e);
} catch (CoreException e) {