Skip to content

Commit

Permalink
prebuilt-tdlib workflow update
Browse files Browse the repository at this point in the history
  • Loading branch information
eilvelia committed Jul 8, 2024
1 parent c7008b2 commit 6644ec6
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 101 deletions.
202 changes: 101 additions & 101 deletions .github/workflows/prebuilt-tdlib.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,139 +20,140 @@ on:
# NOTE: The ZLIB_USE_STATIC_LIBS option requires CMake >= 3.24
jobs:
build-linux-x64:
name: Build TDLib (GNU/Linux x86_64)
runs-on: ubuntu-latest
name: Build TDLib (Linux x86_64 glibc)
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
repository: 'tdlib/td'
ref: ${{ inputs.tdlib }}
- name: Create a build script
- uses: goto-bus-stop/setup-zig@v2
with:
version: '0.13.0'
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y gperf zlib1g-dev libssl-dev
- name: Build TDLib using zig
run: |
cat > prebuilt-tdlib-docker.sh <<EOF
set -e
source /hbb_shlib/activate
set -x
yum install -y gperf
cd /td
mkdir -p build && cd build
set -ex
cmake --version
# Currently, cmake in this image should be 3.22.2
export CC="zig cc -target x86_64-linux-gnu.2.22 -s"
export CXX="zig c++ -target x86_64-linux-gnu.2.22 -s"
mkdir -p to-upload && mkdir -p build && cd build
cmake \
-DCMAKE_BUILD_TYPE=Release \
-DOPENSSL_USE_STATIC_LIBS=TRUE \
-DZLIB_LIBRARY=/hbb_shlib/lib/libz.a \
-DZLIB_INCLUDE_DIR=/hbb_shlib/include \
-DZLIB_USE_STATIC_LIBS=TRUE \
..
cmake --build . --target tdjson -- -j 2
strip libtdjson.so
cmake --build . --target tdjson -- -j 4
cd ..
cp -L build/libtdjson.so to-upload/libtdjson.so
cd to-upload
echo "zig:" >> info.txt && zig version >> info.txt
echo "openssl:" >> info.txt && openssl version >> info.txt
ldd libtdjson.so
touch info.txt
gcc --version | grep -i gcc >> info.txt
ldd --version | grep ldd >> info.txt
openssl version >> info.txt
sed -n 's/#define ZLIB_VERSION "\([^"]*\)"/zlib version: \1/p' /hbb_shlib/include/zlib.h >> info.txt
EOF
- name: Build in docker
run: |
mkdir to-upload
docker run -v $(pwd):/td ghcr.io/phusion/holy-build-box/hbb-64 \
bash /td/prebuilt-tdlib-docker.sh
- name: Info
working-directory: to-upload
run: |
cat info.txt
echo "-----"
du -hs libtdjson.so
ldd libtdjson.so
- uses: actions/upload-artifact@v4
with:
name: tdlib-linux-x64
path: to-upload
build-macos:
name: Build TDLib (macOS universal)
runs-on: macos-12
env:
openssl_dir: /usr/local/opt/custom_openssl
openssl_tag: '1.1.2100' # OpenSSL 1.1.1u
zlib_ver: '1.2.13'
zlib_dir: /usr/local/opt/custom_zlib
build-macos-x64:
name: Build TDLib (macOS x86_64)
runs-on: macos-13
steps:
- uses: actions/checkout@v4
with:
repository: 'tdlib/td'
ref: ${{ inputs.tdlib }}
- name: Install gperf via homebrew
run: HOMEBREW_NO_INSTALL_CLEANUP=1 brew install gperf
- name: CMake version
run: cmake --version
# https://github.com/up9cloud/ios-libtdjson/blob/d4426dca16933b6178acb030955de92f040b7574/build.sh
- name: Download pre-built OpenSSL
run: |
# around 80 mb
curl -SL https://github.com/krzyzanowskim/OpenSSL/archive/refs/tags/${openssl_tag}.tar.gz -o OpenSSL.tar.gz
tar xzf OpenSSL.tar.gz
# As for now, MACOSX_DEPLOYMENT_TARGET in these pre-built openssl binaries should be 10.13
mv OpenSSL-${openssl_tag}/macosx ${openssl_dir}
- name: Download and build zlib
run: |
set -x
curl -SL https://github.com/madler/zlib/releases/download/v${zlib_ver}/zlib-${zlib_ver}.tar.gz -o zlib.tar.gz
tar xzf zlib.tar.gz
cd zlib-${zlib_ver}
MACOSX_DEPLOYMENT_TARGET=10.14 CFLAGS="-O2 -mmacosx-version-min=10.14 -arch x86_64" \
./configure --static --prefix=${zlib_dir}
MACOSX_DEPLOYMENT_TARGET=10.14 make
make install && rm ${zlib_dir}/lib/libz.a
cp libz.a libz-x86_64.a
make clean
MACOSX_DEPLOYMENT_TARGET=11.0 CFLAGS="-O2 -mmacosx-version-min=11.0 -arch arm64" \
./configure --static
MACOSX_DEPLOYMENT_TARGET=11.0 make
mv libz.a libz-arm64.a
lipo -create libz-x86_64.a libz-arm64.a -output libz.a
cp libz.a ${zlib_dir}/lib/libz.a
- name: Install dependencies (homebrew)
run: HOMEBREW_NO_INSTALL_CLEANUP=1 brew install gperf zlib openssl
- name: Build TDLib
run: |
mkdir to-upload
mkdir -p build && cd build
set -ex
cmake --version
mkdir -p to-upload && mkdir -p build && cd build
MACOSX_DEPLOYMENT_TARGET=10.14 cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_OSX_ARCHITECTURES='x86_64;arm64' \
-DOPENSSL_USE_STATIC_LIBS=TRUE -DZLIB_USE_STATIC_LIBS=TRUE \
-DOPENSSL_FOUND=1 \
-DOPENSSL_CRYPTO_LIBRARY=${openssl_dir}/lib/libcrypto.a \
-DOPENSSL_SSL_LIBRARY=${openssl_dir}/lib/libssl.a \
-DOPENSSL_LIBRARIES="${openssl_dir}/lib/libcrypto.a;${openssl_dir}/lib/libssl.a" \
-DOPENSSL_INCLUDE_DIR=${openssl_dir}/include \
-DZLIB_INCLUDE_DIR=${zlib_dir}/include \
-DZLIB_LIBRARY=${zlib_dir}/lib/libz.a \
-DCMAKE_OSX_ARCHITECTURES='x86_64' \
-DOPENSSL_USE_STATIC_LIBS=TRUE \
-DZLIB_USE_STATIC_LIBS=TRUE \
-DZLIB_LIBRARY=/usr/local/opt/zlib/lib/libz.a \
-DZLIB_INCLUDE_DIR=/usr/local/opt/zlib/include \
-DOPENSSL_ROOT_DIR=/usr/local/opt/openssl
..
cmake --build . --target tdjson -- -j 3
cmake --build . --target tdjson -- -j 4
cd ..
cp -L build/libtdjson.dylib to-upload/libtdjson.dylib
install_name_tool -id @rpath/libtdjson.dylib to-upload/libtdjson.dylib
- name: Info
working-directory: to-upload
cd to-upload
install_name_tool -id @rpath/libtdjson.dylib libtdjson.dylib
echo "clang:" >> info.txt && clang --version >> info.txt
echo "openssl:" >> info.txt && /usr/local/opt/openssl/bin/openssl version >> info.txt
file libtdjson.dylib
otool -L libtdjson.dylib
- uses: actions/upload-artifact@v4
with:
name: temp-macos-x64
path: to-upload
build-macos-arm64:
name: Build TDLib (macOS arm64)
runs-on: macos-14
steps:
- uses: actions/checkout@v4
with:
repository: 'tdlib/td'
ref: ${{ inputs.tdlib }}
- name: Install dependencies (homebrew)
run: HOMEBREW_NO_INSTALL_CLEANUP=1 brew install gperf zlib openssl
- name: Build TDLib
run: |
touch info.txt
grep OPENSSL_VERSION_TEXT ${openssl_dir}/include/openssl/opensslv.h | sed 's/.*"\([^"]*\)"/\1/' >> info.txt
echo "zlib version: ${zlib_ver}" >> info.txt
otool -L libtdjson.dylib >> info.txt
cat info.txt
echo "-----"
uname -a
set -ex
cmake --version
mkdir -p to-upload && mkdir -p build && cd build
MACOSX_DEPLOYMENT_TARGET=11.0 cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_OSX_ARCHITECTURES='arm64' \
-DOPENSSL_USE_STATIC_LIBS=TRUE \
-DZLIB_USE_STATIC_LIBS=TRUE \
-DZLIB_LIBRARY=/opt/homebrew/zlib/lib/libz.a \
-DZLIB_INCLUDE_DIR=/opt/homebrew/zlib/include \
-DOPENSSL_ROOT_DIR=/opt/homebrew/openssl
..
cmake --build . --target tdjson -- -j 2
cd ..
cp -L build/libtdjson.dylib to-upload/libtdjson.dylib
cd to-upload
install_name_tool -id @rpath/libtdjson.dylib libtdjson.dylib
echo "clang:" >> info.txt && clang --version >> info.txt
echo "openssl:" >> info.txt && /opt/homebrew/openssl/bin/openssl version >> info.txt
file libtdjson.dylib
du -hs libtdjson.dylib
otool -arch x86_64 -l libtdjson.dylib
echo "---"
otool -arch arm64 -l libtdjson.dylib
otool -L libtdjson.dylib
- uses: actions/upload-artifact@v4
with:
name: tdlib-macos
name: temp-macos-arm64
path: to-upload
build-macos:
name: Create universal macOS shared library
needs: [build-macos-x64, build-macos-arm64]
runs-on: macos-13
steps:
- uses: actions/download-artifact@v4
with:
name: temp-macos-*
merge-multiple: true
- name: Combine shared libraries
run: |
mkdir -p to-upload
lipo temp-macos-x64/libtdjson.dylib temp-macos-arm64/libtdjson.dylib \
-output to-upload/libtdjson.dylib -create
cd to-upload
echo "--x86_64--" >> info.txt
cat ../temp-macos-x64/libtdjson.dylib >> info.txt
echo "--arm64--" >> info.txt
cat ../temp-macos-arm64/libtdjson.dylib >> info.txt
- uses: actions/upload-artifact@v4
with:
name: build-macos
path: to-upload
build-windows-x64:
name: Build TDLib (Windows x86_64)
Expand Down Expand Up @@ -182,12 +183,10 @@ jobs:
-DCMAKE_TOOLCHAIN_FILE=C:\vcpkg\scripts\buildsystems\vcpkg.cmake `
-DVCPKG_TARGET_TRIPLET=x64-windows-static `
-DOPENSSL_USE_STATIC_LIBS=TRUE -DZLIB_USE_STATIC_LIBS=TRUE ..
cmake --build . --target tdjson --config Release --parallel 2
cmake --build . --target tdjson --config Release --parallel 4
cd ..
cp build\Release\tdjson.dll to-upload\tdjson.dll
- name: Info
# It should be possible to print the dependencies using dumpbin.exe
run: |
# It should be possible to print the dependencies using dumpbin.exe
vcpkg list | Select-String openssl,zlib > to-upload\info.txt
cat to-upload\info.txt
- uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -245,6 +244,7 @@ jobs:
pattern: tdlib-*
path: packages/prebuilt-tdlib/prebuilds
- run: tree packages/prebuilt-tdlib
- run: du -hsc packages/prebuilt-tdlib/prebuilds/*
- run: npm run test:integration
env:
PREBUILT_PATH: packages/prebuilt-tdlib
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/publish-tdl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ jobs:
node-version: lts/*
cache: npm
- uses: goto-bus-stop/setup-zig@v2
with:
version: '0.13.0'
if: runner.os == 'Linux'
- name: Install dependencies
run: npm install
Expand Down

0 comments on commit 6644ec6

Please sign in to comment.