Skip to content

Commit 3e8be30

Browse files
authored
Merge pull request #14 from AlwinEsch/Omega-fix-uwp
Add support to build without librtlsdr and use one Windows UWP
2 parents 3f01ec4 + 7574cd7 commit 3e8be30

21 files changed

+204
-124
lines changed

CMakeLists.txt

+24-6
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,25 @@ project(pvr.rtlradio)
33

44
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake)
55

6+
option(DISTRIBUTION_BUILD "Linux distribution build (without use of depends folder)" OFF)
7+
8+
if(CORE_SYSTEM_NAME STREQUAL windowsstore)
9+
set(USB_DEVICE_SUPPORT False)
10+
else()
11+
set(USB_DEVICE_SUPPORT True)
12+
endif()
13+
614
find_package(Kodi REQUIRED)
715
find_package(FFTW REQUIRED)
816
find_package(FDK_AAC REQUIRED)
917
find_package(glm REQUIRED)
10-
find_package(libusb-1.0 REQUIRED)
1118
find_package(MPG123 REQUIRED)
1219
find_package(RapidJSON 1.1.0 REQUIRED)
13-
find_package(rtlsdr REQUIRED)
1420
find_package(SQLite3 REQUIRED)
21+
if(USB_DEVICE_SUPPORT)
22+
find_package(libusb-1.0 REQUIRED)
23+
find_package(rtlsdr REQUIRED)
24+
endif()
1525

1626
if(NOT WIN32 AND (APP_RENDER_SYSTEM STREQUAL "gl" OR NOT APP_RENDER_SYSTEM))
1727
find_package(OpenGl REQUIRED)
@@ -31,19 +41,27 @@ include_directories(${KODI_INCLUDE_DIR}/.. # Hack way with "/..", need bigger Ko
3141
${FFTW_INCLUDE_DIRS}
3242
${FDK_AAC_INCLUDE_DIRS}
3343
${GLM_INCLUDE_DIR}
34-
${LIBUSB_1_INCLUDE_DIRS}
3544
${MPG123_INCLUDE_DIR}
3645
${RAPIDJSON_INCLUDE_DIRS}
37-
${rtlsdr_INCLUDE_DIRS}
3846
${SQLITE3_INCLUDE_DIR})
3947

4048
list(APPEND DEPLIBS ${FDK_AAC_LIBRARIES}
4149
${FFTW_LONGDOUBLE_LIB}
42-
${LIBUSB_1_LIBRARIES}
4350
${MPG123_LIBRARIES}
44-
${RTLSDR_LIBRARIES}
4551
${SQLITE3_LIBRARY})
4652

53+
if(USB_DEVICE_SUPPORT)
54+
if(NOT DISTRIBUTION_BUILD)
55+
list(APPEND DEPLIBS ${LIBUSB_1_LIBRARIES})
56+
endif()
57+
58+
include_directories(${LIBUSB_1_INCLUDE_DIRS}
59+
${rtlsdr_INCLUDE_DIRS})
60+
list(APPEND DEPLIBS ${RTLSDR_LIBRARIES})
61+
62+
add_definitions(-DUSB_DEVICE_SUPPORT)
63+
endif()
64+
4765
add_subdirectory(${PROJECT_SOURCE_DIR}/src)
4866
add_subdirectory(${PROJECT_SOURCE_DIR}/src/dsp_dab)
4967
add_subdirectory(${PROJECT_SOURCE_DIR}/src/dsp_fm)

debian/rules

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
dh $@
1414

1515
override_dh_auto_configure:
16-
dh_auto_configure -- -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=1 -DUSE_LTO=1
16+
dh_auto_configure -- -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=1 -DUSE_LTO=1 -DDISTRIBUTION_BUILD=1
1717

1818
override_dh_strip:
1919
dh_strip -pkodi-pvr-rtlradio --dbg-package=kodi-pvr-rtlradio-dbg

depends/common/libusb/platforms.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
!windows !windowsstore

depends/common/rtl-sdr/platforms.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
!windowsstore

depends/common/sqlite3/0001-no-exe-build.patch

-54
This file was deleted.

