Skip to content

Commit 2c7e65f

Browse files
Add Linux ARM support
Co-authored-by: tedison <[email protected]>
1 parent eadc9ce commit 2c7e65f

File tree

4 files changed

+24
-10
lines changed

4 files changed

+24
-10
lines changed

.github/workflows/build-tdlib.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,33 @@ env:
1010

1111
jobs:
1212
build-linux:
13-
runs-on: ubuntu-latest
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
include:
17+
- os: ubuntu-latest
18+
- os: ubuntu-24.04-arm
19+
runs-on: ${{ matrix.os }}
1420
steps:
1521
- name: Restore cache TDLib
1622
id: cache-tdlib-restore
1723
uses: actions/cache/restore@v4
1824
with:
1925
path: td/
20-
key: tdlib-${{ env.TDLIB_VERSION }}-linux-x86_64
26+
key: tdlib-${{ env.TDLIB_VERSION }}-linux-${{ runner.arch == 'ARM64' && 'aarch64' || 'x86_64' }}
2127
- name: Build TDLib
2228
if: steps.cache-tdlib-restore.outputs.cache-hit != 'true'
2329
run: |
2430
sudo apt-get update
2531
sudo apt-get -y upgrade
26-
sudo apt-get -y install make git zlib1g-dev libssl-dev gperf php-cli cmake clang-14 libc++-dev libc++abi-dev
32+
sudo apt-get install make git zlib1g-dev libssl-dev gperf php-cli cmake clang-18 libc++-18-dev libc++abi-18-dev
2733
git clone https://github.com/tdlib/td.git
2834
cd td
2935
git checkout $TDLIB_COMMIT
3036
rm -rf build
3137
mkdir build
3238
cd build
33-
CXXFLAGS="-stdlib=libc++" CC=/usr/bin/clang-14 CXX=/usr/bin/clang++-14 cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=../tdlib ..
39+
CXXFLAGS="-stdlib=libc++" CC=/usr/bin/clang-18 CXX=/usr/bin/clang++-18 cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=../tdlib ..
3440
cmake --build . --target install
3541
- name: Save cache TDLib
3642
uses: actions/cache/save@v4
@@ -64,7 +70,7 @@ jobs:
6470
if: steps.cache-tdlib-restore.outputs.cache-hit != 'true'
6571
run: |
6672
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
67-
brew install gperf cmake openssl
73+
brew install gperf openssl
6874
git clone https://github.com/tdlib/td.git
6975
cd td
7076
git checkout $TDLIB_COMMIT
@@ -103,7 +109,7 @@ jobs:
103109
git checkout $TDLIB_COMMIT
104110
git clone https://github.com/Microsoft/vcpkg.git
105111
cd vcpkg
106-
git checkout cd5e746ec203c8c3c61647e0886a8df8c1e78e41
112+
git checkout 07b30b49e5136a36100a2ce644476e60d7f3ddc1
107113
./bootstrap-vcpkg.bat
108114
./vcpkg.exe install gperf:x64-windows openssl:x64-windows zlib:x64-windows
109115
cd ..

.github/workflows/ci-linux.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ jobs:
2525
fail-fast: false
2626
matrix:
2727
feature: [local-tdlib, download-tdlib, pkg-config, docs]
28+
os: [ubuntu-latest, ubuntu-24.04-arm]
2829

29-
runs-on: ubuntu-latest
30+
runs-on: ${{ matrix.os }}
3031

3132
steps:
3233
- name: Checkout
@@ -38,7 +39,7 @@ jobs:
3839
- name: Download TDLib
3940
if: matrix.feature == 'local-tdlib' || matrix.feature == 'pkg-config'
4041
run: |
41-
gh release download --pattern 'tdlib-*-linux-x86_64.zip'
42+
gh release download --pattern ${{ runner.arch == 'ARM64' && 'tdlib-*-linux-aarch64.zip' || 'tdlib-*-linux-x86_64.zip' }}
4243
unzip -q *.zip -d .
4344
- name: Set pkg-config environment variables
4445
if: matrix.feature == 'pkg-config'

tdlib-rs/build.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ fn copy_local_tdlib() {
7373
/// Build the project using the generic build configuration.
7474
/// The current supported platforms are:
7575
/// - Linux x86_64
76+
/// - Linux aarch64
7677
/// - Windows x86_64
7778
/// - MacOS x86_64
7879
/// - MacOS aarch64
@@ -82,7 +83,10 @@ fn generic_build() {
8283
let include_dir = format!("{}/include", prefix);
8384
let lib_dir = format!("{}/lib", prefix);
8485
let lib_path = {
85-
#[cfg(all(target_os = "linux", target_arch = "x86_64"))]
86+
#[cfg(any(
87+
all(target_os = "linux", target_arch = "x86_64"),
88+
all(target_os = "linux", target_arch = "aarch64")
89+
))]
8690
{
8791
format!("{}/libtdjson.so.{}", lib_dir, TDLIB_VERSION)
8892
}

tdlib-rs/src/build.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,10 @@ fn generic_build(lib_path: Option<String>) {
160160
let include_dir = format!("{}/include", prefix);
161161
let lib_dir = format!("{}/lib", prefix);
162162
let mut_lib_path = {
163-
#[cfg(all(target_os = "linux", target_arch = "x86_64"))]
163+
#[cfg(any(
164+
all(target_os = "linux", target_arch = "x86_64"),
165+
all(target_os = "linux", target_arch = "aarch64")
166+
))]
164167
{
165168
format!("{}/libtdjson.so.{}", lib_dir, TDLIB_VERSION)
166169
}

0 commit comments

Comments
 (0)