Skip to content

Commit

Permalink
Merge pull request #2288 from srcejon/android_fixes
Browse files Browse the repository at this point in the history
Fix Android build
  • Loading branch information
f4exb authored Oct 22, 2024
2 parents f6f2d9b + 66247ec commit ed89eea
Show file tree
Hide file tree
Showing 21 changed files with 125 additions and 68 deletions.
25 changes: 16 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ set(INSTALL_PLUGINSSRV_DIR "${INSTALL_LIB_DIR}/pluginssrv")
if(ANDROID)
set(PLUGINS_PREFIX "sdrangel_plugins_")
set(PLUGINSSRV_PREFIX "sdrangel_pluginssrv_")
set(ANDROID_PACKAGE_SOURCE_DIR ${PROJECT_SOURCE_DIR}/android/qt6 CACHE INTERNAL "")
else()
set(PLUGINS_PREFIX "")
set(PLUGINSSRV_PREFIX "")
Expand Down Expand Up @@ -428,7 +429,7 @@ elseif (WIN32)
elseif(ANDROID)
set(EXTERNAL_LIBRARY_FOLDER "${CMAKE_SOURCE_DIR}/external/android")

set(Boost_INCLUDE_DIR "${EXTERNAL_LIBRARY_FOLDER}/ndk_21_boost_1.72.0/include" CACHE INTERNAL "")
set(Boost_INCLUDE_DIR "${EXTERNAL_LIBRARY_FOLDER}/ndk_26b_boost_1.83.0/include" CACHE INTERNAL "")

set(FFTW3F_FOUND ON CACHE INTERNAL "")
set(FFTW3F_INCLUDE_DIRS "${EXTERNAL_LIBRARY_FOLDER}/${ANDROID_ABI}/fftw-3/include" CACHE INTERNAL "")
Expand Down Expand Up @@ -485,6 +486,14 @@ elseif(ANDROID)
set(SWSCALE_INCLUDE_DIRS "${EXTERNAL_LIBRARY_FOLDER}/${ANDROID_ABI}/ffmpeg/include" CACHE INTERNAL "")
set(SWSCALE_LIBRARIES "${EXTERNAL_LIBRARY_FOLDER}/${ANDROID_ABI}/ffmpeg/lib/libswscale.so" CACHE INTERNAL "")

set(GGMORSE_FOUND ON CACHE INTERNAL "")
set(GGMORSE_INCLUDE_DIR "${EXTERNAL_LIBRARY_FOLDER}/${ANDROID_ABI}/ggmorse/include/" CACHE INTERNAL "")
set(GGMORSE_LIBRARIES "${EXTERNAL_LIBRARY_FOLDER}/${ANDROID_ABI}/ggmorse/lib/static/libggmorse.a" CACHE INTERNAL "")

set(FLAC_FOUND ON CACHE INTERNAL "")
set(FLAC_INCLUDE_DIR "${EXTERNAL_LIBRARY_FOLDER}/${ANDROID_ABI}/flac/include/" CACHE INTERNAL "")
set(FLAC_LIBRARIES "${EXTERNAL_LIBRARY_FOLDER}/${ANDROID_ABI}/flac/lib/libFLAC.so" CACHE INTERNAL "")

set(LIBUSB_FOUND ON CACHE INTERNAL "")
set(LIBUSB_INCLUDE_DIR "${EXTERNAL_LIBRARY_FOLDER}/${ANDROID_ABI}/libusb/include/" CACHE INTERNAL "")
set(LIBUSB_LIBRARIES "${EXTERNAL_LIBRARY_FOLDER}/${ANDROID_ABI}/libusb/lib/libusb1.0.so" CACHE INTERNAL "")
Expand All @@ -507,11 +516,6 @@ elseif(ANDROID)