depends/common/sqlite3/CMakeLists.txt

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
cmake_minimum_required(VERSION 3.5)
2+
3+
project(sqlite3 VERSION 3.13.0 LANGUAGES C)
4+
5+
file(WRITE cmake/sqlite3-config.cmake "include(\${CMAKE_CURRENT_LIST_DIR}/sqlite3.cmake)")
6+
7+
add_library(sqlite3
8+
src/sqlite3.h
9+
src/sqlite3ext.h
10+
src/sqlite3.c
11+
)
12+
13+
if(CMAKE_SYSTEM_NAME STREQUAL WindowsStore)
14+
target_compile_definitions(sqlite3
15+
PRIVATE
16+
SQLITE_OS_WINRT
17+
)
18+
endif()
19+
20+
target_include_directories(
21+
sqlite3 PRIVATE
22+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
23+
INTERFACE
24+
$<INSTALL_INTERFACE:include>
25+
)
26+
27+
include(CMakePackageConfigHelpers)
28+
write_basic_package_version_file(
29+
${CMAKE_CURRENT_BINARY_DIR}/sqlite3-config-version.cmake
30+
VERSION ${sqlite_VERSION}
31+
COMPATIBILITY AnyNewerVersion
32+
)
33+
34+
install(TARGETS sqlite3 EXPORT sqlite3
35+
RUNTIME DESTINATION bin
36+
ARCHIVE DESTINATION lib
37+
LIBRARY DESTINATION lib
38+
)
39+
40+
install(FILES
41+
${CMAKE_CURRENT_SOURCE_DIR}/src/sqlite3.h
42+
${CMAKE_CURRENT_SOURCE_DIR}/src/sqlite3ext.h
43+
DESTINATION include
44+
)
45+
46+
install(EXPORT sqlite3
47+
FILE
48+
sqlite3.cmake
49+
NAMESPACE
50+
sqlite3::
51+
DESTINATION
52+
lib/cmake/sqlite3
53+
)
54+
install(
55+
FILES
56+
cmake/sqlite3-config.cmake
57+
${CMAKE_CURRENT_BINARY_DIR}/sqlite3-config-version.cmake
58+
DESTINATION
59+
lib/cmake/sqlite3
60+
)
61+
62+
if(MSVC AND BUILD_SHARED_LIBS)
63+
install(FILES
64+
$<TARGET_PDB_FILE:sqlite3>
65+
DESTINATION lib
66+
)
67+
endif()

depends/windows/libusb/libusb.sha256

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
a09bff99c74e03e582aa30759cada218ea8fa03580517e52d463c59c0b25e240
1+
e8f18a7a36ecbb11fb820bd71540350d8f61bcd9db0d2e8c18a6fb80b214a3de

depends/windows/libusb/libusb.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
libusb https://github.com/libusb/libusb/archive/refs/tags/v1.0.26.tar.gz
1+
libusb https://github.com/libusb/libusb/archive/refs/tags/v1.0.27.tar.gz

depends/windows/libusb/platforms.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
!windowsstore
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
--- a/CMakeLists.txt
2+
+++ b/CMakeLists.txt
3+
@@ -35,6 +35,9 @@
4+
# Uncomment this if config.h defines RETAIN_WSALASTERROR
5+
#set(XLIBS wsock32.lib)
6+
7+
+if(CMAKE_SYSTEM_NAME STREQUAL WindowsStore)
8+
+ add_definitions(-DWINDOWS_UWP_BUILD)
9+
+endif()
10+
11+
# Initial include path set. Look in the build directory first, where the
12+
# generated config.h resides, before looking in the source directory.
13+
--- a/pthread_cancel.c
14+
+++ b/pthread_cancel.c
15+
@@ -65,11 +65,12 @@
16+
__ptw32_Registercancellation (PAPCFUNC unused1, HANDLE threadH, DWORD unused2)
17+
{
18+
CONTEXT context;
19+
-
20+
+#ifndef WINDOWS_UWP_BUILD
21+
context.ContextFlags = CONTEXT_CONTROL;
22+
GetThreadContext (threadH, &context);
23+
__PTW32_PROGCTR (context) = (DWORD_PTR) __ptw32_cancel_self;
24+
SetThreadContext (threadH, &context);
25+
+#endif
26+
return 0;
27+
}
28+
29+
--- a/pthread_win32_attach_detach_np.c
30+
+++ b/pthread_win32_attach_detach_np.c
31+
@@ -85,13 +85,13 @@ pthread_win32_process_attach_np ()
32+
__ptw32_h_quserex = LoadLibrary(QuserExDLLPathBuf);
33+
}
34+
#else
35+
-# if ! defined(WINCE)
36+
+#ifndef WINDOWS_UWP_BUILD
37+
if(GetSystemDirectory(QuserExDLLPathBuf, sizeof(QuserExDLLPathBuf)/sizeof(TCHAR)) &&
38+
0 == _tcsncat_s(QuserExDLLPathBuf, _countof(QuserExDLLPathBuf), TEXT("\\QUSEREX.DLL"), 12))
39+
{
40+
__ptw32_h_quserex = LoadLibrary(QuserExDLLPathBuf);
41+
}
42+
-# endif
43+
+#endif
44+
#endif
45+
46+
if (__ptw32_h_quserex != NULL)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
!windowsstore

