Skip to content

Add Linux ARM support #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions .github/workflows/build-tdlib.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,33 @@ env:

jobs:
build-linux:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
- os: ubuntu-24.04-arm
runs-on: ${{ matrix.os }}
steps:
- name: Restore cache TDLib
id: cache-tdlib-restore
uses: actions/cache/restore@v4
with:
path: td/
key: tdlib-${{ env.TDLIB_VERSION }}-linux-x86_64
key: tdlib-${{ env.TDLIB_VERSION }}-linux-${{ runner.arch == 'ARM64' && 'aarch64' || 'x86_64' }}
- name: Build TDLib
if: steps.cache-tdlib-restore.outputs.cache-hit != 'true'
run: |
sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get -y install make git zlib1g-dev libssl-dev gperf php-cli cmake clang-14 libc++-dev libc++abi-dev
sudo apt-get install make git zlib1g-dev libssl-dev gperf php-cli cmake clang-18 libc++-18-dev libc++abi-18-dev
git clone https://github.com/tdlib/td.git
cd td
git checkout $TDLIB_COMMIT
rm -rf build
mkdir build
cd build
CXXFLAGS="-stdlib=libc++" CC=/usr/bin/clang-14 CXX=/usr/bin/clang++-14 cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=../tdlib ..
CXXFLAGS="-stdlib=libc++" CC=/usr/bin/clang-18 CXX=/usr/bin/clang++-18 cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=../tdlib ..
cmake --build . --target install
- name: Save cache TDLib
uses: actions/cache/save@v4
Expand Down Expand Up @@ -64,7 +70,7 @@ jobs:
if: steps.cache-tdlib-restore.outputs.cache-hit != 'true'
run: |
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install gperf cmake openssl
brew install gperf openssl
git clone https://github.com/tdlib/td.git
cd td
git checkout $TDLIB_COMMIT
Expand Down Expand Up @@ -103,7 +109,7 @@ jobs:
git checkout $TDLIB_COMMIT
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
git checkout cd5e746ec203c8c3c61647e0886a8df8c1e78e41
git checkout 07b30b49e5136a36100a2ce644476e60d7f3ddc1
./bootstrap-vcpkg.bat
./vcpkg.exe install gperf:x64-windows openssl:x64-windows zlib:x64-windows
cd ..
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/ci-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ jobs:
fail-fast: false
matrix:
feature: [local-tdlib, download-tdlib, pkg-config, docs]
os: [ubuntu-latest, ubuntu-24.04-arm]

runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}

steps:
- name: Checkout
Expand All @@ -37,7 +38,7 @@ jobs:
- name: Download TDLib
if: matrix.feature == 'local-tdlib' || matrix.feature == 'pkg-config'
run: |
gh release download --pattern 'tdlib-*-linux-x86_64.zip'
gh release download --pattern ${{ runner.arch == 'ARM64' && 'tdlib-*-linux-aarch64.zip' || 'tdlib-*-linux-x86_64.zip' }}
unzip -q *.zip -d .
- name: Set pkg-config environment variables
if: matrix.feature == 'pkg-config'
Expand Down
6 changes: 5 additions & 1 deletion tdlib-rs/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ fn copy_local_tdlib() {
/// Build the project using the generic build configuration.
/// The current supported platforms are:
/// - Linux x86_64
/// - Linux aarch64
/// - Windows x86_64
/// - MacOS x86_64
/// - MacOS aarch64
Expand All @@ -82,7 +83,10 @@ fn generic_build() {
let include_dir = format!("{}/include", prefix);
let lib_dir = format!("{}/lib", prefix);
let lib_path = {
#[cfg(all(target_os = "linux", target_arch = "x86_64"))]
#[cfg(any(
all(target_os = "linux", target_arch = "x86_64"),
all(target_os = "linux", target_arch = "aarch64")
))]
{
format!("{}/libtdjson.so.{}", lib_dir, TDLIB_VERSION)
}
Expand Down
5 changes: 4 additions & 1 deletion tdlib-rs/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,10 @@ fn generic_build(lib_path: Option<String>) {
let include_dir = format!("{}/include", prefix);
let lib_dir = format!("{}/lib", prefix);
let mut_lib_path = {
#[cfg(all(target_os = "linux", target_arch = "x86_64"))]
#[cfg(any(
all(target_os = "linux", target_arch = "x86_64"),
all(target_os = "linux", target_arch = "aarch64")
))]
{
format!("{}/libtdjson.so.{}", lib_dir, TDLIB_VERSION)
}
Expand Down
Loading