tdlib: add recipe

This commit is contained in:
Gerasim Troeglazov
2025-05-19 10:56:19 +10:00
parent 39711f60b0
commit 23da1f7f9f
3 changed files with 240 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,117 @@
From 4840f20f3a8d6dc9ee024e5b5f8423eec5bc2cd2 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Mon, 12 May 2025 13:58:16 +1000
Subject: Fix for Haiku
diff --git a/CMake/TdSetUpCompiler.cmake b/CMake/TdSetUpCompiler.cmake
index b110810..6b366f6 100644
--- a/CMake/TdSetUpCompiler.cmake
+++ b/CMake/TdSetUpCompiler.cmake
@@ -3,7 +3,7 @@
function(td_set_up_compiler)
set(CMAKE_EXPORT_COMPILE_COMMANDS 1 PARENT_SCOPE)
- set(CMAKE_POSITION_INDEPENDENT_CODE ON PARENT_SCOPE)
+# set(CMAKE_POSITION_INDEPENDENT_CODE ON PARENT_SCOPE)
include(illumos)
diff --git a/benchmark/bench_queue.cpp b/benchmark/bench_queue.cpp
index 9c94c85..9e7b595 100644
--- a/benchmark/bench_queue.cpp
+++ b/benchmark/bench_queue.cpp
@@ -22,7 +22,7 @@
#include <pthread.h>
#include <sched.h>
#include <semaphore.h>
-#include <sys/syscall.h>
+//#include <sys/syscall.h>
#include <unistd.h>
#endif
diff --git a/sqlite/sqlite/sqlite3.c b/sqlite/sqlite/sqlite3.c
index 4fb5bc5..eddb54b 100644
--- a/sqlite/sqlite/sqlite3.c
+++ b/sqlite/sqlite/sqlite3.c
@@ -22549,7 +22549,7 @@ end_of_export:
/* #include "sqlcipher.h" */
/* #include "crypto.h" */
// #ifndef OMIT_MEMLOCK
-#if defined(__unix__) || defined(__APPLE__) || defined(_AIX)
+#if defined(__unix__) || defined(__APPLE__) || defined(_AIX) || defined(__HAIKU__)
#include <errno.h>
#include <unistd.h>
#include <sys/resource.h>
diff --git a/td/generate/tl-parser/portable_endian.h b/td/generate/tl-parser/portable_endian.h
index a815547..0a84a0d 100644
--- a/td/generate/tl-parser/portable_endian.h
+++ b/td/generate/tl-parser/portable_endian.h
@@ -17,7 +17,7 @@
#endif
-#if defined(__linux__) || defined(__CYGWIN__) || defined(__sun)
+#if defined(__linux__) || defined(__CYGWIN__) || defined(__sun) || defined(__HAIKU__)
# include <endian.h>
diff --git a/tdutils/CMakeLists.txt b/tdutils/CMakeLists.txt
index 5576fed..25b2f5b 100644
--- a/tdutils/CMakeLists.txt
+++ b/tdutils/CMakeLists.txt
@@ -406,7 +406,7 @@ if (ANDROID)
target_link_libraries(tdutils PRIVATE log)
endif()
-find_package(Atomics REQUIRED)
+find_package(Atomics)
if (ATOMICS_LIBRARIES)
target_link_libraries(tdutils PUBLIC "${ATOMICS_LIBRARIES}")
endif()
diff --git a/tdutils/td/utils/bits.h b/tdutils/td/utils/bits.h
index 85634c4..b783af7 100644
--- a/tdutils/td/utils/bits.h
+++ b/tdutils/td/utils/bits.h
@@ -12,6 +12,10 @@
#include <intrin.h>
#endif
+#if TD_HAIKU
+#include <ByteOrder.h>
+#endif
+
#ifdef bswap32
#undef bswap32
#endif
diff --git a/tdutils/td/utils/port/config.h b/tdutils/td/utils/port/config.h
index 02675d3..d57dac8 100644
--- a/tdutils/td/utils/port/config.h
+++ b/tdutils/td/utils/port/config.h
@@ -19,6 +19,10 @@
#if TD_LINUX || TD_ANDROID || TD_TIZEN
#define TD_POLL_EPOLL 1
#define TD_EVENTFD_LINUX 1
+#elif TD_HAIKU
+ #define TD_POLL_SELECT 1
+ #define TD_EVENTFD_UNSUPPORTED 1
+ #define TD_THREAD_UNSUPPORTED 1
#elif TD_FREEBSD || TD_OPENBSD || TD_NETBSD
#define TD_POLL_KQUEUE 1
#define TD_EVENTFD_BSD 1
diff --git a/tdutils/td/utils/port/platform.h b/tdutils/td/utils/port/platform.h
index d6ee70a..ef56f8f 100644
--- a/tdutils/td/utils/port/platform.h
+++ b/tdutils/td/utils/port/platform.h
@@ -45,6 +45,8 @@
#define TD_TIZEN 1
#elif defined(__linux__)
#define TD_LINUX 1
+#elif defined(__HAIKU__)
+ #define TD_HAIKU 1
#elif defined(__FreeBSD__)
#define TD_FREEBSD 1
#elif defined(__OpenBSD__)
--
2.48.1

