Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios

# Conflicts:
#	submodules/MetalEngine/Sources/MetalEngine.swift
This commit is contained in:
Mikhail Filimonov 2026-05-02 10:10:18 +01:00
commit 5b56675b06
257 changed files with 5559 additions and 22070 deletions

View file

@ -1170,7 +1170,8 @@ static inline uint64_t CRYPTO_rotr_u64(uint64_t value, int shift) {
// CRYPTO_addc_* returns |x + y + carry|, and sets |*out_carry| to the carry
// bit. |carry| must be zero or one.
#if OPENSSL_HAS_BUILTIN(__builtin_addc)
// _Generic is C11-only and not available in C++ mode with GCC.
#if OPENSSL_HAS_BUILTIN(__builtin_addc) && !defined(__cplusplus)
#define CRYPTO_GENERIC_ADDC(x, y, carry, out_carry) \
(_Generic((x), \
@ -1222,7 +1223,7 @@ static inline uint64_t CRYPTO_addc_u64(uint64_t x, uint64_t y, uint64_t carry,
// CRYPTO_subc_* returns |x - y - borrow|, and sets |*out_borrow| to the borrow
// bit. |borrow| must be zero or one.
#if OPENSSL_HAS_BUILTIN(__builtin_subc)
#if OPENSSL_HAS_BUILTIN(__builtin_subc) && !defined(__cplusplus)
#define CRYPTO_GENERIC_SUBC(x, y, borrow, out_borrow) \
(_Generic((x), \

View file

@ -49,6 +49,12 @@ genrule(
BUILD_ARCH="arm64"
elif [ "$(TARGET_CPU)" == "ios_sim_arm64" ]; then
BUILD_ARCH="sim_arm64"
elif [ "$(TARGET_CPU)" == "darwin_arm64" ]; then
BUILD_ARCH="macos_arm64"
elif [ "$(TARGET_CPU)" == "k8" ] || [ "$(TARGET_CPU)" == "x86_64" ]; then
BUILD_ARCH="linux_x86_64"
elif [ "$(TARGET_CPU)" == "aarch64" ] || [ "$(TARGET_CPU)" == "arm64" ]; then
BUILD_ARCH="linux_arm64"
else
echo "Unsupported architecture $(TARGET_CPU)"
fi
@ -57,15 +63,20 @@ genrule(
rm -rf "$$BUILD_DIR"
mkdir -p "$$BUILD_DIR"
MESON_DIR="$$(pwd)/$$BUILD_DIR/meson"
rm -rf "$$MESON_DIR"
mkdir -p "$$MESON_DIR"
tar -xzf "$(location @meson_tar_gz//file)" -C "$$MESON_DIR"
if [ "$${BUILD_ARCH}" = "linux_x86_64" ] || [ "$${BUILD_ARCH}" = "linux_arm64" ]; then
EXTRA_PATH=""
else
MESON_DIR="$$(pwd)/$$BUILD_DIR/meson"
rm -rf "$$MESON_DIR"
mkdir -p "$$MESON_DIR"
tar -xzf "$(location @meson_tar_gz//file)" -C "$$MESON_DIR"
NINJA_DIR="$$(pwd)/$$BUILD_DIR/ninja"
rm -rf "$$NINJA_DIR"
mkdir -p "$$NINJA_DIR"
unzip "$(location @ninja-mac_zip//file)" -d "$$NINJA_DIR"
NINJA_DIR="$$(pwd)/$$BUILD_DIR/ninja"
rm -rf "$$NINJA_DIR"
mkdir -p "$$NINJA_DIR"
unzip "$(location @ninja-mac_zip//file)" -d "$$NINJA_DIR"
EXTRA_PATH="$$MESON_DIR/meson-1.6.0:$$NINJA_DIR"
fi
cp $(location :build-dav1d-bazel.sh) "$$BUILD_DIR/"
cp $(location :arm64-iPhoneSimulator.meson) "$$BUILD_DIR/"
@ -78,7 +89,11 @@ genrule(
mkdir -p "$$BUILD_DIR/Public/compat"
mkdir -p "$$BUILD_DIR/Public/common"
PATH="$$PATH:$$MESON_DIR/meson-1.6.0:$$NINJA_DIR" sh $$BUILD_DIR/build-dav1d-bazel.sh $$BUILD_ARCH "$$BUILD_DIR"
if [ -n "$$EXTRA_PATH" ]; then
PATH="$$PATH:$$EXTRA_PATH" bash $$BUILD_DIR/build-dav1d-bazel.sh $$BUILD_ARCH "$$BUILD_DIR"
else
bash $$BUILD_DIR/build-dav1d-bazel.sh $$BUILD_ARCH "$$BUILD_DIR"
fi
""" +
"\n".join([
"cp -f \"$$BUILD_DIR/dav1d/build/include/{}\" \"$(location Public/{})\"".format(header, header) for header in generated_headers
@ -104,10 +119,8 @@ cc_library(
srcs = [":Public/dav1d/lib/lib" + x + ".a" for x in libs]
)
objc_library(
cc_library(
name = "dav1d",
module_name = "dav1d",
enable_modules = True,
hdrs = [":Public/" + x for x in generated_headers],
includes = [
"Public",

View file

@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
set -e
@ -18,6 +18,43 @@ elif [ "$ARCH" = "sim_arm64" ]; then
custom_xcode_path="$(xcode-select -p)/"
sed -i '' "s|/Applications/Xcode.app/Contents/Developer/|$custom_xcode_path|g" "$TARGET_CROSSFILE"
CROSSFILE="../package/crossfiles/arm64-iPhoneSimulator-custom.meson"
elif [ "$ARCH" = "macos_arm64" ]; then
TARGET_CROSSFILE="$BUILD_DIR/dav1d/package/crossfiles/arm64-MacOSX-custom.meson"
custom_xcode_path="$(xcode-select -p)"
MACOS_SYSROOT="$custom_xcode_path/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"
cat > "$TARGET_CROSSFILE" << MESONEOF
[binaries]
c = ['clang', '-arch', 'arm64', '-isysroot', '$MACOS_SYSROOT']
cpp = ['clang++', '-arch', 'arm64', '-isysroot', '$MACOS_SYSROOT']
objc = ['clang', '-arch', 'arm64', '-isysroot', '$MACOS_SYSROOT']
objcpp = ['clang++', '-arch', 'arm64', '-isysroot', '$MACOS_SYSROOT']
ar = 'ar'
strip = 'strip'
[built-in options]
c_args = ['-mmacosx-version-min=14.0']
cpp_args = ['-mmacosx-version-min=14.0']
c_link_args = ['-mmacosx-version-min=14.0']
cpp_link_args = ['-mmacosx-version-min=14.0']
objc_args = ['-mmacosx-version-min=14.0']
objcpp_args = ['-mmacosx-version-min=14.0']
[properties]
root = '$custom_xcode_path/Platforms/MacOSX.platform/Developer'
needs_exe_wrapper = false
[host_machine]
system = 'darwin'
subsystem = 'macos'
kernel = 'xnu'
cpu_family = 'aarch64'
cpu = 'arm64'
endian = 'little'
MESONEOF
CROSSFILE="../package/crossfiles/arm64-MacOSX-custom.meson"
elif [ "$ARCH" = "linux_arm64" ] || [ "$ARCH" = "linux_x86_64" ]; then
# Native Linux build - no cross file needed
CROSSFILE=""
else
echo "Unsupported architecture $ARCH"
exit 1
@ -28,7 +65,13 @@ rm -rf build
mkdir build
pushd build
meson.py setup .. --cross-file="$CROSSFILE" $MESON_OPTIONS
MESON_CMD=$(command -v meson.py 2>/dev/null || command -v meson 2>/dev/null || echo meson.py)
if [ -n "$CROSSFILE" ]; then
$MESON_CMD setup .. --cross-file="$CROSSFILE" $MESON_OPTIONS
else
$MESON_CMD setup .. $MESON_OPTIONS
fi
ninja
popd

View file

@ -57,6 +57,8 @@ genrule(
BUILD_ARCH="sim_arm64"
elif [ "$(TARGET_CPU)" == "ios_x86_64" ]; then
BUILD_ARCH="x86_64"
elif [ "$(TARGET_CPU)" == "darwin_arm64" ]; then
BUILD_ARCH="macos_arm64"
else
echo "Unsupported architecture $(TARGET_CPU)"
fi

View file

@ -33,7 +33,24 @@ elif [ "$ARCH" = "sim_arm64" ]; then
IOS_SYSROOT=($IOS_PLATFORMDIR/Developer/SDKs/iPhoneSimulator*.sdk)
export CFLAGS="-Wall -arch arm64 --target=arm64-apple-ios13.0-simulator -miphonesimulator-version-min=13.0 -funwind-tables"
export CXXFLAGS="$CFLAGS"
cd "$BUILD_DIR"
mkdir build
cd build
touch toolchain.cmake
echo "set(CMAKE_SYSTEM_NAME Darwin)" >> toolchain.cmake
echo "set(CMAKE_SYSTEM_PROCESSOR aarch64)" >> toolchain.cmake
echo "set(CMAKE_C_COMPILER $(xcode-select -p)/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang)" >> toolchain.cmake
cmake -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake -DCMAKE_OSX_SYSROOT=${IOS_SYSROOT[0]} $CMAKE_OPTIONS ../libjxl
make
elif [ "$ARCH" = "macos_arm64" ]; then
IOS_PLATFORMDIR="$(xcode-select -p)/Platforms/MacOSX.platform"
IOS_SYSROOT=($IOS_PLATFORMDIR/Developer/SDKs/MacOSX*.sdk)
export CFLAGS="-Wall -arch arm64 --target=arm64-apple-macosx14.0 -mmacosx-version-min=14.0 -funwind-tables"
export CXXFLAGS="$CFLAGS"
cd "$BUILD_DIR"
mkdir build
cd build

View file

@ -49,6 +49,15 @@ genrule(
elif [ "$(TARGET_CPU)" == "ios_x86_64" ]; then
BUILD_ARCH="x86_64"
PLATFORM_HEADER_DIR="x86_64-iphonesimulator-gcc"
elif [ "$(TARGET_CPU)" == "darwin_arm64" ]; then
BUILD_ARCH="macos_arm64"
PLATFORM_HEADER_DIR="arm64-darwin22-gcc"
elif [ "$(TARGET_CPU)" == "k8" ] || [ "$(TARGET_CPU)" == "x86_64" ]; then
BUILD_ARCH="linux_x86_64"
PLATFORM_HEADER_DIR="x86_64-linux-gcc"
elif [ "$(TARGET_CPU)" == "aarch64" ] || [ "$(TARGET_CPU)" == "arm64" ]; then
BUILD_ARCH="linux_arm64"
PLATFORM_HEADER_DIR="arm64-linux-gcc"
else
echo "Unsupported architecture $(TARGET_CPU)"
fi
@ -76,7 +85,7 @@ genrule(
mkdir -p "$$BUILD_DIR/Public/libvpx"
PATH="$$PATH:$$ABS_YASM_DIR" sh $$BUILD_DIR/build-libvpx-bazel.sh $$BUILD_ARCH "$$BUILD_DIR/libvpx" "$$BUILD_DIR"
PATH="$$PATH:$$ABS_YASM_DIR" bash $$BUILD_DIR/build-libvpx-bazel.sh $$BUILD_ARCH "$$BUILD_DIR/libvpx" "$$BUILD_DIR"
""" +
"\n".join([
"cp -f \"$$BUILD_DIR/VPX.framework/Headers/vpx/{}\" \"$(location Public/vpx/{})\"".format(header, header) for header in headers
@ -102,10 +111,8 @@ cc_library(
srcs = [":Public/vpx/lib" + x + ".a" for x in libs],
)
objc_library(
cc_library(
name = "vpx",
module_name = "vpx",
enable_modules = True,
hdrs = [":Public/vpx/" + x for x in headers],
includes = [
"Public",

28
third-party/libvpx/build-libvpx-bazel.sh vendored Executable file → Normal file
View file

@ -1,4 +1,4 @@
#! /bin/sh
#!/bin/bash
set -e
set -x
@ -33,18 +33,34 @@ SCRIPT_DIR="$SOURCE_DIR"
LIBVPX_SOURCE_DIR="$SOURCE_DIR"
LIPO=$(xcrun -sdk iphoneos${SDK} -find lipo)
ORIG_PWD="$(pwd)"
EXTRA_CONFIGURE_ARGS=""
if [ "$ARCH" = "armv7" ]; then
TARGETS="armv7-darwin-gcc"
LIPO=$(xcrun -sdk iphoneos${SDK} -find lipo)
elif [ "$ARCH" = "arm64" ]; then
TARGETS="arm64-darwin-gcc"
LIPO=$(xcrun -sdk iphoneos${SDK} -find lipo)
elif [ "$ARCH" = "sim_arm64" ]; then
TARGETS="arm64-iphonesimulator-gcc"
LIPO=$(xcrun -sdk iphoneos${SDK} -find lipo)
elif [ "$ARCH" = "macos_arm64" ]; then
TARGETS="arm64-darwin22-gcc"
LIPO=$(xcrun -sdk macosx -find lipo)
export SDKROOT=$(xcrun --sdk macosx --show-sdk-path)
elif [ "$ARCH" = "linux_arm64" ]; then
TARGETS="arm64-linux-gcc"
LIPO="cp"
EXTRA_CONFIGURE_ARGS="--enable-pic"
elif [ "$ARCH" = "linux_x86_64" ]; then
TARGETS="x86_64-linux-gcc"
LIPO="cp"
EXTRA_CONFIGURE_ARGS="--enable-pic"
elif [ "$ARCH" = "x86_64" ]; then
TARGETS="x86_64-iphonesimulator-gcc"
LIPO=$(xcrun -sdk iphoneos${SDK} -find lipo)
else
echo "Unsupported architecture $ARCH"
exit 1
@ -167,7 +183,11 @@ build_framework() {
cp -p "${target_dist_dir}"/include/vpx/* "${HEADER_DIR}"
# Build the fat library.
${LIPO} -create ${lib_list} -output ${FRAMEWORK_DIR}/VPX
if [ "$LIPO" = "cp" ]; then
cp ${lib_list} ${FRAMEWORK_DIR}/VPX
else
${LIPO} -create ${lib_list} -output ${FRAMEWORK_DIR}/VPX
fi
# Create the vpx_config.h shim that allows usage of vpx_config.h from
# within VPX.framework.

View file

@ -25,7 +25,9 @@ arch_specific_cflags = select({
"@build_bazel_rules_apple//apple:ios_arm64": common_flags + arm64_specific_flags,
"//build-system:ios_sim_arm64": common_flags + arm64_specific_flags,
"@build_bazel_rules_apple//apple:ios_x86_64": common_flags + x86_64_specific_flags,
"//conditions:default": common_flags,
"//build-system:linux_arm64": common_flags + arm64_specific_flags,
"//build-system:linux_x86_64": common_flags + x86_64_specific_flags,
"//conditions:default": common_flags + arm64_specific_flags,
})
cc_library(

View file

@ -36,6 +36,8 @@ genrule(
BUILD_ARCH="sim_arm64"
elif [ "$(TARGET_CPU)" == "ios_x86_64" ]; then
BUILD_ARCH="x86_64"
elif [ "$(TARGET_CPU)" == "darwin_arm64" ]; then
BUILD_ARCH="macos_arm64"
else
echo "Unsupported architecture $(TARGET_CPU)"
fi

View file

@ -37,6 +37,22 @@ elif [ "$ARCH" = "sim_arm64" ]; then
echo "set(CMAKE_SYSTEM_PROCESSOR aarch64)" >> toolchain.cmake
echo "set(CMAKE_C_COMPILER $(xcode-select -p)/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang)" >> toolchain.cmake
cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake -DCMAKE_OSX_SYSROOT=${IOS_SYSROOT[0]} -DPNG_SUPPORTED=FALSE -DENABLE_SHARED=FALSE -DWITH_JPEG8=1 -DBUILD=10000 -DCMAKE_POLICY_VERSION_MINIMUM=3.5 ../mozjpeg
make
elif [ "$ARCH" = "macos_arm64" ]; then
IOS_PLATFORMDIR="$(xcode-select -p)/Platforms/MacOSX.platform"
IOS_SYSROOT=($IOS_PLATFORMDIR/Developer/SDKs/MacOSX*.sdk)
export CFLAGS="-Wall -arch arm64 --target=arm64-apple-macosx14.0 -mmacosx-version-min=14.0 -funwind-tables"
cd "$BUILD_DIR"
mkdir build
cd build
touch toolchain.cmake
echo "set(CMAKE_SYSTEM_NAME Darwin)" >> toolchain.cmake
echo "set(CMAKE_SYSTEM_PROCESSOR aarch64)" >> toolchain.cmake
echo "set(CMAKE_C_COMPILER $(xcode-select -p)/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang)" >> toolchain.cmake
cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake -DCMAKE_OSX_SYSROOT=${IOS_SYSROOT[0]} -DPNG_SUPPORTED=FALSE -DENABLE_SHARED=FALSE -DWITH_JPEG8=1 -DBUILD=10000 -DCMAKE_POLICY_VERSION_MINIMUM=3.5 ../mozjpeg
make
else

View file

@ -1,8 +1,6 @@
objc_library(
cc_library(
name = "ogg",
enable_modules = True,
module_name = "ogg",
srcs = glob([
"Sources/*.c",
"Sources/*.h",

View file

@ -0,0 +1,15 @@
#ifndef __CONFIG_TYPES_H__
#define __CONFIG_TYPES_H__
/* Generated for Linux builds */
#include <stdint.h>
typedef int16_t ogg_int16_t;
typedef uint16_t ogg_uint16_t;
typedef int32_t ogg_int32_t;
typedef uint32_t ogg_uint32_t;
typedef int64_t ogg_int64_t;
typedef uint64_t ogg_uint64_t;
#endif

View file

@ -57,18 +57,21 @@ arch_specific_sources = select({
"@build_bazel_rules_apple//apple:ios_arm64": arm64_specific_sources,
"//build-system:ios_sim_arm64": arm64_specific_sources,
"@build_bazel_rules_apple//apple:ios_x86_64": [],
"//conditions:default": arm64_specific_sources,
})
arch_specific_copts = select({
"@build_bazel_rules_apple//apple:ios_arm64": arm64_specific_copts,
"//build-system:ios_sim_arm64": arm64_specific_copts,
"@build_bazel_rules_apple//apple:ios_x86_64": [],
"//conditions:default": arm64_specific_copts,
})
arch_specific_textual_hdrs = select({
"@build_bazel_rules_apple//apple:ios_arm64": arm64_specific_textual_hdrs,
"//build-system:ios_sim_arm64": arm64_specific_textual_hdrs,
"@build_bazel_rules_apple//apple:ios_x86_64": [],
"//conditions:default": arm64_specific_textual_hdrs,
})
all_sources = arch_specific_sources + [

View file

@ -33,6 +33,8 @@ genrule(
BUILD_ARCH="linux_x86_64"
elif [ "$(TARGET_CPU)" == "aarch64" ] || [ "$(TARGET_CPU)" == "arm64" ]; then
BUILD_ARCH="linux_arm64"
elif [ "$(TARGET_CPU)" == "darwin_arm64" ]; then
BUILD_ARCH="macos_arm64"
else
echo "Unsupported architecture $(TARGET_CPU)"
fi
@ -81,10 +83,8 @@ cc_library(
],
)
objc_library(
cc_library(
name = "opus",
module_name = "opus",
enable_modules = True,
hdrs = [":Public/opus/" + x for x in headers],
includes = [
"Public",

View file

@ -54,6 +54,10 @@ elif [ "${ARCH}" == "sim_arm64" ]; then
PLATFORM="iphonesimulator"
EXTRA_CFLAGS="-arch arm64 --target=arm64-apple-ios$MINIOSVERSION-simulator"
EXTRA_CONFIG="--host=arm-apple-darwin20"
elif [ "${ARCH}" == "macos_arm64" ]; then
PLATFORM="macosx"
EXTRA_CFLAGS="-arch arm64 --target=arm64-apple-macosx14.0"
EXTRA_CONFIG="--host=arm-apple-darwin20"
else
PLATFORM="iphoneos"
EXTRA_CFLAGS="-arch ${ARCH}"

View file

@ -1,8 +1,6 @@
objc_library(
cc_library(
name = "opusfile",
enable_modules = True,
module_name = "opusfile",
srcs = glob([
"Sources/*.c",
"Sources/*.h",

View file

@ -24,11 +24,9 @@ replace_symbol_list = [
"pitch_search",
"remove_doubling",
]
objc_library(
cc_library(
name = "rnnoise",
enable_modules = True,
module_name = "rnnoise",
srcs = glob([
"Sources/*.c",
"Sources/*.h",

View file

@ -38,6 +38,8 @@ genrule(
BUILD_ARCH="arm64"
elif [ "$(TARGET_CPU)" == "ios_sim_arm64" ]; then
BUILD_ARCH="sim_arm64"
elif [ "$(TARGET_CPU)" == "darwin_arm64" ]; then
BUILD_ARCH="macos_arm64"
else
echo "Unsupported architecture $(TARGET_CPU)"
fi

View file

@ -29,15 +29,20 @@ cd ..
if [ "$ARCH" = "arm64" ]; then
IOS_PLATFORMDIR="$(xcode-select -p)/Platforms/iPhoneOS.platform"
IOS_SYSROOT=($IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS*.sdk)
export CFLAGS="-arch arm64 --target=arm64-apple-ios13.0 -miphoneos-version-min=13.0"
export CFLAGS="-arch arm64 --target=arm64-apple-ios13.0 -miphoneos-version-min=13.0 -w"
elif [ "$ARCH" = "sim_arm64" ]; then
IOS_PLATFORMDIR="$(xcode-select -p)/Platforms/iPhoneSimulator.platform"
IOS_SYSROOT=($IOS_PLATFORMDIR/Developer/SDKs/iPhoneSimulator*.sdk)
export CFLAGS="-arch arm64 --target=arm64-apple-ios13.0-simulator -miphonesimulator-version-min=13.0"
export CFLAGS="-arch arm64 --target=arm64-apple-ios13.0-simulator -miphonesimulator-version-min=13.0 -w"
elif [ "$ARCH" = "macos_arm64" ]; then
IOS_PLATFORMDIR="$(xcode-select -p)/Platforms/MacOSX.platform"
IOS_SYSROOT=($IOS_PLATFORMDIR/Developer/SDKs/MacOSX*.sdk)
export CFLAGS="-arch arm64 --target=arm64-apple-macosx14.0 -mmacosx-version-min=14.0 -w"
else
echo "Unsupported architecture $ARCH"
exit 1
fi
export CXXFLAGS="$CFLAGS"
# Common build steps
mkdir build

View file

@ -35,6 +35,8 @@ genrule(
BUILD_ARCH="sim_arm64"
elif [ "$(TARGET_CPU)" == "ios_x86_64" ]; then
BUILD_ARCH="x86_64"
elif [ "$(TARGET_CPU)" == "darwin_arm64" ]; then
BUILD_ARCH="macos_arm64"
else
echo "Unsupported architecture $(TARGET_CPU)"
fi

View file

@ -41,6 +41,22 @@ elif [ "$ARCH" = "sim_arm64" ]; then
echo "set(CMAKE_SYSTEM_PROCESSOR aarch64)" >> toolchain.cmake
echo "set(CMAKE_C_COMPILER $(xcode-select -p)/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang)" >> toolchain.cmake
cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake -DCMAKE_OSX_SYSROOT=${IOS_SYSROOT[0]} $COMMON_ARGS ../libwebp
make
elif [ "$ARCH" = "macos_arm64" ]; then
IOS_PLATFORMDIR="$(xcode-select -p)/Platforms/MacOSX.platform"
IOS_SYSROOT=($IOS_PLATFORMDIR/Developer/SDKs/MacOSX*.sdk)
export CFLAGS="-Wall -arch arm64 --target=arm64-apple-macosx14.0 -mmacosx-version-min=14.0 -funwind-tables"
cd "$BUILD_DIR"
mkdir build
cd build
touch toolchain.cmake
echo "set(CMAKE_SYSTEM_NAME Darwin)" >> toolchain.cmake
echo "set(CMAKE_SYSTEM_PROCESSOR aarch64)" >> toolchain.cmake
echo "set(CMAKE_C_COMPILER $(xcode-select -p)/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang)" >> toolchain.cmake
cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake -DCMAKE_OSX_SYSROOT=${IOS_SYSROOT[0]} $COMMON_ARGS ../libwebp
make
elif [ "$ARCH" = "x86_64" ]; then

View file

@ -15,7 +15,6 @@ optimization_flags = select({
})
webrtc_objcpp_sources = [
"rtc_base/system/cocoa_threading.mm",
]
webrtc_headers = [
@ -2767,46 +2766,58 @@ arm64_specific_sources = ["webrtc/" + path for path in [
arch_specific_sources = select({
"@build_bazel_rules_apple//apple:ios_arm64": common_arm_specific_sources + arm64_specific_sources,
"//build-system:ios_sim_arm64": common_arm_specific_sources + arm64_specific_sources,
"//conditions:default": common_arm_specific_sources + arm64_specific_sources,
})
common_flags = [
"-DWEBRTC_IOS",
"-DWEBRTC_MAC",
platform_shared_flags = [
"-DWEBRTC_POSIX",
"-DHAVE_WEBRTC_VIDEO",
"-DRTC_ENABLE_VP9",
"-DRTC_ENABLE_H265",
"-DWEBRTC_USE_H264",
"-DWEBRTC_USE_H264_DECODER",
"-DHAVE_SCTP",
"-DWEBRTC_HAVE_DCSCTP",
"-DWEBRTC_HAVE_SCTP",
"-DWEBRTC_NS_FLOAT",
"-DRTC_DISABLE_TRACE_EVENTS",
#"-DWEBRTC_OPUS_SUPPORT_120MS_PTIME=1",
"-DWEBRTC_APM_DEBUG_DUMP=0",
"-DBWE_TEST_LOGGING_COMPILE_TIME_ENABLE=0",
"-DABSL_ALLOCATOR_NOTHROW=1",
"-DDYNAMIC_ANNOTATIONS_ENABLED=0",
#"-DNS_BLOCK_ASSERTIONS=1",
"-DWEBRTC_ENABLE_PROTOBUF=0",
"-DWEBRTC_ENABLE_AVX2",
"-DWEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS=0",
"-Wno-shorten-64-to-32",
"-Wno-macro-redefined",
"-D__APPLE__",
"-DWEBRTC_OPUS_USE_CODEC_PLC",
"-DWEBRTC_OPUS_SUPPORT_DRED",
]
apple_specific_flags = [
"-DWEBRTC_IOS",
"-DWEBRTC_MAC",
"-D__APPLE__",
"-D__Userspace_os_Darwin",
"-DWEBRTC_ENABLE_AVX2",
"-Wno-shorten-64-to-32",
"-Wno-macro-redefined",
]
linux_specific_flags = [
"-DWEBRTC_LINUX",
"-D__Userspace_os_Linux",
]
arm64_specific_flags = [
"-DWEBRTC_ARCH_ARM64",
"-DWEBRTC_HAS_NEON",
"-DLIBYUV_NEON",
]
# Flatten platform + arch flags into a single select to avoid nested selects
arch_specific_cflags = select({
"@build_bazel_rules_apple//apple:ios_arm64": common_flags + arm64_specific_flags,
"//build-system:ios_sim_arm64": common_flags + arm64_specific_flags,
"@build_bazel_rules_apple//apple:ios_arm64": platform_shared_flags + apple_specific_flags + arm64_specific_flags,
"//build-system:ios_sim_arm64": platform_shared_flags + apple_specific_flags + arm64_specific_flags,
"@platforms//os:linux": platform_shared_flags + linux_specific_flags + arm64_specific_flags,
"//conditions:default": platform_shared_flags + apple_specific_flags + arm64_specific_flags,
})
dcsctp_sources = [ "webrtc/net/dcsctp/" + path for path in [
@ -2981,11 +2992,44 @@ fft4g_sources = [
"fft4g/fft4g.cc",
]
raw_combined_sources = webrtc_headers + webrtc_sources + webrtc_objcpp_sources
combined_sources = [
"webrtc/" + path for path in raw_combined_sources
raw_combined_cpp_sources = webrtc_headers + webrtc_sources
raw_combined_objcpp_sources = webrtc_objcpp_sources
# Platform-specific source files: GCD task queue on Apple, stdlib on Linux
apple_only_cpp_sources = [
"webrtc/rtc_base/task_queue_gcd.cc",
"webrtc/rtc_base/task_queue_gcd.h",
"webrtc/api/task_queue/default_task_queue_factory_gcd.cc",
"webrtc/rtc_base/mac_ifaddrs_converter.cc",
]
linux_only_cpp_sources = [
"webrtc/rtc_base/task_queue_stdlib.cc",
"webrtc/rtc_base/task_queue_stdlib.h",
"webrtc/api/task_queue/default_task_queue_factory_stdlib.cc",
]
# Files excluded from common sources because they are platform-specific
platform_specific_excludes = [
"rtc_base/task_queue_gcd.cc", "rtc_base/task_queue_gcd.h",
"rtc_base/task_queue_stdlib.cc", "rtc_base/task_queue_stdlib.h",
"rtc_base/mac_ifaddrs_converter.cc",
"api/task_queue/default_task_queue_factory_gcd.cc",
"api/task_queue/default_task_queue_factory_stdlib.cc",
"api/task_queue/default_task_queue_factory_libevent.cc",
"api/task_queue/default_task_queue_factory_win.cc",
"api/task_queue/default_task_queue_factory_stdlib_or_libevent_experiment.cc",
]
combined_cpp_sources = [
"webrtc/" + path for path in raw_combined_cpp_sources
if path not in platform_specific_excludes
] + arch_specific_sources + fft4g_sources + dcsctp_sources
combined_objcpp_sources = [
"webrtc/" + path for path in raw_combined_objcpp_sources
]
genrule(
name = "generate_field_trials_header",
srcs = [
@ -3118,13 +3162,15 @@ objc_library(
visibility = ["//visibility:public"],
)
objc_library(
cc_library(
name = "webrtc",
enable_modules = True,
module_name = "webrtc",
srcs = combined_sources,
srcs = combined_cpp_sources + select({
"@platforms//os:linux": linux_only_cpp_sources,
"//conditions:default": combined_objcpp_sources + apple_only_cpp_sources,
}),
copts = [
"-w",
"-include", "stdint.h",
"-Ithird-party/webrtc/libsrtp/third_party/libsrtp/include",
"-Ithird-party/webrtc/libsrtp/third_party/libsrtp/crypto/include",
"-Ithird-party/webrtc/libsrtp",
@ -3140,7 +3186,6 @@ objc_library(
"-DSCTP_SIMPLE_ALLOCATOR",
"-DSCTP_PROCESS_LEVEL_LOCKS",
"-D__Userspace__",
"-D__Userspace_os_Darwin",
"-DPACKAGE_VERSION=\\\"\\\"",
"-DHAVE_SCTP",
"-DWEBRTC_HAVE_DCSCTP",
@ -3168,20 +3213,51 @@ objc_library(
"//third-party/webrtc/pffft",
"//third-party/webrtc/libsrtp",
"//third-party/webrtc/absl",
] + select({
"@platforms//os:linux": [],
"//conditions:default": [":webrtc_platform_helpers"],
}),
linkopts = select({
"@platforms//os:linux": ["-lpthread", "-lm"],
"//conditions:default": [
"-framework AVFoundation",
"-framework AudioToolbox",
"-framework VideoToolbox",
"-framework CoreMedia",
"-framework CoreVideo",
"-framework CoreGraphics",
"-framework QuartzCore",
"-weak_framework Network",
"-weak_framework Metal",
],
}) + select({
"@platforms//os:macos": ["-framework AppKit"],
"//conditions:default": [],
}),
visibility = ["//visibility:public"],
)
# Minimal helpers needed by tgcalls C++ code on non-iOS platforms.
# Separate from webrtc_objc to avoid pulling in iOS SDK dependencies.
objc_library(
name = "webrtc_platform_helpers",
srcs = [
"webrtc/rtc_base/system/gcd_helpers.m",
"webrtc/rtc_base/system/cocoa_threading.mm",
],
sdk_frameworks = [
"AVFoundation",
"AudioToolbox",
"VideoToolbox",
"UIKit",
"CoreMedia",
"CoreVideo",
"CoreGraphics",
"QuartzCore",
hdrs = [
"webrtc/rtc_base/system/gcd_helpers.h",
"webrtc/rtc_base/system/cocoa_threading.h",
],
weak_sdk_frameworks = [
"Network",
"Metal",
copts = [
"-w",
"-Ithird-party/webrtc/webrtc/",
"-Ithird-party/webrtc/absl",
"-DWEBRTC_MAC",
"-DWEBRTC_IOS",
],
deps = [
"//third-party/webrtc/absl",
],
visibility = ["//visibility:public"],
)

View file

@ -808,13 +808,8 @@
//
// See also the upstream documentation:
// https://clang.llvm.org/docs/AttributeReference.html#lifetimebound
#if ABSL_HAVE_CPP_ATTRIBUTE(clang::lifetimebound)
#define ABSL_ATTRIBUTE_LIFETIME_BOUND [[clang::lifetimebound]]
#elif ABSL_HAVE_ATTRIBUTE(lifetimebound)
#define ABSL_ATTRIBUTE_LIFETIME_BOUND __attribute__((lifetimebound))
#else
// Disabled: newer clang rejects lifetimebound on void-returning functions
#define ABSL_ATTRIBUTE_LIFETIME_BOUND
#endif
// ABSL_ATTRIBUTE_TRIVIAL_ABI
// Indicates that a type is "trivially relocatable" -- meaning it can be

View file

@ -16,7 +16,7 @@ genrule(
cmd_bash =
"""
set -x
core_count=`PATH="$$PATH:/usr/sbin" sysctl -n hw.logicalcpu`
core_count=$$(nproc 2>/dev/null || PATH="$$PATH:/usr/sbin" sysctl -n hw.logicalcpu 2>/dev/null || echo 4)
BUILD_DIR="$(RULEDIR)/build"
rm -rf "$$BUILD_DIR"
mkdir -p "$$BUILD_DIR"
@ -25,14 +25,24 @@ set -x
rm -rf "$$CMAKE_DIR"
mkdir -p "$$CMAKE_DIR"
tar -xf "$(location @cmake_tar_gz//file)" -C "$$CMAKE_DIR"
# Find cmake: try system cmake first, then downloaded macOS cmake
if command -v cmake >/dev/null 2>&1; then
CMAKE_BIN="cmake"
elif [ -d "$$CMAKE_DIR/cmake-4.1.2-macos-universal/CMake.app/Contents/bin" ]; then
CMAKE_BIN="$$CMAKE_DIR/cmake-4.1.2-macos-universal/CMake.app/Contents/bin/cmake"
else
echo "cmake not found"
exit 1
fi
SOURCE_PATH="third-party/yasm/yasm-1.3.0"
cp -R "$$SOURCE_PATH" "$$BUILD_DIR/"
pushd "$$BUILD_DIR/yasm-1.3.0"
mkdir build
cd build
PATH="$$CMAKE_DIR/cmake-4.1.2-macos-universal/CMake.app/Contents/bin:$$PATH" cmake .. -DYASM_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DPYTHON_EXECUTABLE="$$(which python3)"
"$$CMAKE_BIN" .. -DYASM_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DPYTHON_EXECUTABLE="$$(which python3)"
make -j $$core_count
popd