if (ENABLE_QT6)
set(ANDROID_EXTRA_LIBS
${Qt6_DIR}/../../../android_arm64_v8a/lib/libQt6Charts_arm64-v8a.so
${Qt6_DIR}/../../../android_arm64_v8a/lib/libQt6Concurrent_arm64-v8a.so
${Qt6_DIR}/../../../android_arm64_v8a/lib/libQt6MultimediaWidgets_arm64-v8a.so
${Qt6_DIR}/../../../android_arm64_v8a/lib/libQt6SerialPort_arm64-v8a.so
${Qt6_DIR}/../../../android_arm64_v8a/lib/libQt6TextToSpeech_arm64-v8a.so
${EXTERNAL_LIBRARY_FOLDER}/android_openssl/latest/arm64/libssl_1_1.so
${EXTERNAL_LIBRARY_FOLDER}/android_openssl/latest/arm64/libcrypto_1_1.so
${EXTERNAL_LIBRARY_FOLDER}/${ANDROID_ABI}/ffmpeg/lib/libavcodec.so
Expand All @@ -526,6 +530,7 @@ elseif(ANDROID)
${EXTERNAL_LIBRARY_FOLDER}/${ANDROID_ABI}/dsdcc/lib/libdsdcc.so
${EXTERNAL_LIBRARY_FOLDER}/${ANDROID_ABI}/libusb/lib/libunrooted_android.so
${EXTERNAL_LIBRARY_FOLDER}/${ANDROID_ABI}/libusb/lib/libusb1.0.so
${EXTERNAL_LIBRARY_FOLDER}/${ANDROID_ABI}/flac/lib/libFLAC.so
CACHE INTERNAL ""
)
else()
Expand Down Expand Up @@ -576,6 +581,7 @@ elseif(ANDROID)
${EXTERNAL_LIBRARY_FOLDER}/arm64-v8a/dsdcc/lib/libdsdcc.so
${EXTERNAL_LIBRARY_FOLDER}/arm64-v8a/libusb/lib/libunrooted_android.so
${EXTERNAL_LIBRARY_FOLDER}/arm64-v8a/libusb/lib/libusb1.0.so
${EXTERNAL_LIBRARY_FOLDER}/arm64-v8a/flac/lib/libFLAC.so
${EXTERNAL_LIBRARY_FOLDER}/armeabi-v7a/ffmpeg/lib/libavcodec.so
${EXTERNAL_LIBRARY_FOLDER}/armeabi-v7a/ffmpeg/lib/libavdevice.so
${EXTERNAL_LIBRARY_FOLDER}/armeabi-v7a/ffmpeg/lib/libavfilter.so
Expand All @@ -588,6 +594,7 @@ elseif(ANDROID)
${EXTERNAL_LIBRARY_FOLDER}/armeabi-v7a/dsdcc/lib/libdsdcc.so
${EXTERNAL_LIBRARY_FOLDER}/armeabi-v7a/libusb/lib/libunrooted_android.so
${EXTERNAL_LIBRARY_FOLDER}/armeabi-v7a/libusb/lib/libusb1.0.so
${EXTERNAL_LIBRARY_FOLDER}/armeabi-v7a/flac/lib/libFLAC.so
CACHE INTERNAL ""
)
endif()
Expand Down Expand Up @@ -650,8 +657,7 @@ if(ENABLE_QT6)
MultimediaWidgets
Positioning
Charts
SerialPort
Core5Compat)
SerialPort)
else()
find_package(Qt5 5.15
REQUIRED COMPONENTS
Expand Down Expand Up @@ -679,7 +685,8 @@ if (BUILD_GUI)
QuickWidgets
TextToSpeech
Svg
SvgWidgets)
SvgWidgets
StateMachine)
else()
find_package(Qt5
REQUIRED COMPONENTS
Expand Down
5 changes: 0 additions & 5 deletions app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
///////////////////////////////////////////////////////////////////////////////////

#include <QApplication>
#include <QTextCodec>
#include <QProxyStyle>
#include <QStyleFactory>
#include <QFontDatabase>
Expand All @@ -48,10 +47,6 @@

static int runQtApplication(int argc, char* argv[], qtwebapp::LoggerWithFile *logger)
{
/*
QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
*/
QCoreApplication::setOrganizationName(COMPANY);
QCoreApplication::setApplicationName(APPLICATION_NAME);
QCoreApplication::setApplicationVersion(SDRANGEL_VERSION);
Expand Down
8 changes: 4 additions & 4 deletions plugins/channelrx/demodpager/pagerdemodgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <QDockWidget>
#include <QDebug>
#include <QAction>
#include <QRegExp>
#include <QRegularExpression>
#include <QClipboard>
#include <QFileDialog>
#include <QMessageBox>
Expand Down Expand Up @@ -433,15 +433,15 @@ void PagerDemodGUI::filterRow(int row)
bool hidden = false;
if (m_settings.m_filterAddress != "")
{
QRegExp re(m_settings.m_filterAddress);
QRegularExpression re(QRegularExpression::anchoredPattern(m_settings.m_filterAddress));
QTableWidgetItem *fromItem = ui->messages->item(row, PagerDemodSettings::MESSAGE_COL_ADDRESS);
if (!re.exactMatch(fromItem->text())) {
QRegularExpressionMatch match = re.match(fromItem->text());
if (!match.hasMatch()) {
hidden = true;
}
}
ui->messages->setRowHidden(row, hidden);
}

void PagerDemodGUI::filter()
{
for (int i = 0; i < ui->messages->rowCount(); i++) {
Expand Down
14 changes: 10 additions & 4 deletions plugins/feature/antennatools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,17 @@ else()
set(INSTALL_FOLDER ${INSTALL_PLUGINSSRV_DIR})
endif()

add_library(${TARGET_NAME} SHARED
${antennatools_SOURCES}
)
if(NOT Qt6_FOUND)
add_library(${TARGET_NAME} ${antennatools_SOURCES})
else()
qt_add_plugin(${TARGET_NAME} CLASS_NAME AntennaToolsPlugin ${antennatools_SOURCES})
endif()

if(NOT BUILD_SHARED_LIBS)
set_property(GLOBAL APPEND PROPERTY STATIC_PLUGINS_PROPERTY ${TARGET_NAME})
endif()

target_link_libraries(${TARGET_NAME}
target_link_libraries(${TARGET_NAME} PRIVATE
Qt::Core
${TARGET_LIB}
sdrbase
Expand Down
3 changes: 3 additions & 0 deletions plugins/feature/limerfe/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ target_link_libraries(${TARGET_NAME} PRIVATE
${TARGET_LIB_GUI}
${LIMESUITE_LIBRARY}
)
if(ANDROID)
target_link_libraries(${TARGET_NAME} PRIVATE ${LIBUSB_LIBRARIES} log)
endif()

install(TARGETS ${TARGET_NAME} DESTINATION ${INSTALL_FOLDER})

Expand Down
3 changes: 2 additions & 1 deletion plugins/feature/map/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ if(NOT SERVER_MODE)
set(TARGET_LIB ${TARGET_LIB} Qt::WebEngine Qt::WebEngineCore Qt::WebEngineWidgets)
elseif(Qt${QT_DEFAULT_MAJOR_VERSION}WebEngineCore_FOUND)
set(TARGET_LIB ${TARGET_LIB} Qt::SvgWidgets Qt::WebEngineCore Qt::WebEngineWidgets)
else()
elseif(Qt6_FOUND)
# Not on Qt5 Android?
set(TARGET_LIB ${TARGET_LIB} Qt::SvgWidgets)
endif()
else()
Expand Down
1 change: 1 addition & 0 deletions plugins/feature/map/mapsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ void MapSettings::resetToDefaults()
m_displayfoF2 = false;
m_displayRain = false;
m_displayClouds = false;
m_displayRailways = false;
m_displaySeaMarks = false;
m_displayNASAGlobalImagery = false;
m_nasaGlobalImageryIdentifier = "";
Expand Down
43 changes: 22 additions & 21 deletions plugins/feature/pertester/pertesterworker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <QNetworkDatagram>
#include <QEventLoop>
#include <QTimer>
#include <QRegExp>
#include <QRegularExpression>

#include "util/ax25.h"

Expand Down Expand Up @@ -205,54 +205,55 @@ void PERTesterWorker::rx()

void PERTesterWorker::tx()
{
QRegExp ax25Dst("^%\\{ax25\\.dst=([A-Za-z0-9-]+)\\}");
QRegExp ax25Src("^%\\{ax25\\.src=([A-Za-z0-9-]+)\\}");
QRegExp num("^%\\{num\\}");
QRegExp data("^%\\{data=([0-9]+),([0-9]+)\\}");
QRegExp hex("^(0x)?([0-9a-fA-F]?[0-9a-fA-F])");
QRegularExpression ax25Dst("^%\\{ax25\\.dst=([A-Za-z0-9-]+)\\}");
QRegularExpression ax25Src("^%\\{ax25\\.src=([A-Za-z0-9-]+)\\}");
QRegularExpression num("^%\\{num\\}");
QRegularExpression data("^%\\{data=([0-9]+),([0-9]+)\\}");
QRegularExpression hex("^(0x)?([0-9a-fA-F]?[0-9a-fA-F])");
QRegularExpressionMatch match;
QByteArray bytes;
int pos = 0;

while (pos < m_settings.m_packet.size())
{
if (m_settings.m_packet[pos] == '%')
{
if (ax25Dst.indexIn(m_settings.m_packet, pos, QRegExp::CaretAtOffset) != -1)
if ((match = ax25Dst.match(m_settings.m_packet, pos, QRegularExpression::NormalMatch, QRegularExpression::AnchoredMatchOption)).hasMatch())
{
// AX.25 destination callsign & SSID
QString address = ax25Dst.capturedTexts()[1];
QString address = match.captured(1);
bytes.append(AX25Packet::encodeAddress(address));
pos += ax25Dst.matchedLength();
pos += match.capturedLength();
}
else if (ax25Src.indexIn(m_settings.m_packet, pos, QRegExp::CaretAtOffset) != -1)
else if ((match = ax25Src.match(m_settings.m_packet, pos, QRegularExpression::NormalMatch, QRegularExpression::AnchoredMatchOption)).hasMatch())
{
// AX.25 source callsign & SSID
QString address = ax25Src.capturedTexts()[1];
QString address = match.captured(1);
bytes.append(AX25Packet::encodeAddress(address, 1));
pos += ax25Src.matchedLength();
pos += match.capturedLength();
}
else if (num.indexIn(m_settings.m_packet, pos, QRegExp::CaretAtOffset) != -1)
else if ((match = num.match(m_settings.m_packet, pos, QRegularExpression::NormalMatch, QRegularExpression::AnchoredMatchOption)).hasMatch())
{
// Big endian packet number
bytes.append((m_tx >> 24) & 0xff);
bytes.append((m_tx >> 16) & 0xff);
bytes.append((m_tx >> 8) & 0xff);
bytes.append(m_tx & 0xff);
pos += num.matchedLength();
pos += match.capturedLength();
}
else if (data.indexIn(m_settings.m_packet, pos, QRegExp::CaretAtOffset) != -1)
else if ((match = data.match(m_settings.m_packet, pos, QRegularExpression::NormalMatch, QRegularExpression::AnchoredMatchOption)).hasMatch())
{
// Constrained random number of random bytes
int minBytes = data.capturedTexts()[1].toInt();
int maxBytes = data.capturedTexts()[2].toInt();
int minBytes = match.captured(1).toInt();
int maxBytes = match.captured(2).toInt();
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<> distr0(minBytes, maxBytes);
std::uniform_int_distribution<> distr1(0, 255);
int count = distr0(gen);
for (int i = 0; i < count; i++)
bytes.append(distr1(gen));
pos += data.matchedLength();
pos += match.capturedLength();
}
else
{
Expand All @@ -278,12 +279,12 @@ void PERTesterWorker::tx()
break;
}
}
else if (hex.indexIn(m_settings.m_packet, pos, QRegExp::CaretAtOffset) != -1)
else if ((match = hex.match(m_settings.m_packet, pos, QRegularExpression::NormalMatch, QRegularExpression::AnchoredMatchOption)).hasMatch())
{
// Hex byte
int value = hex.capturedTexts()[2].toInt(nullptr, 16);
int value = match.captured(2).toInt(nullptr, 16);
bytes.append(value);
pos += hex.matchedLength();
pos += match.capturedLength();
}
else if ((m_settings.m_packet[pos] == ' ') || (m_settings.m_packet[pos] == ',') || (m_settings.m_packet[pos] == ':'))
{
Expand Down
3 changes: 0 additions & 3 deletions plugins/feature/satellitetracker/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,6 @@ target_link_libraries(${TARGET_NAME} PRIVATE
${TARGET_LIB_GUI}
${SGP4_LIBRARIES}
)
if (Qt6_FOUND)
target_link_libraries(${TARGET_NAME} PRIVATE Qt::Core5Compat)
endif()

install(TARGETS ${TARGET_NAME} DESTINATION ${INSTALL_FOLDER})

Expand Down
2 changes: 1 addition & 1 deletion plugins/samplesource/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ add_subdirectory(audioinput)
add_subdirectory(kiwisdr)
add_subdirectory(remotetcpinput)

if(ENABLE_AARONIARTSA)
if(ENABLE_AARONIARTSA AND NOT ANDROID)
add_subdirectory(aaroniartsainput)
else()
message(STATUS "Not building aaroniartsainput (ENABLE_AARONIARTSA=${ENABLE_AARONIARTSA})")
Expand Down
2 changes: 1 addition & 1 deletion plugins/samplesource/androidsdrdriverinput/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ target_link_libraries(${TARGET_NAME} PRIVATE
swagger
)
if(NOT ENABLE_QT6 AND ANDROID)
target_link_libraries(${TARGET_NAME} Qt::AndroidExtras)
target_link_libraries(${TARGET_NAME} PRIVATE Qt::AndroidExtras)
endif()

install(TARGETS ${TARGET_NAME} DESTINATION ${INSTALL_FOLDER})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "SWGDeviceReport.h"
#include "SWGAndroidSDRDriverInputReport.h"

#include "util/android.h"
#include "util/simpleserializer.h"
#include "dsp/dspcommands.h"
#include "device/deviceapi.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <QRecursiveMutex>
#include <QDateTime>

#include "util/message.h"
#include "util/messagequeue.h"
#include "util/message.h"
#include "androidsdrdriverinputsettings.h"
Expand Down
3 changes: 3 additions & 0 deletions plugins/samplesource/fileinput/fileinputworker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
#include <stdio.h>
#include <errno.h>
#include <QDebug>
#ifdef ANDROID
#include <QFile>
#endif

#include "fileinputworker.h"
#include "dsp/samplesinkfifo.h"
Expand Down
3 changes: 3 additions & 0 deletions plugins/samplesource/limesdrinput/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ target_link_libraries(${TARGET_NAME} PRIVATE
${LIMESUITE_LIBRARY}
limesdrdevice
)
if(ANDROID)
target_link_libraries(${TARGET_NAME} PRIVATE ${LIBUSB_LIBRARIES} log)
endif()

install(TARGETS ${TARGET_NAME} DESTINATION ${INSTALL_FOLDER})

Expand Down
2 changes: 1 addition & 1 deletion plugins/samplesource/rtlsdr/rtlsdrinput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ bool RTLSDRInput::openDevice()
qCritical("RTLSDRInput::openDevice: could not open USB device %s", qPrintable(m_deviceAPI->getSamplingDeviceSerial()));
return false;
}
if ((res = rtlsdr_open_fd(&m_dev, fd)) < 0)
if ((rtlsdr_open_fd(&m_dev, fd)) < 0)
{
qCritical("RTLSDRInput::openDevice: could not open RTLSDR: %s", strerror(errno));
return false;
Expand Down
1 change: 0 additions & 1 deletion sdrbase/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,6 @@ if (LIBSIGMF_FOUND)
endif()
if (Qt6_FOUND)
target_link_libraries(sdrbase
Qt::Core5Compat
Qt::CorePrivate
)
endif()
Expand Down
Loading

0 comments on commit ed89eea

Please sign in to comment.