View File

@@ -0,0 +1,100 @@
SUMMARY="Telegram Database library"
DESCRIPTION="TDLib (Telegram Database library) is a cross-platform library for building \
Telegram clients. It can be easily used from almost any programming language."
HOMEPAGE="https://github.com/tdlib/td"
COPYRIGHT="2013-2025 Telegram"
LICENSE="Boost v1.0"
REVISION="1"
srcGitRev="51743dfd01dff6179e2d8f7095729caa4e2222e9"
SOURCE_URI="https://github.com/tdlib/td/archive/$srcGitRev.tar.gz"
SOURCE_DIR="td-$srcGitRev"
CHECKSUM_SHA256="f2c6b92533ba41a024b9fdb86d346c8bfc876d5961738ad463effbd844d61405"
SOURCE_FILENAME="tdlib-$srcGitRev.tar.gz"
PATCHES="tdlib-$portVersion.patchset"
ARCHITECTURES="all !x86_gcc2"
SECONDARY_ARCHITECTURES="x86"
PROVIDES="
tdlib$secondaryArchSuffix = $portVersion
devel:libtdactor$secondaryArchSuffix = 0.0.0 compat >= 0
devel:libtdapi$secondaryArchSuffix = 0.0.0 compat >= 0
devel:libtdclient$secondaryArchSuffix = 0.0.0 compat >= 0
devel:libtdcore$secondaryArchSuffix = 0.0.0 compat >= 0
devel:libtddb$secondaryArchSuffix = 0.0.0 compat >= 0
devel:libtde2e$secondaryArchSuffix = 0.0.0 compat >= 0
devel:libtdjson$secondaryArchSuffix = 0.0.0 compat >= 0
devel:libtdjson_private$secondaryArchSuffix = 0.0.0 compat >= 0
devel:libtdjson_static$secondaryArchSuffix = 0.0.0 compat >= 0
devel:libtdmtproto$secondaryArchSuffix = 0.0.0 compat >= 0
devel:libtdnet$secondaryArchSuffix = 0.0.0 compat >= 0
devel:libtdsqlite$secondaryArchSuffix = 0.0.0 compat >= 0
devel:libtdutils$secondaryArchSuffix = 0.0.0 compat >= 0
"
REQUIRES="
haiku$secondaryArchSuffix
lib:libcrypto$secondaryArchSuffix
lib:libz$secondaryArchSuffix
"
BUILD_REQUIRES="
haiku${secondaryArchSuffix}_devel
devel:libcrypto$secondaryArchSuffix >= 3
devel:libssl$secondaryArchSuffix >= 3
devel:libz$secondaryArchSuffix
"
BUILD_PREREQUIRES="
cmd:cmake
cmd:gcc$secondaryArchSuffix
cmd:gperf
cmd:make
cmd:pkg_config$secondaryArchSuffix
cmd:python3
cmd:sed
cmd:yasm
"
BUILD()
{
cmake -B build -S. \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_LIBDIR=$developLibDir \
-DCMAKE_INSTALL_INCLUDEDIR=$includeDir \
-DCMAKE_EXE_LINKER_FLAGS="-lnetwork" \
-DTD_INSTALL_STATIC_LIBRARIES=ON \
-DTD_INSTALL_SHARED_LIBRARIES=OFF \
-DTD_ENABLE_JNI=OFF \
-DTD_ENABLE_DOTNET=OFF \
-DTD_ENABLE_LTO=OFF \
-DTD_E2E_ONLY=OFF \
-DBUILD_TESTING=OFF \
-DMEMPROF=OFF
make -C build $jobArgs
cmake -B build_e2e -S. \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_LIBDIR=$developLibDir \
-DCMAKE_INSTALL_INCLUDEDIR=$includeDir \
-DCMAKE_EXE_LINKER_FLAGS="-lnetwork" \
-DTD_INSTALL_STATIC_LIBRARIES=ON \
-DTD_INSTALL_SHARED_LIBRARIES=OFF \
-DTD_ENABLE_JNI=OFF \
-DTD_ENABLE_DOTNET=OFF \
-DTD_ENABLE_LTO=OFF \
-DTD_E2E_ONLY=ON \
-DBUILD_TESTING=OFF \
-DMEMPROF=OFF
make -C build_e2e $jobArgs
}
INSTALL()
{
make -C build install
make -C build_e2e install
mkdir -p $libDir
mv $developLibDir/cmake $libDir
}