src/CMakeLists.txt

+5-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ set(SOURCES dabmuxscanner.cpp
1111
signalmeter.cpp
1212
tcpdevice.cpp
1313
uecp.cpp
14-
usbdevice.cpp
1514
wxstream.cpp)
1615

1716
set(HEADERS dabmuxscanner.h
@@ -33,9 +32,13 @@ set(HEADERS dabmuxscanner.h
3332
signalmeter.h
3433
tcpdevice.h
3534
uecp.h
36-
usbdevice.h
3735
wxstream.h)
3836

37+
if(USB_DEVICE_SUPPORT)
38+
list(APPEND SOURCES usbdevice.cpp)
39+
list(APPEND HEADERS usbdevice.h)
40+
endif()
41+
3942
add_library(code_src OBJECT ${SOURCES} ${HEADERS})
4043
target_link_libraries(code_src ${DEPLIBS})
4144
target_include_directories(code_src PRIVATE ${PROJECT_SOURCE_DIR}/src)

src/CMakeLists.txt.orig

-48
This file was deleted.

src/addon.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727
#include "fmstream.h"
2828
#include "hdstream.h"
2929
#include "tcpdevice.h"
30+
#ifdef USB_DEVICE_SUPPORT
3031
#include "usbdevice.h"
32+
#endif
3133
#include "wxstream.h"
3234
#include "exception_control/sqlite_exception.h"
3335
#include "exception_control/string_exception.h"
@@ -48,7 +50,10 @@
4850
#include <vector>
4951

5052
#ifdef WIN32
51-
#include <Windows.h>
53+
#include <windows.h>
54+
#ifdef TARGET_WINDOWS_STORE
55+
#include <ws2tcpip.h>
56+
#endif
5257

5358
#ifdef CreateDirectory
5459
#undef CreateDirectory
@@ -549,9 +554,11 @@ std::unique_ptr<rtldevice> addon::create_device(struct settings const& settings)
549554
}
550555
}
551556

557+
#ifdef USB_DEVICE_SUPPORT
552558
// USB device
553559
if (settings.device_connection == device_connection::usb)
554560
return usbdevice::create(settings.device_connection_usb_index);
561+
#endif
555562

556563
// Network device
557564
if (settings.device_connection == device_connection::rtltcp)

src/dsp_hd/config.h

-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ float crealf(float _Complex __z);
5353
// MacOS
5454
#elif defined(__APPLE__)
5555

56-
#define HAVE_PTHREAD_SETNAME_NP
5756
#define HAVE_STRNDUP
5857
#define HAVE_CMPLXF
5958
#define HAVE_COMPLEX_I
@@ -62,7 +61,6 @@ float crealf(float _Complex __z);
6261
// Linux
6362
#else
6463

65-
#define HAVE_PTHREAD_SETNAME_NP
6664
#define HAVE_STRNDUP
6765
#define HAVE_CMPLXF
6866
#define HAVE_COMPLEX_I

src/dsp_hd/conv_dec.c

+10
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@
1919
* Author: Tom Tsou <tom.tsou@ettus.com>
2020
*/
2121

22+
// Hack fix about build with SSE use.
23+
// Currently it always generate within Linux by use on call function e.g. like this
24+
// "error: inlining failed in call to ‘always_inline’ ‘_mm_minpos_epu16’: target specific option mismatch".
25+
// This fix prevent the use about if something has set in defines.
26+
//
27+
#if defined(HAVE_SSE3) && defined(TARGET_LINUX)
28+
#warning Undefined HAVE_SSE3 to workaround compile problems
29+
#undef HAVE_SSE3
30+
#endif
31+
2232
#include "config.h"
2333

2434
#include <stdlib.h>

0 commit comments

Comments
 (0)