Skip to content

Commit

Permalink
Merge pull request #10 from phunkyfish/win-pthreads
Browse files Browse the repository at this point in the history
Enable pthreads for FFmpeg on Windows
  • Loading branch information
phunkyfish authored Feb 9, 2020
2 parents f7a7c31 + 7aa3f7b commit 1b0e63b
Show file tree
Hide file tree
Showing 23 changed files with 471 additions and 27 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ if(WIN32)
find_package(LibXml2 REQUIRED)
find_package(Iconv REQUIRED)
find_package(OpenSSL REQUIRED)
find_package(PThreads REQUIRED)
endif()
find_package(p8-platform REQUIRED)
find_package(Kodi REQUIRED)
Expand Down Expand Up @@ -87,6 +88,7 @@ if(WIN32)
${OPENSSL_LIBRARIES}
${LIBXML2_LIBRARIES}
${FFMPEG_LIBRARIES}
${PTHREADS_LIBRARIES}
Winmm.lib
WS2_32.lib
Bcrypt.lib
Expand Down
22 changes: 22 additions & 0 deletions FindPThreads.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# - Find PThreads
# Find the native pthread for windows includes and library
#
# PTHREADS_FOUND - True if pthread for windows found.
# PTHREADS_INCLUDE_DIRS - where to find pthread.h, etc.
# PTHREADS_LIBRARIES - List of libraries when using pthread for windows.
#

find_package(PkgConfig)
if(PKG_CONFIG_FOUND)
pkg_check_modules(PC_PTHREADS pthreads QUIET)
endif()

find_path(PTHREADS_INCLUDE_DIRS NAMES pthread.h
PATHS ${PC_PTHREADS_INCLUDEDIR})
find_library(PTHREADS_LIBRARIES NAMES pthreads
PATHS ${PC_PTHREADS_LIBDIR})

include("FindPackageHandleStandardArgs")
find_package_handle_standard_args(PThreads REQUIRED_VARS PTHREADS_INCLUDE_DIRS PTHREADS_LIBRARIES)

mark_as_advanced(PTHREADS_INCLUDE_DIRS PTHREADS_LIBRARIES)
3 changes: 2 additions & 1 deletion depends/common/ffmpeg/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,8 @@ else()
--prefix=[DQ]${CMAKE_INSTALL_PREFIX}[DQ]
--arch=${EXTRA_ARCH}
--toolchain=msvc
--enable-w32threads
--disable-w32threads
--enable-pthreads
--enable-openssl
--enable-nonfree
--disable-gnutls
Expand Down
1 change: 1 addition & 0 deletions depends/common/ffmpeg/windows-deps.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ openssl
mingw
xz-utils
zlib
pthreads
1 change: 1 addition & 0 deletions depends/common/ffmpeg/windowsstore-deps.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ openssl
mingw
xz-utils
zlib
pthreads
20 changes: 9 additions & 11 deletions depends/common/gnutls/03-include-libdl-if-available.patch
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
diff --git a/configure.ac b/configure.ac
index db1ce841f..264712b56 100644
--- a/configure.ac
+++ b/configure.ac
@@ -512,6 +512,9 @@ LT_INIT([disable-static,win32-dll,shared])
diff -ur gnutls/configure.ac gnutls-patched/configure.ac
--- gnutls/configure.ac 2020-02-01 23:41:10.000000000 +0000
+++ gnutls-patched/configure.ac 2020-02-01 23:49:15.000000000 +0000
@@ -522,6 +522,9 @@


