Commit 0e5bf481 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

Make it possible to build with cmake

Summary:
Introduces a CMake-based build system that is compatible with
binary-factory.kde.org and works like the rest of KDE applications.
It doesn't make use of the taglib here but fetches the sources on build
time on android. For other platforms it will look for the dependency in
the system like the rest of depedencencies.

Test Plan: Can build both using cmake and qmake on linux and android.

Reviewers: camiloh

Reviewed By: camiloh

Differential Revision: https://phabricator.kde.org/D12286
parent cefafbf9
project(kalgebra)
cmake_minimum_required(VERSION 3.0)
find_package(ECM 1.7.0 REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${ECM_MODULE_PATH})
find_package(Qt5 REQUIRED NO_MODULE COMPONENTS Qml Quick Network WebSockets Sql QuickControls2 Xml Multimedia Widgets)
include(KDEInstallDirs)
include(KDECompilerSettings NO_POLICY_SCOPE)
include(KDECMakeSettings)
include(ECMInstallIcons)
include(FeatureSummary)
include(ECMAddAppIcon)
set(CMAKE_AUTORCC ON)
add_executable(vvave
qml.qrc
main.cpp
babe.cpp
pulpo/services/geniusService.cpp
pulpo/services/deezerService.cpp
pulpo/services/lastfmService.cpp
pulpo/services/lyricwikiaService.cpp
pulpo/services/spotifyService.cpp
pulpo/services/musicbrainzService.cpp
pulpo/pulpo.cpp
pulpo/htmlparser.cpp
services/local/taginfo.cpp
services/local/player.cpp
services/local/youtubedl.cpp
services/local/linking.cpp
services/local/socket.cpp
services/web/babeit.cpp
services/web/youtube.cpp
db/conthread.cpp
db/collectionDB.cpp
settings/BabeSettings.cpp
settings/fileloader.cpp
utils/brain.cpp
utils/babeconsole.cpp
)
if (ANDROID)
find_package(Qt5 REQUIRED COMPONENTS AndroidExtras WebView)
include(ExternalProject)
externalproject_add(taglib
URL http://taglib.org/releases/taglib-1.11.1.tar.gz
CMAKE_ARGS -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
)
set(TAGLIB_INCLUDE_DIRS ${CMAKE_INSTALL_PREFIX}/include ${CMAKE_INSTALL_PREFIX}/include/taglib)
find_library(TAGLIB_LIBRARIES tag PATHS ${LIB_INSTALL_DIR})
target_sources(vvave PRIVATE
android/android.cpp
android/notificationclient.cpp
android.qrc
)
target_link_libraries(vvave Qt5::AndroidExtras Qt5::WebView)
kde_source_files_enable_exceptions(vvave android/android.cpp android/notificationclient.cpp babe.cpp)
else()
find_package(Taglib REQUIRED)
find_package(Qt5 REQUIRED COMPONENTS WebEngine)
find_package(KF5 ${KF5_VERSION} REQUIRED COMPONENTS I18n Notifications Config)
target_sources(vvave PRIVATE
kde/kdeconnect.cpp
kde/mpris2.cpp
kde/notify.cpp
)
target_link_libraries(vvave Qt5::WebEngine KF5::ConfigCore KF5::Notifications KF5::I18n)
endif()
target_include_directories(vvave PRIVATE ${TAGLIB_INCLUDE_DIRS})
target_link_libraries(vvave Qt5::Network Qt5::Sql Qt5::WebSockets Qt5::Qml Qt5::Xml Qt5::Multimedia Qt5::Widgets ${TAGLIB_LIBRARIES})
install(TARGETS vvave ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
# install(FILES org.kde.vvave.appdata.xml DESTINATION ${KDE_INSTALL_METAINFODIR})
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
<?xml version="1.0"?>
<manifest package="org.qtproject.babe" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.0" android:versionCode="1" android:installLocation="auto">
<manifest package="org.kde.vvave" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.0" android:versionCode="1" android:installLocation="auto">
<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="-- %%INSERT_APP_NAME%% --" android:icon="@drawable/icon">
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation" android:name="org.qtproject.qt5.android.bindings.QtActivity" android:label="-- %%INSERT_APP_NAME%% --" android:screenOrientation="unspecified" android:launchMode="singleTop">
android:name="com.example.android.tools.NotificationClient"
......@@ -13,7 +13,7 @@
<!-- Application arguments -->
<meta-data android:name="android.app.lib_name" android:value="-- %%INSERT_APP_LIB_NAME%% --"/>
<meta-data android:name="android.app.lib_name" android:value="vvave"/>
<meta-data android:name="android.app.qt_sources_resource_id" android:resource="@array/qt_sources"/>
<meta-data android:name="android.app.repository" android:value="default"/>
<meta-data android:name="android.app.qt_libs_resource_id" android:resource="@array/qt_libs"/>
......@@ -79,7 +79,7 @@
-->
<!-- Application to launch -->
<meta-data android:name="android.app.lib_name" android:value="-- %%INSERT_APP_LIB_NAME%% --"/>
<meta-data android:name="android.app.lib_name" android:value="vvave"/>
<!-- Application to launch -->
<!-- Ministro -->
......
## This file is automatically generated by QtCreator.
#
# This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
androidBuildToolsVersion=26.0.2
androidCompileSdkVersion=26
buildDir=.build
qt5AndroidDir=/home/camilo/Qt/5.10.1/android_armv7/src/android/java
......@@ -7,18 +7,18 @@
#include "utils/babeconsole.h"
#include <QPalette>
#include <QWidget>
#include <QColor>
#include <QIcon>
#include <QApplication>
#include <QDesktopWidget>
#include <QGuiApplication>
#include <QDirIterator>
#include <QtQml>
#include <QDesktopServices>
#include <QCursor>
//#include "Python.h"
#if (defined (Q_OS_LINUX) && !defined (Q_OS_ANDROID))
#include <QWidget>
#include "kde/notify.h"
#include "kde/kdeconnect.h"
#endif
......@@ -680,7 +680,7 @@ bool Babe::isMobile()
int Babe::screenGeometry(QString side)
{
side = side.toLower();
auto geo = QApplication::desktop()->screenGeometry();
auto geo = QGuiApplication::primaryScreen()->geometry();
if(side == "width")
return geo.width();
......@@ -892,6 +892,8 @@ QVariantList Babe::getDevices()
{
#if (defined (Q_OS_LINUX) && !defined (Q_OS_ANDROID))
return KdeConnect::getDevices();
#else
return {};
#endif
}
......@@ -899,6 +901,8 @@ bool Babe::sendToDevice(const QString &name, const QString &id, const QString &u
{
#if (defined (Q_OS_LINUX) && !defined (Q_OS_ANDROID))
return KdeConnect::sendToDevice(name, id, url) ? true : false;
#else
return {};
#endif
}
......
# - Try to find the Taglib library
# Once done this will define
#
# TAGLIB_FOUND - system has the taglib library
# TAGLIB_CFLAGS - the taglib cflags
# TAGLIB_LIBRARIES - The libraries needed to use taglib
# Copyright (c) 2006, Laurent Montel, <montel@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
if(NOT TAGLIB_MIN_VERSION)
set(TAGLIB_MIN_VERSION "1.7")
endif()
if(NOT WIN32)
find_program(TAGLIBCONFIG_EXECUTABLE
NAMES taglib-config
PATHS ${BIN_INSTALL_DIR}
)
endif()
#reset vars
set(TAGLIB_LIBRARIES)
set(TAGLIB_CFLAGS)
# if taglib-config has been found
if(TAGLIBCONFIG_EXECUTABLE)
exec_program(${TAGLIBCONFIG_EXECUTABLE} ARGS --version RETURN_VALUE _return_VALUE OUTPUT_VARIABLE TAGLIB_VERSION)
if(TAGLIB_VERSION VERSION_LESS "${TAGLIB_MIN_VERSION}")
message(STATUS "TagLib version too old: version searched :${TAGLIB_MIN_VERSION}, found ${TAGLIB_VERSION}")
set(TAGLIB_FOUND FALSE)
else()
exec_program(${TAGLIBCONFIG_EXECUTABLE} ARGS --libs RETURN_VALUE _return_VALUE OUTPUT_VARIABLE TAGLIB_LIBRARIES)
exec_program(${TAGLIBCONFIG_EXECUTABLE} ARGS --cflags RETURN_VALUE _return_VALUE OUTPUT_VARIABLE TAGLIB_CFLAGS)
if(TAGLIB_LIBRARIES AND TAGLIB_CFLAGS)
set(TAGLIB_FOUND TRUE)
endif()
string(REGEX REPLACE " *-I" ";" TAGLIB_INCLUDE_DIRS "${TAGLIB_CFLAGS}")
string(SUBSTRING ${TAGLIB_INCLUDE_DIRS} 0 -1 TAGLIB_INCLUDE_DIRS) #we remove the initial ;
endif()
mark_as_advanced(TAGLIB_CFLAGS TAGLIB_LIBRARIES TAGLIB_INCLUDES)
else()
find_path(TAGLIB_INCLUDE_DIRS
NAMES tag.h
PATH_SUFFIXES taglib
PATHS ${INCLUDE_INSTALL_DIR}
)
if(NOT WIN32)
# on non-win32 we don't need to take care about WIN32_DEBUG_POSTFIX
find_library(TAGLIB_LIBRARIES tag PATHS ${LIB_INSTALL_DIR})
else()
# 1. get all possible libnames
set(args PATHS ${LIB_INSTALL_DIR})
set(newargs "")
set(libnames_release "")
set(libnames_debug "")
list(LENGTH args listCount)
# just one name
list(APPEND libnames_release "tag")
list(APPEND libnames_debug "tagd")
set(newargs ${args})
# search the release lib
find_library(TAGLIB_LIBRARIES_RELEASE
NAMES ${libnames_release}
${newargs}
)
# search the debug lib
find_library(TAGLIB_LIBRARIES_DEBUG
NAMES ${libnames_debug}
${newargs}
)
if(TAGLIB_LIBRARIES_RELEASE AND TAGLIB_LIBRARIES_DEBUG)
# both libs found
set(TAGLIB_LIBRARIES optimized ${TAGLIB_LIBRARIES_RELEASE}
debug ${TAGLIB_LIBRARIES_DEBUG}
)
else()
if(TAGLIB_LIBRARIES_RELEASE)
# only release found
set(TAGLIB_LIBRARIES ${TAGLIB_LIBRARIES_RELEASE})
else()
# only debug (or nothing) found
set(TAGLIB_LIBRARIES ${TAGLIB_LIBRARIES_DEBUG})
endif()
endif()
mark_as_advanced(TAGLIB_LIBRARIES_RELEASE)
mark_as_advanced(TAGLIB_LIBRARIES_DEBUG)
endif()
include(FindPackageMessage)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Taglib DEFAULT_MSG TAGLIB_INCLUDE_DIRS_ TAGLIB_LIBRARIES)
endif()
if(TAGLIB_FOUND)
if(NOT Taglib_FIND_QUIETLY AND TAGLIBCONFIG_EXECUTABLE)
message(STATUS "Taglib found: ${TAGLIB_LIBRARIES}")
endif()
else()
if(Taglib_FIND_REQUIRED)
message(FATAL_ERROR "Could not find Taglib")
endif()
endif()
......@@ -6,12 +6,11 @@
#include "babe.h"
#include "services/local/player.h"
#include <QLibrary>
#include <QQuickStyle>
// #include <QQuickStyle>
#include <QStyleHints>
#include "services/local/linking.h"
#ifdef Q_OS_ANDROID
#include "./3rdparty/kirigami/src/kirigamiplugin.h"
#include <QtWebView/QtWebView>
#else
#include <QtWebEngine>
......@@ -21,6 +20,9 @@
#include <QCommandLineParser>
#include "services/web/youtube.h"
#ifdef Q_OS_ANDROID
Q_DECL_EXPORT
#endif
int main(int argc, char *argv[])
{
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
......@@ -82,7 +84,6 @@ int main(int argc, char *argv[])
);
#ifdef Q_OS_ANDROID
KirigamiPlugin::getInstance().registerTypes();
QtWebView::initialize();
#else
// if(QQuickStyle::availableStyles().contains("nomad"))
......
......@@ -8,7 +8,6 @@
#include <QtCore>
#include <QtNetwork>
#include <QUrl>
#include <QWidget>
#include <QObject>
#include <QNetworkAccessManager>
#include <QDomDocument>
......
......@@ -5,8 +5,8 @@
#include <QByteArray>
#include <QObject>
#include <./3rdparty/taglib/tag.h>
#include <./3rdparty/taglib/fileref.h>
#include <taglib/tag.h>
#include <taglib/fileref.h>
namespace TagLib
{
......
......@@ -8,9 +8,6 @@
#include <QDebug>
#include <QDirIterator>
#include <fstream>
#include <iostream>
#include "../../utils/bae.h"
#include "../local/taginfo.h"
......
#ifndef SETTINGS_H
#define SETTINGS_H
#include <QWidget>
#include <QString>
#include <QStringList>
#include <QDebug>
#include <QDir>
#include <QDirIterator>
#include <QFile>
#include <QFileDialog>
#include <QFileSystemWatcher>
#include <QLabel>
#include <QMovie>
#include <QFileSystemWatcher>
#include <QTimer>
#include "fileloader.h"
......
#include "fileloader.h"
FileLoader::FileLoader()
: CollectionDB(nullptr)
{
qRegisterMetaType<BAE::DB>("BAE::DB");
qRegisterMetaType<BAE::TABLE>("BAE::TABLE");
qRegisterMetaType<QMap<BAE::TABLE, bool>>("QMap<BAE::TABLE,bool>");
this->moveToThread(&t);
t.start();
}
FileLoader::~FileLoader()
{
this->go = false;
this->t.quit();
this->t.wait();
}
void FileLoader::requestPaths(const QStringList& paths)
{
qDebug()<<"FROM file loader"<< paths;
this->go = true;
QMetaObject::invokeMethod(this, "getTracks", Q_ARG(QStringList, paths));
}
void FileLoader::nextTrack()
{
this->wait = !this->wait;
}
void FileLoader::getTracks(const QStringList& paths)
{
qDebug()<<"GETTING TRACKS FROM SETTINGS";
QStringList urls;
for(auto path : paths)
{
if (QFileInfo(path).isDir())
{
this->addFolder(path);
QDirIterator it(path, BAE::formats, QDir::Files, QDirIterator::Subdirectories);
while (it.hasNext()) urls<<it.next();
} else if (QFileInfo(path).isFile()) urls<<path;
}
qDebug()<<"URLS SIZEW FOR:"<<paths<< urls.size();
int newTracks = 0;
if(!urls.isEmpty())
{
this->execQuery("PRAGMA synchronous=OFF");
for(auto url : urls)
{
if(go)
{
if(!check_existance(BAE::TABLEMAP[BAE::TABLE::TRACKS],BAE::KEYMAP[BAE::KEY::URL],url))
{
if(info.feed(url))
{
auto album = BAE::fixString(info.getAlbum());
auto track= info.getTrack();
auto title = BAE::fixString(info.getTitle()); /* to fix*/
auto artist = BAE::fixString(info.getArtist());
auto genre = info.getGenre();
auto sourceUrl = QFileInfo(url).dir().path();
auto duration = info.getDuration();
auto year = info.getYear();
BAE::DB trackMap =
{
{BAE::KEY::URL, url},
{BAE::KEY::TRACK, QString::number(track)},
{BAE::KEY::TITLE, title},
{BAE::KEY::ARTIST, artist},
{BAE::KEY::ALBUM, album},
{BAE::KEY::DURATION,QString::number(duration)},
{BAE::KEY::GENRE, genre},
{BAE::KEY::SOURCES_URL, sourceUrl},
{BAE::KEY::BABE, url.startsWith(BAE::YoutubeCachePath) ? "1": "0"},
{BAE::KEY::RELEASE_DATE, QString::number(year)}
};
qDebug()<<url;
this->addTrack(trackMap);
newTracks++;
}
}
}else break;
}
}
this->t.msleep(100);
emit this->finished(newTracks);
this->go = false;
}
......@@ -13,108 +13,17 @@ class FileLoader : public CollectionDB
Q_OBJECT
public:
FileLoader() : CollectionDB(nullptr)
{
qRegisterMetaType<BAE::DB>("BAE::DB");
qRegisterMetaType<BAE::TABLE>("BAE::TABLE");
qRegisterMetaType<QMap<BAE::TABLE, bool>>("QMap<BAE::TABLE,bool>");
this->moveToThread(&t);
t.start();
}
FileLoader();
~FileLoader()
{
this->go = false;
this->t.quit();
this->t.wait();
}
~FileLoader() override;
void requestPaths(QStringList paths)
{
qDebug()<<"FROM file loader"<< paths;
void requestPaths(const QStringList &paths);
this->go = true;
QMetaObject::invokeMethod(this, "getTracks", Q_ARG(QStringList, paths));
}
void nextTrack()
{
this->wait = !this->wait;
}
void nextTrack();
public slots:
void getTracks(QStringList paths)
{
qDebug()<<"GETTING TRACKS FROM SETTINGS";
QStringList urls;
for(auto path : paths)
{
if (QFileInfo(path).isDir())
{
this->addFolder(path);
QDirIterator it(path, BAE::formats, QDir::Files, QDirIterator::Subdirectories);
while (it.hasNext()) urls<<it.next();
} else if (QFileInfo(path).isFile()) urls<<path;
}
qDebug()<<"URLS SIZEW FOR:"<<paths<< urls.size();
int newTracks = 0;
if(!urls.isEmpty())
{
this->execQuery("PRAGMA synchronous=OFF");
for(auto url : urls)
{
if(go)
{
if(!check_existance(BAE::TABLEMAP[BAE::TABLE::TRACKS],BAE::KEYMAP[BAE::KEY::URL],url))
{
if(info.feed(url))
{
auto album = BAE::fixString(info.getAlbum());
auto track= info.getTrack();
auto title = BAE::fixString(info.getTitle()); /* to fix*/
auto artist = BAE::fixString(info.getArtist());
auto genre = info.getGenre();
auto sourceUrl = QFileInfo(url).dir().path();
auto duration = info.getDuration();
auto year = info.getYear();
BAE::DB trackMap =
{
{BAE::KEY::URL, url},
{BAE::KEY::TRACK, QString::number(track)},
{BAE::KEY::TITLE, title},
{BAE::KEY::ARTIST, artist},
{BAE::KEY::ALBUM, album},
{BAE::KEY::DURATION,QString::number(duration)},
{BAE::KEY::GENRE, genre},
{BAE::KEY::SOURCES_URL, sourceUrl},
{BAE::KEY::BABE, url.startsWith(BAE::YoutubeCachePath) ? "1": "0"},
{BAE::KEY::RELEASE_DATE, QString::number(year)}
};
qDebug()<<url;
this->addTrack(trackMap);
newTracks++;
}
}
}else break;
}
}
this->t.msleep(100);
emit this->finished(newTracks);
this->go = false;
}
void getTracks(const QStringList &paths);
signals:
void trackReady(BAE::DB track);
......
......@@ -10,7 +10,6 @@
#include <QTime>
#include <QSettings>
#include <QDirIterator>
#include <QApplication>
#include <QScreen>
#include <QtNetwork>
#include <QEventLoop>
......
......@@ -5,7 +5,6 @@ QT += websockets
QT += network
QT += xml
QT += qml
QT += quickcontrols2
QT += widgets
......@@ -65,7 +64,8 @@ SOURCES += main.cpp \
services/web/babeit.cpp \
utils/babeconsole.cpp \
services/local/youtubedl.cpp \
services/local/linking.cpp
services/local/linking.cpp \
settings/fileloader.cpp
RESOURCES += qml.qrc \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment