Skip to content

Commit

Permalink
Added files and scripts to enable Launchpad.net package building
Browse files Browse the repository at this point in the history
  • Loading branch information
projectkk2glider authored and bsongis committed Mar 5, 2017
1 parent d9c95f9 commit 0e90616
Show file tree
Hide file tree
Showing 16 changed files with 705 additions and 34 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
/doc/
build*/
cmake-build-*/
/debian/
12 changes: 10 additions & 2 deletions companion/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
set(SIMULATOR_INSTALL_PREFIX "" CACHE STRING "Alternative simulator library search path")

if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(C9X_NAME_SUFFIX ${VERSION_MAJOR}${VERSION_MINOR})
set(COMPANION_NAME "companion${C9X_NAME_SUFFIX}")
set(SIMULATOR_NAME "simulator${C9X_NAME_SUFFIX}")
set(SIMULATOR_LIB_PATH ${CMAKE_INSTALL_PREFIX}/lib/companion${C9X_NAME_SUFFIX})
if (NOT ${SIMULATOR_INSTALL_PREFIX} STREQUAL "")
set(SIMULATOR_LIB_PATH ${SIMULATOR_INSTALL_PREFIX}/lib/companion${C9X_NAME_SUFFIX})
else()
set(SIMULATOR_LIB_PATH ${CMAKE_INSTALL_PREFIX}/lib/companion${C9X_NAME_SUFFIX})
endif()
message(STATUS "Simulators library search path: " ${SIMULATOR_LIB_PATH})
set(SIMULATOR_LIB_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/lib/companion${C9X_NAME_SUFFIX})
else(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(COMPANION_NAME "companion")
set(SIMULATOR_NAME "simulator")
Expand Down Expand Up @@ -318,7 +326,7 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
message(STATUS "install " ${CMAKE_BINARY_DIR} " to " ${CMAKE_INSTALL_PREFIX}/bin)
install(TARGETS ${COMPANION_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
install(TARGETS ${SIMULATOR_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
install(FILES ${simulator_plugins} DESTINATION "${SIMULATOR_LIB_PATH}")
install(FILES ${simulator_plugins} DESTINATION "${SIMULATOR_LIB_INSTALL_PATH}")
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/companion.desktop DESTINATION share/applications RENAME companion${C9X_NAME_SUFFIX}.desktop)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/simulator.desktop DESTINATION share/applications RENAME simulator${C9X_NAME_SUFFIX}.desktop)
if(${CMAKE_INSTALL_PREFIX} MATCHES "/usr/local")
Expand Down
61 changes: 31 additions & 30 deletions companion/src/simulation/simulatorinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,30 +32,25 @@

QMap<QString, SimulatorFactory *> registered_simulators;

void registerSimulatorFactory(SimulatorFactory *factory)
{
qDebug() << "registering" << factory->name() << "simulator";
registered_simulators[factory->name()] = factory;
}

void registerSimulator(const QString &filename)
void registerSimulator(const QString & filename)
{
QLibrary lib(filename);
typedef SimulatorFactory * (*RegisterSimulator)();
RegisterSimulator registerSimulator = (RegisterSimulator)lib.resolve("registerSimu");
if (registerSimulator) {
SimulatorFactory * factory = registerSimulator();
registerSimulatorFactory(factory);
qDebug() << "trying to register simulator in " << filename;
RegisterSimulator registerFunc = (RegisterSimulator)lib.resolve("registerSimu");
if (registerFunc) {
SimulatorFactory * factory = registerFunc();
registered_simulators[factory->name()] = factory;
qDebug() << "Registered" << factory->name() << "simulator";
}
else {
qWarning() << "Library error" << filename << lib.errorString();
}
}

void registerSimulators()
int registerSimulators(const QDir & dir)
{
bool simulatorsFound = false;
QDir dir(".");
int noSimulatorsFound = 0;
QStringList filters;
#if defined(__APPLE__)
filters << "*-simulator.dylib";
Expand All @@ -65,28 +60,34 @@ void registerSimulators()
filters << "*-simulator.so";
#endif

qDebug() << "Searching for simulators in" << dir.path();
foreach(QString filename, dir.entryList(filters, QDir::Files)) {
registerSimulator(filename.prepend("./"));
simulatorsFound = true;
QString libraryFilename = dir.path() + "/" + filename;
registerSimulator(libraryFilename);
noSimulatorsFound++;
}
return noSimulatorsFound;
}

void registerSimulators()
{
QDir dir(".");
if (registerSimulators(dir)) {
return;
}

if (!simulatorsFound) {
#if defined(__APPLE__)
dir = QLibraryInfo::location(QLibraryInfo::PrefixPath) + "/Resources";
#elif (!defined __GNUC__)
char name[MAX_PATH];
GetModuleFileName(NULL, name, MAX_PATH);
QString path(name);
path.truncate(path.lastIndexOf('\\'));
dir.setPath(path);
dir = QLibraryInfo::location(QLibraryInfo::PrefixPath) + "/Resources";
#elif (!defined __GNUC__)
char name[MAX_PATH];
GetModuleFileName(NULL, name, MAX_PATH);
QString path(name);
path.truncate(path.lastIndexOf('\\'));
dir.setPath(path);
#else
dir = SIMULATOR_LIB_SEARCH_PATH;
dir = SIMULATOR_LIB_SEARCH_PATH;
#endif
foreach(QString filename, dir.entryList(filters, QDir::Files)) {
registerSimulator(filename.prepend(dir.path() + "/"));
simulatorsFound = true;
}
}
registerSimulators(dir);
}

SimulatorFactory * getSimulatorFactory(const QString & name)
Expand Down
2 changes: 1 addition & 1 deletion jenkins/get-from-server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -e
set -x

# in this file define ssh options (like private key)
source ./settings.sh
source ~/.opentx-jenkins-settings

function download() {
# $1 is release directory name
Expand Down
2 changes: 1 addition & 1 deletion jenkins/upload-to-server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -e
set -x

# in this file define ssh options (like private key)
source ./settings.sh
source ~/.opentx-jenkins-settings

function upload() {
# $1 is release directory name
Expand Down
1 change: 1 addition & 0 deletions launchpad/common/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/suffix
21 changes: 21 additions & 0 deletions launchpad/common/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Source: opentx-companion22
Section: utils
Priority: optional
Maintainer: projectkk2glider <[email protected]>
Build-Depends: cmake,
build-essential,
python,
python-qt4,
qt5-default,
qttools5-dev-tools,
qtmultimedia5-dev,
qttools5-dev,
libsdl1.2-dev,
libqt5svg5-dev
Homepage: http://www.open-tx.org/

Package: opentx-companion22
Architecture: any
Depends: ${shlibs:Depends}
Description: OpenTX Companion
Models and settings editor for the OpenTX open source firmware
Loading

0 comments on commit 0e90616

Please sign in to comment.