Permalink
Browse files

Merged windows support and mac os x updates

  • Loading branch information...
bmcdorman committed Jan 11, 2013
2 parents 1305ae2 + 76a327a commit 82e938e52b81600361c975f2354b53f6384b3422
View
@@ -9,6 +9,7 @@ SET(RC ${KISS_SOURCE_DIR}/rc)
SET(SRC ${KISS_SOURCE_DIR}/src)
SET(UI ${KISS_SOURCE_DIR}/ui)
SET(TRADEMARKS ${KISS_SOURCE_DIR}/trademarks)
+SET(COMPAT ${KISS_SOURCE_DIR}/compat)
SET(KISS_INCLUDE_DIRS ${INCLUDE}
${INCLUDE}/dialogs
@@ -50,7 +51,16 @@ FILE(GLOB INCLUDES ${INCLUDE}/*.hpp
${INCLUDE}/compiler/*
${INCLUDE}/interface/*)
-FILE(GLOB SOURCES ${SRC}/* ${SRC}/lexer/* ${SRC}/dialogs/* ${SRC}/widgets/* ${SRC}/menus/* ${SRC}/js/* ${SRC}/project/* ${SRC}/compiler/* ${SRC}/interface/*)
+FILE(GLOB SOURCES ${SRC}/*
+ ${SRC}/lexer/*
+ ${SRC}/dialogs/*
+ ${SRC}/widgets/*
+ ${SRC}/menus/*
+ ${SRC}/js/*
+ ${SRC}/project/*
+ ${SRC}/compiler/*
+ ${SRC}/interface/*)
+
FILE(GLOB UIS ${UI}/*)
SET(KISS_SRCS_CXX ${SOURCES})
@@ -79,17 +89,25 @@ ELSEIF(UNIX)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
ADD_EXECUTABLE(KISS ${KISS_SRCS_CXX})
ELSEIF(WIN32)
- SET(CMAKE_CXX_FLAGS "-Wl,--enable-auto-import")
- ADD_EXECUTABLE(KISS WIN32 ${KISS_SRCS_CXX} rc/logos/kiss.rc)
+ SET(COMPAT_SRCS ${COMPAT}/mingw.c)
+ SET(CMAKE_CXX_FLAGS "-Wl,--enable-auto-import")
+ ADD_EXECUTABLE(KISS ${KISS_SRCS_CXX} ${COMPAT_SRCS} ${CMAKE_SOURCE_DIR}/rc/logos/kiss.rc)
ENDIF()
-
-
ADD_LIBRARY(kisside STATIC ${KISS_SRCS_CXX})
SET(EXECUTABLE_OUTPUT_PATH ${KISS_SOURCE_DIR}/deploy)
+IF(WIN32)
+SET(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/../prefix/lib)
+ELSE(WIN32)
SET(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/lib)
-TARGET_LINK_LIBRARIES(KISS ${QT_LIBRARIES} qscintilla2 pcompiler kar)
+ENDIF(WIN32)
+
+TARGET_LINK_LIBRARIES(KISS ${QT_LIBRARIES} qscintilla2 pcompiler kar libkovanserial)
+
+IF(WIN32)
+ TARGET_LINK_LIBRARIES(KISS ws2_32)
+ENDIF(WIN32)
IF(APPLE)
ADD_CUSTOM_TARGET(MacDeployQt ALL
View
@@ -0,0 +1,20 @@
+#include <winsock.h>
+#include <windows.h>
+#include <stdio.h>
+
+// Derived from: https://github.com/jamescoxon/dl-fldigi/blob/master/src/compat/mingw.c
+__attribute__((constructor))
+static void wsa_init(void)
+{
+ static int s_init = 0;
+ if (s_init) return;
+
+ WSADATA wsa;
+ if (WSAStartup(MAKEWORD(2, 2), &wsa)) {
+ fprintf(stderr, "ERROR: WSAStartup failed. Code: %d\n", WSAGetLastError());
+ fprintf(stderr, "ERROR: Network communication will not work.\n");
+ }
+
+ atexit((void(*)(void)) WSACleanup);
+ s_init = 1;
+}
@@ -35,5 +35,10 @@ namespace Kiss
}
}
+#define REGISTER_INTERFACE(x) __attribute__((constructor)) \
+static void __##x##_register() \
+{ \
+ InterfaceManager::ref().addInterface(new x()); \
+}
#endif
@@ -49,6 +49,7 @@ namespace Kiss
virtual Base *construct(const QString& apis) const = 0;
virtual Base *_new() const = 0;
+ virtual void _delete(Base *base) const = 0;
virtual QStringList extensions() const = 0;
@@ -62,8 +63,7 @@ namespace Kiss
: m_lexer(lexer),
m_constructor(constructor),
m_apis(lexer)
- {
-
+ {
}
const Constructor *constructor() const
View
@@ -58,6 +58,7 @@ namespace Kiss
namespace Lexer
{
class Constructor;
+ class Base;
}
namespace Widget
@@ -187,6 +188,8 @@ namespace Kiss
void updateLexer();
bool actionPreconditions();
+
+ Kiss::Lexer::Base *m_currentLexer;
};
}
}
@@ -1,57 +0,0 @@
-SET(PLUGIN_NAME computer_interface)
-
-PROJECT(${PLUGIN_NAME})
-cmake_minimum_required(VERSION 2.6.0)
-
-IF(APPLE)
-SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -arch x86_64 -g")
-ENDIF(APPLE)
-
-FIND_PACKAGE(Qt4 REQUIRED)
-
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR} ${QT_INCLUDE_DIR} ${KISS_INCLUDE_DIRS} ../shared)
-
-INCLUDE(${QT_USE_FILE})
-
-FILE(GLOB LOCAL_INCLUDES *.hpp ../shared/*.hpp)
-FILE(GLOB LOCAL_SOURCES *.cpp ../shared/*.cpp)
-
-QT4_WRAP_CPP(INCLUDES_MOC ${LOCAL_INCLUDES})
-
-ADD_DEFINITIONS(${QT_DEFINITIONS})
-ADD_DEFINITIONS(-DQT_PLUGIN)
-ADD_DEFINITIONS(-DQT_DEBUG)
-ADD_DEFINITIONS(-DQT_SHARED)
-ADD_DEFINITIONS(-DQT_DLL)
-
-ADD_LIBRARY(${PLUGIN_NAME} SHARED ${LOCAL_SOURCES} ${INCLUDES_MOC})
-LINK_DIRECTORIES(${LIBRARY_OUTPUT_PATH})
-
-TARGET_LINK_LIBRARIES(${PLUGIN_NAME} ${QT_LIBRARIES} kisside pcompiler easydevice kar)
-
-IF(APPLE)
-SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -headerpad_max_install_names")
-ADD_CUSTOM_TARGET(${PLUGIN_NAME}_osx_install_names ALL
- COMMAND ${OSX_INSTALL_NAMES_SCRIPT} lib${PLUGIN_NAME}.dylib
- QtCore.framework/Versions/4/QtCore
- QtScript.framework/Versions/4/QtScript
- QtDBus.framework/Versions/4/QtDBus
- QtGui.framework/Versions/4/QtGui
- QtNetwork.framework/Versions/4/QtNetwork
- QtXml.framework/Versions/4/QtXml
- QtXmlPatterns.framework/Versions/4/QtXmlPatterns
- QtSvg.framework/Versions/4/QtSvg
- QtSql.framework/Versions/4/QtSql
- QtWebKit.framework/Versions/4/QtWebKit
- phonon.framework/Versions/4/phonon
- QtDeclarative.framework/Versions/4/QtDeclarative
- libkar.dylib
- libpcompiler.dylib
- WORKING_DIRECTORY ${LIBRARY_OUTPUT_PATH}
- DEPENDS ${PLUGIN_NAME})
-INSTALL(TARGETS ${PLUGIN_NAME} LIBRARY DESTINATION ${EXECUTABLE_OUTPUT_PATH}/KISS.app/Contents/interfaces)
-ENDIF(APPLE)
-
-IF(UNIX)
- INSTALL(TARGETS ${PLUGIN_NAME} LIBRARY DESTINATION ${EXECUTABLE_OUTPUT_PATH}/interfaces)
-ENDIF(UNIX)
@@ -1,57 +0,0 @@
-#include "computer_interface.hpp"
-
-#include "tcp_socket_device.hpp"
-
-#include <QProcess>
-#include <QDir>
-#include <QTextStream>
-#include <QDebug>
-
-#include <QTcpSocket>
-#include <QHostAddress>
-#include <QBuffer>
-
-using namespace EasyDevice;
-using namespace Kiss;
-
-ComputerInterface::ComputerInterface()
- : Interface("Computer"),
- m_server(new DiscoveryServer()),
- m_responder(0)
-{
- connect(m_server, SIGNAL(discoveryStarted()), SLOT(scanStarted()));
- connect(m_server,
- SIGNAL(discoveredDevice(EasyDevice::DeviceInfo, const QHostAddress&)),
- SLOT(found(EasyDevice::DeviceInfo, const QHostAddress&)));
-}
-
-ComputerInterface::~ComputerInterface()
-{
- delete m_server;
-}
-
-const bool ComputerInterface::scan(Target::InterfaceResponder *responder)
-{
- m_responder = responder;
- m_server->setup();
- m_server->discover("computer");
- return true;
-}
-
-void ComputerInterface::invalidateResponder()
-{
- m_responder = 0;
-}
-
-void ComputerInterface::scanStarted()
-{
- if(!m_responder) return;
- m_responder->targetScanStarted(this);
-}
-
-void ComputerInterface::found(DeviceInfo deviceInfo, const QHostAddress& address)
-{
- if(!m_responder) return;
-}
-
-Q_EXPORT_PLUGIN2(computer_interface, ComputerInterface);
@@ -1,26 +0,0 @@
-#ifndef _COMPUTER_INTERFACE_HPP_
-#define _COMPUTER_INTERFACE_HPP_
-
-#include <QtPlugin>
-#include "interface.hpp"
-
-class ComputerInterface : public QObject, public Kiss::Target::Interface
-{
-Q_OBJECT
-Q_INTERFACES(Kiss::Target::Interface)
-public:
- ComputerInterface();
- ~ComputerInterface();
-
- virtual const bool scan(Kiss::Target::InterfaceResponder *responder);
- virtual void invalidateResponder();
-
-private slots:
- void scanStarted();
- void found(EasyDevice::DeviceInfo deviceInfo, const QHostAddress& address);
-
-private:
- Kiss::Target::InterfaceResponder *m_responder;
-};
-
-#endif
@@ -28,7 +28,7 @@ ADD_DEFINITIONS(-DQT_DLL)
ADD_LIBRARY(${PLUGIN_NAME} SHARED ${LOCAL_SOURCES} ${INCLUDES_MOC})
LINK_DIRECTORIES(${LIBRARY_OUTPUT_PATH})
-TARGET_LINK_LIBRARIES(${PLUGIN_NAME} ${QT_LIBRARIES} kisside pcompiler kovanserial kar)
+TARGET_LINK_LIBRARIES(${PLUGIN_NAME} kisside pcompiler kovanserial kar ${QT_LIBRARIES})
IF(APPLE)
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -headerpad_max_install_names")
@@ -51,8 +51,7 @@ ADD_CUSTOM_TARGET(${PLUGIN_NAME}_osx_install_names ALL
WORKING_DIRECTORY ${LIBRARY_OUTPUT_PATH}
DEPENDS ${PLUGIN_NAME})
INSTALL(TARGETS ${PLUGIN_NAME} LIBRARY DESTINATION ${EXECUTABLE_OUTPUT_PATH}/KISS.app/Contents/interfaces)
-ENDIF(APPLE)
-
-IF(UNIX)
- INSTALL(TARGETS ${PLUGIN_NAME} LIBRARY DESTINATION ${EXECUTABLE_OUTPUT_PATH}/interfaces)
-ENDIF(UNIX)
+ELSE(APPLE)
+ INSTALL(TARGETS ${PLUGIN_NAME} LIBRARY DESTINATION ${EXECUTABLE_OUTPUT_PATH}/interfaces
+ RUNTIME DESTINATION ${EXECUTABLE_OUTPUT_PATH}/interfaces)
+ENDIF(APPLE)
@@ -30,19 +30,23 @@ AdvertSampler::~AdvertSampler()
void AdvertSampler::run()
{
for(quint16 i = 0; i < m_samples; ++i) {
+ fprintf(stderr, "Sampling...\n");
std::list<IncomingAdvert> adverts = m_advertiser->sample(m_sampleTime);
+ fprintf(stderr, "Sampled!\n");
std::list<IncomingAdvert>::const_iterator it = adverts.begin();
for(; it != adverts.end(); ++it) {
QHostAddress addr((sockaddr *)&(*it).sender);
if(m_found.contains(addr)) continue;
m_found.push_back(addr);
+ fprintf(stderr, "Emitting found\n");
emit found((*it).ad, (*it).sender);
}
}
+ fprintf(stderr, "AdvertSampler::run finished\n");
}
KovanInterface::KovanInterface()
- : Interface("Kovan (Networked)"),
+ : Interface("Network"),
m_advertiser(new UdpAdvertiser(false)),
m_responder(0)
{
@@ -55,6 +59,7 @@ KovanInterface::~KovanInterface()
Kiss::Target::TargetPtr KovanInterface::createTarget(const QString &address)
{
+ fprintf(stderr, "createTarget\n");
// TODO: Add input verification
TcpSerial *serial = new TcpSerial(address.toAscii(), KOVAN_SERIAL_PORT);
KovanProtoTarget *device = new Kiss::Target::KovanProtoTarget(serial, this);
@@ -63,9 +68,11 @@ Kiss::Target::TargetPtr KovanInterface::createTarget(const QString &address)
const bool KovanInterface::scan(InterfaceResponder *responder)
{
+ fprintf(stderr, "scan\n");
m_responder = responder;
m_advertiser->reset();
AdvertSampler *sampler = new AdvertSampler(m_advertiser, 100, 100);
+ sampler->setAutoDelete(true);
qRegisterMetaType<Advert>("Advert");
qRegisterMetaType<sockaddr_in>("sockaddr_in");
connect(sampler, SIGNAL(found(Advert, sockaddr_in)), SLOT(found(Advert, sockaddr_in)));
@@ -75,17 +82,20 @@ const bool KovanInterface::scan(InterfaceResponder *responder)
void KovanInterface::invalidateResponder()
{
+ fprintf(stderr, "invalidateResponder\n");
m_responder = 0;
}
void KovanInterface::scanStarted()
{
+ fprintf(stderr, "scanStarted\n");
if(!m_responder) return;
m_responder->targetScanStarted(this);
}
void KovanInterface::found(const Advert &ad, const sockaddr_in& addr)
{
+ fprintf(stderr, "found\n");
if(!m_responder) return;
QHostAddress ha((sockaddr *)&addr);
@@ -28,7 +28,7 @@ ADD_DEFINITIONS(-DQT_DLL)
ADD_LIBRARY(${PLUGIN_NAME} SHARED ${LOCAL_SOURCES} ${INCLUDES_MOC})
LINK_DIRECTORIES(${LIBRARY_OUTPUT_PATH})
-TARGET_LINK_LIBRARIES(${PLUGIN_NAME} ${QT_LIBRARIES} kisside pcompiler kovanserial kar)
+TARGET_LINK_LIBRARIES(${PLUGIN_NAME} kisside pcompiler kovanserial kar ${QT_LIBRARIES})
IF(APPLE)
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -headerpad_max_install_names")
@@ -51,8 +51,7 @@ ADD_CUSTOM_TARGET(${PLUGIN_NAME}_osx_install_names ALL
WORKING_DIRECTORY ${LIBRARY_OUTPUT_PATH}
DEPENDS ${PLUGIN_NAME})
INSTALL(TARGETS ${PLUGIN_NAME} LIBRARY DESTINATION ${EXECUTABLE_OUTPUT_PATH}/KISS.app/Contents/interfaces)
-ENDIF(APPLE)
-
-IF(UNIX)
- INSTALL(TARGETS ${PLUGIN_NAME} LIBRARY DESTINATION ${EXECUTABLE_OUTPUT_PATH}/interfaces)
-ENDIF(UNIX)
+ELSE(APPLE)
+ INSTALL(TARGETS ${PLUGIN_NAME} LIBRARY DESTINATION ${EXECUTABLE_OUTPUT_PATH}/interfaces
+ RUNTIME DESTINATION ${EXECUTABLE_OUTPUT_PATH}/interfaces)
+ENDIF(APPLE)
@@ -53,7 +53,7 @@ void PortSampler::run()
}
KovanSerialInterface::KovanSerialInterface()
- : Interface("Kovan (Serial)"),
+ : Interface("USB Serial"),
m_responder(0)
{
}
Oops, something went wrong.

0 comments on commit 82e938e

Please sign in to comment.