Update the runtime to properly support Windows.

This commit is contained in:
Neel Patel
2016-02-02 13:16:01 +00:00
committed by Dave Page
parent 14583e68b2
commit efc8815ecb
2 changed files with 53 additions and 12 deletions

View File

@@ -83,7 +83,8 @@ bool Server::Init()
// Find the webapp
QStringList paths;
paths.append("../web/"); // Windows/Linux source tree
paths.append("../web/"); // Linux source tree
paths.append("../../web/"); // Windows source tree
paths.append("../../../../web/"); // Mac source tree (in the app bundle)
paths.append(settings.value("ApplicationPath").toString()); // System configured value
paths.append(""); // Should be last!
@@ -122,8 +123,16 @@ void Server::run()
// Set the port number
PyRun_SimpleString(QString("PGADMIN_PORT = %1").arg(m_port).toLatin1());
if (PyRun_SimpleFile(cp, m_appfile.toUtf8().data()) != 0)
#ifdef PYTHON2
PyObject* PyFileObject = PyFile_FromString(m_appfile.toUtf8().data(), (char *)"r");
if (PyRun_SimpleFile(PyFile_AsFile(PyFileObject), m_appfile.toUtf8().data()) != 0)
setError(tr("Failed to launch the application server, server thread exiting."));
#else
int fd = fileno(cp);
PyObject* PyFileObject = PyFile_FromFd(fd, m_appfile.toUtf8().data(), (char *)"r", -1, NULL, NULL,NULL,1);
if (PyRun_SimpleFile(fdopen(PyObject_AsFileDescriptor(PyFileObject),"r"), m_appfile.toUtf8().data()) != 0)
setError(tr("Failed to launch the application server, server thread exiting."));
#endif
fclose(cp);
}

View File

@@ -7,20 +7,52 @@ greaterThan(QT_MAJOR_VERSION, 4) {
QT += webkit network
}
PYTHON_CONFIG=python3-config
win32 {
message(Building for Windows...)
# Find and configure Python
!system(which python3-config > /dev/null 2>&1) {
# Read the PYTHON_HOME and PYTHON_VERSION system environment variables.
PY_HOME = $$(PYTHON_HOME)
PY_VERSION = $$(PYTHON_VERSION)
isEmpty(PY_HOME) {
error(Please define the PYTHON_HOME variable in the system environment.)
}
else {
isEmpty(PY_VERSION) {
error(Please define the PYTHON_VERSION variable in the system environment.)
}
else {
INCLUDEPATH = $$PY_HOME\include
LIBS += -L"$$PY_HOME\libs" -lpython$$PY_VERSION
PY2_VERSION = $$find(PY_VERSION, "^2")
# Set the PYTHON2 macro if appropriate
PY2_VERSION = $$find(PY_VERSION, "^2")
count( PY2_VERSION, 1) {
message(Python version 2.x detected.)
DEFINES += PYTHON2
}
}
}
}
else {
message(Building for Linux/Mac...)
PYTHON_CONFIG=python3-config
# Find and configure Python
!system(which python3-config > /dev/null 2>&1) {
!system(which python-config > /dev/null 2>&1) {
error(The python-config executable could not be found. Ensure Python is installed and in the system path.)
} else {
PYTHON_CONFIG=python-config
DEFINES += PYTHON2
}
}
}
QMAKE_CXXFLAGS += $$system($$PYTHON_CONFIG --includes)
QMAKE_LFLAGS += $$system($$PYTHON_CONFIG --ldflags)
QMAKE_CXXFLAGS += $$system($$PYTHON_CONFIG --includes)
QMAKE_LFLAGS += $$system($$PYTHON_CONFIG --ldflags)
}
# Source code
HEADERS = BrowserWindow.h \