AC_LIB_HAVE_LINKFLAGS(dl,, [#include <dlfcn.h>], [dladdr (0, 0);])
+if test "x$HAVE_LIBDL" = "xyes"; then
+ AC_SUBST([LIBDL], [-ldl])
+ AC_SUBST([LIBDL], [-ldl])
+fi

AC_ARG_ENABLE(fips140-mode,
AS_HELP_STRING([--enable-fips140-mode], [enable FIPS140-2 mode]),
diff --git a/lib/gnutls.pc.in b/lib/gnutls.pc.in
index ffad3e168..15b990764 100644
--- a/lib/gnutls.pc.in
+++ b/lib/gnutls.pc.in
@@ -19,6 +19,6 @@ Description: Transport Security Layer implementation for the GNU system
diff -ur gnutls/lib/gnutls.pc.in gnutls-patched/lib/gnutls.pc.in
--- gnutls/lib/gnutls.pc.in 2020-02-01 23:41:11.000000000 +0000
+++ gnutls-patched/lib/gnutls.pc.in 2020-02-01 23:51:05.000000000 +0000
@@ -19,6 +19,6 @@
URL: https://www.gnutls.org/
Version: @VERSION@
Libs: -L${libdir} -lgnutls
Expand Down
2 changes: 1 addition & 1 deletion depends/common/gnutls/gnutls.sha256
Original file line number Diff line number Diff line change
@@ -1 +1 @@
fbba12f3db9a55dbf027e14111755817ec44b57eabec3e8089aac8ac6f533cf8
bfacf16e342949ffd977a9232556092c47164bd26e166736cf3459a870506c4b
2 changes: 1 addition & 1 deletion depends/common/gnutls/gnutls.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
gnutls http://mirrors.kodi.tv/build-deps/sources/gnutls-3.6.11.1.tar.xz
gnutls http://mirrors.kodi.tv/build-deps/sources/gnutls-3.6.12.tar.xz
24 changes: 24 additions & 0 deletions depends/windows/pthreads/01-fix-ARM-build.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
From: Alwin Esch <[email protected]>
Date: Wed, 8 Jan 2020 12:13:40 +0000
Subject: [PATCH] fix ARM build

---
context.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/context.h b/context.h
index 33294c1..f959de2 100644
--- a/context.h
+++ b/context.h
@@ -62,7 +62,7 @@
#endif

#if defined(_ARM_) || defined(ARM) || defined(_M_ARM) || defined(_M_ARM64)
-#define PTW32_PROGCTR(Context) ((Context).Pc)
+#define __PTW32_PROGCTR(Context) ((Context).Pc)
#endif

#if !defined (__PTW32_PROGCTR)
--
2.19.2.windows.1

162 changes: 162 additions & 0 deletions depends/windows/pthreads/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
cmake_minimum_required(VERSION 3.5)
project(pthreads)

set(SOURCES ptw32_MCS_lock.c
ptw32_is_attr.c
ptw32_processInitialize.c
ptw32_processTerminate.c
ptw32_threadStart.c
ptw32_threadDestroy.c
ptw32_tkAssocCreate.c
ptw32_tkAssocDestroy.c
ptw32_callUserDestroyRoutines.c
ptw32_semwait.c
ptw32_timespec.c
ptw32_throw.c
ptw32_getprocessors.c
ptw32_calloc.c
ptw32_new.c
ptw32_reuse.c
ptw32_relmillisecs.c
ptw32_cond_check_need_init.c
ptw32_mutex_check_need_init.c
ptw32_rwlock_check_need_init.c
ptw32_rwlock_cancelwrwait.c
ptw32_spinlock_check_need_init.c
pthread_attr_init.c
pthread_attr_destroy.c
pthread_attr_getaffinity_np.c
pthread_attr_setaffinity_np.c
pthread_attr_getdetachstate.c
pthread_attr_setdetachstate.c
pthread_attr_getname_np.c
pthread_attr_setname_np.c
pthread_attr_getscope.c
pthread_attr_setscope.c
pthread_attr_getstackaddr.c
pthread_attr_setstackaddr.c
pthread_attr_getstacksize.c
pthread_attr_setstacksize.c
pthread_barrier_init.c
pthread_barrier_destroy.c
pthread_barrier_wait.c
pthread_barrierattr_init.c
pthread_barrierattr_destroy.c
pthread_barrierattr_setpshared.c
pthread_barrierattr_getpshared.c
pthread_setcancelstate.c
pthread_setcanceltype.c
pthread_testcancel.c
pthread_cancel.c
pthread_condattr_destroy.c
pthread_condattr_getpshared.c
pthread_condattr_init.c
pthread_condattr_setpshared.c
pthread_cond_destroy.c
pthread_cond_init.c
pthread_cond_signal.c
pthread_cond_wait.c
create.c
cleanup.c
dll.c
errno.c
pthread_exit.c
global.c
pthread_equal.c
pthread_getconcurrency.c
pthread_kill.c
pthread_once.c
pthread_self.c
pthread_setconcurrency.c
w32_CancelableWait.c
pthread_mutex_init.c
pthread_mutex_destroy.c
pthread_mutexattr_init.c
pthread_mutexattr_destroy.c
pthread_mutexattr_getpshared.c
pthread_mutexattr_setpshared.c
pthread_mutexattr_settype.c
pthread_mutexattr_gettype.c
pthread_mutexattr_setrobust.c
pthread_mutexattr_getrobust.c
pthread_mutex_lock.c
pthread_mutex_timedlock.c
pthread_mutex_unlock.c
pthread_mutex_trylock.c
pthread_mutex_consistent.c
pthread_mutexattr_setkind_np.c
pthread_mutexattr_getkind_np.c
pthread_getw32threadhandle_np.c
pthread_getunique_np.c
pthread_setaffinity.c
pthread_delay_np.c
pthread_num_processors_np.c
pthread_win32_attach_detach_np.c
pthread_timechange_handler_np.c
pthread_rwlock_init.c
pthread_rwlock_destroy.c
pthread_rwlockattr_init.c
pthread_rwlockattr_destroy.c
pthread_rwlockattr_getpshared.c
pthread_rwlockattr_setpshared.c
pthread_rwlock_rdlock.c
pthread_rwlock_timedrdlock.c
pthread_rwlock_wrlock.c
pthread_rwlock_timedwrlock.c
pthread_rwlock_unlock.c
pthread_rwlock_tryrdlock.c
pthread_rwlock_trywrlock.c
pthread_attr_setschedpolicy.c
pthread_attr_getschedpolicy.c
pthread_attr_setschedparam.c
pthread_attr_getschedparam.c
pthread_attr_setinheritsched.c
pthread_attr_getinheritsched.c
pthread_getname_np.c
pthread_setname_np.c
pthread_setschedparam.c
pthread_getschedparam.c
sched_get_priority_max.c
sched_get_priority_min.c
sched_setscheduler.c
sched_getscheduler.c
sched_yield.c
sched_setaffinity.c
sem_init.c
sem_destroy.c
sem_trywait.c
sem_timedwait.c
sem_wait.c
sem_post.c
sem_post_multiple.c
sem_getvalue.c
sem_open.c
sem_close.c
sem_unlink.c
pthread_spin_init.c
pthread_spin_destroy.c
pthread_spin_lock.c
pthread_spin_unlock.c
pthread_spin_trylock.c
pthread_detach.c
pthread_join.c
pthread_timedjoin_np.c
pthread_tryjoin_np.c
pthread_key_create.c
pthread_key_delete.c
pthread_setspecific.c
pthread_getspecific.c
config.h
context.h)

set(HEADERS ${PROJECT_SOURCE_DIR}/_ptw32.h
${PROJECT_SOURCE_DIR}/pthread.h
${PROJECT_SOURCE_DIR}/sched.h
${PROJECT_SOURCE_DIR}/semaphore.h)

add_library(pthreads ${SOURCES} ${HEADERS})
target_include_directories(pthreads PRIVATE ${CMAKE_SOURCE_DIR})
target_compile_definitions(pthreads PUBLIC -D__PTW32_CONFIG_H)

install(FILES ${HEADERS} DESTINATION ${CMAKE_INSTALL_PREFIX}/include)
install(TARGETS pthreads DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
1 change: 1 addition & 0 deletions depends/windows/pthreads/pthreads.sha256
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
b81136effb7185c77601fe2e0e6ac19bd996912e4814cebdd3010b0fac9e259b
1 change: 1 addition & 0 deletions depends/windows/pthreads/pthreads.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pthreads http://mirrors.kodi.tv/build-deps/sources/pthreads4w-code-v3.0.0.zip
24 changes: 24 additions & 0 deletions depends/windowsstore/pthreads/01-fix-ARM-build.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
From: Alwin Esch <[email protected]>
Date: Wed, 8 Jan 2020 12:13:40 +0000
Subject: [PATCH] fix ARM build

---
context.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/context.h b/context.h
index 33294c1..f959de2 100644
--- a/context.h
+++ b/context.h
@@ -62,7 +62,7 @@
#endif

#if defined(_ARM_) || defined(ARM) || defined(_M_ARM) || defined(_M_ARM64)
-#define PTW32_PROGCTR(Context) ((Context).Pc)
+#define __PTW32_PROGCTR(Context) ((Context).Pc)
#endif

#if !defined (__PTW32_PROGCTR)
--
2.19.2.windows.1

Loading

0 comments on commit 1b0e63b

Please sign in to comment.