├── .dockerignore ├── .editorconfig ├── .github └── workflows │ └── release.yml ├── .gitignore ├── .vscode ├── extensions.json └── settings.json ├── Dockerfile ├── LICENSE ├── README.md ├── patches ├── 25-lcms │ └── sse2neon.patch ├── 45-de265 │ └── sse2neon.patch ├── 50-soxr │ └── fix-aarch64-cmake-pkgconfig.patch └── 99-ffmpeg │ ├── remove_lzma_apple_non_public_api.patch │ └── use-vaMapBuffer2-for-mapping-image.patch ├── renovate.json ├── scripts ├── build.sh ├── cc.sh ├── cmake.sh ├── convert_yolo.ipynb ├── create-macos-framework.sh ├── curl_tar.sh ├── meson.sh ├── rc.sh ├── sw_vers.sh ├── tool-wrapper.sh └── toolchain.sh └── stages ├── 00-apple ├── 00-sdk.sh ├── 01-xar.sh ├── 02-tapi.sh ├── 03-dispatch.sh ├── 04-cctools.sh └── 05-ldid.sh ├── 00-ndk.sh ├── 10-compiler-rt.sh ├── 10-sse2neon.sh ├── 20-brotli.sh ├── 20-bzip2.sh ├── 20-lzo.sh ├── 20-zlib.sh ├── 25-lcms.sh ├── 25-lzma.sh ├── 25-ogg.sh ├── 25-pciaccess.sh ├── 45-dav1d.sh ├── 45-de265.sh ├── 45-drm.sh ├── 45-opencl ├── 25-opencl-headers.sh └── 45-opencl.sh ├── 45-sharpyuv.sh ├── 45-vorbis.sh ├── 45-vvenc.sh ├── 50-amf.sh ├── 50-lame.sh ├── 50-nvenc.sh ├── 50-onevpl.sh ├── 50-opus.sh ├── 50-soxr.sh ├── 50-svt-av1.sh ├── 50-theora.sh ├── 50-va.sh ├── 50-vpx.sh ├── 50-vulkan ├── 45-vulkan.sh ├── 50-shaderc.sh ├── 55-spirv-cross.sh └── 60-placebo.sh ├── 50-x264.sh ├── 50-x265.sh ├── 50-zimg.sh ├── 99-ffmpeg.sh ├── 99-heif.sh ├── 99-onnx.sh ├── 99-pdfium.sh ├── 99-protoc.sh └── 99-yolov8.sh /.dockerignore: -------------------------------------------------------------------------------- 1 | .gitignore -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: http://EditorConfig.org 2 | 3 | # https://github.com/jokeyrhyme/standard-editorconfig 4 | 5 | # top-most EditorConfig file 6 | root = true 7 | 8 | # defaults 9 | [*] 10 | charset = utf-8 11 | end_of_line = lf 12 | max_line_length = 100 13 | insert_final_newline = true 14 | trim_trailing_whitespace = true 15 | 16 | # BATS: https://github.com/bats-core/bats-core 17 | # https://github.com/bats-core/bats-core/master/.editorconfig 18 | [*.bats] 19 | indent_style = space 20 | indent_size = 2 21 | insert_final_newline = true 22 | max_line_length = 80 23 | trim_trailing_whitespace = true 24 | 25 | # Bazel: https://bazel.build/ 26 | # https://github.com/bazelbuild/buildtools/blob/master/BUILD.bazel 27 | [*.{bazel,bzl}] 28 | indent_size = 4 29 | indent_style = space 30 | 31 | # GNU make 32 | # https://www.gnu.org/software/make/manual/html_node/Recipe-Syntax.html 33 | [Makefile] 34 | indent_style = tab 35 | 36 | # JavaScript, JSON, JSX, JavaScript Modules, TypeScript 37 | # https://github.com/feross/standard 38 | # https://prettier.io 39 | [*.{cjs,js,json,jsx,mjs,ts,tsx}] 40 | indent_size = 2 41 | indent_style = space 42 | 43 | # Python 44 | # https://www.python.org/dev/peps/pep-0008/#code-lay-out 45 | [*.py] 46 | indent_size = 4 47 | indent_style = space 48 | 49 | # Shell 50 | # https://google.github.io/styleguide/shell.xml#Indentation 51 | [*.{bash,sh,zsh}] 52 | indent_size = 2 53 | indent_style = space 54 | 55 | # TOML 56 | # https://github.com/toml-lang/toml/tree/master/examples 57 | [*.toml] 58 | indent_size = 2 59 | indent_style = space 60 | 61 | # YAML 62 | # http://yaml.org/spec/1.2/2009-07-21/spec.html#id2576668 63 | [*.{yaml,yml}] 64 | indent_size = 2 65 | indent_style = space 66 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Build native deps 2 | on: 3 | push: 4 | paths: 5 | - 'stages/**' 6 | - 'patches/**' 7 | - 'scripts/**' 8 | - 'Dockerfile' 9 | - '.github/workflows/release.yml' 10 | branches: 11 | - main 12 | pull_request: 13 | paths: 14 | - 'stages/**' 15 | - 'patches/**' 16 | - 'scripts/**' 17 | - 'Dockerfile' 18 | - '.github/workflows/release.yml' 19 | workflow_dispatch: 20 | 21 | # Cancel previous runs of the same workflow on the same branch. 22 | concurrency: 23 | group: ${{ github.workflow }}-${{ github.ref }} 24 | cancel-in-progress: true 25 | 26 | jobs: 27 | build-native-deps: 28 | strategy: 29 | matrix: 30 | settings: 31 | - target: x86_64-iossim-apple 32 | - target: aarch64-iossim-apple 33 | - target: aarch64-ios-apple 34 | - target: x86_64-darwin-apple 35 | - target: aarch64-darwin-apple 36 | - target: x86_64-windows-gnu 37 | - target: aarch64-windows-gnu 38 | - target: x86_64-linux-gnu 39 | - target: aarch64-linux-gnu 40 | - target: x86_64-linux-musl 41 | - target: aarch64-linux-musl 42 | - target: x86_64-linux-android 43 | - target: aarch64-linux-android 44 | name: Build native-deps ${{ matrix.settings.target }} 45 | runs-on: ubuntu-latest 46 | defaults: 47 | run: 48 | shell: bash 49 | steps: 50 | - name: Checkout repository 51 | uses: actions/checkout@v4 52 | 53 | - name: Set up Docker Buildx 54 | uses: docker/setup-buildx-action@v3 55 | with: 56 | install: true 57 | platforms: linux/amd64 58 | driver-opts: | 59 | image=moby/buildkit:master 60 | network=host 61 | 62 | - name: Build native-deps 63 | run: | 64 | set -euxo pipefail 65 | 66 | TARGET=${{ matrix.settings.target }} 67 | OS_IPHONE=0 68 | if [ "$TARGET" = 'x86_64-iossim-apple' ]; then 69 | TARGET='x86_64-darwin-apple' 70 | OS_IPHONE=2 71 | elif [ "$TARGET" = 'aarch64-iossim-apple' ]; then 72 | TARGET='aarch64-darwin-apple' 73 | OS_IPHONE=2 74 | elif [ "$TARGET" = 'aarch64-ios-apple' ]; then 75 | TARGET='aarch64-darwin-apple' 76 | OS_IPHONE=1 77 | fi 78 | 79 | docker build --no-cache --build-arg TARGET="$TARGET" --build-arg OS_IPHONE="$OS_IPHONE" --build-arg VERSION="$(echo ${{ github.ref }} | sed -E 's/refs\/tags\/v?//g' | sed -E 's/[^0-9.]//g')" -o . . 80 | mv out/src.tar.xz ./native-deps-${{ matrix.settings.target }}-src.tar.xz 81 | export XZ_OPT='-T0 -7' 82 | tar -cJf "native-deps-${{ matrix.settings.target }}.tar.xz" -C out . 83 | 84 | - name: Publish native-deps 85 | uses: actions/upload-artifact@v4 86 | with: 87 | name: native-deps-${{ matrix.settings.target }} 88 | path: native-deps-${{ matrix.settings.target }}.tar.xz 89 | if-no-files-found: error 90 | 91 | - name: Publish built source 92 | uses: actions/upload-artifact@v4 93 | with: 94 | name: native-deps-${{ matrix.settings.target }}-src 95 | path: native-deps-${{ matrix.settings.target }}-src.tar.xz 96 | if-no-files-found: warn 97 | 98 | release: 99 | if: startsWith(github.ref, 'refs/tags/') 100 | runs-on: ubuntu-latest 101 | name: Create Release 102 | needs: build-native-deps 103 | permissions: 104 | contents: write 105 | steps: 106 | - name: Download artifacts 107 | uses: actions/download-artifact@v4 108 | 109 | - name: Create Release 110 | uses: softprops/action-gh-release@v2 111 | with: 112 | draft: true 113 | files: '*/**' 114 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by https://www.toptal.com/developers/gitignore/api/c,c++,autotools,autotools+strict,windows,linux,macos,cmake,meson,visualstudiocode 2 | # Edit at https://www.toptal.com/developers/gitignore?templates=c,c++,autotools,autotools+strict,windows,linux,macos,cmake,meson,visualstudiocode 3 | 4 | ### Autotools ### 5 | # http://www.gnu.org/software/automake 6 | 7 | Makefile.in 8 | /ar-lib 9 | /mdate-sh 10 | /py-compile 11 | /test-driver 12 | /ylwrap 13 | .deps/ 14 | .dirstamp 15 | 16 | # http://www.gnu.org/software/autoconf 17 | 18 | autom4te.cache 19 | /autoscan.log 20 | /autoscan-*.log 21 | /aclocal.m4 22 | /compile 23 | /config.cache 24 | /config.guess 25 | /config.h.in 26 | /config.log 27 | /config.status 28 | /config.sub 29 | /configure 30 | /configure.scan 31 | /depcomp 32 | /install-sh 33 | /missing 34 | /stamp-h1 35 | 36 | # https://www.gnu.org/software/libtool/ 37 | 38 | /ltmain.sh 39 | 40 | # http://www.gnu.org/software/texinfo 41 | 42 | /texinfo.tex 43 | 44 | # http://www.gnu.org/software/m4/ 45 | 46 | m4/libtool.m4 47 | m4/ltoptions.m4 48 | m4/ltsugar.m4 49 | m4/ltversion.m4 50 | m4/lt~obsolete.m4 51 | 52 | # Generated Makefile 53 | # (meta build system like autotools, 54 | # can automatically generate from config.status script 55 | # (which is called by configure script)) 56 | Makefile 57 | 58 | ### Autotools Patch ### 59 | 60 | ### Autotools+strict ### 61 | # http://www.gnu.org/software/automake 62 | 63 | 64 | # http://www.gnu.org/software/autoconf 65 | 66 | 67 | # https://www.gnu.org/software/libtool/ 68 | 69 | 70 | # http://www.gnu.org/software/texinfo 71 | 72 | 73 | # http://www.gnu.org/software/m4/ 74 | 75 | 76 | # Generated Makefile 77 | # (meta build system like autotools, 78 | # can automatically generate from config.status script 79 | # (which is called by configure script)) 80 | 81 | ### Autotools+strict Patch ### 82 | # Generated source files 83 | configure 84 | 85 | ### C ### 86 | # Prerequisites 87 | *.d 88 | 89 | # Object files 90 | *.o 91 | *.ko 92 | *.obj 93 | *.elf 94 | 95 | # Linker output 96 | *.ilk 97 | *.map 98 | *.exp 99 | 100 | # Precompiled Headers 101 | *.gch 102 | *.pch 103 | 104 | # Libraries 105 | *.lib 106 | *.a 107 | *.la 108 | *.lo 109 | 110 | # Shared objects (inc. Windows DLLs) 111 | *.dll 112 | *.so 113 | *.so.* 114 | *.dylib 115 | 116 | # Executables 117 | *.exe 118 | *.out 119 | *.app 120 | *.i*86 121 | *.x86_64 122 | *.hex 123 | 124 | # Debug files 125 | *.dSYM/ 126 | *.su 127 | *.idb 128 | *.pdb 129 | 130 | # Kernel Module Compile Results 131 | *.mod* 132 | *.cmd 133 | .tmp_versions/ 134 | modules.order 135 | Module.symvers 136 | Mkfile.old 137 | dkms.conf 138 | 139 | ### C++ ### 140 | # Prerequisites 141 | 142 | # Compiled Object files 143 | *.slo 144 | 145 | # Precompiled Headers 146 | 147 | # Compiled Dynamic libraries 148 | 149 | # Fortran module files 150 | *.mod 151 | *.smod 152 | 153 | # Compiled Static libraries 154 | *.lai 155 | 156 | # Executables 157 | 158 | ### CMake ### 159 | CMakeLists.txt.user 160 | CMakeCache.txt 161 | CMakeFiles 162 | CMakeScripts 163 | Testing 164 | cmake_install.cmake 165 | install_manifest.txt 166 | compile_commands.json 167 | CTestTestfile.cmake 168 | _deps 169 | 170 | ### CMake Patch ### 171 | # External projects 172 | *-prefix/ 173 | 174 | ### Linux ### 175 | *~ 176 | 177 | # temporary files which can be created if a process still has a handle open of a deleted file 178 | .fuse_hidden* 179 | 180 | # KDE directory preferences 181 | .directory 182 | 183 | # Linux trash folder which might appear on any partition or disk 184 | .Trash-* 185 | 186 | # .nfs files are created when an open file is removed but is still being accessed 187 | .nfs* 188 | 189 | ### macOS ### 190 | # General 191 | .DS_Store 192 | .AppleDouble 193 | .LSOverride 194 | 195 | # Icon must end with two \r 196 | Icon 197 | 198 | 199 | # Thumbnails 200 | ._* 201 | 202 | # Files that might appear in the root of a volume 203 | .DocumentRevisions-V100 204 | .fseventsd 205 | .Spotlight-V100 206 | .TemporaryItems 207 | .Trashes 208 | .VolumeIcon.icns 209 | .com.apple.timemachine.donotpresent 210 | 211 | # Directories potentially created on remote AFP share 212 | .AppleDB 213 | .AppleDesktop 214 | Network Trash Folder 215 | Temporary Items 216 | .apdisk 217 | 218 | ### macOS Patch ### 219 | # iCloud generated files 220 | *.icloud 221 | 222 | ### Meson ### 223 | # subproject directories 224 | /subprojects/* 225 | !/subprojects/*.wrap 226 | 227 | # Meson Directories 228 | meson-logs 229 | meson-private 230 | 231 | # Meson Files 232 | meson_benchmark_setup.dat 233 | meson_test_setup.dat 234 | sanitycheckcpp.cc # C++ specific 235 | sanitycheckcpp.exe # C++ specific 236 | 237 | # Ninja 238 | build.ninja 239 | .ninja_deps 240 | .ninja_logs 241 | 242 | # Misc 243 | 244 | ### VisualStudioCode ### 245 | .vscode/* 246 | !.vscode/settings.json 247 | !.vscode/tasks.json 248 | !.vscode/launch.json 249 | !.vscode/extensions.json 250 | !.vscode/*.code-snippets 251 | 252 | # Local History for Visual Studio Code 253 | .history/ 254 | 255 | # Built Visual Studio Code Extensions 256 | *.vsix 257 | 258 | ### VisualStudioCode Patch ### 259 | # Ignore all local history of files 260 | .history 261 | .ionide 262 | 263 | ### Windows ### 264 | # Windows thumbnail cache files 265 | Thumbs.db 266 | Thumbs.db:encryptable 267 | ehthumbs.db 268 | ehthumbs_vista.db 269 | 270 | # Dump file 271 | *.stackdump 272 | 273 | # Folder config file 274 | [Dd]esktop.ini 275 | 276 | # Recycle Bin used on file shares 277 | $RECYCLE.BIN/ 278 | 279 | # Windows Installer files 280 | *.cab 281 | *.msi 282 | *.msix 283 | *.msm 284 | *.msp 285 | 286 | # Windows shortcuts 287 | *.lnk 288 | 289 | # End of https://www.toptal.com/developers/gitignore/api/c,c++,autotools,autotools+strict,windows,linux,macos,cmake,meson,visualstudiocode 290 | 291 | out* 292 | *.log 293 | __zig_fix_stdin* 294 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "timonwong.shellcheck", 4 | "codezombiech.gitignore", 5 | "foxundermoon.shell-format", 6 | "EditorConfig.EditorConfig", 7 | "ms-azuretools.vscode-docker", 8 | "github.vscode-github-actions", 9 | "mads-hartmann.bash-ide-vscode", 10 | "jeff-hykin.better-shellscript-syntax" 11 | ], 12 | } 13 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "shellformat.flag": "-bn -ci", 3 | "[dockerfile]": { 4 | "editor.defaultFormatter": "ms-azuretools.vscode-docker" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # escape=` 2 | 3 | ARG OUT='/opt/out' 4 | ARG TARGET='x86_64-linux-gnu' 5 | ARG VERSION='0.0.0' 6 | ARG OS_IPHONE='0' 7 | 8 | # renovate: datasource=github-releases depName=ziglang/zig 9 | ARG ZIG_VERSION='0.12.1' 10 | # renovate: datasource=github-releases depName=mesonbuild/meson 11 | ARG MESON_VERSION='1.7.2' 12 | # renovate: datasource=github-releases depName=Kitware/CMake 13 | ARG CMAKE_VERSION='3.31.6' 14 | # renovate: datasource=github-releases depName=NixOS/patchelf 15 | ARG PATCHELF_VERSION='0.18.0' 16 | ARG MACOS_SDK_VERSION='14.0' 17 | ARG IOS_SDK_VERSION='17.0' 18 | ARG ANDROID_API_LEVEL='28' 19 | 20 | #-- 21 | 22 | FROM debian:bookworm@sha256:00cd074b40c4d99ff0c24540bdde0533ca3791edcdac0de36d6b9fb3260d89e2 AS build-base 23 | 24 | SHELL ["bash", "-euxo", "pipefail", "-c"] 25 | 26 | # Configure apt to be docker friendly 27 | ADD https://gist.githubusercontent.com/HeavenVolkoff/ff7b77b9087f956b8df944772e93c071/raw ` 28 | /etc/apt/apt.conf.d/99docker-apt-config 29 | 30 | RUN rm -f /etc/apt/apt.conf.d/docker-clean 31 | 32 | RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections 33 | 34 | RUN --mount=type=cache,target=/var/cache/apt --mount=type=cache,target=/var/lib/apt ` 35 | apt-get update && apt-get upgrade && apt-get install -y ca-certificates 36 | 37 | # Add LLVM 17 repository 38 | ADD https://apt.llvm.org/llvm-snapshot.gpg.key /etc/apt/trusted.gpg.d/apt.llvm.org.asc 39 | 40 | RUN chmod 644 /etc/apt/trusted.gpg.d/apt.llvm.org.asc 41 | 42 | RUN echo "deb https://apt.llvm.org/bookworm/ llvm-toolchain-bookworm-17 main" ` 43 | > /etc/apt/sources.list.d/llvm.list 44 | 45 | # Install build dependencies 46 | RUN --mount=type=cache,target=/var/cache/apt --mount=type=cache,target=/var/lib/apt ` 47 | apt-get update && apt-get install ` 48 | nasm ` 49 | curl ` 50 | make ` 51 | patch ` 52 | rsync ` 53 | lld-17 ` 54 | libtool ` 55 | python3 ` 56 | gettext ` 57 | llvm-17 ` 58 | autoconf ` 59 | clang-17 ` 60 | pkg-config ` 61 | ninja-build ` 62 | libarchive-tools ` 63 | protobuf-compiler 64 | 65 | # Configure sysroot and prefix 66 | ARG OUT 67 | ENV OUT="${OUT:?}" 68 | ENV PREFIX="/opt/prefix" 69 | ENV SYSROOT="/opt/sysroot" 70 | ENV CCTOOLS="/opt/cctools" 71 | ENV CIPHERSUITES="TLS_AES_128_GCM_SHA256:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_256_GCM_SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384" 72 | 73 | # Ensure sysroot and cctools are present on PATH 74 | ENV PATH="${CCTOOLS}/bin:${SYSROOT}/bin:$PATH" 75 | 76 | # Create required directories 77 | RUN mkdir -p "$OUT" "$CCTOOLS" "${PREFIX}/bin" "${SYSROOT}/bin" "${SYSROOT}/wrapper" 78 | 79 | # Utility to download, extract and cache archived files 80 | COPY --chmod=0750 ./scripts/curl_tar.sh "${SYSROOT}/bin/curl_tar" 81 | 82 | # Download and install zig toolchain 83 | ARG ZIG_VERSION 84 | RUN --mount=type=cache,target=/root/.cache ` 85 | curl_tar "https://ziglang.org/download/${ZIG_VERSION:?}/zig-linux-$(uname -m)-${ZIG_VERSION:?}.tar.xz" "$SYSROOT" 1 ` 86 | && mv "${SYSROOT}/zig" "${SYSROOT}/bin/zig" 87 | 88 | # Download and install cmake 89 | ARG CMAKE_VERSION 90 | RUN --mount=type=cache,target=/root/.cache ` 91 | curl_tar "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION:?}/cmake-${CMAKE_VERSION:?}-linux-$(uname -m).tar.gz" "$SYSROOT" 1 92 | 93 | # Download and install meson, with a patch to add zig support 94 | ARG MESON_VERSION 95 | RUN --mount=type=cache,target=/root/.cache ` 96 | curl_tar "https://github.com/mesonbuild/meson/archive/refs/tags/${MESON_VERSION:?}.tar.gz" /srv/meson 1 97 | RUN cd /srv/meson ` 98 | && packaging/create_zipapp.py --outfile "${SYSROOT}/bin/meson" --compress ` 99 | && rm -rf /srv/meson 100 | 101 | # Download and install patchelf, used to do some light rpath ELF manipulation 102 | ARG PATCHELF_VERSION 103 | RUN --mount=type=cache,target=/root/.cache ` 104 | curl_tar "https://github.com/NixOS/patchelf/releases/download/${PATCHELF_VERSION:?}/patchelf-${PATCHELF_VERSION:?}-$(uname -m).tar.gz" "$SYSROOT" 1 105 | 106 | # Download and install gas-preprocessor, used by our zig wrapper to handle GNU flavored assembly files 107 | ADD --chmod=0750 'https://github.com/libav/gas-preprocessor/raw/master/gas-preprocessor.pl' "${SYSROOT}/bin/gas-preprocessor.pl" 108 | 109 | # Download compat tool for generating def files for windows 110 | ADD --chmod=0750 'https://github.com/FFmpeg/FFmpeg/raw/master/compat/windows/makedef' "${SYSROOT}/bin/makedef" 111 | 112 | # Workaround for -lsynchronization linking issue on Windows GNU targets 113 | # https://github.com/ziglang/zig/issues/14919 114 | RUN cd "${SYSROOT}/lib/libc/mingw/lib-common" ` 115 | && { [ -f 'synchronization.def' ] || ln -s 'api-ms-win-core-synch-l1-2-0.def' 'synchronization.def'; } 116 | 117 | #-- 118 | 119 | FROM build-base AS base-layer 120 | 121 | # Configure android ndk sysroot 122 | ENV NDK_SDKROOT="${SYSROOT}/sysroot" 123 | ARG ANDROID_API_LEVEL 124 | ENV ANDROID_API_LEVEL="${ANDROID_API_LEVEL:?}" 125 | 126 | # Configure macOS SDK for darwin targets 127 | ARG MACOS_SDK_VERSION 128 | ENV MACOS_SDK_VERSION="${MACOS_SDK_VERSION:?}" 129 | ENV MACOS_SDKROOT="/opt/MacOSX${MACOS_SDK_VERSION}.sdk" 130 | ARG IOS_SDK_VERSION 131 | ENV IOS_SDK_VERSION="${IOS_SDK_VERSION:?}" 132 | ENV IOS_SDKROOT="/opt/iPhoneOS${IOS_SDK_VERSION}.sdk" 133 | ENV IOS_SIMULATOR_SDKROOT="/opt/iPhoneSimulator${IOS_SDK_VERSION}.sdk" 134 | 135 | # Export which target we are building for 136 | ARG TARGET 137 | ENV TARGET="${TARGET:?}" 138 | ARG OS_IPHONE 139 | ENV OS_IPHONE="${OS_IPHONE:?}" 140 | 141 | # Cache bust 142 | RUN echo "Building: ${TARGET}$(case "$TARGET" in *darwin*) echo " (macOS SDK: ${MACOS_SDK_VERSION}, iOS SDK: ${IOS_SDK_VERSION})" ;; esac)" 143 | 144 | # Script wrapper for some common build tools. Auto choose between llvm, zig or apple specific versions 145 | COPY --chmod=0750 ./scripts/tool-wrapper.sh "${SYSROOT}/bin/tool-wrapper.sh" 146 | RUN for tool in ` 147 | ar nm lib lipo size otool strip ranlib readelf libtool objdump dlltool objcopy strings bitcode-strip install_name_tool; ` 148 | do ln -s "$(command -v tool-wrapper.sh)" "${SYSROOT}/bin/${tool}"; done 149 | 150 | # Custom llvm rc wrapper script with some pre-configurations 151 | # Do not name this llvm-rc or rc.exe, to avoid cmake weird special behavior for those tool names 152 | COPY --chmod=0750 ./scripts/rc.sh "${SYSROOT}/bin/rc" 153 | COPY --chmod=0750 ./scripts/rc.sh "${SYSROOT}/bin/windres" 154 | 155 | # Polyfill macOS sw_vers command 156 | COPY --chmod=0750 ./scripts/sw_vers.sh "${SYSROOT}/bin/sw_vers" 157 | 158 | #-- 159 | 160 | FROM base-layer AS layer-00 161 | 162 | # Download, build and install Apple specific SDK and tools 163 | RUN --mount=type=cache,target=/root/.cache ` 164 | --mount=type=bind,source=stages/00-apple/00-sdk.sh,target=/srv/00-sdk.sh ` 165 | /srv/00-sdk.sh 166 | 167 | RUN --mount=type=cache,target=/var/cache/apt --mount=type=cache,target=/var/lib/apt --mount=type=cache,target=/root/.cache ` 168 | --mount=type=bind,source=stages/00-apple/01-xar.sh,target=/srv/01-xar.sh ` 169 | /srv/01-xar.sh 170 | 171 | RUN --mount=type=cache,target=/root/.cache ` 172 | --mount=type=bind,source=stages/00-apple/02-tapi.sh,target=/srv/02-tapi.sh ` 173 | /srv/02-tapi.sh 174 | 175 | RUN --mount=type=cache,target=/var/cache/apt --mount=type=cache,target=/var/lib/apt --mount=type=cache,target=/root/.cache ` 176 | --mount=type=bind,source=stages/00-apple/03-dispatch.sh,target=/srv/03-dispatch.sh ` 177 | /srv/03-dispatch.sh 178 | 179 | RUN --mount=type=cache,target=/var/cache/apt --mount=type=cache,target=/var/lib/apt --mount=type=cache,target=/root/.cache ` 180 | --mount=type=bind,source=stages/00-apple/04-cctools.sh,target=/srv/04-cctools.sh ` 181 | /srv/04-cctools.sh 182 | 183 | RUN --mount=type=cache,target=/root/.cache ` 184 | --mount=type=bind,source=stages/00-apple/05-ldid.sh,target=/srv/05-ldid.sh ` 185 | /srv/05-ldid.sh 186 | 187 | # Download NDK sysroot 188 | RUN --mount=type=cache,target=/root/.cache ` 189 | --mount=type=bind,source=stages/00-ndk.sh,target=/srv/00-ndk.sh ` 190 | /srv/00-ndk.sh 191 | 192 | # Ensure no one tries to call the native system linker 193 | RUN ln -s '/usr/bin/false' "${SYSROOT}/bin/ld" 194 | 195 | # Add wrapper script for zig compilers, we need to ensure that they are called with the correct arguments 196 | COPY --chmod=0750 ./scripts/cc.sh "${SYSROOT}/bin/cc" 197 | RUN ln -s 'cc' "${SYSROOT}/bin/c++" 198 | # Hack for cmake to work when compiling android targets 199 | RUN ln -s 'cc' "${SYSROOT}/bin/android-gcc" 200 | RUN ln -s 'cc' "${SYSROOT}/bin/android-g++" 201 | 202 | # Create cmake and meson toolchain files 203 | RUN --mount=type=bind,rw,source=scripts/toolchain.sh,target=/srv/toolchain.sh /srv/toolchain.sh 204 | 205 | # Create a cmake wrapper script with some pre-configurations 206 | COPY --chmod=0750 ./scripts/cmake.sh "${SYSROOT}/wrapper/cmake" 207 | 208 | # Create a meson wrapper script with some pre-configurations 209 | COPY --chmod=0750 ./scripts/meson.sh "${SYSROOT}/wrapper/meson" 210 | 211 | # Wrapper script that pre-configure autotools and build flags fro each target 212 | COPY --chmod=0750 ./scripts/build.sh /srv/build.sh 213 | 214 | #-- 215 | 216 | FROM layer-00 AS layer-10-sse2neon 217 | 218 | RUN --mount=type=cache,target=/root/.cache --mount=type=bind,source=stages/10-sse2neon.sh,target=/srv/stage.sh ` 219 | /srv/build.sh 220 | 221 | FROM layer-00 AS layer-10-compiler-rt 222 | 223 | RUN --mount=type=cache,target=/root/.cache ` 224 | --mount=type=bind,source=stages/10-compiler-rt.sh,target=/srv/stage.sh ` 225 | env CRT_HACK=1 /srv/build.sh 226 | 227 | FROM layer-00 AS layer-10 228 | 229 | COPY --from=layer-10-sse2neon "${PREFIX}/." "$PREFIX" 230 | COPY --from=layer-10-compiler-rt "/usr/lib/llvm-17/lib/clang/17/." '/usr/lib/llvm-17/lib/clang/17' 231 | 232 | #-- 233 | 234 | FROM layer-10 AS layer-20-brotli 235 | 236 | RUN --mount=type=cache,target=/root/.cache ` 237 | --mount=type=bind,source=stages/20-brotli.sh,target=/srv/stage.sh ` 238 | /srv/build.sh 239 | 240 | FROM layer-10 AS layer-20-bzip2 241 | 242 | RUN --mount=type=cache,target=/root/.cache ` 243 | --mount=type=bind,source=stages/20-bzip2.sh,target=/srv/stage.sh ` 244 | /srv/build.sh 245 | 246 | FROM layer-10 AS layer-20-lzo 247 | 248 | RUN --mount=type=cache,target=/root/.cache ` 249 | --mount=type=bind,source=stages/20-lzo.sh,target=/srv/stage.sh ` 250 | /srv/build.sh 251 | 252 | FROM layer-10 AS layer-20-zlib 253 | 254 | RUN --mount=type=cache,target=/root/.cache ` 255 | --mount=type=bind,source=stages/20-zlib.sh,target=/srv/stage.sh ` 256 | /srv/build.sh 257 | 258 | FROM layer-10 AS layer-20 259 | 260 | COPY --from=layer-20-brotli "${PREFIX}/." "$PREFIX" 261 | COPY --from=layer-20-bzip2 "${PREFIX}/." "$PREFIX" 262 | COPY --from=layer-20-lzo "${PREFIX}/." "$PREFIX" 263 | COPY --from=layer-20-zlib "${PREFIX}/." "$PREFIX" 264 | 265 | #-- 266 | 267 | FROM layer-20 AS layer-25-lcms 268 | 269 | RUN --mount=type=cache,target=/root/.cache ` 270 | --mount=type=bind,source=stages/25-lcms.sh,target=/srv/stage.sh ` 271 | --mount=type=bind,source=patches/25-lcms,target="${PREFIX}/patches" ` 272 | /srv/build.sh 273 | 274 | FROM layer-20 AS layer-25-lzma 275 | 276 | RUN --mount=type=cache,target=/root/.cache ` 277 | --mount=type=bind,source=stages/25-lzma.sh,target=/srv/stage.sh ` 278 | /srv/build.sh 279 | 280 | FROM layer-20 AS layer-25-ogg 281 | 282 | RUN --mount=type=cache,target=/root/.cache ` 283 | --mount=type=bind,source=stages/25-ogg.sh,target=/srv/stage.sh ` 284 | /srv/build.sh 285 | 286 | FROM layer-20 AS layer-25-pciaccess 287 | 288 | RUN --mount=type=cache,target=/root/.cache ` 289 | --mount=type=bind,source=stages/25-pciaccess.sh,target=/srv/stage.sh ` 290 | /srv/build.sh 291 | 292 | FROM layer-20 AS layer-25 293 | 294 | COPY --from=layer-25-lcms "${PREFIX}/." "$PREFIX" 295 | COPY --from=layer-25-lzma "${PREFIX}/." "$PREFIX" 296 | COPY --from=layer-25-ogg "${PREFIX}/." "$PREFIX" 297 | COPY --from=layer-25-pciaccess "${PREFIX}/." "$PREFIX" 298 | 299 | #-- 300 | 301 | FROM layer-25 AS layer-45-dav1d 302 | 303 | RUN --mount=type=cache,target=/root/.cache ` 304 | --mount=type=bind,source=stages/45-dav1d.sh,target=/srv/stage.sh ` 305 | /srv/build.sh 306 | 307 | FROM layer-25 AS layer-45-de265 308 | 309 | RUN --mount=type=cache,target=/root/.cache ` 310 | --mount=type=bind,source=stages/45-de265.sh,target=/srv/stage.sh ` 311 | --mount=type=bind,source=patches/45-de265,target="${PREFIX}/patches" ` 312 | /srv/build.sh 313 | 314 | FROM layer-25 AS layer-45-drm 315 | 316 | RUN --mount=type=cache,target=/root/.cache ` 317 | --mount=type=bind,source=stages/45-drm.sh,target=/srv/stage.sh ` 318 | /srv/build.sh 319 | 320 | FROM layer-25 AS layer-45-opencl 321 | 322 | RUN --mount=type=cache,target=/root/.cache ` 323 | --mount=type=bind,source=stages/45-opencl/25-opencl-headers.sh,target=/srv/stage.sh ` 324 | /srv/build.sh 325 | 326 | RUN --mount=type=cache,target=/root/.cache ` 327 | --mount=type=bind,source=stages/45-opencl/45-opencl.sh,target=/srv/stage.sh ` 328 | /srv/build.sh 329 | 330 | FROM layer-25 AS layer-45-sharpyuv 331 | 332 | RUN --mount=type=cache,target=/root/.cache ` 333 | --mount=type=bind,source=stages/45-sharpyuv.sh,target=/srv/stage.sh ` 334 | /srv/build.sh 335 | 336 | FROM layer-25 AS layer-45-vorbis 337 | 338 | RUN --mount=type=cache,target=/root/.cache ` 339 | --mount=type=bind,source=stages/45-vorbis.sh,target=/srv/stage.sh ` 340 | /srv/build.sh 341 | 342 | FROM layer-25 AS layer-45-vvenc 343 | 344 | RUN --mount=type=cache,target=/root/.cache ` 345 | --mount=type=bind,source=stages/45-vvenc.sh,target=/srv/stage.sh ` 346 | /srv/build.sh 347 | 348 | FROM layer-25 AS layer-45 349 | 350 | COPY --from=layer-45-dav1d "${PREFIX}/." "$PREFIX" 351 | COPY --from=layer-45-de265 "${PREFIX}/." "$PREFIX" 352 | COPY --from=layer-45-drm "${PREFIX}/." "$PREFIX" 353 | COPY --from=layer-45-opencl "${PREFIX}/." "$PREFIX" 354 | COPY --from=layer-45-sharpyuv "${PREFIX}/." "$PREFIX" 355 | COPY --from=layer-45-vorbis "${PREFIX}/." "$PREFIX" 356 | COPY --from=layer-45-vvenc "${PREFIX}/." "$PREFIX" 357 | 358 | #-- 359 | 360 | FROM layer-45 AS layer-50-amf 361 | 362 | RUN --mount=type=cache,target=/root/.cache ` 363 | --mount=type=bind,source=stages/50-amf.sh,target=/srv/stage.sh ` 364 | /srv/build.sh 365 | 366 | FROM layer-45 AS layer-50-nvenc 367 | 368 | RUN --mount=type=cache,target=/root/.cache ` 369 | --mount=type=bind,source=stages/50-nvenc.sh,target=/srv/stage.sh ` 370 | /srv/build.sh 371 | 372 | FROM layer-45 AS layer-50-lame 373 | 374 | RUN --mount=type=cache,target=/root/.cache ` 375 | --mount=type=bind,source=stages/50-lame.sh,target=/srv/stage.sh ` 376 | /srv/build.sh 377 | 378 | FROM layer-45 AS layer-50-onevpl 379 | 380 | RUN --mount=type=cache,target=/root/.cache ` 381 | --mount=type=bind,source=stages/50-onevpl.sh,target=/srv/stage.sh ` 382 | /srv/build.sh 383 | 384 | FROM layer-45 AS layer-50-opus 385 | 386 | RUN --mount=type=cache,target=/root/.cache ` 387 | --mount=type=bind,source=stages/50-opus.sh,target=/srv/stage.sh ` 388 | /srv/build.sh 389 | 390 | FROM layer-45 AS layer-50-soxr 391 | 392 | RUN --mount=type=cache,target=/root/.cache ` 393 | --mount=type=bind,source=stages/50-soxr.sh,target=/srv/stage.sh ` 394 | --mount=type=bind,source=patches/50-soxr,target="${PREFIX}/patches" ` 395 | /srv/build.sh 396 | 397 | FROM layer-45 AS layer-50-svt-av1 398 | 399 | RUN --mount=type=cache,target=/root/.cache ` 400 | --mount=type=bind,source=stages/50-svt-av1.sh,target=/srv/stage.sh ` 401 | /srv/build.sh 402 | 403 | FROM layer-45 AS layer-50-theora 404 | 405 | RUN --mount=type=cache,target=/root/.cache ` 406 | --mount=type=bind,source=stages/50-theora.sh,target=/srv/stage.sh ` 407 | /srv/build.sh 408 | 409 | FROM layer-45 AS layer-50-va 410 | 411 | RUN --mount=type=cache,target=/root/.cache ` 412 | --mount=type=bind,source=stages/50-va.sh,target=/srv/stage.sh ` 413 | /srv/build.sh 414 | 415 | FROM layer-45 AS layer-50-vpx 416 | 417 | RUN --mount=type=cache,target=/root/.cache ` 418 | --mount=type=bind,source=stages/50-vpx.sh,target=/srv/stage.sh ` 419 | /srv/build.sh 420 | 421 | FROM layer-45 AS layer-50-vulkan 422 | 423 | RUN --mount=type=cache,target=/root/.cache ` 424 | --mount=type=bind,source=stages/50-vulkan/45-vulkan.sh,target=/srv/stage.sh ` 425 | /srv/build.sh 426 | RUN --mount=type=cache,target=/root/.cache ` 427 | --mount=type=bind,source=stages/50-vulkan/50-shaderc.sh,target=/srv/stage.sh ` 428 | /srv/build.sh 429 | RUN --mount=type=cache,target=/root/.cache ` 430 | --mount=type=bind,source=stages/50-vulkan/55-spirv-cross.sh,target=/srv/stage.sh ` 431 | /srv/build.sh 432 | RUN --mount=type=cache,target=/root/.cache ` 433 | --mount=type=bind,source=stages/50-vulkan/60-placebo.sh,target=/srv/stage.sh ` 434 | /srv/build.sh 435 | 436 | FROM layer-45 AS layer-50-x264 437 | 438 | RUN --mount=type=cache,target=/root/.cache ` 439 | --mount=type=bind,source=stages/50-x264.sh,target=/srv/stage.sh ` 440 | /srv/build.sh 441 | 442 | FROM layer-45 AS layer-50-x265 443 | 444 | RUN --mount=type=cache,target=/root/.cache ` 445 | --mount=type=bind,source=stages/50-x265.sh,target=/srv/stage.sh ` 446 | /srv/build.sh 447 | 448 | FROM layer-45 AS layer-50-zimg 449 | 450 | RUN --mount=type=cache,target=/root/.cache ` 451 | --mount=type=bind,source=stages/50-zimg.sh,target=/srv/stage.sh ` 452 | /srv/build.sh 453 | 454 | FROM layer-45 AS layer-50 455 | 456 | COPY --from=layer-50-amf "${PREFIX}/." "$PREFIX" 457 | COPY --from=layer-50-nvenc "${PREFIX}/." "$PREFIX" 458 | COPY --from=layer-50-lame "${PREFIX}/." "$PREFIX" 459 | COPY --from=layer-50-onevpl "${PREFIX}/." "$PREFIX" 460 | COPY --from=layer-50-opus "${PREFIX}/." "$PREFIX" 461 | COPY --from=layer-50-soxr "${PREFIX}/." "$PREFIX" 462 | COPY --from=layer-50-svt-av1 "${PREFIX}/." "$PREFIX" 463 | COPY --from=layer-50-theora "${PREFIX}/." "$PREFIX" 464 | COPY --from=layer-50-va "${PREFIX}/." "$PREFIX" 465 | COPY --from=layer-50-vpx "${PREFIX}/." "$PREFIX" 466 | COPY --from=layer-50-vulkan "${PREFIX}/." "$PREFIX" 467 | COPY --from=layer-50-x264 "${PREFIX}/." "$PREFIX" 468 | COPY --from=layer-50-x265 "${PREFIX}/." "$PREFIX" 469 | COPY --from=layer-50-zimg "${PREFIX}/." "$PREFIX" 470 | 471 | #-- 472 | 473 | FROM layer-00 AS layer-99-protoc 474 | 475 | ADD https://raw.githubusercontent.com/protocolbuffers/protobuf/v25.0/LICENSE '/srv/protoc/LICENSE' 476 | 477 | RUN --mount=type=cache,target=/root/.cache ` 478 | --mount=type=bind,source=stages/99-protoc.sh,target=/srv/stage.sh ` 479 | /srv/build.sh 480 | 481 | FROM layer-00 AS layer-99-pdfium 482 | 483 | RUN --mount=type=cache,target=/root/.cache ` 484 | --mount=type=bind,source=stages/99-pdfium.sh,target=/srv/stage.sh ` 485 | /srv/build.sh 486 | 487 | FROM layer-00 AS layer-99-yolo 488 | 489 | RUN --mount=type=cache,target=/root/.cache ` 490 | --mount=type=bind,source=stages/99-yolov8.sh,target=/srv/stage.sh ` 491 | /srv/build.sh 492 | 493 | FROM layer-20 AS layer-99-onnx 494 | 495 | RUN --mount=type=cache,target=/root/.cache ` 496 | --mount=type=bind,source=stages/99-onnx.sh,target=/srv/stage.sh ` 497 | /srv/build.sh 498 | 499 | FROM layer-50 AS layer-99-ffmpeg 500 | 501 | RUN --mount=type=cache,target=/root/.cache ` 502 | --mount=type=bind,source=stages/99-ffmpeg.sh,target=/srv/stage.sh ` 503 | --mount=type=bind,source=patches/99-ffmpeg,target="${PREFIX}/patches" ` 504 | /srv/build.sh 505 | 506 | FROM layer-45 AS layer-99-heif 507 | 508 | COPY --from=layer-99-ffmpeg "${OUT}/." "$PREFIX" 509 | 510 | RUN --mount=type=cache,target=/root/.cache ` 511 | --mount=type=bind,source=stages/99-heif.sh,target=/srv/stage.sh ` 512 | /srv/build.sh 513 | 514 | FROM layer-00 AS layer-99 515 | 516 | COPY --from=layer-99-heif "${OUT}/." "$OUT" 517 | COPY --from=layer-99-heif "${PREFIX}/srv/." "${OUT}/srv" 518 | COPY --from=layer-99-heif "${PREFIX}/licenses/." "${OUT}/licenses" 519 | 520 | COPY --from=layer-99-protoc "${OUT}/." "$OUT" 521 | COPY --from=layer-99-protoc "${PREFIX}/licenses/." "${OUT}/licenses" 522 | 523 | COPY --from=layer-99-pdfium "${OUT}/." "$OUT" 524 | COPY --from=layer-99-pdfium "${PREFIX}/licenses/." "${OUT}/licenses" 525 | 526 | COPY --from=layer-99-yolo "${OUT}/." "$OUT" 527 | 528 | COPY --from=layer-99-onnx "${OUT}/." "$OUT" 529 | COPY --from=layer-99-onnx "${PREFIX}/srv/." "${OUT}/srv" 530 | COPY --from=layer-99-onnx "${PREFIX}/licenses/." "${OUT}/licenses" 531 | 532 | COPY --from=layer-99-ffmpeg "${OUT}/." "$OUT" 533 | COPY --from=layer-99-ffmpeg "${PREFIX}/srv/." "${OUT}/srv" 534 | COPY --from=layer-99-ffmpeg "${PREFIX}/licenses/." "${OUT}/licenses" 535 | 536 | # Remove build only files from output 537 | RUN rm -rf "${OUT}/share" "${OUT}/lib/pkgconfig" "${OUT}/lib/cmake" 538 | RUN find "${OUT}" \( -name '*.def' -o -name '*.dll.a' \) -delete 539 | 540 | # Move .lib files to the lib folder (Windows target only) 541 | RUN if [ -d "${OUT}/bin" ]; then find "${OUT}/bin" -name '*.lib' -exec install -Dt ../lib/ -m a-rwx,u+rw,g+r,o+r {} + ; fi 542 | 543 | # Copy .lib to .dll.a (Windows target only) 544 | RUN find "$OUT/lib" -name '*.lib' -exec ` 545 | sh -euxc 'for _file in "$@"; do cp "$_file" "$(dirname "$_file")/lib$(basename "$_file" .lib).dll.a"; done' sh {} + 546 | 547 | # Strip debug symbols and ensure any .so, .dll, .dylib has the execution flag set 548 | # Strip must run before patchelf 549 | # https://github.com/NixOS/patchelf/issues/507 550 | RUN --mount=type=cache,target=/root/.cache ` 551 | echo 'strip -S "$@" && chmod +x "$@"' >/srv/stage.sh ` 552 | && find "$OUT" -type f \( -name '*.so' -o -name '*.so.*' -o -name '*.dll' -o -name '*.dylib' \) -exec /srv/build.sh {} + 553 | 554 | # Ensure all .so files have the correct rpaths (Linux target only) 555 | RUN find "$OUT" -type f \( -name '*.so' -o -name '*.so.*' \) -exec patchelf --set-rpath '$ORIGIN' {} \; 556 | 557 | # Remove non executable files from bin folder 558 | RUN if [ -d "${OUT}/bin" ]; then find "${OUT}/bin" -type f -not -executable -delete; fi 559 | 560 | # Remove empty directories 561 | RUN find "$OUT" -type d -delete 2>/dev/null || true 562 | 563 | # Ensure correct file permissions 564 | RUN find "${OUT}" -type f -exec chmod u+rw,g+r,g-w,o+r,o-w {} + 565 | 566 | # Create macOS Frameworks from the built libs (Darwin target only) 567 | ARG VERSION 568 | ENV VERSION="${VERSION:-0.0.0}" 569 | RUN --mount=type=cache,target=/root/.cache ` 570 | --mount=type=bind,source=scripts/create-macos-framework.sh,target=/srv/stage.sh ` 571 | /srv/build.sh 572 | 573 | # Compress source code backup of the built libraries 574 | RUN cd "${OUT}/srv" && env XZ_OPT='-T0 -7' bsdtar -cJf ../src.tar.xz * 575 | RUN rm -rf "${OUT}/srv" 576 | 577 | #-- 578 | 579 | FROM scratch 580 | 581 | ARG OUT 582 | 583 | COPY --from=layer-99 "${OUT:?}/." /out 584 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Spacedrive native dependencies 2 | 3 | ## Build instructions 4 | 5 | To build the native dependencies a `docker` or `podman` installation is required. 6 | It is recomended to enable [`BuildKit`](https://docs.docker.com/build/buildkit/#getting-started) in docker. 7 | 8 | Just run the following inside this directory: 9 | 10 | ```sh 11 | $> docker build --build-arg TARGET= -o . . 12 | ``` 13 | 14 | or 15 | 16 | ```sh 17 | $> podman build --jobs 4 --format docker --build-arg TARGET= -o . . 18 | ``` 19 | 20 | Where `` is one of: 21 | 22 | - x86_64-darwin-apple 23 | - aarch64-darwin-apple 24 | - x86_64-windows-gnu 25 | - aarch64-windows-gnu 26 | - x86_64-linux-gnu 27 | - aarch64-linux-gnu 28 | - x86_64-linux-musl 29 | - aarch64-linux-musl 30 | - x86_64-linux-android 31 | - aarch64-linux-android 32 | 33 | > To build for iOS choose one of the `darwin` targets and pass `--build-arg OS_IPHONE=<1|2>` as an argument, `1` means iOS and `2` means iOS Simulator. Only iOS simulator supports `x86_64`. 34 | 35 | After some time (it takes aroung 1~2 hours in Github CI) a directory named `out` will show up in the current directory containing our native dependencies. 36 | 37 | ## TODO (Order of importance) 38 | 39 | - Fortify linux-musl shared libs: 40 | > https://git.2f30.org/fortify-headers/file/README.html 41 | - Add stack check to windows dlls whenever zig adds support to it: 42 | > https://github.com/ziglang/zig/blob/b3462b7/src/target.zig#L326-L329 43 | - Add stack check/protector to linux arm64 shared libs whenever zig fix the bug preventing it from working: 44 | > https://github.com/ziglang/zig/issues/17430#issuecomment-1752592338 45 | - Add support for pthread in windows builds: 46 | > https://github.com/GerHobbelt/pthread-win32 47 | > https://sourceforge.net/p/mingw-w64/mingw-w64/ci/master/tree/mingw-w64-libraries/winpthreads/ 48 | > https://github.com/msys2/MINGW-packages/blob/f4bd368/mingw-w64-winpthreads-git/PKGBUILD 49 | - Add libplacebo and vulkan support for apple builds through MoltenVK: 50 | > https://github.com/KhronosGroup/MoltenVK 51 | - Add Metal shader support for ffmpeg in apple builds: 52 | > https://github.com/darlinghq/darling/issues/326 53 | - Investigate why LTO fails at linking ffmpeg's libav* libs for windows builds 54 | - Investigate why LTO fails when linking any static lib in apple builds: 55 | > https://github.com/tpoechtrager/osxcross/issues/366 56 | 57 | ## Acknowledgments 58 | 59 | This build system is losely base on: 60 | 61 | - https://github.com/BtbN/FFmpeg-Builds 62 | 63 | It uses Zig 0.12 as a C/C++ toolchain to build the Windows and Linux targets: 64 | 65 | - https://github.com/ziglang/zig/tree/0.11.0 66 | 67 | It uses LLVM/Clang 17 with some tweaks from osxcross + Apple's cctools and linker to build the Darwin (macOS, iOS) targets: 68 | 69 | - https://github.com/llvm/llvm-project/tree/llvmorg-17.0.6 70 | - https://github.com/tpoechtrager/osxcross 71 | - https://github.com/tpoechtrager/cctools-port 72 | 73 | > By building the Darwin target you are agreeing with the [Apple Public Source License (APSL)](https://opensource.apple.com/apsl/) and the [Xcode license terms](https://www.apple.com/legal/sla/docs/xcode.pdf) 74 | 75 | Thanks to all the developers involved in making the dependencies used by this project 76 | -------------------------------------------------------------------------------- /patches/25-lcms/sse2neon.patch: -------------------------------------------------------------------------------- 1 | diff --git a/meson.build b/meson.build 2 | index c2b4f82..7734834 100644 3 | --- a/meson.build 4 | +++ b/meson.build 5 | @@ -72,7 +72,7 @@ tiff_dep = dependency('libtiff-4', required: get_option('tiff')) 6 | if ( 7 | not cc.compiles( 8 | ''' 9 | - #include 10 | + #include 11 | int main() { __m128i n = _mm_set1_epi8(42); } 12 | ''', 13 | name: 'supports SSE2 intrinsics', 14 | diff --git a/plugins/fast_float/src/fast_8_matsh_sse.c b/plugins/fast_float/src/fast_8_matsh_sse.c 15 | index 3d5f88b..2dd5871 100644 16 | --- a/plugins/fast_float/src/fast_8_matsh_sse.c 17 | +++ b/plugins/fast_float/src/fast_8_matsh_sse.c 18 | @@ -26,14 +26,7 @@ 19 | 20 | #ifndef CMS_DONT_USE_SSE2 21 | 22 | -#ifdef _MSC_VER 23 | -#include 24 | -#else 25 | -#include 26 | -#include 27 | -#endif 28 | - 29 | -#include 30 | +#include 31 | 32 | 33 | // This is the private data container used by this optimization 34 | @@ -297,30 +290,6 @@ void MatShaperXform8SSE(struct _cmstransform_struct *CMMcargo, 35 | } 36 | 37 | 38 | -static 39 | -cmsBool IsSSE2Available(void) 40 | -{ 41 | -#ifdef _MSC_VER 42 | - int cpuinfo[4]; 43 | - 44 | - __cpuid(cpuinfo, 1); 45 | - if (!(cpuinfo[3] & (1 << 26))) return FALSE; 46 | - return TRUE; 47 | - 48 | -#else 49 | - unsigned int level = 1u; 50 | - unsigned int eax, ebx, ecx, edx; 51 | - unsigned int bits = (1u << 26); 52 | - unsigned int max = __get_cpuid_max(0, NULL); 53 | - if (level > max) { 54 | - return FALSE; 55 | - } 56 | - __cpuid_count(level, 0, eax, ebx, ecx, edx); 57 | - return (edx & bits) == bits; 58 | -#endif 59 | -} 60 | - 61 | - 62 | // 8 bits on input allows matrix-shaper boost up a little bit 63 | cmsBool Optimize8MatrixShaperSSE(_cmsTransform2Fn* TransformFn, 64 | void** UserData, 65 | @@ -338,10 +307,7 @@ cmsBool Optimize8MatrixShaperSSE(_cmsTransform2Fn* TransformFn, 66 | cmsBool IdentityMat = FALSE; 67 | cmsPipeline* Dest, *Src; 68 | cmsContext ContextID; 69 | - cmsUInt32Number nChans; 70 | - 71 | - // Check for SSE2 support 72 | - if (!(IsSSE2Available())) return FALSE; 73 | + cmsUInt32Number nChans; 74 | 75 | // Only works on 3 to 3, probably RGB 76 | if ( !( (T_CHANNELS(*InputFormat) == 3 && T_CHANNELS(*OutputFormat) == 3) ) ) return FALSE; 77 | -------------------------------------------------------------------------------- /patches/45-de265/sse2neon.patch: -------------------------------------------------------------------------------- 1 | diff --git a/libde265/CMakeLists.txt b/libde265/CMakeLists.txt 2 | index 86d49ffd..76cd6ad6 100644 3 | --- a/libde265/CMakeLists.txt 4 | +++ b/libde265/CMakeLists.txt 5 | @@ -95,15 +95,9 @@ add_definitions(-DLIBDE265_EXPORTS) 6 | add_subdirectory (encoder) 7 | 8 | if(NOT DISABLE_SSE) 9 | - if (MSVC) 10 | set(SUPPORTS_SSE2 1) 11 | set(SUPPORTS_SSSE3 1) 12 | set(SUPPORTS_SSE4_1 1) 13 | - else (MSVC) 14 | - check_c_compiler_flag(-msse2 SUPPORTS_SSE2) 15 | - check_c_compiler_flag(-mssse3 SUPPORTS_SSSE3) 16 | - check_c_compiler_flag(-msse4.1 SUPPORTS_SSE4_1) 17 | - endif (MSVC) 18 | 19 | if(SUPPORTS_SSE4_1) 20 | add_definitions(-DHAVE_SSE4_1) 21 | diff --git a/libde265/x86/CMakeLists.txt b/libde265/x86/CMakeLists.txt 22 | index d6caf1d0..15243917 100644 23 | --- a/libde265/x86/CMakeLists.txt 24 | +++ b/libde265/x86/CMakeLists.txt 25 | @@ -12,14 +12,6 @@ add_library(x86_sse OBJECT ${x86_sse_sources}) 26 | 27 | set(sse_flags "") 28 | 29 | -if(NOT MSVC) 30 | - if(CMAKE_SIZEOF_VOID_P EQUAL 8) 31 | - set(sse_flags "${sse_flags} -msse4.1") 32 | - else(CMAKE_SIZEOF_VOID_P EQUAL 8) 33 | - set(sse_flags "${sse_flags} -msse2 -mssse3 -msse4.1") 34 | - endif(CMAKE_SIZEOF_VOID_P EQUAL 8) 35 | -endif() 36 | - 37 | set(X86_OBJECTS $ $ PARENT_SCOPE) 38 | 39 | SET_TARGET_PROPERTIES(x86_sse PROPERTIES COMPILE_FLAGS "${sse_flags}") 40 | diff --git a/libde265/x86/sse-dct.cc b/libde265/x86/sse-dct.cc 41 | index 3a9b7bab..ef4175a6 100644 42 | --- a/libde265/x86/sse-dct.cc 43 | +++ b/libde265/x86/sse-dct.cc 44 | @@ -26,12 +26,7 @@ 45 | #include "config.h" 46 | #endif 47 | 48 | -#include // SSE2 49 | -#include // SSSE3 50 | - 51 | -#if HAVE_SSE4_1 52 | -#include // SSE4.1 53 | -#endif 54 | +#include "sse2neon.h" 55 | 56 | 57 | ALIGNED_16(static const int16_t) transform4x4_luma[8][8] = 58 | diff --git a/libde265/x86/sse-motion.cc b/libde265/x86/sse-motion.cc 59 | index c8c7571d..fb3b2b6b 100644 60 | --- a/libde265/x86/sse-motion.cc 61 | +++ b/libde265/x86/sse-motion.cc 62 | @@ -24,11 +24,7 @@ 63 | #endif 64 | 65 | #include 66 | -#include 67 | -#include // SSSE3 68 | -#if HAVE_SSE4_1 69 | -#include 70 | -#endif 71 | +#include "sse2neon.h" 72 | 73 | #include "sse-motion.h" 74 | #include "libde265/util.h" 75 | diff --git a/libde265/x86/sse.cc b/libde265/x86/sse.cc 76 | index 2ee0f8f2..c8559634 100644 77 | --- a/libde265/x86/sse.cc 78 | +++ b/libde265/x86/sse.cc 79 | @@ -30,10 +30,6 @@ 80 | #include "config.h" 81 | #endif 82 | 83 | -#ifdef __GNUC__ 84 | -#include 85 | -#endif 86 | - 87 | void init_acceleration_functions_sse(struct acceleration_functions* accel) 88 | { 89 | uint32_t ecx=0,edx=0; 90 | @@ -47,15 +43,15 @@ void init_acceleration_functions_sse(struct acceleration_functions* accel) 91 | ecx = regs[2]; 92 | edx = regs[3]; 93 | #else 94 | - uint32_t eax,ebx; 95 | - __get_cpuid(1, &eax,&ebx,&ecx,&edx); 96 | + // uint32_t eax,ebx; 97 | + // __get_cpuid(1, &eax,&ebx,&ecx,&edx); 98 | #endif 99 | 100 | // printf("CPUID EAX=1 -> ECX=%x EDX=%x\n", regs[2], regs[3]); 101 | 102 | //int have_MMX = !!(edx & (1<<23)); 103 | - int have_SSE = !!(edx & (1<<25)); 104 | - int have_SSE4_1 = !!(ecx & (1<<19)); 105 | + int have_SSE = 1; 106 | + int have_SSE4_1 = 1; 107 | 108 | // printf("MMX:%d SSE:%d SSE4_1:%d\n",have_MMX,have_SSE,have_SSE4_1); 109 | 110 | -------------------------------------------------------------------------------- /patches/50-soxr/fix-aarch64-cmake-pkgconfig.patch: -------------------------------------------------------------------------------- 1 | diff --git a/CMakeLists.txt b/CMakeLists.txt 2 | index ee48f6c..0030b39 100644 3 | --- a/CMakeLists.txt 4 | +++ b/CMakeLists.txt 5 | @@ -3,7 +3,6 @@ 6 | 7 | cmake_minimum_required (VERSION 3.1 FATAL_ERROR) 8 | 9 | -project (soxr C) 10 | set (DESCRIPTION_SUMMARY 11 | "High quality, one-dimensional sample-rate conversion library") 12 | 13 | @@ -29,7 +28,11 @@ math (EXPR SO_VERSION_MAJOR "${SO_VERSION_CURRENT} - ${SO_VERSION_AGE}") 14 | math (EXPR SO_VERSION_MINOR "${SO_VERSION_AGE}") 15 | math (EXPR SO_VERSION_PATCH "${SO_VERSION_REVISION}") 16 | 17 | +set (PROJECT_VERSION 18 | + ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}) 19 | +set (SO_VERSION ${SO_VERSION_MAJOR}.${SO_VERSION_MINOR}.${SO_VERSION_PATCH}) 20 | 21 | +project (soxr VERSION "${PROJECT_VERSION}" LANGUAGES C) 22 | 23 | # Main options: 24 | 25 | @@ -41,6 +44,7 @@ if (NOT CMAKE_BUILD_TYPE) 26 | endif () 27 | 28 | option (BUILD_TESTS "Build sanity-tests." ON) 29 | +option (INSTALL_DOCS "Install docs." ON) 30 | option (BUILD_EXAMPLES "Build examples." OFF) 31 | option (WITH_OPENMP "Include OpenMP threading." ON) 32 | option (WITH_LSR_BINDINGS "Include a `libsamplerate'-like interface." ON) 33 | @@ -101,7 +105,7 @@ if (NEED_LIBM) 34 | endif () 35 | 36 | if (${BUILD_EXAMPLES}) 37 | - project (${PROJECT_NAME}) # Adds c++ compiler 38 | + project (${PROJECT_NAME} VERSION "${PROJECT_VERSION}") # Adds c++ compiler 39 | endif () 40 | 41 | if (WITH_OPENMP) 42 | @@ -109,6 +113,8 @@ if (WITH_OPENMP) 43 | if (OPENMP_FOUND) 44 | set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") 45 | set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") 46 | + set (LIBS ${LIBS} ${OpenMP_C_LIBRARIES}) 47 | + set (PKGCONF_LIBS_PRIV ${PKGCONF_LIBS_PRIV} -lgomp) 48 | if (MINGW) # Is this still needed? 49 | set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_C_FLAGS}") 50 | set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${OpenMP_C_FLAGS}") 51 | @@ -134,11 +140,14 @@ if (WITH_AVFFT) 52 | endif () 53 | endif () 54 | 55 | -if (WITH_AVFFT OR (CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" AND SIMD32_FOUND AND WITH_CR32)) 56 | +if (WITH_AVFFT OR (SIMD32_FOUND AND WITH_CR32 57 | + AND (CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" 58 | + OR CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64"))) 59 | find_package (LibAVUtil) 60 | if (AVUTIL_FOUND) 61 | include_directories (${AVUTIL_INCLUDE_DIRS}) 62 | set (LIBS ${LIBS} ${AVUTIL_LIBRARIES}) 63 | + set (PKGCONF_LIBS_PRIV ${PKGCONF_LIBS_PRIV} -lavutil) 64 | endif () 65 | endif () 66 | 67 | @@ -253,10 +262,6 @@ endif () 68 | 69 | # Top-level: 70 | 71 | -set (PROJECT_VERSION 72 | - ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}) 73 | -set (SO_VERSION ${SO_VERSION_MAJOR}.${SO_VERSION_MINOR}.${SO_VERSION_PATCH}) 74 | - 75 | configure_file ( 76 | ${PROJECT_SOURCE_DIR}/${PROJECT_NAME}-config.h.in 77 | ${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config.h) 78 | @@ -266,11 +271,13 @@ if (NOT CMAKE_CROSSCOMPILING AND (BUILD_TESTS OR BUILD_LSR_TESTS)) 79 | enable_testing () 80 | endif () 81 | 82 | -install (FILES 83 | +if (INSTALL_DOCS) 84 | + install (FILES 85 | ${CMAKE_CURRENT_SOURCE_DIR}/README 86 | ${CMAKE_CURRENT_SOURCE_DIR}/LICENCE 87 | ${CMAKE_CURRENT_SOURCE_DIR}/NEWS 88 | DESTINATION ${DOC_INSTALL_DIR}) 89 | +endif () 90 | 91 | 92 | 93 | diff --git a/cmake/Modules/FindSIMD32.cmake b/cmake/Modules/FindSIMD32.cmake 94 | index 9e42373..b2cefc1 100644 95 | --- a/cmake/Modules/FindSIMD32.cmake 96 | +++ b/cmake/Modules/FindSIMD32.cmake 97 | @@ -9,9 +9,11 @@ 98 | 99 | if (DEFINED SIMD32_C_FLAGS) 100 | set (TRIAL_C_FLAGS) 101 | -elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^arm") 102 | +elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" 103 | + OR CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64") 104 | set (TRIAL_C_FLAGS 105 | # Gcc 106 | + "-mcpu=cortex-a53" 107 | "-mfpu=neon-vfpv4 -mcpu=cortex-a7" 108 | "-mfpu=neon -mfloat-abi=hard" 109 | "-mfpu=neon -mfloat-abi=softfp" 110 | diff --git a/cmake/Modules/FindSIMD64.cmake b/cmake/Modules/FindSIMD64.cmake 111 | index d412644..9e47c29 100644 112 | --- a/cmake/Modules/FindSIMD64.cmake 113 | +++ b/cmake/Modules/FindSIMD64.cmake 114 | @@ -7,7 +7,9 @@ 115 | # SIMD64_C_FLAGS - flags to add to the C compiler for this package. 116 | # SIMD64_FOUND - true if support for this package is found. 117 | 118 | -if (DEFINED SIMD64_C_FLAGS OR CMAKE_SYSTEM_PROCESSOR MATCHES "^arm") 119 | +if (DEFINED SIMD64_C_FLAGS 120 | + OR CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" 121 | + OR CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64") 122 | set (TRIAL_C_FLAGS) 123 | else () 124 | set (TRIAL_C_FLAGS 125 | diff --git a/cmake/Modules/SetSystemProcessor.cmake b/cmake/Modules/SetSystemProcessor.cmake 126 | index 8e2c292..49ad1c6 100644 127 | --- a/cmake/Modules/SetSystemProcessor.cmake 128 | +++ b/cmake/Modules/SetSystemProcessor.cmake 129 | @@ -11,9 +11,10 @@ macro (set_system_processor) 130 | if (NOT DEFINED CMAKE_SYSTEM_PROCESSOR) 131 | include (CheckCSourceCompiles) 132 | set (CPU_LINES 133 | - "#if defined __x86_64__ || defined _M_X64 /*\;x86_64\;*/" 134 | - "#if defined __i386__ || defined _M_IX86 /*\;x86_32\;*/" 135 | - "#if defined __arm__ || defined _M_ARM /*\;arm\;*/" 136 | + "#if defined (__x86_64__) || defined _M_X64 /*\;x86_64\;*/" 137 | + "#if defined (__i386__) || defined _M_IX86 /*\;x86_32\;*/" 138 | + "#if defined (__arm__) || defined _M_ARM /*\;arm\;*/" 139 | + "#if defined (__aarch64__) || defined _M_ARM64 /*\;arm64\;*/" 140 | ) 141 | foreach (CPU_LINE ${CPU_LINES}) 142 | string (CONCAT CPU_SOURCE "${CPU_LINE}" " 143 | diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt 144 | index bb01a0d..b2f1712 100644 145 | --- a/src/CMakeLists.txt 146 | +++ b/src/CMakeLists.txt 147 | @@ -86,11 +86,11 @@ set_target_properties (${PROJECT_NAME} PROPERTIES 148 | PUBLIC_HEADER "${PROJECT_NAME}.h") 149 | if (BUILD_FRAMEWORK) 150 | set_target_properties (${PROJECT_NAME} PROPERTIES FRAMEWORK TRUE) 151 | -elseif (NOT WIN32) 152 | - set (TARGET_PCS ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc) 153 | - configure_file (${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc.in ${TARGET_PCS}) 154 | - install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) 155 | endif () 156 | +set (TARGET_PCS ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc) 157 | +configure_file (${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc.in ${TARGET_PCS} @ONLY) 158 | +install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) 159 | + 160 | 161 | 162 | 163 | @@ -110,11 +110,10 @@ if (WITH_LSR_BINDINGS) 164 | PUBLIC_HEADER "${LSR}.h") 165 | if (BUILD_FRAMEWORK) 166 | set_target_properties (${LSR} PROPERTIES FRAMEWORK TRUE) 167 | - elseif (NOT WIN32) 168 | + endif () 169 | set (TARGET_PCS "${TARGET_PCS} ${CMAKE_CURRENT_BINARY_DIR}/${LSR}.pc") 170 | - configure_file (${CMAKE_CURRENT_SOURCE_DIR}/${LSR}.pc.in ${CMAKE_CURRENT_BINARY_DIR}/${LSR}.pc) 171 | + configure_file (${CMAKE_CURRENT_SOURCE_DIR}/${LSR}.pc.in ${CMAKE_CURRENT_BINARY_DIR}/${LSR}.pc @ONLY) 172 | install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${LSR}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) 173 | - endif () 174 | endif () 175 | 176 | 177 | diff --git a/src/cr-core.c b/src/cr-core.c 178 | index 159a5d9..44b175b 100644 179 | --- a/src/cr-core.c 180 | +++ b/src/cr-core.c 181 | @@ -80,7 +80,7 @@ static void cubic_stage_fn(stage_t * p, fifo_t * output_fifo) 182 | #define DEFINED_X86 0 183 | #endif 184 | 185 | -#if defined __arm__ 186 | +#if defined (__arm__) || defined(__aarch64__) 187 | #define DEFINED_ARM 1 188 | #else 189 | #define DEFINED_ARM 0 190 | diff --git a/src/dev32s.h b/src/dev32s.h 191 | index 7edae86..b804fff 100644 192 | --- a/src/dev32s.h 193 | +++ b/src/dev32s.h 194 | @@ -31,7 +31,7 @@ SIMD_INLINE(void) vStorSum(float * a, v4_t b) { 195 | v4_t t = vAdd(_mm_movehl_ps(b, b), b); 196 | _mm_store_ss(a, vAdd(t, _mm_shuffle_ps(t,t,1)));} 197 | 198 | -#elif defined __arm__ 199 | +#elif defined (__arm__) || defined(__aarch64__) 200 | 201 | #include 202 | 203 | diff --git a/src/pffft-wrap.c b/src/pffft-wrap.c 204 | index c920f06..1641fc4 100644 205 | --- a/src/pffft-wrap.c 206 | +++ b/src/pffft-wrap.c 207 | @@ -40,7 +40,7 @@ static void pffft_zconvolve(PFFFT_Setup *s, const float *a, const float *b, floa 208 | 209 | float ar, ai, br, bi; 210 | 211 | -#ifdef __arm__ 212 | +#if defined(__arm__) || defined(__aarch64__) 213 | __builtin_prefetch(va); 214 | __builtin_prefetch(vb); 215 | __builtin_prefetch(va+2); 216 | diff --git a/src/pffft.c b/src/pffft.c 217 | index 46c841e..8c775a9 100644 218 | --- a/src/pffft.c 219 | +++ b/src/pffft.c 220 | @@ -157,7 +157,7 @@ typedef __m128 v4sf; 221 | /* 222 | ARM NEON support macros 223 | */ 224 | -#elif !defined(PFFFT_SIMD_DISABLE) && defined(__arm__) 225 | +#elif !defined(PFFFT_SIMD_DISABLE) && (defined(__arm__) || defined(__aarch64__)) 226 | # include 227 | typedef float32x4_t v4sf; 228 | # define SIMD_SZ 4 229 | @@ -1732,7 +1732,7 @@ void pffft_zconvolve_accumulate(PFFFT_Setup *s, const float *a, const float *b, 230 | const v4sf * RESTRICT vb = (const v4sf*)b; 231 | v4sf * RESTRICT vab = (v4sf*)ab; 232 | 233 | -#ifdef __arm__ 234 | +#if defined(__arm__) || defined(__aarch64__) 235 | __builtin_prefetch(va); 236 | __builtin_prefetch(vb); 237 | __builtin_prefetch(vab); 238 | diff --git a/src/soxr-lsr.pc.in b/src/soxr-lsr.pc.in 239 | index 7b75757..899f44a 100644 240 | --- a/src/soxr-lsr.pc.in 241 | +++ b/src/soxr-lsr.pc.in 242 | @@ -1,5 +1,10 @@ 243 | -Name: ${LSR} 244 | -Description: ${DESCRIPTION_SUMMARY} (with libsamplerate-like bindings) 245 | -Version: ${PROJECT_VERSION} 246 | -Libs: -L${LIB_INSTALL_DIR} -l${LSR} 247 | -Cflags: -I${INCLUDE_INSTALL_DIR} 248 | +prefix=@CMAKE_INSTALL_PREFIX@ 249 | +exec_prefix=@CMAKE_INSTALL_PREFIX@ 250 | +libdir=${exec_prefix}/lib 251 | +includedir=${prefix}/include 252 | + 253 | +Name: @LSR@ 254 | +Description: @DESCRIPTION_SUMMARY@ (with libsamplerate-like bindings) 255 | +Version: @PROJECT_VERSION@ 256 | +Libs: -L${libdir} -l@LSR@ 257 | +Cflags: -I${includedir} 258 | \ No newline at end of file 259 | diff --git a/src/soxr.pc.in b/src/soxr.pc.in 260 | index 69d225b..4f4ae9d 100644 261 | --- a/src/soxr.pc.in 262 | +++ b/src/soxr.pc.in 263 | @@ -1,5 +1,11 @@ 264 | -Name: ${PROJECT_NAME} 265 | -Description: ${DESCRIPTION_SUMMARY} 266 | -Version: ${PROJECT_VERSION} 267 | -Libs: -L${LIB_INSTALL_DIR} -l${PROJECT_NAME} 268 | -Cflags: -I${INCLUDE_INSTALL_DIR} 269 | +prefix=@CMAKE_INSTALL_PREFIX@ 270 | +exec_prefix=@CMAKE_INSTALL_PREFIX@ 271 | +libdir=${exec_prefix}/lib 272 | +includedir=${prefix}/include 273 | + 274 | +Name: @PROJECT_NAME@ 275 | +Description: @DESCRIPTION_SUMMARY@ 276 | +Version: @PROJECT_VERSION@ 277 | +Libs: -L${libdir} -l@PROJECT_NAME@ 278 | +Libs.private: ${PKGCONF_LIBS_PRIV} 279 | +Cflags: -I${includedir} 280 | \ No newline at end of file 281 | -------------------------------------------------------------------------------- /patches/99-ffmpeg/remove_lzma_apple_non_public_api.patch: -------------------------------------------------------------------------------- 1 | diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c 2 | index bfa345b3d8..f445686d0d 100644 3 | --- a/libavcodec/tiff.c 4 | +++ b/libavcodec/tiff.c 5 | @@ -28,10 +28,6 @@ 6 | #if CONFIG_ZLIB 7 | #include 8 | #endif 9 | -#if CONFIG_LZMA 10 | -#define LZMA_API_STATIC 11 | -#include 12 | -#endif 13 | 14 | #include 15 | 16 | @@ -559,71 +555,6 @@ static int tiff_unpack_zlib(TiffContext *s, AVFrame *p, uint8_t *dst, int stride 17 | } 18 | #endif 19 | 20 | -#if CONFIG_LZMA 21 | -static int tiff_uncompress_lzma(uint8_t *dst, uint64_t *len, const uint8_t *src, 22 | - int size) 23 | -{ 24 | - lzma_stream stream = LZMA_STREAM_INIT; 25 | - lzma_ret ret; 26 | - 27 | - stream.next_in = src; 28 | - stream.avail_in = size; 29 | - stream.next_out = dst; 30 | - stream.avail_out = *len; 31 | - ret = lzma_stream_decoder(&stream, UINT64_MAX, 0); 32 | - if (ret != LZMA_OK) { 33 | - av_log(NULL, AV_LOG_ERROR, "LZMA init error: %d\n", ret); 34 | - return ret; 35 | - } 36 | - ret = lzma_code(&stream, LZMA_RUN); 37 | - lzma_end(&stream); 38 | - *len = stream.total_out; 39 | - return ret == LZMA_STREAM_END ? LZMA_OK : ret; 40 | -} 41 | - 42 | -static int tiff_unpack_lzma(TiffContext *s, AVFrame *p, uint8_t *dst, int stride, 43 | - const uint8_t *src, int size, int width, int lines, 44 | - int strip_start, int is_yuv) 45 | -{ 46 | - uint64_t outlen = width * (uint64_t)lines; 47 | - int ret, line; 48 | - uint8_t *buf = av_malloc(outlen); 49 | - if (!buf) 50 | - return AVERROR(ENOMEM); 51 | - if (s->fill_order) { 52 | - if ((ret = deinvert_buffer(s, src, size)) < 0) { 53 | - av_free(buf); 54 | - return ret; 55 | - } 56 | - src = s->deinvert_buf; 57 | - } 58 | - ret = tiff_uncompress_lzma(buf, &outlen, src, size); 59 | - if (ret != LZMA_OK) { 60 | - av_log(s->avctx, AV_LOG_ERROR, 61 | - "Uncompressing failed (%"PRIu64" of %"PRIu64") with error %d\n", outlen, 62 | - (uint64_t)width * lines, ret); 63 | - av_free(buf); 64 | - return AVERROR_UNKNOWN; 65 | - } 66 | - src = buf; 67 | - for (line = 0; line < lines; line++) { 68 | - if (s->bpp < 8 && s->avctx->pix_fmt == AV_PIX_FMT_PAL8) { 69 | - horizontal_fill(s, s->bpp, dst, 1, src, 0, width, 0); 70 | - } else { 71 | - memcpy(dst, src, width); 72 | - } 73 | - if (is_yuv) { 74 | - unpack_yuv(s, p, dst, strip_start + line); 75 | - line += s->subsampling[1] - 1; 76 | - } 77 | - dst += stride; 78 | - src += width; 79 | - } 80 | - av_free(buf); 81 | - return 0; 82 | -} 83 | -#endif 84 | - 85 | static int tiff_unpack_fax(TiffContext *s, uint8_t *dst, int stride, 86 | const uint8_t *src, int size, int width, int lines) 87 | { 88 | @@ -796,14 +727,9 @@ static int tiff_unpack_strip(TiffContext *s, AVFrame *p, uint8_t *dst, int strid 89 | #endif 90 | } 91 | if (s->compr == TIFF_LZMA) { 92 | -#if CONFIG_LZMA 93 | - return tiff_unpack_lzma(s, p, dst, stride, src, size, width, lines, 94 | - strip_start, is_yuv); 95 | -#else 96 | av_log(s->avctx, AV_LOG_ERROR, 97 | "LZMA support not enabled\n"); 98 | return AVERROR(ENOSYS); 99 | -#endif 100 | } 101 | if (s->compr == TIFF_LZW) { 102 | if (s->fill_order) { 103 | @@ -1374,12 +1300,8 @@ static int tiff_decode_tag(TiffContext *s, AVFrame *frame) 104 | s->is_jpeg = 1; 105 | break; 106 | case TIFF_LZMA: 107 | -#if CONFIG_LZMA 108 | - break; 109 | -#else 110 | av_log(s->avctx, AV_LOG_ERROR, "LZMA not compiled in\n"); 111 | return AVERROR(ENOSYS); 112 | -#endif 113 | default: 114 | av_log(s->avctx, AV_LOG_ERROR, "Unknown compression method %i\n", 115 | s->compr); 116 | -------------------------------------------------------------------------------- /patches/99-ffmpeg/use-vaMapBuffer2-for-mapping-image.patch: -------------------------------------------------------------------------------- 1 | From 1e2ac489a475198460e424fd4a3d166bb3f424a4 Mon Sep 17 00:00:00 2001 2 | From: David Rosca 3 | Date: Fri, 27 Oct 2023 22:25:50 +0200 4 | Subject: [PATCH] lavu/hwcontext_vaapi: Use vaMapBuffer2 for mapping image 5 | buffers 6 | 7 | This allows some optimizations in driver, such as not having to read 8 | back the data if write-only mapping is requested. 9 | --- 10 | libavutil/hwcontext_vaapi.c | 12 ++++++++++++ 11 | 1 file changed, 12 insertions(+) 12 | 13 | diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c 14 | index 56d03aa4cdd3a..4cb25dd03212e 100644 15 | --- a/libavutil/hwcontext_vaapi.c 16 | +++ b/libavutil/hwcontext_vaapi.c 17 | @@ -809,6 +809,9 @@ static int vaapi_map_frame(AVHWFramesContext *hwfc, 18 | VAStatus vas; 19 | void *address = NULL; 20 | int err, i; 21 | +#if VA_CHECK_VERSION(1, 21, 0) 22 | + uint32_t vaflags = 0; 23 | +#endif 24 | 25 | surface_id = (VASurfaceID)(uintptr_t)src->data[3]; 26 | av_log(hwfc, AV_LOG_DEBUG, "Map surface %#x.\n", surface_id); 27 | @@ -892,7 +895,16 @@ static int vaapi_map_frame(AVHWFramesContext *hwfc, 28 | } 29 | } 30 | 31 | +#if VA_CHECK_VERSION(1, 21, 0) 32 | + if (flags & AV_HWFRAME_MAP_READ) 33 | + vaflags |= VA_MAPBUFFER_FLAG_READ; 34 | + if (flags & AV_HWFRAME_MAP_WRITE) 35 | + vaflags |= VA_MAPBUFFER_FLAG_WRITE; 36 | + // On drivers not implementing vaMapBuffer2 libva calls vaMapBuffer instead. 37 | + vas = vaMapBuffer2(hwctx->display, map->image.buf, &address, vaflags); 38 | +#else 39 | vas = vaMapBuffer(hwctx->display, map->image.buf, &address); 40 | +#endif 41 | if (vas != VA_STATUS_SUCCESS) { 42 | av_log(hwfc, AV_LOG_ERROR, "Failed to map image from surface " 43 | "%#x: %d (%s).\n", surface_id, vas, vaErrorStr(vas)); 44 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json", 3 | "extends": [ 4 | "config:recommended", 5 | ":label(type/renovate)", 6 | ":docker", 7 | "docker:enableMajor", 8 | "docker:pinDigests", 9 | ":disableRateLimiting", 10 | ":ignoreUnstable", 11 | ":pinVersions", 12 | ":separateMajorReleases", 13 | ":automergePr", 14 | ":automergeRequireAllStatusChecks", 15 | ":automergeAll", 16 | ":semanticCommits", 17 | ":enableVulnerabilityAlerts", 18 | ":enableVulnerabilityAlertsWithLabel(security)" 19 | ], 20 | "rebaseWhen": "conflicted", 21 | "platformAutomerge": true, 22 | "rebaseLabel": "renovate/rebase", 23 | "stopUpdatingLabel": "renovate/stop-updating", 24 | "major": { 25 | "labels": [ 26 | "bump/major" 27 | ] 28 | }, 29 | "minor": { 30 | "labels": [ 31 | "bump/minor" 32 | ] 33 | }, 34 | "patch": { 35 | "labels": [ 36 | "bump/patch" 37 | ] 38 | }, 39 | "pin": { 40 | "labels": [ 41 | "bump/pin" 42 | ] 43 | }, 44 | "digest": { 45 | "labels": [ 46 | "bump/digest" 47 | ] 48 | }, 49 | "customManagers": [ 50 | { 51 | "customType": "regex", 52 | "fileMatch": [ 53 | "^stages/.*\\.sh$" 54 | ], 55 | "matchStrings": [ 56 | "#\\s*renovate:\\s*datasource=(?.*?) depName=(?.*?)( versioning=(?.*?))?( registryUrl=(?.*?))?\\n_tag='(?.*)'\\s" 57 | ], 58 | "versioningTemplate": "{{#if versioning}}{{{versioning}}}{{else}}semver{{/if}}" 59 | }, 60 | { 61 | "customType": "regex", 62 | "fileMatch": [ 63 | "^stages/.*\\.sh$" 64 | ], 65 | "matchStrings": [ 66 | "#\\s*renovate:\\s*depName=(?.*?)\\n_commit='(?)(?.*?)'" 67 | ], 68 | "versioningTemplate": "git", 69 | "datasourceTemplate": "git-refs" 70 | }, 71 | { 72 | "customType": "regex", 73 | "fileMatch": [ 74 | "^Dockerfile$" 75 | ], 76 | "matchStrings": [ 77 | "#\\s*renovate:\\s*datasource=(?.*?) depName=(?.*?)( versioning=(?.*?))?( registryUrl=(?.*?))?\\n(ENV|ARG) .*?_VERSION='(?.*)'\\s" 78 | ], 79 | "versioningTemplate": "{{#if versioning}}{{{versioning}}}{{else}}semver{{/if}}" 80 | } 81 | ], 82 | "packageRules": [ 83 | { 84 | "matchPackageNames": [ 85 | "Kitware/CMake", 86 | "DLTcollab/sse2neon", 87 | "tukaani-project/xz", 88 | "xiph/ogg", 89 | "strukturag/libde265", 90 | "xiph/vorbis", 91 | "Fintel/libvpl", 92 | "xiph/opus", 93 | "AOMediaCodec/SVT-AV1", 94 | "strukturag/libheif", 95 | "protocolbuffers/protobuf", 96 | "microsoft/onnxruntime" 97 | ], 98 | "extractVersion": "^v(?.+)$" 99 | }, 100 | { 101 | "matchPackageNames": [ 102 | "mm2/Little-CMS" 103 | ], 104 | "extractVersion": "^lcms(?.+)$" 105 | }, 106 | { 107 | "matchPackageNames": [ 108 | "FFmpeg/nv-codec-headers" 109 | ], 110 | "extractVersion": "^n(?.+)$" 111 | }, 112 | { 113 | "matchPackageNames": [ 114 | "sekrit-twc/zimg" 115 | ], 116 | "extractVersion": "^release-(?.+)$" 117 | }, 118 | { 119 | "matchPackageNames": [ 120 | "bblanchon/pdfium-binaries" 121 | ], 122 | "extractVersion": "^chromium/(?.+)$" 123 | }, 124 | { 125 | "matchPackageNames": [ 126 | "intel/libva" 127 | ], 128 | "extractVersion": "^(?\\d+\\.\\d+\\.\\d+)$" 129 | }, 130 | { 131 | "matchPackageNames": [ 132 | "intel/libvpl" 133 | ], 134 | "extractVersion": "^v(?\\d+\\.\\d+\\.\\d+)$", 135 | "allowedVersions": "!/^v20[0-9]{6}$/" 136 | }, 137 | { 138 | "matchPackageNames": [ 139 | "mesa/drm" 140 | ], 141 | "extractVersion": "^libdrm-(?.+)$" 142 | }, 143 | { 144 | "matchPackageNames": [ 145 | "xorg/lib/libpciaccess" 146 | ], 147 | "extractVersion": "^libpciaccess-(?.+)$" 148 | } 149 | ] 150 | } 151 | -------------------------------------------------------------------------------- /scripts/build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euo pipefail 4 | 5 | # Ensure file exists before sourcing 6 | touch /etc/environment 7 | # Import any environment specific variables 8 | set -o allexport 9 | # shellcheck disable=SC1091 10 | . /etc/environment 11 | set +o allexport 12 | 13 | # Configure cross compiler environment variables 14 | export RC="rc" 15 | export CC="cc" 16 | export LD="cc" 17 | export AR="ar" 18 | export NM="nm" 19 | export CXX="c++" 20 | export STRIP="strip" 21 | export RANLIB="ranlib" 22 | export WINDRES="windres" 23 | export DLLTOOL="dlltool" 24 | export OBJCOPY="objcopy" 25 | export OBJDUMP="objdump" 26 | export PKG_CONFIG="pkg-config" 27 | export PKG_CONFIG_LIBDIR="${PREFIX}/lib/pkgconfig:${PREFIX}/share/pkgconfig" 28 | 29 | case "$TARGET" in 30 | x86_64*) 31 | export AS="nasm" 32 | ;; 33 | aarch64*) 34 | export AS="cc -xassembler" 35 | ;; 36 | esac 37 | 38 | FFLAGS="-fasynchronous-unwind-tables -fexceptions -fstack-protector-strong" 39 | case "$TARGET" in 40 | x86_64*) 41 | FFLAGS="${FFLAGS} -fcf-protection" 42 | ;; 43 | esac 44 | 45 | CFLAGS="-I${PREFIX}/include -pipe -Wall -Werror=format-security -fPIC -D_FORTIFY_SOURCE=2" 46 | LDFLAGS="-L${PREFIX}/lib -pipe" 47 | case "$TARGET" in 48 | *linux*) 49 | FFLAGS="-fno-semantic-interposition" 50 | LDFLAGS="${LDFLAGS} -Wl,-z,relro,-z,now,-z,defs" 51 | 52 | case "$TARGET" in 53 | x86_64*) 54 | FFLAGS="${FFLAGS} -fstack-check -fstack-clash-protection" 55 | ;; 56 | aarch64*) 57 | # https://github.com/ziglang/zig/issues/17430#issuecomment-1752592338 58 | FFLAGS="${FFLAGS} -fno-stack-protector -fno-stack-check" 59 | ;; 60 | esac 61 | 62 | LLVM_BUILTIN='/usr/lib/llvm-17/lib/clang/17/lib' 63 | case "$TARGET" in 64 | *gnu) 65 | CFLAGS="${CFLAGS} -D_GLIBCXX_ASSERTIONS=1" 66 | ;; 67 | *musl) 68 | CFLAGS="${CFLAGS} -D_LARGEFILE64_SOURCE=1" 69 | ;; 70 | *android*) 71 | export SDKROOT="${NDK_SDKROOT:?Missing ndk sysroot}" 72 | ANDROID_LIB="${SDKROOT}/usr/lib/${TARGET}" 73 | CFLAGS="${CFLAGS} -D__ANDROID_API__=${ANDROID_API_LEVEL:?Missing android api level}" 74 | LDFLAGS="-fuse-ld=$(command -v ld.lld-17) -B${ANDROID_LIB}/${ANDROID_API_LEVEL:?} -L${ANDROID_LIB}/${ANDROID_API_LEVEL:?} -L${ANDROID_LIB} -lm ${LDFLAGS}" 75 | ;;& # Resume switch/case matching from this point forward 76 | x86_64-linux-android*) 77 | # VERY UGLY HACK, no ideia why clang is not picking this up automatically 78 | LDFLAGS="-L${LLVM_BUILTIN}/linux -lclang_rt.builtins-x86_64-android ${LDFLAGS}" 79 | ;; 80 | aarch64-linux-android*) 81 | # VERY UGLY HACK, no ideia why clang is not picking this up automatically 82 | LDFLAGS="-L${LLVM_BUILTIN}/baremetal -L${LLVM_BUILTIN}/linux -lclang_rt.builtins-aarch64-android -lclang_rt.builtins-aarch64 ${LDFLAGS}" 83 | ;; 84 | esac 85 | ;; 86 | *darwin*) 87 | # Apple tools and linker fails to LTO static libraries 88 | # https://github.com/tpoechtrager/osxcross/issues/366 89 | export LTO=0 90 | export LD_LIBRARY_PATH="${CCTOOLS}/lib:/usr/local/lib:${LD_LIBRARY_PATH:-}" 91 | 92 | OS_IPHONE="${OS_IPHONE:-0}" 93 | if [ "$OS_IPHONE" -ge 1 ]; then 94 | export IPHONEOS_DEPLOYMENT_TARGET="14.0" 95 | LDFLAGS="${LDFLAGS} -Wl,-adhoc_codesign" 96 | fi 97 | 98 | case "$TARGET" in 99 | x86_64*) 100 | if [ "$OS_IPHONE" -lt 1 ]; then 101 | export MACOSX_DEPLOYMENT_TARGET="10.15" 102 | export CMAKE_APPLE_SILICON_PROCESSOR='x86_64' 103 | fi 104 | LDFLAGS="${LDFLAGS} -Wl,-arch,x86_64" 105 | ;; 106 | aarch64*) 107 | if [ "$OS_IPHONE" -lt 1 ]; then 108 | export MACOSX_DEPLOYMENT_TARGET="11.0" 109 | export CMAKE_APPLE_SILICON_PROCESSOR='aarch64' 110 | fi 111 | LDFLAGS="${LDFLAGS} -Wl,-arch,arm64" 112 | ;; 113 | esac 114 | 115 | FFLAGS="${FFLAGS} -fstack-check" 116 | 117 | if [ "$OS_IPHONE" -eq 1 ]; then 118 | export SDKROOT="${IOS_SDKROOT:?Missing iOS SDK}" 119 | if [ "${CRT_HACK:-0}" -ne 1 ]; then 120 | CFLAGS="${CFLAGS} -mios-version-min=${IPHONEOS_DEPLOYMENT_TARGET} -miphoneos-version-min=${IPHONEOS_DEPLOYMENT_TARGET}" 121 | fi 122 | elif [ "$OS_IPHONE" -eq 2 ]; then 123 | export SDKROOT="${IOS_SIMULATOR_SDKROOT:?Missing iOS simulator SDK}" 124 | if [ "${CRT_HACK:-0}" -ne 1 ]; then 125 | CFLAGS="${CFLAGS} -mios-simulator-version-min=${IPHONEOS_DEPLOYMENT_TARGET} -miphonesimulator-version-min=${IPHONEOS_DEPLOYMENT_TARGET}" 126 | fi 127 | else 128 | export SDKROOT="${MACOS_SDKROOT:?Missing macOS SDK}" 129 | if [ "${CRT_HACK:-0}" -ne 1 ]; then 130 | # https://github.com/tpoechtrager/osxcross/commit/3279f86 131 | CFLAGS="${CFLAGS} -mmacos-version-min=${MACOSX_DEPLOYMENT_TARGET} -mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET}" 132 | LDFLAGS="-L${SDKROOT}/usr/lib/system ${LDFLAGS}" 133 | fi 134 | fi 135 | 136 | # Ugly workaround for apple linker not finding the SDK's Framework directory 137 | ln -fs "${SDKROOT}/System" '/System' 138 | 139 | if [ "${CRT_HACK:-0}" -ne 1 ]; then 140 | LDFLAGS="-L${SDKROOT}/usr/lib -F${SDKROOT}/System/Library/Frameworks -F${SDKROOT}/System/Cryptexes/OS/System/Library/Frameworks ${LDFLAGS}" 141 | fi 142 | 143 | LDFLAGS="-fuse-ld=$(command -v "${APPLE_TARGET:?}-ld") ${LDFLAGS}" 144 | ;; 145 | *windows*) 146 | # Zig doesn't support stack probing on Windows 147 | # https://github.com/ziglang/zig/blob/0.12.0/src/target.zig#L195-L198 148 | FFLAGS="${FFLAGS} -fno-stack-check" 149 | # https://github.com/strukturag/libheif/issues/357 150 | CFLAGS="${CFLAGS} -D_GLIBCXX_ASSERTIONS=1 -D__MINGW64__" 151 | ;; 152 | esac 153 | export CFLAGS="${CFLAGS} ${FFLAGS}" 154 | export LDFLAGS="${LDFLAGS} ${FFLAGS}" 155 | export CXXFLAGS="${CFLAGS}" 156 | 157 | curl() { 158 | env curl --proto '=https' --tlsv1.2 --ciphers "${CIPHERSUITES:?Missing curl ciphersuite}" --silent --show-error --fail --location "$@" 159 | } 160 | 161 | bak_src() { 162 | if ! { [ "$#" -eq 1 ] && [ -d "$1" ]; }; then 163 | echo "bak_src: " >&2 164 | exit 1 165 | fi 166 | 167 | set -- "$(CDPATH='' cd -- "$1" && pwd -P)" 168 | 169 | case "$1" in 170 | /srv/*) ;; 171 | *) 172 | echo "Soruce dir must be under /srv" >&2 173 | exit 1 174 | ;; 175 | esac 176 | 177 | mkdir -p "${PREFIX}/srv" 178 | cp -at "${PREFIX}/srv" "$1" 179 | } 180 | 181 | cd /srv 182 | 183 | # Source stage script to compile current library 184 | ( 185 | _exit=0 186 | UNSUPPORTED=0 187 | trap '_exit=$?; if [ "$UNSUPPORTED" -eq 1 ]; then echo "Stage ignored in current environment" >&2; _exit=0; fi; exit $_exit' EXIT 188 | 189 | # Add wrappers to PATH 190 | export PATH="${SYSROOT}/wrapper:${PATH}" 191 | 192 | set -x 193 | 194 | # Make sure license directory exists 195 | mkdir -p "${PREFIX}/licenses/" 196 | 197 | OS_ANDROID="$(case "${TARGET##*-}" in android*) echo 1 ;; *) echo 0 ;; esac)" 198 | export OS_ANDROID 199 | 200 | # shellcheck disable=SC1091 201 | . /srv/stage.sh 202 | ) 203 | 204 | # Move cmake files in share to lib 205 | if [ -d "${PREFIX}/share/cmake" ]; then 206 | mkdir -p "${PREFIX}/lib/cmake" 207 | mv "$PREFIX"/share/cmake/* "${PREFIX}/lib/cmake" 208 | fi 209 | 210 | # Move pkgconfig files in share to lib 211 | if [ -d "${PREFIX}/share/pkgconfig" ]; then 212 | mkdir -p "${PREFIX}/lib/pkgconfig" 213 | mv "$PREFIX"/share/pkgconfig/* "${PREFIX}/lib/pkgconfig" 214 | fi 215 | 216 | # Remove superfluous files 217 | rm -rf "${PREFIX:?}"/{bin,etc,man,lib/*.{.la,.so*,.dll.a},share} 218 | 219 | # Copy licenses 220 | while IFS= read -r _license; do 221 | case "${_license}" in 222 | # Ignore license for tests, examples, contrib, ..., as we are not compiling, running or distributing those files 223 | # Ignore GPLv2 licenses, because we opt for GPLv3 for all libraries 224 | *.sh | *.cfg | *.build | */test/* | */tests/* | */demos/* | */build/* | \ 225 | */utils/* | */contrib/* | */examples/* | */3rdparty/* | */third_party/* | \ 226 | *GPL2* | *GPLv2* | *gpl2* | *gplv2*) 227 | continue 228 | ;; 229 | esac 230 | 231 | # Rename license files to include the package name 232 | cp "$_license" "${PREFIX}/licenses/$(dirname "${_license#/srv/}" | tr '/' '-').$(basename "$_license" .txt)" 233 | done < <(find /srv -type f \( -iname 'license*' -o -iname 'copying*' \) -not -wholename "${PREFIX}/**") 234 | -------------------------------------------------------------------------------- /scripts/cc.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euo pipefail 4 | 5 | OS_IPHONE=${OS_IPHONE:-0} 6 | 7 | case "${TARGET:?TARGET envvar is required to be defined}" in 8 | x86_64-linux-musl | aarch64-linux-musl) ;; 9 | x86_64-linux-gnu* | aarch64-linux-gnu*) 10 | # Set the glibc minimum version, RHEL-7.9 and CentOS 7 11 | TARGET="${TARGET%%.*}.2.17" 12 | ;; 13 | x86_64-linux-android | aarch64-linux-android) 14 | export SDKROOT="${NDK_SDKROOT:?Missing ndk sysroot}" 15 | ;; 16 | x86_64-darwin-apple | x86_64-apple-darwin-macho) 17 | if [ "$OS_IPHONE" -eq 1 ]; then 18 | export SDKROOT="${IOS_SDKROOT:?Missing iOS SDK}" 19 | elif [ "$OS_IPHONE" -eq 2 ]; then 20 | export SDKROOT="${IOS_SIMULATOR_SDKROOT:?Missing iOS simulator SDK}" 21 | else 22 | export SDKROOT="${MACOS_SDKROOT:?Missing macOS SDK}" 23 | fi 24 | TARGET="x86_64-apple-darwin-macho" 25 | ;; 26 | aarch64-darwin-apple | arm64-apple-darwin-macho) 27 | if [ "$OS_IPHONE" -eq 1 ]; then 28 | export SDKROOT="${IOS_SDKROOT:?Missing iOS SDK}" 29 | elif [ "$OS_IPHONE" -eq 2 ]; then 30 | export SDKROOT="${IOS_SIMULATOR_SDKROOT:?Missing iOS simulator SDK}" 31 | else 32 | export SDKROOT="${MACOS_SDKROOT:?Missing macOS SDK}" 33 | fi 34 | TARGET="arm64-apple-darwin-macho" 35 | ;; 36 | x86_64-windows-gnu | aarch64-windows-gnu) ;; 37 | *) 38 | echo "Unsupported target: $TARGET" >&2 39 | exit 1 40 | ;; 41 | esac 42 | 43 | is_cpp=0 44 | case "$(basename "$0")" in 45 | cc | android-gcc) 46 | case "$TARGET" in 47 | *darwin* | *android*) 48 | # Use clang instead of zig for darwin targets 49 | CMD='clang-17' 50 | ;; 51 | *) CMD='zig cc' ;; 52 | esac 53 | ;; 54 | c++ | android-g++) 55 | is_cpp=1 56 | case "$TARGET" in 57 | *darwin* | *android*) 58 | # Use clang instead of zig for darwin targets 59 | CMD='clang++-17' 60 | ;; 61 | *) CMD='zig c++' ;; 62 | esac 63 | ;; 64 | *) 65 | echo "Unsupported mode: $(basename "$0")" >&2 66 | exit 1 67 | ;; 68 | esac 69 | 70 | args_bak=("$@") 71 | 72 | lto='' 73 | argv=() 74 | stdin=0 75 | stdout=0 76 | l_args=() 77 | c_argv=('-target' "$TARGET") 78 | sysroot='' 79 | assembler=0 80 | os_iphone="${OS_IPHONE:-0}" 81 | preprocessor=0 82 | cpu_features=() 83 | assembler_file=0 84 | should_add_libcharset=0 85 | has_undefined_dynamic_lookup=0 86 | while [ "$#" -gt 0 ]; do 87 | # Grab linker args into a separate array 88 | if (case "$1" in -Wl,*) exit 0 ;; *) exit 1 ;; esac) then 89 | IFS=',' read -ra _args <<<"$1" 90 | unset "_args[0]" 91 | l_args+=("${_args[@]}") 92 | shift 93 | continue 94 | fi 95 | 96 | if [ "$1" = '-Xlinker' ] || [ "$1" = '--for-linker' ]; then 97 | l_args+=("${2:?Linker argument not passed}") 98 | shift 2 99 | continue 100 | elif (case "$1" in --for-linker=*) exit 0 ;; *) exit 1 ;; esac) then 101 | l_args+=("${1#*=}") 102 | shift 103 | continue 104 | elif [ "$1" = '-o-' ] || [ "$1" = '-o=-' ]; then 105 | # -E redirect to stdout by default, -o - breaks it so we ignore it 106 | stdout=1 107 | elif [ "$1" = '-o' ] && [ "${2:-}" = '-' ]; then 108 | stdout=1 109 | shift 2 110 | continue 111 | elif [ "$1" = '-g' ] || [ "$1" = '-gfull' ] || [ "$1" = '--debug' ]; then 112 | true 113 | elif (case "$1" in --debug=* | -gdwarf*) exit 0 ;; *) exit 1 ;; esac) then 114 | true 115 | elif [ "$1" = "-fuse-ld=gold" ]; then 116 | # spirv-tools tries to use gold linker for some reason, but we don't support it 117 | true 118 | elif [ "$1" = '-' ]; then 119 | stdin=1 120 | elif [ "$1" = '-lgcc_s' ]; then 121 | # Replace libgcc_s with libunwind 122 | argv+=('-lunwind') 123 | elif [ "$1" == '-lgcc_eh' ]; then 124 | # zig doesn't provide gcc_eh alternative 125 | # https://github.com/ziglang/zig/issues/17268 126 | # We use libc++ to replace it 127 | argv+=('-lc++') 128 | elif [ "$1" = '-fno-lto' ]; then 129 | # Zig dont respect -fno-lto when -flto is set, so keep track of it here and strip it if needed 130 | lto='-fno-lto' 131 | elif [ "$1" = '-flto' ]; then 132 | if [ -z "$lto" ]; then 133 | lto="-flto=auto" 134 | fi 135 | elif (case "$1" in -flto=*) exit 0 ;; *) exit 1 ;; esac) then 136 | if [ "$lto" != '-fno-lto' ]; then 137 | lto="$1" 138 | fi 139 | elif [ "$1" = '-target' ]; then 140 | shift 2 141 | continue 142 | elif (case "$1" in --target=*) exit 0 ;; *) exit 1 ;; esac) then 143 | # Drop target flag, we handle that ourself 144 | true 145 | elif (case "$1" in -O* | --optimize*) exit 0 ;; *) exit 1 ;; esac) then 146 | # Drop optmize flags, we force -Os below 147 | # This also misteriosly fix an aarch64 compiler bug in clang 16 148 | # https://github.com/llvm/llvm-project/issues/47432 149 | # https://github.com/llvm/llvm-project/issues/66912 150 | true 151 | elif [ "$1" = '-xassembler' ] || [ "$1" = '-Xassembler' ] || [ "$1" = '--language=assembler' ]; then 152 | # Zig behaves very oddly when passed the explicit assembler language option 153 | # https://github.com/ziglang/zig/issues/10915 154 | # https://github.com/ziglang/zig/pull/13544 155 | assembler=1 156 | elif { [ "$1" = '-x' ] || [ "$1" = '--language' ]; } && [ "${2:-}" = 'assembler' ]; then 157 | assembler=1 158 | shift 2 159 | continue 160 | elif (case "$1" in -mcpu=* | -march=*) exit 0 ;; *) exit 1 ;; esac) then 161 | # Save each feature to the cpu_features array 162 | IFS='+' read -ra _features <<<"$1" 163 | unset "_features[0]" 164 | cpu_features+=("${_features[@]}") 165 | elif [ "$1" = '--sysroot' ]; then 166 | sysroot="${2:?Sysroot argument not passed}" 167 | shift 168 | elif (case "$1" in --sysroot=*) exit 0 ;; *) exit 1 ;; esac) then 169 | sysroot="$(echo "$1" | cut -d "=" -f 2-)" 170 | else 171 | case "$TARGET" in 172 | *darwin*) 173 | if [ "$1" = '-arch=aarch64' ]; then 174 | # macOS uses arm64 instead of aarch64 175 | argv+=('-arch=arm64') 176 | elif [ "$1" = '-arch' ] && [ "${2:-}" = 'aarch64' ]; then 177 | argv+=('-arch' 'arm64') 178 | shift 2 179 | continue 180 | elif (case "$1" in -DTARGET_OS_IPHONE*) exit 0 ;; *) exit 1 ;; esac) then 181 | if [ "$os_iphone" -lt 1 ]; then 182 | os_iphone=1 183 | fi 184 | elif (case "$1" in -DTARGET_OS_SIMULATOR*) exit 0 ;; *) exit 1 ;; esac) then 185 | os_iphone=2 186 | else 187 | argv+=("$1") 188 | 189 | # See https://github.com/apple-oss-distributions/libiconv/blob/a167071/xcodeconfig/libiconv.xcconfig 190 | if [ "$1" = '-lcharset' ]; then 191 | should_add_libcharset=-1 192 | elif [ "$1" = '-liconv' ] && [ "$should_add_libcharset" -eq 0 ]; then 193 | should_add_libcharset=1 194 | fi 195 | fi 196 | ;; 197 | *windows*) 198 | if (case "$1" in *.rlib | *libcompiler_builtins-*) exit 0 ;; *) exit 1 ;; esac) then 199 | # compiler-builtins is duplicated with zig's compiler-rt 200 | case "$CMD" in 201 | clang*) argv+=("$1") ;; 202 | esac 203 | else 204 | argv+=("$1") 205 | fi 206 | ;; 207 | *) 208 | argv+=("$1") 209 | ;; 210 | esac 211 | fi 212 | 213 | if [ "$1" = '-E' ]; then 214 | preprocessor=1 215 | elif [ "$1" = '--help' ] || [ "$1" = '--version' ] || [ "$1" = '-dumpversion' ]; then 216 | exec $CMD "${c_argv[@]}" "$1" 217 | elif (case "$1" in *.S) exit 0 ;; *) exit 1 ;; esac) then 218 | assembler_file=1 219 | elif [ "$1" = '-undefined' ] && [ "${2:-}" == 'dynamic_lookup' ]; then 220 | argv+=("$2") 221 | has_undefined_dynamic_lookup=1 222 | shift 223 | fi 224 | 225 | shift 226 | done 227 | 228 | # Ensure compiler informs linker about how to handle undefined symbols 229 | if [ $has_undefined_dynamic_lookup -eq 1 ]; then 230 | l_args+=('-undefined=dynamic_lookup') 231 | fi 232 | 233 | # Set linker flags as global args to be parsed below 234 | set -- "${l_args[@]}" 235 | 236 | l_args=() 237 | while [ "$#" -gt 0 ]; do 238 | if [ "$1" = '-h' ] || [ "$1" = '-help' ] || [ "$1" = '--help' ] || [ "$1" = '/?' ]; then 239 | case "$TARGET" in 240 | *linux*) 241 | exec zig ld.lld --help 242 | ;; 243 | *windows*) 244 | exec zig lld-link -help 245 | ;; 246 | *darwin*) 247 | exec $CMD "${c_argv[@]}" -Wl,--help 248 | ;; 249 | esac 250 | elif [ "$1" = '-v' ]; then 251 | case "$CMD" in 252 | clang*) 253 | l_args+=(-v) 254 | ;; 255 | *) 256 | # Verbose (Linker doesn't support flag, but compiler does, so just redirect it) 257 | argv+=(-v) 258 | ;; 259 | esac 260 | elif [ "$1" = '-Bdynamic' ]; then 261 | case "$CMD" in 262 | clang*) 263 | l_args+=(-Bdynamic) 264 | ;; 265 | *) 266 | # https://github.com/ziglang/zig/pull/16058 267 | # zig changes the linker behavior, -Bdynamic won't search *.a for mingw, but this may be fixed in the later version 268 | # here is a workaround to replace the linker switch with -search_paths_first, which will search for *.dll,*lib first, 269 | # then fallback to *.a 270 | l_args+=(-search_paths_first) 271 | ;; 272 | esac 273 | elif [ "$1" = '-dynamic' ]; then 274 | case "$CMD" in 275 | clang*) 276 | l_args+=(-dynamic) 277 | ;; 278 | *) 279 | # Verbose (Linker doesn't support flag, but compiler does, so just redirect it) 280 | argv+=(-dynamic) 281 | ;; 282 | esac 283 | elif [ "$1" = '-rpath-link' ]; then 284 | case "$CMD" in 285 | clang*) 286 | l_args+=("$1" "${2:?rpath-link requires an argument}") 287 | ;; 288 | esac 289 | 290 | # zig doesn't support -rpath-link arg 291 | # https://github.com/ziglang/zig/pull/10948 292 | shift 293 | elif [ "$1" = '-pie' ] \ 294 | || [ "$1" = '--pic-executable' ]; then 295 | case "$CMD" in 296 | clang*) 297 | l_args+=(-pie) 298 | ;; 299 | *) 300 | # zig cc doesn't support -Wl,-pie or -Wl,--pic-executable, so we add -fPIE instead 301 | argv+=('-fPIE') 302 | ;; 303 | esac 304 | elif [ "$1" = '-dylib' ] \ 305 | || [ "$1" = '--dynamicbase' ] \ 306 | || [ "$1" = '--large-address-aware' ] \ 307 | || [ "$1" = '--disable-auto-image-base' ]; then 308 | # zig doesn't support -dylib, --dynamicbase, --large-address-aware and --disable-auto-image-base 309 | # https://github.com/rust-cross/cargo-zigbuild/blob/841df510dff8c585690e85354998bbcb6695460f/src/zig.rs#L187-L190 310 | # https://github.com/ziglang/zig/issues/10336 311 | case "$CMD" in 312 | clang*) 313 | l_args+=("$1") 314 | ;; 315 | esac 316 | elif [ "$1" = '-exported_symbols_list' ]; then 317 | case "$CMD" in 318 | clang*) 319 | l_args+=("$1" "${2:?exported_symbols_list requires an argument}") 320 | ;; 321 | esac 322 | 323 | # zig doesn't support -exported_symbols_list arg 324 | # https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-exported_symbols_list 325 | shift 326 | elif (case "$1" in --exported_symbols_list*) exit 0 ;; *) exit 1 ;; esac) then 327 | case "$CMD" in 328 | clang*) 329 | l_args+=("$1") 330 | ;; 331 | esac 332 | elif (case "$1" in --version-script=*) exit 0 ;; *) exit 1 ;; esac) then 333 | # Zig only support --version-script with a separate argument 334 | l_args+=(--version-script "${1#*=}") 335 | else 336 | l_args+=("$1") 337 | fi 338 | 339 | shift 340 | done 341 | 342 | if [ $stdout -eq 1 ] && ! [ $preprocessor -eq 1 ]; then 343 | echo "stdout mode is only supported for preprocessor" >&2 344 | exit 1 345 | fi 346 | 347 | # Work-around Zig not respecting -fno-lto when -flto is set 348 | if [ "${LTO:-1}" -eq 0 ]; then 349 | argv+=('-fno-lto') 350 | elif [ -n "$lto" ]; then 351 | argv+=("$lto") 352 | fi 353 | 354 | # Macos requires -lcharset to be defined when using -liconv 355 | if [ $should_add_libcharset -eq 1 ]; then 356 | argv+=('-lcharset') 357 | fi 358 | 359 | # Compiler specific flags 360 | features="" 361 | for feature in "${cpu_features[@]}"; do 362 | case "$CMD" in 363 | clang*) ;; 364 | *) 365 | if [ "$assembler" -eq 0 ] || [ "$preprocessor" -eq 1 ]; then 366 | # Zig specific changes 367 | case "$feature" in 368 | fp16) 369 | feature="fullfp16" 370 | ;; 371 | esac 372 | fi 373 | ;; 374 | esac 375 | 376 | features="${features}\n${feature}" 377 | done 378 | 379 | if [ -n "$features" ]; then 380 | features="$(printf "$features" | awk '!NF || !seen[$0]++' | xargs -r printf '+%s')" 381 | fi 382 | 383 | case "${TARGET:-}" in 384 | x86_64*) 385 | case "${TARGET:-}" in 386 | *darwin*) 387 | # macOS 10.15 (Catalina) only supports Macs made with Ivy Bridge or later 388 | c_argv+=("-march=ivybridge${features}") 389 | ;; 390 | *) 391 | case "$CMD" in 392 | clang*) 393 | c_argv+=("-march=x86-64-v2${features}") 394 | ;; 395 | *) 396 | c_argv+=("-march=x86_64_v2${features}") 397 | ;; 398 | esac 399 | ;; 400 | esac 401 | ;; 402 | arm64* | aarch64*) 403 | if [ "$preprocessor" -eq 0 ] && { [ $assembler -eq 1 ] || [ $assembler_file -eq 1 ]; }; then 404 | # This is an workaround for zig not supporting passing explict features when compiling assembler code 405 | # https://github.com/ziglang/zig/issues/10411 406 | c_argv+=(-Xassembler "-march=armv8.2-a${features}") 407 | else 408 | case "${TARGET:-}" in 409 | *darwin*) 410 | if [ "$os_iphone" -eq 0 ]; then 411 | c_argv+=("-mcpu=apple-m1${features}") 412 | else 413 | c_argv+=("-mcpu=apple-a10${features}") 414 | fi 415 | ;; 416 | *) 417 | # Raspberry Pi 3 418 | case "$CMD" in 419 | clang*) 420 | c_argv+=("-mcpu=cortex-a53${features}") 421 | ;; 422 | *) 423 | c_argv+=("-mcpu=cortex_a53${features}") 424 | ;; 425 | esac 426 | ;; 427 | esac 428 | fi 429 | ;; 430 | esac 431 | 432 | # Like -O2, but with extra optimizations to reduce code size 433 | c_argv+=(-Os) 434 | 435 | # If a SDK is defined resolve its absolute path 436 | if [ -z "$sysroot" ] && [ -d "${SDKROOT:-}" ]; then 437 | sysroot="$(CDPATH='' cd -- "$SDKROOT" && pwd -P)" 438 | fi 439 | 440 | # Configure the propert target between macOS and iOS 441 | case "$TARGET" in 442 | *darwin*) 443 | # https://stackoverflow.com/a/49560690 444 | c_argv+=('-DTARGET_OS_MAC=1') 445 | if [ "$os_iphone" -eq 1 ]; then 446 | # FIX-ME: Will need to expand this if we ever support tvOS/visionOS/watchOS 447 | c_argv+=('-DTARGET_OS_IPHONE=1' '-DTARGET_OS_IOS=1') 448 | elif [ "$os_iphone" -eq 2 ]; then 449 | # FIX-ME: Will need to expand this if we ever support tvOS/visionOS/watchOS simulators 450 | c_argv+=('-DTARGET_OS_IPHONE=1' '-DTARGET_OS_IOS=1' '-DTARGET_OS_SIMULATOR=1') 451 | else 452 | c_argv+=('-DTARGET_OS_IPHONE=0') 453 | fi 454 | ;; 455 | esac 456 | 457 | # Add sysroot to the include path 458 | if [ -n "$sysroot" ]; then 459 | c_argv+=( 460 | "--sysroot=${sysroot}" 461 | '-isysroot' "$sysroot" 462 | ) 463 | 464 | if [ $is_cpp -eq 1 ]; then 465 | c_argv+=('-isystem' "${sysroot}/usr/include/c++/v1") 466 | fi 467 | 468 | c_argv+=('-isystem' "${sysroot}/usr/include") 469 | 470 | if [ -d "${sysroot}/usr/include/android" ]; then 471 | c_argv+=('-isystem' "${sysroot}/usr/include/android") 472 | fi 473 | 474 | if [ -d "${sysroot}/usr/include/${TARGET}" ]; then 475 | c_argv+=('-isystem' "${sysroot}/usr/include/${TARGET}") 476 | fi 477 | fi 478 | 479 | # Add linker args back 480 | for arg in "${l_args[@]}"; do 481 | c_argv+=("-Wl,$arg") 482 | done 483 | 484 | # Zig's behaves very oddly when stdin is used, so we use a temporary file instead 485 | # https://github.com/ziglang/zig/issues/10389 486 | if [ $stdin -eq 1 ]; then 487 | if [ $assembler -eq 1 ]; then 488 | _file=$(mktemp __zig_fix_stdin.XXXXXX.S) 489 | else 490 | _file=$(mktemp __zig_fix_stdin.XXXXXX.c) 491 | fi 492 | 493 | trap 'rm -f $_file' EXIT 494 | 495 | cat >"$_file" 496 | 497 | argv+=("$_file") 498 | elif [ $assembler -eq 1 ] && ! [ $assembler_file -eq 1 ]; then 499 | echo "Assembler mode without stdin or an explicit assembly file is not supported" >&2 500 | exit 1 501 | fi 502 | 503 | # https://stackoverflow.com/q/11027679#answer-59592881 504 | # SYNTAX: 505 | # catch STDOUT_VARIABLE STDERR_VARIABLE COMMAND [ARG1[ ARG2[ ...[ ARGN]]]] 506 | catch() { 507 | { 508 | IFS=$'\n' read -r -d '' "${1}" 509 | IFS=$'\n' read -r -d '' "${2}" 510 | ( 511 | IFS=$'\n' read -r -d '' _ERRNO_ 512 | return "$_ERRNO_" 513 | ) 514 | } < <((printf '\0%s\0%d\0' "$( ( ( ({ 515 | shift 2 516 | "${@}" 517 | echo "${?}" 1>&3- 518 | } | tr -d '\0' 1>&4-) 4>&2- 2>&1- | tr -d '\0' 1>&4-) 3>&1- | exit "$(cat)") 4>&1-)" "${?}" 1>&2) 2>&1) 519 | } 520 | 521 | if [ "${_USING_GAS_PREPROCESSOR:-0}" -eq 0 ] && [ "$preprocessor" -eq 0 ] && { 522 | [ $assembler -eq 1 ] || [ $assembler_file -eq 1 ] 523 | }; then 524 | _cc_out= 525 | _cc_err= 526 | if catch _cc_out _cc_err $CMD "${c_argv[@]}" "${argv[@]}"; then 527 | printf '%s' "$_cc_out" 528 | printf '%s' "$_cc_err" >&2 529 | else 530 | _gas_out= 531 | _gas_err= 532 | export _USING_GAS_PREPROCESSOR=1 533 | # If zig failed to compile the assembly, try again through gas-preprocessor.pl 534 | if catch _gas_out _gas_err gas-preprocessor.pl -arch "${TARGET%%-*}" -as-type clang -- "$0" "${args_bak[@]}"; then 535 | printf '%s' "$_gas_out" 536 | printf '%s' "$_gas_err" >&2 537 | else 538 | printf '%s' "$_cc_out" 539 | printf '%s' "$_cc_err" >&2 540 | printf '%s' "$_gas_out" 541 | printf '%s' "$_gas_err" >&2 542 | exit 1 543 | fi 544 | fi 545 | else 546 | exec $CMD "${c_argv[@]}" "${argv[@]}" 547 | fi 548 | -------------------------------------------------------------------------------- /scripts/cmake.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -xeuo pipefail 4 | 5 | exec /opt/sysroot/bin/cmake \ 6 | -GNinja \ 7 | -Wno-dev \ 8 | -DCMAKE_TOOLCHAIN_FILE=/srv/toolchain.cmake \ 9 | -DCMAKE_BUILD_TYPE=MinSizeRel \ 10 | -DBUILD_SHARED_LIBS="${SHARED:-Off}" \ 11 | -DCMAKE_INSTALL_PREFIX="${PREFIX:?Prefix must be defined}" \ 12 | -DCMAKE_BUILD_WITH_INSTALL_RPATH=On \ 13 | -DCMAKE_POSITION_INDEPENDENT_CODE=On \ 14 | -DCMAKE_INTERPROCEDURAL_OPTIMIZATION="$([ "${LTO:-1}" -eq 1 ] && echo On || echo Off)" \ 15 | "$@" 16 | -------------------------------------------------------------------------------- /scripts/convert_yolo.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "provenance": [], 7 | "gpuType": "T4" 8 | }, 9 | "kernelspec": { 10 | "name": "python3", 11 | "display_name": "Python 3" 12 | }, 13 | "language_info": { 14 | "name": "python" 15 | }, 16 | "accelerator": "GPU" 17 | }, 18 | "cells": [ 19 | { 20 | "cell_type": "code", 21 | "execution_count": 1, 22 | "metadata": { 23 | "colab": { 24 | "base_uri": "https://localhost:8080/" 25 | }, 26 | "id": "yOP37uXEgHJg", 27 | "outputId": "2d0e899a-2728-4939-d137-1acaee0dc782" 28 | }, 29 | "outputs": [ 30 | { 31 | "output_type": "stream", 32 | "name": "stdout", 33 | "text": [ 34 | "Collecting ultralytics\n", 35 | " Downloading ultralytics-8.1.10-py3-none-any.whl (709 kB)\n", 36 | "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m709.4/709.4 kB\u001b[0m \u001b[31m6.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", 37 | "\u001b[?25hRequirement already satisfied: matplotlib>=3.3.0 in /usr/local/lib/python3.10/dist-packages (from ultralytics) (3.7.1)\n", 38 | "Requirement already satisfied: numpy>=1.22.2 in /usr/local/lib/python3.10/dist-packages (from ultralytics) (1.23.5)\n", 39 | "Requirement already satisfied: opencv-python>=4.6.0 in /usr/local/lib/python3.10/dist-packages (from ultralytics) (4.8.0.76)\n", 40 | "Requirement already satisfied: pillow>=7.1.2 in /usr/local/lib/python3.10/dist-packages (from ultralytics) (9.4.0)\n", 41 | "Requirement already satisfied: pyyaml>=5.3.1 in /usr/local/lib/python3.10/dist-packages (from ultralytics) (6.0.1)\n", 42 | "Requirement already satisfied: requests>=2.23.0 in /usr/local/lib/python3.10/dist-packages (from ultralytics) (2.31.0)\n", 43 | "Requirement already satisfied: scipy>=1.4.1 in /usr/local/lib/python3.10/dist-packages (from ultralytics) (1.11.4)\n", 44 | "Requirement already satisfied: torch>=1.8.0 in /usr/local/lib/python3.10/dist-packages (from ultralytics) (2.1.0+cu121)\n", 45 | "Requirement already satisfied: torchvision>=0.9.0 in /usr/local/lib/python3.10/dist-packages (from ultralytics) (0.16.0+cu121)\n", 46 | "Requirement already satisfied: tqdm>=4.64.0 in /usr/local/lib/python3.10/dist-packages (from ultralytics) (4.66.1)\n", 47 | "Requirement already satisfied: psutil in /usr/local/lib/python3.10/dist-packages (from ultralytics) (5.9.5)\n", 48 | "Requirement already satisfied: py-cpuinfo in /usr/local/lib/python3.10/dist-packages (from ultralytics) (9.0.0)\n", 49 | "Collecting thop>=0.1.1 (from ultralytics)\n", 50 | " Downloading thop-0.1.1.post2209072238-py3-none-any.whl (15 kB)\n", 51 | "Requirement already satisfied: pandas>=1.1.4 in /usr/local/lib/python3.10/dist-packages (from ultralytics) (1.5.3)\n", 52 | "Requirement already satisfied: seaborn>=0.11.0 in /usr/local/lib/python3.10/dist-packages (from ultralytics) (0.13.1)\n", 53 | "Requirement already satisfied: contourpy>=1.0.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib>=3.3.0->ultralytics) (1.2.0)\n", 54 | "Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.10/dist-packages (from matplotlib>=3.3.0->ultralytics) (0.12.1)\n", 55 | "Requirement already satisfied: fonttools>=4.22.0 in /usr/local/lib/python3.10/dist-packages (from matplotlib>=3.3.0->ultralytics) (4.47.2)\n", 56 | "Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib>=3.3.0->ultralytics) (1.4.5)\n", 57 | "Requirement already satisfied: packaging>=20.0 in /usr/local/lib/python3.10/dist-packages (from matplotlib>=3.3.0->ultralytics) (23.2)\n", 58 | "Requirement already satisfied: pyparsing>=2.3.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib>=3.3.0->ultralytics) (3.1.1)\n", 59 | "Requirement already satisfied: python-dateutil>=2.7 in /usr/local/lib/python3.10/dist-packages (from matplotlib>=3.3.0->ultralytics) (2.8.2)\n", 60 | "Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.10/dist-packages (from pandas>=1.1.4->ultralytics) (2023.4)\n", 61 | "Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests>=2.23.0->ultralytics) (3.3.2)\n", 62 | "Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests>=2.23.0->ultralytics) (3.6)\n", 63 | "Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests>=2.23.0->ultralytics) (2.0.7)\n", 64 | "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests>=2.23.0->ultralytics) (2024.2.2)\n", 65 | "Requirement already satisfied: filelock in /usr/local/lib/python3.10/dist-packages (from torch>=1.8.0->ultralytics) (3.13.1)\n", 66 | "Requirement already satisfied: typing-extensions in /usr/local/lib/python3.10/dist-packages (from torch>=1.8.0->ultralytics) (4.9.0)\n", 67 | "Requirement already satisfied: sympy in /usr/local/lib/python3.10/dist-packages (from torch>=1.8.0->ultralytics) (1.12)\n", 68 | "Requirement already satisfied: networkx in /usr/local/lib/python3.10/dist-packages (from torch>=1.8.0->ultralytics) (3.2.1)\n", 69 | "Requirement already satisfied: jinja2 in /usr/local/lib/python3.10/dist-packages (from torch>=1.8.0->ultralytics) (3.1.3)\n", 70 | "Requirement already satisfied: fsspec in /usr/local/lib/python3.10/dist-packages (from torch>=1.8.0->ultralytics) (2023.6.0)\n", 71 | "Requirement already satisfied: triton==2.1.0 in /usr/local/lib/python3.10/dist-packages (from torch>=1.8.0->ultralytics) (2.1.0)\n", 72 | "Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.10/dist-packages (from python-dateutil>=2.7->matplotlib>=3.3.0->ultralytics) (1.16.0)\n", 73 | "Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.10/dist-packages (from jinja2->torch>=1.8.0->ultralytics) (2.1.5)\n", 74 | "Requirement already satisfied: mpmath>=0.19 in /usr/local/lib/python3.10/dist-packages (from sympy->torch>=1.8.0->ultralytics) (1.3.0)\n", 75 | "Installing collected packages: thop, ultralytics\n", 76 | "Successfully installed thop-0.1.1.post2209072238 ultralytics-8.1.10\n" 77 | ] 78 | } 79 | ], 80 | "source": [ 81 | "!pip install ultralytics" 82 | ] 83 | }, 84 | { 85 | "cell_type": "code", 86 | "source": [ 87 | "!for size in n s m l x; do yolo export model=\"yolov8${size}.pt\" device=0 format=onnx imgsz=640 half=True simplify=True dynamic=False opset=12; done" 88 | ], 89 | "metadata": { 90 | "colab": { 91 | "base_uri": "https://localhost:8080/" 92 | }, 93 | "id": "ptWh-Komggm4", 94 | "outputId": "db56630e-81a8-4e30-cfa6-9b80eeb29e95" 95 | }, 96 | "execution_count": 2, 97 | "outputs": [ 98 | { 99 | "output_type": "stream", 100 | "name": "stdout", 101 | "text": [ 102 | "Downloading https://github.com/ultralytics/assets/releases/download/v8.1.0/yolov8n.pt to 'yolov8n.pt'...\n", 103 | "100% 6.23M/6.23M [00:00<00:00, 117MB/s]\n", 104 | "Ultralytics YOLOv8.1.10 🚀 Python-3.10.12 torch-2.1.0+cu121 CUDA:0 (Tesla T4, 15102MiB)\n", 105 | "YOLOv8n summary (fused): 168 layers, 3151904 parameters, 0 gradients, 8.7 GFLOPs\n", 106 | "\n", 107 | "\u001b[34m\u001b[1mPyTorch:\u001b[0m starting from 'yolov8n.pt' with input shape (1, 3, 640, 640) BCHW and output shape(s) (1, 84, 8400) (6.2 MB)\n", 108 | "\u001b[31m\u001b[1mrequirements:\u001b[0m Ultralytics requirements ['onnx>=1.12.0', 'onnxsim>=0.4.33', 'onnxruntime-gpu'] not found, attempting AutoUpdate...\n", 109 | "Collecting onnx>=1.12.0\n", 110 | " Downloading onnx-1.15.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (15.7 MB)\n", 111 | " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 15.7/15.7 MB 78.0 MB/s eta 0:00:00\n", 112 | "Collecting onnxsim>=0.4.33\n", 113 | " Downloading onnxsim-0.4.35-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.2 MB)\n", 114 | " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.2/2.2 MB 143.9 MB/s eta 0:00:00\n", 115 | "Collecting onnxruntime-gpu\n", 116 | " Downloading onnxruntime_gpu-1.17.0-cp310-cp310-manylinux_2_28_x86_64.whl (192.1 MB)\n", 117 | " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 192.1/192.1 MB 159.4 MB/s eta 0:00:00\n", 118 | "Requirement already satisfied: numpy in /usr/local/lib/python3.10/dist-packages (from onnx>=1.12.0) (1.23.5)\n", 119 | "Requirement already satisfied: protobuf>=3.20.2 in /usr/local/lib/python3.10/dist-packages (from onnx>=1.12.0) (3.20.3)\n", 120 | "Requirement already satisfied: rich in /usr/local/lib/python3.10/dist-packages (from onnxsim>=0.4.33) (13.7.0)\n", 121 | "Collecting coloredlogs (from onnxruntime-gpu)\n", 122 | " Downloading coloredlogs-15.0.1-py2.py3-none-any.whl (46 kB)\n", 123 | " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 46.0/46.0 kB 194.6 MB/s eta 0:00:00\n", 124 | "Requirement already satisfied: flatbuffers in /usr/local/lib/python3.10/dist-packages (from onnxruntime-gpu) (23.5.26)\n", 125 | "Requirement already satisfied: packaging in /usr/local/lib/python3.10/dist-packages (from onnxruntime-gpu) (23.2)\n", 126 | "Requirement already satisfied: sympy in /usr/local/lib/python3.10/dist-packages (from onnxruntime-gpu) (1.12)\n", 127 | "Collecting humanfriendly>=9.1 (from coloredlogs->onnxruntime-gpu)\n", 128 | " Downloading humanfriendly-10.0-py2.py3-none-any.whl (86 kB)\n", 129 | " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 86.8/86.8 kB 168.8 MB/s eta 0:00:00\n", 130 | "Requirement already satisfied: markdown-it-py>=2.2.0 in /usr/local/lib/python3.10/dist-packages (from rich->onnxsim>=0.4.33) (3.0.0)\n", 131 | "Requirement already satisfied: pygments<3.0.0,>=2.13.0 in /usr/local/lib/python3.10/dist-packages (from rich->onnxsim>=0.4.33) (2.16.1)\n", 132 | "Requirement already satisfied: mpmath>=0.19 in /usr/local/lib/python3.10/dist-packages (from sympy->onnxruntime-gpu) (1.3.0)\n", 133 | "Requirement already satisfied: mdurl~=0.1 in /usr/local/lib/python3.10/dist-packages (from markdown-it-py>=2.2.0->rich->onnxsim>=0.4.33) (0.1.2)\n", 134 | "Installing collected packages: onnx, humanfriendly, coloredlogs, onnxsim, onnxruntime-gpu\n", 135 | "Successfully installed coloredlogs-15.0.1 humanfriendly-10.0 onnx-1.15.0 onnxruntime-gpu-1.17.0 onnxsim-0.4.35\n", 136 | "\n", 137 | "\u001b[31m\u001b[1mrequirements:\u001b[0m AutoUpdate success ✅ 18.8s, installed 3 packages: ['onnx>=1.12.0', 'onnxsim>=0.4.33', 'onnxruntime-gpu']\n", 138 | "\u001b[31m\u001b[1mrequirements:\u001b[0m ⚠️ \u001b[1mRestart runtime or rerun command for updates to take effect\u001b[0m\n", 139 | "\n", 140 | "\n", 141 | "\u001b[34m\u001b[1mONNX:\u001b[0m starting export with onnx 1.15.0 opset 12...\n", 142 | "\u001b[34m\u001b[1mONNX:\u001b[0m simplifying with onnxsim 0.4.35...\n", 143 | "\u001b[34m\u001b[1mONNX:\u001b[0m export success ✅ 20.0s, saved as 'yolov8n.onnx' (6.1 MB)\n", 144 | "\n", 145 | "Export complete (21.7s)\n", 146 | "Results saved to \u001b[1m/content\u001b[0m\n", 147 | "Predict: yolo predict task=detect model=yolov8n.onnx imgsz=640 half \n", 148 | "Validate: yolo val task=detect model=yolov8n.onnx imgsz=640 data=coco.yaml half \n", 149 | "Visualize: https://netron.app\n", 150 | "💡 Learn more at https://docs.ultralytics.com/modes/export\n", 151 | "Downloading https://github.com/ultralytics/assets/releases/download/v8.1.0/yolov8s.pt to 'yolov8s.pt'...\n", 152 | "100% 21.5M/21.5M [00:00<00:00, 238MB/s]\n", 153 | "Ultralytics YOLOv8.1.10 🚀 Python-3.10.12 torch-2.1.0+cu121 CUDA:0 (Tesla T4, 15102MiB)\n", 154 | "YOLOv8s summary (fused): 168 layers, 11156544 parameters, 0 gradients, 28.6 GFLOPs\n", 155 | "\n", 156 | "\u001b[34m\u001b[1mPyTorch:\u001b[0m starting from 'yolov8s.pt' with input shape (1, 3, 640, 640) BCHW and output shape(s) (1, 84, 8400) (21.5 MB)\n", 157 | "\n", 158 | "\u001b[34m\u001b[1mONNX:\u001b[0m starting export with onnx 1.15.0 opset 12...\n", 159 | "\u001b[34m\u001b[1mONNX:\u001b[0m simplifying with onnxsim 0.4.35...\n", 160 | "\u001b[34m\u001b[1mONNX:\u001b[0m export success ✅ 1.5s, saved as 'yolov8s.onnx' (21.4 MB)\n", 161 | "\n", 162 | "Export complete (2.3s)\n", 163 | "Results saved to \u001b[1m/content\u001b[0m\n", 164 | "Predict: yolo predict task=detect model=yolov8s.onnx imgsz=640 half \n", 165 | "Validate: yolo val task=detect model=yolov8s.onnx imgsz=640 data=coco.yaml half \n", 166 | "Visualize: https://netron.app\n", 167 | "💡 Learn more at https://docs.ultralytics.com/modes/export\n", 168 | "Downloading https://github.com/ultralytics/assets/releases/download/v8.1.0/yolov8m.pt to 'yolov8m.pt'...\n", 169 | "100% 49.7M/49.7M [00:00<00:00, 319MB/s]\n", 170 | "Ultralytics YOLOv8.1.10 🚀 Python-3.10.12 torch-2.1.0+cu121 CUDA:0 (Tesla T4, 15102MiB)\n", 171 | "YOLOv8m summary (fused): 218 layers, 25886080 parameters, 0 gradients, 78.9 GFLOPs\n", 172 | "\n", 173 | "\u001b[34m\u001b[1mPyTorch:\u001b[0m starting from 'yolov8m.pt' with input shape (1, 3, 640, 640) BCHW and output shape(s) (1, 84, 8400) (49.7 MB)\n", 174 | "\n", 175 | "\u001b[34m\u001b[1mONNX:\u001b[0m starting export with onnx 1.15.0 opset 12...\n", 176 | "\u001b[34m\u001b[1mONNX:\u001b[0m simplifying with onnxsim 0.4.35...\n", 177 | "\u001b[34m\u001b[1mONNX:\u001b[0m export success ✅ 2.2s, saved as 'yolov8m.onnx' (49.5 MB)\n", 178 | "\n", 179 | "Export complete (3.3s)\n", 180 | "Results saved to \u001b[1m/content\u001b[0m\n", 181 | "Predict: yolo predict task=detect model=yolov8m.onnx imgsz=640 half \n", 182 | "Validate: yolo val task=detect model=yolov8m.onnx imgsz=640 data=coco.yaml half \n", 183 | "Visualize: https://netron.app\n", 184 | "💡 Learn more at https://docs.ultralytics.com/modes/export\n", 185 | "Downloading https://github.com/ultralytics/assets/releases/download/v8.1.0/yolov8l.pt to 'yolov8l.pt'...\n", 186 | "100% 83.7M/83.7M [00:00<00:00, 326MB/s]\n", 187 | "Ultralytics YOLOv8.1.10 🚀 Python-3.10.12 torch-2.1.0+cu121 CUDA:0 (Tesla T4, 15102MiB)\n", 188 | "YOLOv8l summary (fused): 268 layers, 43668288 parameters, 0 gradients, 165.2 GFLOPs\n", 189 | "\n", 190 | "\u001b[34m\u001b[1mPyTorch:\u001b[0m starting from 'yolov8l.pt' with input shape (1, 3, 640, 640) BCHW and output shape(s) (1, 84, 8400) (83.7 MB)\n", 191 | "\n", 192 | "\u001b[34m\u001b[1mONNX:\u001b[0m starting export with onnx 1.15.0 opset 12...\n", 193 | "\u001b[34m\u001b[1mONNX:\u001b[0m simplifying with onnxsim 0.4.35...\n", 194 | "\u001b[34m\u001b[1mONNX:\u001b[0m export success ✅ 3.3s, saved as 'yolov8l.onnx' (83.4 MB)\n", 195 | "\n", 196 | "Export complete (4.5s)\n", 197 | "Results saved to \u001b[1m/content\u001b[0m\n", 198 | "Predict: yolo predict task=detect model=yolov8l.onnx imgsz=640 half \n", 199 | "Validate: yolo val task=detect model=yolov8l.onnx imgsz=640 data=coco.yaml half \n", 200 | "Visualize: https://netron.app\n", 201 | "💡 Learn more at https://docs.ultralytics.com/modes/export\n", 202 | "Downloading https://github.com/ultralytics/assets/releases/download/v8.1.0/yolov8x.pt to 'yolov8x.pt'...\n", 203 | "100% 131M/131M [00:00<00:00, 289MB/s]\n", 204 | "Ultralytics YOLOv8.1.10 🚀 Python-3.10.12 torch-2.1.0+cu121 CUDA:0 (Tesla T4, 15102MiB)\n", 205 | "YOLOv8x summary (fused): 268 layers, 68200608 parameters, 0 gradients, 257.8 GFLOPs\n", 206 | "\n", 207 | "\u001b[34m\u001b[1mPyTorch:\u001b[0m starting from 'yolov8x.pt' with input shape (1, 3, 640, 640) BCHW and output shape(s) (1, 84, 8400) (130.5 MB)\n", 208 | "\n", 209 | "\u001b[34m\u001b[1mONNX:\u001b[0m starting export with onnx 1.15.0 opset 12...\n", 210 | "\u001b[34m\u001b[1mONNX:\u001b[0m simplifying with onnxsim 0.4.35...\n", 211 | "\u001b[34m\u001b[1mONNX:\u001b[0m export success ✅ 4.3s, saved as 'yolov8x.onnx' (130.2 MB)\n", 212 | "\n", 213 | "Export complete (5.8s)\n", 214 | "Results saved to \u001b[1m/content\u001b[0m\n", 215 | "Predict: yolo predict task=detect model=yolov8x.onnx imgsz=640 half \n", 216 | "Validate: yolo val task=detect model=yolov8x.onnx imgsz=640 data=coco.yaml half \n", 217 | "Visualize: https://netron.app\n", 218 | "💡 Learn more at https://docs.ultralytics.com/modes/export\n" 219 | ] 220 | } 221 | ] 222 | }, 223 | { 224 | "cell_type": "code", 225 | "source": [ 226 | "from google.colab import files\n", 227 | "\n", 228 | "for size in ['n', 's', 'm', 'l', 'x']:\n", 229 | " files.download(f'yolov8{size}.onnx')" 230 | ], 231 | "metadata": { 232 | "colab": { 233 | "base_uri": "https://localhost:8080/", 234 | "height": 17 235 | }, 236 | "id": "HcWW9KltgSQ8", 237 | "outputId": "4d6f5018-ce3c-4e93-d59b-16457cc5dae1" 238 | }, 239 | "execution_count": 3, 240 | "outputs": [ 241 | { 242 | "output_type": "display_data", 243 | "data": { 244 | "text/plain": [ 245 | "" 246 | ], 247 | "application/javascript": [ 248 | "\n", 249 | " async function download(id, filename, size) {\n", 250 | " if (!google.colab.kernel.accessAllowed) {\n", 251 | " return;\n", 252 | " }\n", 253 | " const div = document.createElement('div');\n", 254 | " const label = document.createElement('label');\n", 255 | " label.textContent = `Downloading \"${filename}\": `;\n", 256 | " div.appendChild(label);\n", 257 | " const progress = document.createElement('progress');\n", 258 | " progress.max = size;\n", 259 | " div.appendChild(progress);\n", 260 | " document.body.appendChild(div);\n", 261 | "\n", 262 | " const buffers = [];\n", 263 | " let downloaded = 0;\n", 264 | "\n", 265 | " const channel = await google.colab.kernel.comms.open(id);\n", 266 | " // Send a message to notify the kernel that we're ready.\n", 267 | " channel.send({})\n", 268 | "\n", 269 | " for await (const message of channel.messages) {\n", 270 | " // Send a message to notify the kernel that we're ready.\n", 271 | " channel.send({})\n", 272 | " if (message.buffers) {\n", 273 | " for (const buffer of message.buffers) {\n", 274 | " buffers.push(buffer);\n", 275 | " downloaded += buffer.byteLength;\n", 276 | " progress.value = downloaded;\n", 277 | " }\n", 278 | " }\n", 279 | " }\n", 280 | " const blob = new Blob(buffers, {type: 'application/binary'});\n", 281 | " const a = document.createElement('a');\n", 282 | " a.href = window.URL.createObjectURL(blob);\n", 283 | " a.download = filename;\n", 284 | " div.appendChild(a);\n", 285 | " a.click();\n", 286 | " div.remove();\n", 287 | " }\n", 288 | " " 289 | ] 290 | }, 291 | "metadata": {} 292 | }, 293 | { 294 | "output_type": "display_data", 295 | "data": { 296 | "text/plain": [ 297 | "" 298 | ], 299 | "application/javascript": [ 300 | "download(\"download_09848bb8-3865-4ba8-ab5b-f670838560ca\", \"yolov8n.onnx\", 6414704)" 301 | ] 302 | }, 303 | "metadata": {} 304 | }, 305 | { 306 | "output_type": "display_data", 307 | "data": { 308 | "text/plain": [ 309 | "" 310 | ], 311 | "application/javascript": [ 312 | "\n", 313 | " async function download(id, filename, size) {\n", 314 | " if (!google.colab.kernel.accessAllowed) {\n", 315 | " return;\n", 316 | " }\n", 317 | " const div = document.createElement('div');\n", 318 | " const label = document.createElement('label');\n", 319 | " label.textContent = `Downloading \"${filename}\": `;\n", 320 | " div.appendChild(label);\n", 321 | " const progress = document.createElement('progress');\n", 322 | " progress.max = size;\n", 323 | " div.appendChild(progress);\n", 324 | " document.body.appendChild(div);\n", 325 | "\n", 326 | " const buffers = [];\n", 327 | " let downloaded = 0;\n", 328 | "\n", 329 | " const channel = await google.colab.kernel.comms.open(id);\n", 330 | " // Send a message to notify the kernel that we're ready.\n", 331 | " channel.send({})\n", 332 | "\n", 333 | " for await (const message of channel.messages) {\n", 334 | " // Send a message to notify the kernel that we're ready.\n", 335 | " channel.send({})\n", 336 | " if (message.buffers) {\n", 337 | " for (const buffer of message.buffers) {\n", 338 | " buffers.push(buffer);\n", 339 | " downloaded += buffer.byteLength;\n", 340 | " progress.value = downloaded;\n", 341 | " }\n", 342 | " }\n", 343 | " }\n", 344 | " const blob = new Blob(buffers, {type: 'application/binary'});\n", 345 | " const a = document.createElement('a');\n", 346 | " a.href = window.URL.createObjectURL(blob);\n", 347 | " a.download = filename;\n", 348 | " div.appendChild(a);\n", 349 | " a.click();\n", 350 | " div.remove();\n", 351 | " }\n", 352 | " " 353 | ] 354 | }, 355 | "metadata": {} 356 | }, 357 | { 358 | "output_type": "display_data", 359 | "data": { 360 | "text/plain": [ 361 | "" 362 | ], 363 | "application/javascript": [ 364 | "download(\"download_79b03f7d-ac34-41a4-b6e0-85896004cfd6\", \"yolov8s.onnx\", 22424155)" 365 | ] 366 | }, 367 | "metadata": {} 368 | }, 369 | { 370 | "output_type": "display_data", 371 | "data": { 372 | "text/plain": [ 373 | "" 374 | ], 375 | "application/javascript": [ 376 | "\n", 377 | " async function download(id, filename, size) {\n", 378 | " if (!google.colab.kernel.accessAllowed) {\n", 379 | " return;\n", 380 | " }\n", 381 | " const div = document.createElement('div');\n", 382 | " const label = document.createElement('label');\n", 383 | " label.textContent = `Downloading \"${filename}\": `;\n", 384 | " div.appendChild(label);\n", 385 | " const progress = document.createElement('progress');\n", 386 | " progress.max = size;\n", 387 | " div.appendChild(progress);\n", 388 | " document.body.appendChild(div);\n", 389 | "\n", 390 | " const buffers = [];\n", 391 | " let downloaded = 0;\n", 392 | "\n", 393 | " const channel = await google.colab.kernel.comms.open(id);\n", 394 | " // Send a message to notify the kernel that we're ready.\n", 395 | " channel.send({})\n", 396 | "\n", 397 | " for await (const message of channel.messages) {\n", 398 | " // Send a message to notify the kernel that we're ready.\n", 399 | " channel.send({})\n", 400 | " if (message.buffers) {\n", 401 | " for (const buffer of message.buffers) {\n", 402 | " buffers.push(buffer);\n", 403 | " downloaded += buffer.byteLength;\n", 404 | " progress.value = downloaded;\n", 405 | " }\n", 406 | " }\n", 407 | " }\n", 408 | " const blob = new Blob(buffers, {type: 'application/binary'});\n", 409 | " const a = document.createElement('a');\n", 410 | " a.href = window.URL.createObjectURL(blob);\n", 411 | " a.download = filename;\n", 412 | " div.appendChild(a);\n", 413 | " a.click();\n", 414 | " div.remove();\n", 415 | " }\n", 416 | " " 417 | ] 418 | }, 419 | "metadata": {} 420 | }, 421 | { 422 | "output_type": "display_data", 423 | "data": { 424 | "text/plain": [ 425 | "" 426 | ], 427 | "application/javascript": [ 428 | "download(\"download_b3ab4252-4651-4565-97e2-a2c7cf1dc103\", \"yolov8m.onnx\", 51900600)" 429 | ] 430 | }, 431 | "metadata": {} 432 | }, 433 | { 434 | "output_type": "display_data", 435 | "data": { 436 | "text/plain": [ 437 | "" 438 | ], 439 | "application/javascript": [ 440 | "\n", 441 | " async function download(id, filename, size) {\n", 442 | " if (!google.colab.kernel.accessAllowed) {\n", 443 | " return;\n", 444 | " }\n", 445 | " const div = document.createElement('div');\n", 446 | " const label = document.createElement('label');\n", 447 | " label.textContent = `Downloading \"${filename}\": `;\n", 448 | " div.appendChild(label);\n", 449 | " const progress = document.createElement('progress');\n", 450 | " progress.max = size;\n", 451 | " div.appendChild(progress);\n", 452 | " document.body.appendChild(div);\n", 453 | "\n", 454 | " const buffers = [];\n", 455 | " let downloaded = 0;\n", 456 | "\n", 457 | " const channel = await google.colab.kernel.comms.open(id);\n", 458 | " // Send a message to notify the kernel that we're ready.\n", 459 | " channel.send({})\n", 460 | "\n", 461 | " for await (const message of channel.messages) {\n", 462 | " // Send a message to notify the kernel that we're ready.\n", 463 | " channel.send({})\n", 464 | " if (message.buffers) {\n", 465 | " for (const buffer of message.buffers) {\n", 466 | " buffers.push(buffer);\n", 467 | " downloaded += buffer.byteLength;\n", 468 | " progress.value = downloaded;\n", 469 | " }\n", 470 | " }\n", 471 | " }\n", 472 | " const blob = new Blob(buffers, {type: 'application/binary'});\n", 473 | " const a = document.createElement('a');\n", 474 | " a.href = window.URL.createObjectURL(blob);\n", 475 | " a.download = filename;\n", 476 | " div.appendChild(a);\n", 477 | " a.click();\n", 478 | " div.remove();\n", 479 | " }\n", 480 | " " 481 | ] 482 | }, 483 | "metadata": {} 484 | }, 485 | { 486 | "output_type": "display_data", 487 | "data": { 488 | "text/plain": [ 489 | "" 490 | ], 491 | "application/javascript": [ 492 | "download(\"download_f77c1e97-1003-468b-83f7-ca012501e9fa\", \"yolov8l.onnx\", 87482534)" 493 | ] 494 | }, 495 | "metadata": {} 496 | }, 497 | { 498 | "output_type": "display_data", 499 | "data": { 500 | "text/plain": [ 501 | "" 502 | ], 503 | "application/javascript": [ 504 | "\n", 505 | " async function download(id, filename, size) {\n", 506 | " if (!google.colab.kernel.accessAllowed) {\n", 507 | " return;\n", 508 | " }\n", 509 | " const div = document.createElement('div');\n", 510 | " const label = document.createElement('label');\n", 511 | " label.textContent = `Downloading \"${filename}\": `;\n", 512 | " div.appendChild(label);\n", 513 | " const progress = document.createElement('progress');\n", 514 | " progress.max = size;\n", 515 | " div.appendChild(progress);\n", 516 | " document.body.appendChild(div);\n", 517 | "\n", 518 | " const buffers = [];\n", 519 | " let downloaded = 0;\n", 520 | "\n", 521 | " const channel = await google.colab.kernel.comms.open(id);\n", 522 | " // Send a message to notify the kernel that we're ready.\n", 523 | " channel.send({})\n", 524 | "\n", 525 | " for await (const message of channel.messages) {\n", 526 | " // Send a message to notify the kernel that we're ready.\n", 527 | " channel.send({})\n", 528 | " if (message.buffers) {\n", 529 | " for (const buffer of message.buffers) {\n", 530 | " buffers.push(buffer);\n", 531 | " downloaded += buffer.byteLength;\n", 532 | " progress.value = downloaded;\n", 533 | " }\n", 534 | " }\n", 535 | " }\n", 536 | " const blob = new Blob(buffers, {type: 'application/binary'});\n", 537 | " const a = document.createElement('a');\n", 538 | " a.href = window.URL.createObjectURL(blob);\n", 539 | " a.download = filename;\n", 540 | " div.appendChild(a);\n", 541 | " a.click();\n", 542 | " div.remove();\n", 543 | " }\n", 544 | " " 545 | ] 546 | }, 547 | "metadata": {} 548 | }, 549 | { 550 | "output_type": "display_data", 551 | "data": { 552 | "text/plain": [ 553 | "" 554 | ], 555 | "application/javascript": [ 556 | "download(\"download_a09800dc-d34a-4b4e-b97b-3eda221bfe42\", \"yolov8x.onnx\", 136547174)" 557 | ] 558 | }, 559 | "metadata": {} 560 | } 561 | ] 562 | }, 563 | { 564 | "cell_type": "code", 565 | "source": [], 566 | "metadata": { 567 | "id": "0XFU4sawh7WG" 568 | }, 569 | "execution_count": null, 570 | "outputs": [] 571 | } 572 | ] 573 | } -------------------------------------------------------------------------------- /scripts/create-macos-framework.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -xeuo pipefail 4 | 5 | case "$TARGET" in 6 | *darwin*) 7 | if [ "$OS_IPHONE" -ne 0 ]; then 8 | echo "iOS target uses another framework structure" >&2 9 | exit 0 10 | fi 11 | ;; 12 | *) 13 | echo "Framework creation is only for macOS" >&2 14 | exit 0 15 | ;; 16 | esac 17 | 18 | if [ -z "${VERSION:-}" ]; then 19 | VERSION="0.0.0" 20 | fi 21 | 22 | # Create Spacedrive.framework 23 | # https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/FrameworkAnatomy.html 24 | _framework="Spacedrive.framework" 25 | 26 | # Create basic structure 27 | mkdir -p "${OUT:?Missing out dir}/${_framework}/Versions/A/Resources" 28 | 29 | # Move libs to Framework 30 | mv "${OUT}/lib" "${OUT}/${_framework}/Versions/A/Libraries" 31 | 32 | # Fix linker load path for each library and it's dependency 33 | while IFS= read -r _lib; do 34 | # Loop through each of the library's dependencies 35 | for _dep in $(otool -L "$_lib" | tail -n+3 | awk '{print $1}'); do 36 | case "$_dep" in 37 | "${OUT}/lib/"*) # One of our built libraries 38 | # Change the dependency linker path so it loads it from the same directory as the library 39 | install_name_tool -change "$_dep" "@loader_path/${_dep#"${OUT}/lib/"}" "$_lib" 40 | ;; 41 | *) # Ignore system libraries 42 | continue 43 | ;; 44 | esac 45 | done 46 | 47 | # Update the library's own id 48 | if ! install_name_tool -id "@executable_path/../Frameworks/${_framework}/Libraries/$(basename "$_lib")" "$_lib"; then 49 | # Some libraries have a header pad too small, so use a relative path instead 50 | install_name_tool -id "./$(basename "$_lib")" "$_lib" 51 | fi 52 | done < <(find "${OUT}/${_framework}/Versions/A/Libraries" -type f -name '*.dylib') 53 | 54 | # Move headers to Framework 55 | mv "${OUT}/include" "${OUT}/${_framework}/Versions/A/Headers" 56 | 57 | # Move licenses to Framework 58 | mv "${OUT}/licenses" "${OUT}/${_framework}/Versions/A/Resources/Licenses" 59 | 60 | # Move models to Framework 61 | mv "${OUT}/models" "${OUT}/${_framework}/Versions/A/Resources/Models" 62 | 63 | # Create required framework symlinks 64 | ln -s A "${OUT}/${_framework}/Versions/Current" 65 | ln -s Versions/Current/Headers "${OUT}/${_framework}/Headers" 66 | ln -s Versions/Current/Resources "${OUT}/${_framework}/Resources" 67 | ln -s Versions/Current/Libraries "${OUT}/${_framework}/Libraries" 68 | 69 | # Symlink framework directories back to our original layout 70 | ln -s "${_framework}/Headers" "${OUT}/include" 71 | ln -s "${_framework}/Libraries" "${OUT}/lib" 72 | ln -s "${_framework}/Resources/Licenses" "${OUT}/licenses" 73 | 74 | # Framework Info.plist (based on macOS internal OpenGL.framework Info.plist) 75 | cat <"${OUT}/${_framework}/Versions/Current/Resources/Info.plist" 76 | 77 | 78 | 79 | 80 | CFBundleDevelopmentRegion 81 | en 82 | CFBundleExecutable 83 | Spacedrive 84 | CFBundleGetInfoString 85 | Spacedrive Native Dependencies ${VERSION} 86 | CFBundleIdentifier 87 | com.spacedrive 88 | CFBundleInfoDictionaryVersion 89 | 6.0 90 | CFBundleName 91 | Spacedrive 92 | CFBundlePackageType 93 | FMWK 94 | CFBundleShortVersionString 95 | ${VERSION} 96 | CFBundleSignature 97 | ???? 98 | CFBundleVersion 99 | ${VERSION} 100 | NSHumanReadableCopyright 101 | Copyright (c) 2021-present Spacedrive Technology Inc. 102 | 103 | 104 | EOF 105 | 106 | cat <"${OUT}/${_framework}/Versions/Current/Resources/version.plist" 107 | 108 | 109 | 110 | 111 | BuildVersion 112 | 1 113 | CFBundleShortVersionString 114 | ${VERSION} 115 | CFBundleVersion 116 | ${VERSION} 117 | ProjectName 118 | Spacedrive 119 | SourceVersion 120 | $(date '+%Y%m%d%H%M%S') 121 | 122 | 123 | EOF 124 | -------------------------------------------------------------------------------- /scripts/curl_tar.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euo pipefail 4 | 5 | if ! { [ "$#" -gt 1 ] && [ -n "$1" ] && [ -n "$2" ]; }; then 6 | echo "Usage: $0 " >&2 7 | exit 1 8 | fi 9 | 10 | if [ -e "$2" ] && ! [ -d "$2" ]; then 11 | echo " must be a valid directory path" >&2 12 | exit 1 13 | fi 14 | 15 | case "${3:-}" in 16 | '') 17 | set -- "$1" "$2" 0 18 | ;; 19 | *[0-9]*) ;; 20 | *) 21 | echo " must be a valid number" >&2 22 | exit 1 23 | ;; 24 | esac 25 | 26 | mkdir -p "$2" 27 | 28 | _url="$1" 29 | _cache="/root/.cache/_curl_tar/$(md5sum - <<<"$_url" | awk '{ print $1 }')" 30 | 31 | mkdir -p "$(dirname "$_cache")" 32 | 33 | if ! [ -s "$_cache" ]; then 34 | curl --proto '=https' --tlsv1.2 --ciphers "${CIPHERSUITES:?Missing curl ciphersuite}" --silent --show-error --fail --location "$_url" >"$_cache" 35 | fi 36 | 37 | trap 'rm -rf "$_cache"' ERR 38 | 39 | if [ "$3" -eq 0 ]; then 40 | if [ -n "${4:-}" ]; then 41 | set -- -C "$2" "${4:-}" 42 | else 43 | set -- -C "$2" 44 | fi 45 | else 46 | if [ -n "${4:-}" ]; then 47 | set -- --strip-component="$3" -C "$2" "${4:-}" 48 | else 49 | set -- --strip-component="$3" -C "$2" 50 | fi 51 | fi 52 | 53 | bsdtar -xf "$_cache" --no-acls --no-xattrs --no-same-owner --no-mac-metadata --no-same-permissions "$@" 54 | -------------------------------------------------------------------------------- /scripts/meson.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -xeuo pipefail 4 | 5 | exec /opt/sysroot/bin/meson setup \ 6 | --prefix="${PREFIX:?Prefix must be defined}" \ 7 | --buildtype=minsize \ 8 | --wrap-mode=nofallback \ 9 | --cross-file=/srv/cross.meson \ 10 | --default-library="${SHARED:-static}" \ 11 | -Db_lto="$([ "${LTO:-1}" -eq 1 ] && echo true || echo false)" \ 12 | -Db_staticpic=true \ 13 | -Db_pie=true \ 14 | "$@" 15 | -------------------------------------------------------------------------------- /scripts/rc.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euo pipefail 4 | 5 | case "${TARGET:?TARGET envvar is required to be defined}" in 6 | *windows-gnu) 7 | _win_include="${SYSROOT:?SYSROOT envvar is required to be defined}/lib/libc/include/any-windows-any" 8 | ;; 9 | *) 10 | echo "Only valid on windows targets" >&2 11 | exit 1 12 | ;; 13 | esac 14 | 15 | _name="$(basename "$0")" 16 | case "$_name" in 17 | rc) 18 | # Work-around meson not recognising llvm-rc 19 | if [ "$1" = '/?' ]; then 20 | echo 'LLVM Resource Converter' 21 | fi 22 | 23 | set -- -target="${TARGET%%-*}-pc-windows-gnu" /D __GNUC__ /I "$_win_include" "$@" 24 | ;; 25 | windres) 26 | set -- --target="${TARGET%%-*}-w64-mingw32" --define=__GNUC__ --include-dir="$_win_include" "$@" 27 | ;; 28 | *) 29 | echo "Script name must be rc or windres" >&2 30 | exit 1 31 | ;; 32 | esac 33 | 34 | exec "/usr/bin/llvm-${_name}-17" "$@" 35 | -------------------------------------------------------------------------------- /scripts/sw_vers.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euo pipefail 4 | 5 | case "$TARGET" in 6 | *darwin*) ;; 7 | *) 8 | echo "Not Darwin target" >&2 9 | exit 1 10 | ;; 11 | esac 12 | 13 | _help="Usage: sw_vers [--help|--productName|--productVersion|--productVersionExtra|--buildVersion]" 14 | _name="macOS" 15 | _build="23a344" 16 | _version="${MACOS_SDK_VERSION:?Missing macOS SDK version}}" 17 | 18 | if [ "$#" -eq 0 ]; then 19 | cat </dev/null 2>&1; then 7 | _prefix='llvm-' 8 | if [ "$0" = 'libtool' ]; then 9 | _suffix='-darwin-17' 10 | else 11 | _suffix='-17' 12 | fi 13 | fi 14 | } 15 | 16 | case "${TARGET:?TARGET envvar is required to be defined}" in 17 | *darwin*) 18 | _prefix="${APPLE_TARGET:?}-" 19 | fallback_llvm 20 | ;; 21 | *) 22 | case "$0" in 23 | ar | dlltool | lib | ranlib | objcopy) 24 | # The extra space is intentional 25 | _prefix='zig ' 26 | ;; 27 | *) 28 | _prefix='llvm-' 29 | _suffix='-17' 30 | ;; 31 | esac 32 | ;; 33 | esac 34 | 35 | _tool="${_prefix:?}$(basename "$0")${_suffix:-}" 36 | 37 | exec $_tool "$@" 38 | -------------------------------------------------------------------------------- /scripts/toolchain.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euo pipefail 4 | 5 | if [ -z "${TARGET:-}" ]; then 6 | echo "Missing TARGET envvar" >&2 7 | exit 1 8 | fi 9 | 10 | if ! [ -d "${SYSROOT:-}" ]; then 11 | echo "Invalid sysroot provided: ${2:-}" >&2 12 | exit 1 13 | fi 14 | 15 | if ! [ -d "${PREFIX:-}" ]; then 16 | echo "Invalid prefix provided: ${3:-}" >&2 17 | exit 1 18 | fi 19 | 20 | # The the target system name (*-middle-*) from the target triple 21 | SYSTEM_NAME="${TARGET#*-}" 22 | SYSTEM_NAME="${SYSTEM_NAME%-*}" 23 | 24 | # On windows this should be AMD64 or ARM64 25 | # On macOS aarch64 is called arm64 26 | # However most projects don't check for the windows/macOS specific names 27 | # Considering this we will just use the generic names, and patch any specific issues for those platforms 28 | SYSTEM_PROCESSOR="${TARGET%%-*}" 29 | 30 | # Wheter to build iOS versions instead of macOS 31 | OS_IPHONE="${OS_IPHONE:-0}" 32 | 33 | # Check if target last part (*-*-last) is android 34 | OS_ANDROID="$(case "${TARGET##*-}" in android*) echo 1 ;; *) echo 0 ;; esac)" 35 | 36 | case "$SYSTEM_NAME" in 37 | windows) 38 | KERNEL="nt" 39 | SUBSYSTEM="windows" 40 | SYSTEM_VERSION="" 41 | ;; 42 | darwin) 43 | KERNEL="xnu" 44 | # https://theapplewiki.com/wiki/Kernel 45 | if [ "$OS_IPHONE" -eq 1 ]; then 46 | SDKROOT="${IOS_SDKROOT:?Missing iOS SDK}" 47 | SUBSYSTEM="ios" 48 | # iOS 14 49 | SYSTEM_VERSION="20.0.0" 50 | elif [ "$OS_IPHONE" -eq 2 ]; then 51 | SDKROOT="${IOS_SIMULATOR_SDKROOT:?Missing iOS simulator SDK}" 52 | SUBSYSTEM="ios-simulator" 53 | # iOS 14 54 | SYSTEM_VERSION="20.0.0" 55 | else 56 | SDKROOT="${MACOS_SDKROOT:?Missing macOS SDK}" 57 | SUBSYSTEM="macos" 58 | case "$SYSTEM_PROCESSOR" in 59 | x86_64) 60 | # macOS 10.15 61 | SYSTEM_VERSION="19.0.0" 62 | ;; 63 | aarch64) 64 | # macOS 11 65 | SYSTEM_VERSION="20.1.0" 66 | ;; 67 | esac 68 | fi 69 | ;; 70 | linux) 71 | KERNEL="linux" 72 | if [ "$OS_ANDROID" -eq 1 ]; then 73 | SDKROOT="${NDK_SDKROOT:?Missing ndk sysroot}" 74 | SUBSYSTEM="android" 75 | SYSTEM_NAME="android" 76 | SYSTEM_VERSION="${ANDROID_API_LEVEL:?Missing android api level}" 77 | else 78 | SUBSYSTEM="linux" 79 | # Linux kernel shipped with CentOS 7 80 | SYSTEM_VERSION="3.10.0" 81 | fi 82 | ;; 83 | esac 84 | 85 | cat </srv/cross.meson 86 | [binaries] 87 | c = ['cc'] 88 | ar = ['ar'] 89 | cpp = ['c++'] 90 | lib = ['lib'] 91 | strip = ['strip'] 92 | ranlib = ['ranlib'] 93 | windres = ['rc'] 94 | dlltool = ['dlltool'] 95 | objcopy = ['objcopy'] 96 | objdump = ['objdump'] 97 | readelf = ['readelf'] 98 | 99 | [properties] 100 | cmake_defaults = false 101 | pkg_config_libdir = ['${PREFIX}/lib/pkgconfig', '${PREFIX}/share/pkgconfig'] 102 | cmake_toolchain_file = '/srv/toolchain.cmake' 103 | 104 | [host_machine] 105 | cpu = '${SYSTEM_PROCESSOR}' 106 | kernel = '${KERNEL}' 107 | endian = 'little' 108 | system = '${SYSTEM_NAME}' 109 | subsystem = '${SUBSYSTEM}' 110 | cpu_family = '${SYSTEM_PROCESSOR}' 111 | 112 | EOF 113 | 114 | cat </srv/toolchain.cmake 115 | $( 116 | if [ "$SYSTEM_NAME" = 'darwin' ] && [ "$OS_IPHONE" -ge 1 ]; then 117 | echo 'set(CMAKE_SYSTEM_NAME iOS)' 118 | else 119 | echo "set(CMAKE_SYSTEM_NAME ${SYSTEM_NAME^})" 120 | fi 121 | ) 122 | set(CMAKE_SYSTEM_VERSION ${SYSTEM_VERSION}) 123 | set(CMAKE_SYSTEM_PROCESSOR ${SYSTEM_PROCESSOR}) 124 | 125 | $( 126 | case "$TARGET" in 127 | x86_64-darwin*) 128 | echo 'set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "")' 129 | ;; 130 | aarch64-darwin*) 131 | echo 'set(CMAKE_OSX_ARCHITECTURES "arm64" CACHE STRING "")' 132 | ;; 133 | x86_64-linux-android) 134 | echo 'set(CMAKE_ANDROID_ARCH_ABI x86_64)' 135 | ;; 136 | aarch64-linux-android) 137 | echo 'set(CMAKE_ANDROID_ARCH_ABI arm64-v8a)' 138 | ;; 139 | esac 140 | ) 141 | 142 | $( 143 | if [ "$OS_ANDROID" -eq 1 ]; then 144 | echo 'set(CMAKE_ANDROID_STL_TYPE c++-fexceptions)' 145 | echo 'set(CMAKE_ANDROID_RTTI TRUE)' 146 | echo 'set(CMAKE_ANDROID_EXCEPTIONS TRUE)' 147 | echo "set(ANDROID_PLATFORM android-${SYSTEM_VERSION})" 148 | echo "set(CMAKE_ANDROID_STANDALONE_TOOLCHAIN ${SYSROOT})" 149 | fi 150 | ) 151 | 152 | $(if [ -n "${SDKROOT:-}" ]; then echo "set(CMAKE_SYSROOT ${SDKROOT})"; fi) 153 | 154 | set(CMAKE_CROSSCOMPILING TRUE) 155 | 156 | # Do a no-op access on the CMAKE_TOOLCHAIN_FILE variable so that CMake will not 157 | # issue a warning on it being unused. 158 | if (CMAKE_TOOLCHAIN_FILE) 159 | endif() 160 | 161 | set(CMAKE_C_COMPILER cc) 162 | set(CMAKE_CXX_COMPILER c++) 163 | set(CMAKE_RANLIB ranlib) 164 | set(CMAKE_C_COMPILER_RANLIB ranlib) 165 | set(CMAKE_CXX_COMPILER_RANLIB ranlib) 166 | set(CMAKE_AR ar) 167 | set(CMAKE_OBJCOPY objcopy) 168 | set(CMAKE_OBJDUMP objdump) 169 | set(CMAKE_READELF readelf) 170 | set(CMAKE_C_COMPILER_AR ar) 171 | set(CMAKE_CXX_COMPILER_AR ar) 172 | set(CMAKE_RC_COMPILER rc) 173 | 174 | set(CMAKE_FIND_ROOT_PATH ${PREFIX} ${SYSROOT}) 175 | set(CMAKE_SYSTEM_PREFIX_PATH /) 176 | 177 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 178 | set(CMAKE_INSTALL_PREFIX "${PREFIX}" CACHE PATH 179 | "Install path prefix, prepended onto install directories." FORCE) 180 | endif() 181 | 182 | # To find programs to execute during CMake run time with find_program(), e.g. 183 | # 'git' or so, we allow looking into system paths. 184 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 185 | 186 | if (NOT CMAKE_FIND_ROOT_PATH_MODE_LIBRARY) 187 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 188 | endif() 189 | if (NOT CMAKE_FIND_ROOT_PATH_MODE_INCLUDE) 190 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 191 | endif() 192 | if (NOT CMAKE_FIND_ROOT_PATH_MODE_PACKAGE) 193 | set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) 194 | endif() 195 | 196 | if ("\${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}" STREQUAL "") 197 | set(CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES ${PREFIX}/include) 198 | endif() 199 | if ("\${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES}" STREQUAL "") 200 | set(CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES ${PREFIX}/include) 201 | endif() 202 | EOF 203 | 204 | mkdir -p "${PREFIX}/lib/pkgconfig" 205 | 206 | case "$TARGET" in 207 | *darwin*) ;; 208 | *) 209 | # Zig has internal support for libunwind 210 | cat <"${PREFIX}/lib/pkgconfig/unwind.pc" 211 | prefix=${SYSROOT}/lib/libunwind 212 | includedir=\${prefix}/include 213 | 214 | Name: Libunwind 215 | Description: Zig has internal support for libunwind 216 | Version: 9999 217 | Cflags: -I\${includedir} 218 | Libs: -lunwind 219 | EOF 220 | 221 | ln -s "unwind.pc" "${PREFIX}/lib/pkgconfig/libunwind.pc" 222 | 223 | # Replace libgcc_s with libunwind 224 | ln -s "unwind.pc" "${PREFIX}/lib/pkgconfig/gcc_s.pc" 225 | ln -s "unwind.pc" "${PREFIX}/lib/pkgconfig/libgcc_s.pc" 226 | 227 | # zig doesn't provide libgcc_eh 228 | # As an alternative use libc++ to replace it on windows gnu targets 229 | cat <"${PREFIX}/lib/pkgconfig/gcc_eh.pc" 230 | Name: libgcc_eh 231 | Description: Replace libgcc_eh with libc++ 232 | Version: 9999 233 | Libs.private: -lc++ 234 | EOF 235 | 236 | ln -s "gcc_eh.pc.pc" "${PREFIX}/lib/pkgconfig/libgcc_eh.pc" 237 | ;; 238 | esac 239 | -------------------------------------------------------------------------------- /stages/00-apple/00-sdk.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -xeuo pipefail 4 | 5 | case "$TARGET" in 6 | *darwin*) 7 | curl_tar \ 8 | "https://github.com/spacedriveapp/apple-sdks/releases/download/2024.07.24/MacOSX${MACOS_SDK_VERSION:?}.sdk.tar.xz" \ 9 | "${MACOS_SDKROOT:?Missing macOS SDK}" 0 10 | 11 | curl_tar \ 12 | "https://github.com/spacedriveapp/apple-sdks/releases/download/2024.07.24/iPhoneOS${IOS_SDK_VERSION:?}.sdk.tar.xz" \ 13 | "${IOS_SDKROOT:?Missing iOS SDK}" 0 14 | 15 | curl_tar \ 16 | "https://github.com/spacedriveapp/apple-sdks/releases/download/2024.07.24/iPhoneSimulator${IOS_SDK_VERSION:?}.sdk.tar.xz" \ 17 | "${IOS_SIMULATOR_SDKROOT:?Missing iOS simulator SDK}" 0 18 | ;; 19 | *) 20 | mkdir -p "${MACOS_SDKROOT:?Missing macOS SDK}" "${IOS_SDKROOT:?Missing iOS SDK}" "${IOS_SIMULATOR_SDKROOT:?Missing iOS simulator SDK}" 21 | ;; 22 | esac 23 | -------------------------------------------------------------------------------- /stages/00-apple/01-xar.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -xeuo pipefail 4 | 5 | case "$TARGET" in 6 | *darwin*) ;; 7 | *) 8 | exit 0 9 | ;; 10 | esac 11 | 12 | apt-get install libssl-dev libz-dev 13 | 14 | export CC="clang-17" 15 | export CXX="clang++-17" 16 | export CFLAGS="-I${CCTOOLS}/include" 17 | export LDFLAGS="-L${CCTOOLS}/lib" 18 | export APPLE_TARGET='__BYPASS__' 19 | 20 | cd /srv 21 | 22 | echo "Download xar ..." 23 | 24 | mkdir -p "xar/build" 25 | 26 | # renovate: depName=git@github.com:tpoechtrager/xar.git 27 | _commit='5fa4675419cfec60ac19a9c7f7c2d0e7c831a497' 28 | 29 | curl_tar "https://github.com/tpoechtrager/xar/archive/${_commit}.tar.gz" 'xar' 1 30 | 31 | cd xar/xar 32 | 33 | ./configure --prefix="$CCTOOLS" 34 | 35 | make -j"$(nproc)" 36 | 37 | make install 38 | 39 | rm -r /srv/xar 40 | -------------------------------------------------------------------------------- /stages/00-apple/02-tapi.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euo pipefail 4 | 5 | case "$TARGET" in 6 | *darwin*) ;; 7 | *) 8 | exit 0 9 | ;; 10 | esac 11 | 12 | export CC="clang-17" 13 | export CXX="clang++-17" 14 | export CFLAGS="-I${CCTOOLS}/include" 15 | export LDFLAGS="-L${CCTOOLS}/lib" 16 | export APPLE_TARGET='__BYPASS__' 17 | 18 | cd /srv 19 | 20 | # LLVM install path 21 | export INSTALLPREFIX="$CCTOOLS" 22 | 23 | echo "Download tapi ..." 24 | 25 | mkdir -p "tapi" 26 | 27 | # renovate: depName=git@github.com:tpoechtrager/apple-libtapi.git 28 | _commit='54c9044082ba35bdb2b0edf282ba1a340096154c' 29 | 30 | curl_tar "https://github.com/tpoechtrager/apple-libtapi/archive/${_commit}.tar.gz" 'tapi' 1 31 | 32 | cd tapi 33 | 34 | export NINJA=1 35 | 36 | ./build.sh 37 | ./install.sh 38 | 39 | rm -r /srv/tapi 40 | -------------------------------------------------------------------------------- /stages/00-apple/03-dispatch.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euo pipefail 4 | 5 | case "$TARGET" in 6 | *darwin*) ;; 7 | *) 8 | exit 0 9 | ;; 10 | esac 11 | 12 | apt-get install systemtap-sdt-dev libbsd-dev linux-libc-dev 13 | 14 | export CC="clang-17" 15 | export CXX="clang++-17" 16 | export CFLAGS="-I${CCTOOLS}/include" 17 | export LDFLAGS="-L${CCTOOLS}/lib" 18 | export APPLE_TARGET='__BYPASS__' 19 | 20 | cd /srv 21 | 22 | echo "Download dispatch ..." 23 | 24 | mkdir -p 'dispatch/build' 25 | 26 | # renovate: depName=git@github.com:tpoechtrager/apple-libdispatch.git 27 | _commit='fdf3fc85a9557635668c78801d79f10161d83f12' 28 | 29 | curl_tar "https://github.com/tpoechtrager/apple-libdispatch/archive/${_commit}.tar.gz" 'dispatch' 1 30 | 31 | cd dispatch/build 32 | 33 | cmake -G Ninja -DCMAKE_C_COMPILER="$CC" -DCMAKE_CXX_COMPILER="$CXX" .. 34 | 35 | ninja -j"$(nproc)" 36 | 37 | ninja install 38 | 39 | rm -r /srv/dispatch 40 | -------------------------------------------------------------------------------- /stages/00-apple/04-cctools.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euo pipefail 4 | 5 | case "$TARGET" in 6 | x86_64-darwin*) 7 | if [ "$OS_IPHONE" -ge 1 ]; then 8 | _target='x86_64-apple-darwin20' 9 | else 10 | _target='x86_64-apple-darwin19' 11 | fi 12 | ;; 13 | aarch64-darwin*) 14 | _target='arm64-apple-darwin20' 15 | ;; 16 | *) 17 | exit 0 18 | ;; 19 | esac 20 | 21 | echo "APPLE_TARGET=$_target" >>/etc/environment 22 | 23 | apt-get install uuid-dev libedit-dev 24 | 25 | export CC="clang-17" 26 | export CXX="clang++-17" 27 | export CFLAGS="-I${CCTOOLS}/include" 28 | export LDFLAGS="-L${CCTOOLS}/lib" 29 | export APPLE_TARGET='__BYPASS__' 30 | 31 | cd /srv 32 | 33 | echo "Download cctools ..." 34 | 35 | mkdir -p "cctools" 36 | 37 | # renovate: depName=git@github.com:tpoechtrager/cctools-port.git 38 | _commit='93ffa47ee2139aba177deb07de9b6626486037ae' 39 | 40 | curl_tar "https://github.com/tpoechtrager/cctools-port/archive/${_commit}.tar.gz" 'cctools' 1 41 | 42 | cd cctools/cctools 43 | 44 | ./configure \ 45 | --prefix="$CCTOOLS" \ 46 | --target="$_target" \ 47 | --with-libxar="$CCTOOLS" \ 48 | --with-libtapi="$CCTOOLS" \ 49 | --with-libdispatch="$CCTOOLS" \ 50 | --with-llvm-config=llvm-config-17 \ 51 | --with-libblocksruntime="$CCTOOLS" \ 52 | --enable-xar-support \ 53 | --enable-lto-support \ 54 | --enable-tapi-support 55 | 56 | make -j"$(nproc)" 57 | 58 | make install 59 | 60 | rm -r /srv/cctools 61 | 62 | # Create symlinks for llvm-otool because cctools use it when calling its own otool 63 | ln -fs "$(command -v llvm-otool-17)" /opt/cctools/bin/llvm-otool 64 | -------------------------------------------------------------------------------- /stages/00-apple/05-ldid.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euo pipefail 4 | 5 | case "$TARGET" in 6 | *darwin*) ;; 7 | *) 8 | exit 0 9 | ;; 10 | esac 11 | 12 | export CC="clang-17" 13 | export CXX="clang++-17" 14 | export CFLAGS="-I${CCTOOLS}/include" 15 | export LDFLAGS="-L${CCTOOLS}/lib" 16 | export APPLE_TARGET='__BYPASS__' 17 | 18 | cd /srv 19 | 20 | echo "Download ldid ..." 21 | 22 | mkdir -p "ldid" 23 | 24 | # renovate: depName=git@github.com:HeavenVolkoff/ldid.git 25 | _commit='4bd94f4eb253ca1eea45fb1a9bd414a6c0664867' 26 | 27 | curl_tar "https://github.com/HeavenVolkoff/ldid/archive/${_commit}.tar.gz" 'ldid' 1 28 | 29 | # renovate: datasource=github-releases depName=libimobiledevice/libplist 30 | _tag='2.6.0' 31 | 32 | curl_tar "https://github.com/libimobiledevice/libplist/archive/refs/tags/${_tag}.tar.gz" 'ldid/libplist' 1 33 | echo "$_tag" >'ldid/libplist/.tarball-version' 34 | 35 | cd ldid/libplist 36 | 37 | ./autogen.sh 38 | 39 | ./configure \ 40 | --prefix="$CCTOOLS" \ 41 | --with-pic \ 42 | --enable-static \ 43 | --without-tests \ 44 | --without-cython \ 45 | --disable-debug \ 46 | --disable-shared 47 | 48 | make -j"$(nproc)" 49 | 50 | cd .. 51 | 52 | make -j"$(nproc)" 53 | 54 | cp ldid "${CCTOOLS}/bin/" 55 | 56 | rm -r /srv/ldid 57 | -------------------------------------------------------------------------------- /stages/00-ndk.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -xeuo pipefail 4 | 5 | case "$TARGET" in 6 | *-android*) 7 | curl_tar \ 8 | https://github.com/spacedriveapp/ndk-sysroot/releases/download/2024.10.20/ndk_sysroot.tar.xz \ 9 | "${NDK_SDKROOT:?Missing ndk sysroot}" 0 10 | ;; 11 | *) 12 | mkdir -p "${NDK_SDKROOT:?Missing ndk sysroot}" 13 | ;; 14 | esac 15 | -------------------------------------------------------------------------------- /stages/10-compiler-rt.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S bash -euo pipefail 2 | 3 | # LLVM install path 4 | LLVM_PATH="/usr/lib/llvm-17" 5 | 6 | case "$TARGET" in 7 | *darwin*) ;; 8 | *android*) 9 | echo "Download llvm compiler_rt..." 10 | curl_tar 'https://github.com/spacedriveapp/ndk-sysroot/releases/download/2024.10.20/android_compiler-rt.tar.xz' \ 11 | "${LLVM_PATH}/lib/clang/17/lib" 0 12 | exit 0 13 | ;; 14 | *) 15 | export UNSUPPORTED=1 16 | exit 1 17 | ;; 18 | esac 19 | 20 | # Remove wrapper from PATH, because we need to call the original cmake 21 | PATH="$(echo "${PATH}" | awk -v RS=: -v ORS=: '/\/wrapper^/ {next} {print}')" 22 | export PATH 23 | 24 | echo "Download llvm compiler_rt..." 25 | 26 | mkdir -p "${LLVM_PATH}/compiler_rt/build" 27 | 28 | curl_tar 'https://github.com/llvm/llvm-project/releases/download/llvmorg-17.0.6/cmake-17.0.6.src.tar.xz' \ 29 | "${LLVM_PATH}/cmake" 1 30 | curl_tar 'https://github.com/llvm/llvm-project/releases/download/llvmorg-17.0.6/compiler-rt-17.0.6.src.tar.xz' \ 31 | "${LLVM_PATH}/compiler_rt" 1 32 | 33 | # Link cmake files to where compiler_rt expect to find them 34 | ln -s . "${LLVM_PATH}/cmake/modules" 35 | if [ -d "${LLVM_PATH}/cmake/Modules" ]; then 36 | rsync -a --update --ignore-existing "${LLVM_PATH}/cmake/Modules/" "${LLVM_PATH}/cmake/modules/" 37 | fi 38 | 39 | cd "${LLVM_PATH}/compiler_rt/build" 40 | 41 | _arch="${TARGET%%-*}" 42 | 43 | cmake_config=( 44 | -GNinja 45 | -Wno-dev 46 | -DLLVM_PATH="$LLVM_PATH" 47 | -DLLVM_CMAKE_DIR="${LLVM_PATH}/cmake/modules" 48 | -DLLVM_CONFIG_PATH="${LLVM_PATH}/bin/llvm-config" 49 | -DLLVM_MAIN_SRC_DIR="$LLVM_PATH" 50 | -DCMAKE_LINKER="$(command -v "${APPLE_TARGET:?}-ld")" 51 | -DCMAKE_INSTALL_PREFIX="${LLVM_PATH}/lib/clang/17" 52 | -DCMAKE_TOOLCHAIN_FILE='/srv/toolchain.cmake' 53 | -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=Off 54 | -DCOMPILER_RT_ENABLE_IOS=On 55 | -DCOMPILER_RT_BUILD_XRAY=Off 56 | -DCOMPILER_RT_BUILD_SANITIZERS=Off 57 | -DDARWIN_macosx_CACHED_SYSROOT="${MACOS_SDKROOT:?Missing macOS SDK path}" 58 | -DDARWIN_macosx_OVERRIDE_SDK_VERSION="${MACOS_SDK_VERSION:?Missing macOS SDK version}" 59 | -DDARWIN_PREFER_PUBLIC_SDK=On 60 | -DDARWIN_iphonesimulator_CACHED_SYSROOT="${IOS_SDKROOT:?Missing iOS SDK path}" 61 | -DDARWIN_iphonesimulator_OVERRIDE_SDK_VERSION="${IOS_SDK_VERSION:?Missing iOS SDK version}" 62 | -DDARWIN_iphoneos_CACHED_SYSROOT="${IOS_SDKROOT:?Missing iOS SDK path}" 63 | -DDARWIN_iphoneos_OVERRIDE_SDK_VERSION="${IOS_SDK_VERSION:?Missing iOS SDK version}" 64 | -DDEFAULT_SANITIZER_MIN_OSX_VERSION="${MACOS_SDK_VERSION:?Missing macOS SDK version}" 65 | ) 66 | 67 | if [ "$_arch" == 'aarch64' ]; then 68 | if [ "$OS_IPHONE" -eq 0 ]; then 69 | cmake_config+=( 70 | -DDARWIN_osx_ARCHS="arm64" 71 | -DDARWIN_osx_BUILTIN_ARCHS="arm64" 72 | -DDARWIN_ios_ARCHS="-" 73 | -DDARWIN_ios_BUILTIN_ARCHS="-" 74 | -DDARWIN_iossim_ARCHS="-" 75 | -DDARWIN_iossim_BUILTIN_ARCHS="-" 76 | ) 77 | elif [ "$OS_IPHONE" -eq 1 ]; then 78 | cmake_config+=( 79 | -DDARWIN_osx_ARCHS="-" 80 | -DDARWIN_osx_BUILTIN_ARCHS="-" 81 | -DDARWIN_ios_ARCHS="arm64" 82 | -DDARWIN_ios_BUILTIN_ARCHS="arm64" 83 | -DDARWIN_iossim_ARCHS="-" 84 | -DDARWIN_iossim_BUILTIN_ARCHS="-" 85 | ) 86 | elif [ "$OS_IPHONE" -eq 2 ]; then 87 | cmake_config+=( 88 | -DDARWIN_osx_ARCHS="-" 89 | -DDARWIN_osx_BUILTIN_ARCHS="-" 90 | -DDARWIN_ios_ARCHS="-" 91 | -DDARWIN_ios_BUILTIN_ARCHS="-" 92 | -DDARWIN_iossim_ARCHS="arm64" 93 | -DDARWIN_iossim_BUILTIN_ARCHS="arm64" 94 | ) 95 | fi 96 | else 97 | if [ "$OS_IPHONE" -eq 0 ]; then 98 | cmake_config+=( 99 | -DDARWIN_osx_ARCHS="$_arch" 100 | -DDARWIN_osx_BUILTIN_ARCHS="$_arch" 101 | -DDARWIN_ios_ARCHS="-" 102 | -DDARWIN_ios_BUILTIN_ARCHS="-" 103 | -DDARWIN_iossim_ARCHS="-" 104 | -DDARWIN_iossim_BUILTIN_ARCHS="-" 105 | ) 106 | elif [ "$OS_IPHONE" -eq 1 ]; then 107 | echo "iOS don't support $_arch" >&2 108 | exit 1 109 | elif [ "$OS_IPHONE" -eq 2 ]; then 110 | cmake_config+=( 111 | -DDARWIN_osx_ARCHS="-" 112 | -DDARWIN_osx_BUILTIN_ARCHS="-" 113 | -DDARWIN_ios_ARCHS="-" 114 | -DDARWIN_ios_BUILTIN_ARCHS="-" 115 | -DDARWIN_iossim_ARCHS="$_arch" 116 | -DDARWIN_iossim_BUILTIN_ARCHS="$_arch" 117 | ) 118 | fi 119 | fi 120 | 121 | cmake "${cmake_config[@]}" .. 122 | 123 | ninja -j"$(nproc)" 124 | 125 | ninja install 126 | 127 | # HACK: Some projects fail to find compiler-rt when compiling for iOS due to 128 | # looking for darwin directory, work around by linking darwin to ios 129 | if [ "$OS_IPHONE" -ge 1 ]; then 130 | ln -s ./ios "${LLVM_PATH}/lib/clang/17/lib/darwin" 131 | fi 132 | 133 | # Symlink clang_rt to arch specific names 134 | while IFS= read -r _lib; do 135 | _lib_name="$(basename "${_lib}" .a)" 136 | ln -s "${_lib_name}.a" "$(dirname "${_lib}")/${_lib_name}-${_arch}.a" 137 | if [ "$_arch" == 'aarch64' ]; then 138 | ln -s "${_lib_name}.a" "$(dirname "${_lib}")/${_lib_name}-arm64.a" 139 | fi 140 | done < <(find "${LLVM_PATH}/lib/clang/17/lib/darwin/" -name 'libclang_rt.*') 141 | -------------------------------------------------------------------------------- /stages/10-sse2neon.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S bash -euo pipefail 2 | 3 | case "$TARGET" in 4 | aarch64*) ;; 5 | *) 6 | export UNSUPPORTED=1 7 | exit 1 8 | ;; 9 | esac 10 | 11 | echo "Download sse2neon..." 12 | 13 | mkdir -p sse2neon 14 | 15 | # renovate: datasource=github-releases depName=DLTcollab/sse2neon 16 | _tag='1.8.0' 17 | 18 | curl_tar "https://github.com/DLTcollab/sse2neon/archive/refs/tags/v${_tag}.tar.gz" 'sse2neon' 1 19 | 20 | # Remove unused components 21 | rm -r sse2neon/{.ci,.github,tests} 22 | 23 | # Backup source 24 | bak_src 'sse2neon' 25 | 26 | # Install 27 | mkdir -p "${PREFIX}/include" 28 | mv sse2neon/sse2neon.h "${PREFIX}/include/" 29 | -------------------------------------------------------------------------------- /stages/20-brotli.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S bash -euo pipefail 2 | 3 | echo "Download brotli..." 4 | mkdir -p brotli 5 | 6 | curl_tar 'https://github.com/google/brotli/archive/refs/tags/v1.1.0.tar.gz' brotli 1 7 | 8 | # Add meson build support 9 | curl_tar 'https://github.com/mesonbuild/wrapdb/releases/download/google-brotli_1.1.0-1/google-brotli_1.1.0-1_patch.zip' brotli 1 10 | 11 | sed -i '/^executable(/,/^)/d;' brotli/meson.build 12 | 13 | # Remove unused components 14 | rm -r brotli/{setup.py,CMakeLists.txt,tests,docs,python} 15 | 16 | # Backup source 17 | bak_src 'brotli' 18 | 19 | mkdir -p brotli/build 20 | cd brotli/build 21 | 22 | echo "Build brotli..." 23 | if ! meson ..; then 24 | cat meson-logs/meson-log.txt 25 | exit 1 26 | fi 27 | 28 | ninja -j"$(nproc)" 29 | 30 | ninja install 31 | -------------------------------------------------------------------------------- /stages/20-bzip2.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S bash -euo pipefail 2 | 3 | case "$TARGET" in 4 | *darwin*) 5 | # MacOS SDK ships bzip2 6 | export UNSUPPORTED=1 7 | exit 1 8 | ;; 9 | esac 10 | 11 | echo "Download bzip2..." 12 | mkdir -p bzip2 13 | 14 | # renovate: depName=https://gitlab.com/bzip2/bzip2.git 15 | _commit='66c46b8c9436613fd81bc5d03f63a61933a4dcc3' 16 | 17 | curl_tar "https://gitlab.com/bzip2/bzip2/-/archive/${_commit}/bzip2.tar.gz" bzip2 1 18 | 19 | sed -i '/add_subdirectory(man)/d' bzip2/CMakeLists.txt 20 | 21 | # Remove some superfluous files 22 | rm -rf bzip2/{man,docs,tests,.gitlab*} 23 | 24 | # Backup source 25 | bak_src 'bzip2' 26 | 27 | mkdir -p bzip2/build 28 | cd bzip2/build 29 | 30 | export CFLAGS="${CFLAGS:-} -DBZ_DEBUG=0" 31 | export CXXFLAGS="${CXXFLAGS:-} -DBZ_DEBUG=0" 32 | 33 | echo "Build bzip2..." 34 | cmake \ 35 | -DUSE_OLD_SONAME=On \ 36 | -DENABLE_STATIC_LIB=On \ 37 | -DENABLE_STATIC_LIB_IS_PIC=On \ 38 | -DENABLE_APP=Off \ 39 | -DENABLE_DOCS=Off \ 40 | -DENABLE_TESTS=Off \ 41 | -DENABLE_EXAMPLES=Off \ 42 | -DENABLE_SHARED_LIB=Off \ 43 | .. 44 | 45 | ninja -j"$(nproc)" 46 | 47 | ninja install 48 | 49 | ln -s libbz2_static.a "${PREFIX}/lib/libbz2.a" 50 | -------------------------------------------------------------------------------- /stages/20-lzo.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S bash -euo pipefail 2 | 3 | echo "Download lzo..." 4 | mkdir -p lzo 5 | 6 | curl_tar 'https://www.oberhumer.com/opensource/lzo/download/lzo-2.10.tar.gz' lzo 1 7 | 8 | sed -i "/^if(0)/d" lzo/CMakeLists.txt 9 | sed -i "/^add_test/d" lzo/CMakeLists.txt 10 | sed -i "/^include(CTest)/d" lzo/CMakeLists.txt 11 | sed -ie 's/^if(1)/if(0)/' lzo/CMakeLists.txt 12 | sed -ie 's/^# main test driver/if(0)/' lzo/CMakeLists.txt 13 | 14 | # Remove unused components 15 | rm -r lzo/{B,util,tests,minilzo,lzotest,examples,autoconf,lzo2.pc.in,Makefile.am,Makefile.in,aclocal.m4,configure,config.hin} 16 | 17 | # Backup source 18 | bak_src 'lzo' 19 | 20 | mkdir -p lzo/build 21 | cd lzo/build 22 | 23 | echo "Build lzo..." 24 | cmake .. 25 | 26 | ninja -j"$(nproc)" 27 | 28 | ninja install 29 | -------------------------------------------------------------------------------- /stages/20-zlib.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S bash -euo pipefail 2 | 3 | case "$TARGET" in 4 | *darwin* | *android*) 5 | # MacOS SDK and Android NDK ships zlib 6 | export UNSUPPORTED=1 7 | exit 1 8 | ;; 9 | esac 10 | 11 | echo "Download zlib..." 12 | mkdir -p zlib 13 | 14 | # renovate: datasource=github-releases depName=zlib-ng/zlib-ng 15 | _tag='2.2.4' 16 | 17 | curl_tar "https://github.com/zlib-ng/zlib-ng/archive/refs/tags/${_tag}.tar.gz" zlib 1 18 | 19 | # Patch cmake to disable armv6 assembly, it thinks we support it, but we don't 20 | sed -i 's/HAVE_ARMV6_INLINE_ASM OR HAVE_ARMV6_INTRIN/HAVE_ARMV6_INLINE_ASM AND HAVE_ARMV6_INTRIN/' zlib/CMakeLists.txt 21 | 22 | # Remove some superfluous files 23 | rm -rf zlib/{.github,doc,test} 24 | 25 | # Backup source 26 | bak_src 'zlib' 27 | 28 | mkdir -p zlib/build 29 | cd zlib/build 30 | 31 | echo "Build zlib..." 32 | 33 | cmake \ 34 | -DWITH_OPTIM=On \ 35 | -DZLIB_COMPAT=On \ 36 | -DWITH_NATIVE_INSTRUCTIONS=On \ 37 | -DWITH_GTEST=Off \ 38 | -DWITH_FUZZERS=Off \ 39 | -DWITH_REDUCED_MEM=Off \ 40 | -DWITH_BENCHMARK_APPS=Off \ 41 | -DWITH_BENCHMARKS=Off \ 42 | -DZLIB_ENABLE_TESTS=Off \ 43 | -DZLIBNG_ENABLE_TESTS=Off \ 44 | -DINSTALL_UTILS=Off \ 45 | .. 46 | 47 | ninja -j"$(nproc)" 48 | 49 | ninja install 50 | -------------------------------------------------------------------------------- /stages/25-lcms.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S bash -euo pipefail 2 | 3 | echo "Download lcms..." 4 | mkdir -p lcms 5 | 6 | # renovate: datasource=github-releases depName=mm2/Little-CMS versioning=semver-coerced 7 | _tag='2.17' 8 | 9 | curl_tar "https://github.com/mm2/Little-CMS/releases/download/lcms${_tag}/lcms2-${_tag}.tar.gz" lcms 1 10 | 11 | case "$TARGET" in 12 | aarch64*) 13 | # Patch to enable SSE codepath on aarch64 14 | patch -F5 -lp1 -d lcms -t <"$PREFIX"/patches/sse2neon.patch 15 | ;; 16 | esac 17 | 18 | sed -i "/subdir('testbed')/d" lcms/plugins/threaded/meson.build 19 | sed -i "/subdir('testbed')/d" lcms/plugins/fast_float/meson.build 20 | 21 | # Remove some superfluous files 22 | rm -rf lcms/{.github,configure.ac,install-sh,depcomp,Makefile.in,config.sub,aclocal.m4,config.guess,ltmain.sh,m4,utils,configure,Projects,doc,testbed,plugins/{threaded/testbed,fast_float/testbed}} 23 | 24 | # Backup source 25 | bak_src 'lcms' 26 | 27 | mkdir -p lcms/build 28 | cd lcms/build 29 | 30 | echo "Build lcms..." 31 | meson \ 32 | --errorlogs \ 33 | -Dutils=false \ 34 | -Dtests=disabled \ 35 | -Dthreaded="$( 36 | case "$TARGET" in 37 | *windows*) 38 | # TODO: Add support for pthreads on Windows 39 | echo "false" 40 | ;; 41 | *) 42 | echo "true" 43 | ;; 44 | esac 45 | )" \ 46 | -Dfastfloat=true \ 47 | .. 48 | 49 | ninja -j"$(nproc)" 50 | 51 | ninja install 52 | -------------------------------------------------------------------------------- /stages/25-lzma.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S bash -euo pipefail 2 | 3 | echo "Download lzma..." 4 | mkdir -p lzma 5 | 6 | # renovate: datasource=github-releases depName=tukaani-project/xz 7 | _tag='5.6.4' 8 | 9 | curl_tar "https://github.com/tukaani-project/xz/releases/download/v${_tag}/xz-${_tag}.tar.xz" lzma 1 10 | 11 | case "$TARGET" in 12 | *darwin*) 13 | mkdir -p "${PREFIX:?Missing prefix}/include/" 14 | # MacOS ships liblzma, however it doesn't include its headers 15 | cp -avr lzma/src/liblzma/api/{lzma,lzma.h} "${PREFIX}/include/" 16 | exit 0 17 | ;; 18 | esac 19 | 20 | # Remove some superfluous files 21 | shopt -s extglob 22 | rm -rf lzma/{.github,config.h.in,dos,Makefile.in,configure.ac,aclocal.m4,debug,lib,doxygen,windows,build-aux,m4,configure,tests,po,doc/examples,doc/*.!(txt),po4a} 23 | 24 | # Ignore i18n compilation 25 | sed -i 's/if(ENABLE_NLS)/if(FALSE)/' lzma/CMakeLists.txt 26 | sed -i 's/if(GETTEXT_FOUND)/if(FALSE)/' lzma/CMakeLists.txt 27 | 28 | # Backup source 29 | bak_src 'lzma' 30 | 31 | mkdir -p lzma/build 32 | cd lzma/build 33 | 34 | echo "Build lzma..." 35 | 36 | cmake \ 37 | -DENABLE_SMALL=On \ 38 | -DBUILD_TESTING=Off \ 39 | -DCREATE_XZ_SYMLINKS=Off \ 40 | -DCREATE_LZMA_SYMLINKS=Off \ 41 | -DCMAKE_SKIP_INSTALL_ALL_DEPENDENCY=On \ 42 | .. 43 | 44 | ninja -j"$(nproc)" liblzma 45 | 46 | mkdir -p ../doc/examples 47 | case "$TARGET" in 48 | *windows*) 49 | touch xz.exe xzdec.exe lzmadec.exe lzmainfo.exe 50 | ;; 51 | *) 52 | touch xz xzdec lzmadec lzmainfo 53 | ;; 54 | esac 55 | 56 | ninja install 57 | -------------------------------------------------------------------------------- /stages/25-ogg.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S bash -euo pipefail 2 | 3 | echo "Download ogg..." 4 | mkdir -p ogg 5 | 6 | # renovate: datasource=github-releases depName=xiph/ogg versioning=semver-coerced 7 | _tag='1.3.5' 8 | 9 | curl_tar "https://github.com/xiph/ogg/releases/download/v${_tag}/libogg-${_tag}.tar.gz" ogg 1 10 | 11 | # Remove some superfluous files 12 | rm -rf ogg/{.github,install-sh,depcomp,Makefile.in,config.sub,aclocal.m4,config.guess,ltmain.sh,m4,configure,doc} 13 | 14 | # Backup source 15 | bak_src 'ogg' 16 | 17 | mkdir -p ogg/build 18 | cd ogg/build 19 | 20 | echo "Build ogg..." 21 | cmake \ 22 | -DINSTALL_DOCS=Off \ 23 | -DBUILD_TESTING=Off \ 24 | -DINSTALL_PKG_CONFIG_MODULE=On \ 25 | -DINSTALL_CMAKE_PACKAGE_MODULE=On \ 26 | .. 27 | 28 | ninja -j"$(nproc)" 29 | 30 | ninja install 31 | -------------------------------------------------------------------------------- /stages/25-pciaccess.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S bash -euo pipefail 2 | 3 | case "$TARGET" in 4 | *linux*) ;; 5 | *) 6 | export UNSUPPORTED=1 7 | exit 1 8 | ;; 9 | esac 10 | 11 | echo "Download pciaccess..." 12 | mkdir -p pciaccess 13 | 14 | # renovate: datasource=gitlab-tags depName=xorg/lib/libpciaccess registryUrl=https://gitlab.freedesktop.org 15 | _tag='0.18.1' 16 | 17 | curl_tar "https://xorg.freedesktop.org/releases/individual/lib/libpciaccess-${_tag}.tar.xz" pciaccess 1 18 | 19 | sed -i "/subdir('scanpci')/d" pciaccess/meson.build 20 | sed -i "/subdir('man')/d" pciaccess/meson.build 21 | 22 | rm -rf pciaccess/{.gitlab-ci.yml,man,scanpci} 23 | 24 | # Backup source 25 | bak_src 'pciaccess' 26 | 27 | mkdir -p pciaccess/build 28 | cd pciaccess/build 29 | 30 | echo "Build pciaccess..." 31 | if ! meson -Dzlib=enabled ..; then 32 | cat meson-logs/meson-log.txt 33 | exit 1 34 | fi 35 | 36 | ninja -j"$(nproc)" 37 | 38 | ninja install 39 | -------------------------------------------------------------------------------- /stages/45-dav1d.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S bash -euo pipefail 2 | 3 | echo "Download dav1d..." 4 | mkdir -p dav1d 5 | 6 | # renovate: datasource=gitlab-releases depName=videolan/dav1d registryUrl=https://code.videolan.org 7 | _tag='1.5.1' 8 | 9 | curl_tar "https://downloads.videolan.org/pub/videolan/dav1d/${_tag}/dav1d-${_tag}.tar.xz" dav1d 1 10 | 11 | sed -i "/subdir('doc')/d" dav1d/meson.build 12 | sed -i "/subdir('tools')/d" dav1d/meson.build 13 | sed -i "/subdir('tests')/d" dav1d/meson.build 14 | sed -i "/subdir('examples')/d" dav1d/meson.build 15 | 16 | mv dav1d/tools/compat "${TMP:-/tmp}/dav1d-compat" 17 | # Remove some superfluous files 18 | rm -rf dav1d/{.github,package,doc,examples,tools/*,tests} 19 | mv "${TMP:-/tmp}/dav1d-compat" dav1d/tools/compat 20 | 21 | # Backup source 22 | bak_src 'dav1d' 23 | 24 | mkdir -p dav1d/build 25 | cd dav1d/build 26 | 27 | echo "Build dav1d..." 28 | if ! meson \ 29 | -Denable_docs=false \ 30 | -Denable_tools=false \ 31 | -Denable_tests=false \ 32 | -Denable_examples=false \ 33 | ..; then 34 | cat meson-logs/meson-log.txt 35 | exit 1 36 | fi 37 | 38 | ninja -j"$(nproc)" 39 | 40 | ninja install 41 | -------------------------------------------------------------------------------- /stages/45-de265.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S bash -euo pipefail 2 | 3 | echo "Download de265..." 4 | mkdir -p de265 5 | 6 | # renovate: datasource=github-releases depName=strukturag/libde265 7 | _tag='1.0.15' 8 | 9 | curl_tar "https://github.com/strukturag/libde265/archive/refs/tags/v${_tag}.tar.gz" de265 1 10 | 11 | case "$TARGET" in 12 | aarch64*) 13 | # Patch to enable SSE codepath on aarch64 14 | patch -F5 -lp1 -d de265 -t <"$PREFIX"/patches/sse2neon.patch 15 | ;; 16 | esac 17 | 18 | # Remove unused components 19 | rm -r de265/{.github,dec265,enc265,sherlock265} 20 | 21 | # Backup source 22 | bak_src 'de265' 23 | 24 | mkdir -p de265/build 25 | cd de265/build 26 | 27 | echo "Build de265..." 28 | cmake \ 29 | -DENABLE_SDL=Off \ 30 | -DDISABLE_SSE=Off \ 31 | -DENABLE_DECODER=Off \ 32 | -DENABLE_ENCODER=Off \ 33 | .. 34 | 35 | ninja -j"$(nproc)" 36 | 37 | ninja install 38 | -------------------------------------------------------------------------------- /stages/45-drm.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S bash -euo pipefail 2 | 3 | case "$TARGET" in 4 | *linux*) ;; 5 | *) 6 | export UNSUPPORTED=1 7 | exit 1 8 | ;; 9 | esac 10 | 11 | echo "Download drm..." 12 | mkdir -p drm 13 | 14 | # renovate: datasource=gitlab-tags depName=mesa/drm registryUrl=https://gitlab.freedesktop.org 15 | _tag='2.4.124' 16 | 17 | curl_tar "https://dri.freedesktop.org/libdrm/libdrm-${_tag}.tar.xz" drm 1 18 | 19 | rm -rf drm/{etnaviv,man,tests} 20 | 21 | # Backup source 22 | bak_src 'drm' 23 | 24 | mkdir -p drm/build 25 | cd drm/build 26 | 27 | configs=() 28 | 29 | case "$TARGET" in 30 | android) configs+=(-Dudev=false) ;;& 31 | aarch64-linux-android) configs+=(-Dfreedreno-kgsl=true) ;; 32 | *) configs+=(-Dudev=true) ;; 33 | esac 34 | 35 | echo "Build drm..." 36 | if ! meson \ 37 | "${configs[@]}" \ 38 | -Dintel=auto \ 39 | -Dradeon=auto \ 40 | -Damdgpu=auto \ 41 | -Dnouveau=auto \ 42 | -Domap=auto \ 43 | -Dexynos=auto \ 44 | -Dfreedreno=auto \ 45 | -Dtegra=auto \ 46 | -Dvc4=auto \ 47 | -Dvmwgfx=disabled \ 48 | -Detnaviv=disabled \ 49 | -Dvalgrind=disabled \ 50 | -Dcairo-tests=disabled \ 51 | -Dman-pages=disabled \ 52 | -Dtests=false \ 53 | -Dinstall-test-programs=false \ 54 | ..; then 55 | cat meson-logs/meson-log.txt 56 | exit 1 57 | fi 58 | 59 | ninja -j"$(nproc)" 60 | 61 | ninja install 62 | -------------------------------------------------------------------------------- /stages/45-opencl/25-opencl-headers.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S bash -euo pipefail 2 | 3 | # OpenCL is only available on iOS through a private framework 4 | if [ "$OS_IPHONE" -ge 1 ]; then 5 | export UNSUPPORTED=1 6 | exit 1 7 | fi 8 | 9 | echo "Download opencl headers..." 10 | 11 | mkdir -p opencl-headers 12 | 13 | curl_tar 'https://github.com/KhronosGroup/OpenCL-Headers/archive/refs/tags/v2023.12.14.tar.gz' opencl-headers 1 14 | 15 | # Remove some superfluous files 16 | rm -rf opencl-headers/{.github,tests} 17 | 18 | # Backup source 19 | bak_src 'opencl-headers' 20 | 21 | # Install 22 | mkdir -p "${PREFIX}/include" 23 | mv 'opencl-headers/CL' "${PREFIX}/include/" 24 | -------------------------------------------------------------------------------- /stages/45-opencl/45-opencl.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S bash -euo pipefail 2 | 3 | # OpenCL is only available on iOS through a private framework 4 | if [ "$OS_IPHONE" -ge 1 ]; then 5 | export UNSUPPORTED=1 6 | exit 1 7 | fi 8 | 9 | echo "Download opencl..." 10 | 11 | mkdir -p opencl 12 | 13 | curl_tar 'https://github.com/KhronosGroup/OpenCL-ICD-Loader/archive/refs/tags/v2023.12.14.tar.gz' opencl 1 14 | 15 | # Remove some superfluous files 16 | rm -rf opencl/{.github,test} 17 | 18 | # Backup source 19 | bak_src 'opencl' 20 | 21 | mkdir -p opencl/build 22 | cd opencl/build 23 | 24 | echo "Build opencl..." 25 | cmake \ 26 | -DOPENCL_ICD_LOADER_PIC=On \ 27 | -DOPENCL_ICD_LOADER_HEADERS_DIR="${PREFIX}/include" \ 28 | -DBUILD_TESTING=Off \ 29 | -DENABLE_OPENCL_LAYERINFO=Off \ 30 | -DOPENCL_ICD_LOADER_BUILD_TESTING=Off \ 31 | -DOPENCL_ICD_LOADER_BUILD_SHARED_LIBS=Off \ 32 | .. 33 | 34 | ninja -j"$(nproc)" 35 | 36 | ninja install 37 | 38 | case "$TARGET" in 39 | *linux*) 40 | LIBS='-lOpenCL' 41 | LIBS_P='-pthread -ldl' 42 | ;; 43 | *darwin*) 44 | LIBS='-lOpenCL' 45 | LIBS_P='-pthread -framework OpenCL' 46 | ;; 47 | *windows*) 48 | LIBS='-lOpenCL' 49 | LIBS_P='-lole32 -lshlwapi -lcfgmgr32' 50 | ;; 51 | esac 52 | 53 | mkdir -p "${PREFIX}/lib/pkgconfig" 54 | cat <"${PREFIX}/lib/pkgconfig/OpenCL.pc" 55 | prefix=$PREFIX 56 | exec_prefix=\${prefix} 57 | libdir=\${exec_prefix}/lib 58 | includedir=\${prefix}/include 59 | 60 | Name: OpenCL 61 | Description: OpenCL ICD Loader 62 | Version: 9999 63 | Cflags: -I\${includedir} -DCL_TARGET_OPENCL_VERSION=120 64 | Libs: -L\${libdir} $LIBS 65 | Libs.private: $LIBS_P 66 | EOF 67 | 68 | if [ -f "${PREFIX}/lib/OpenCL.a" ] && ! [ -f "${PREFIX}/lib/libOpenCL.a" ]; then 69 | ln -s OpenCL.a "${PREFIX}/lib/libOpenCL.a" 70 | fi 71 | -------------------------------------------------------------------------------- /stages/45-sharpyuv.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S bash -euo pipefail 2 | 3 | echo "Download sharpyuv..." 4 | mkdir -p sharpyuv 5 | 6 | curl_tar 'https://github.com/webmproject/libwebp/archive/refs/tags/v1.3.2.tar.gz' sharpyuv 1 7 | 8 | # Add meson build support 9 | curl_tar 'https://github.com/mesonbuild/wrapdb/releases/download/libwebp_1.3.2-1/libwebp_1.3.2-1_patch.zip' sharpyuv 1 10 | 11 | # Fix install location for sharpyuv headers 12 | sed -i "s|subdir: 'webp/sharpyuv'|subdir: 'sharpyuv'|" sharpyuv/sharpyuv/meson.build 13 | 14 | sed -i "/subdir('examples')/d" sharpyuv/meson.build 15 | 16 | # Remove some superfluous files 17 | rm -rf sharpyuv/{.github,.cmake-format.py,PRESUBMIT.py,build.gradle,xcframeworkbuild.sh,.pylintrc,m4,Makefile.vc,makefile.unix,cmake,CMakeLists.txt,configure.ac,infra,extras,man,gradle,doc,swig,examples,tests,webp_js} 18 | 19 | # Backup source 20 | bak_src 'sharpyuv' 21 | 22 | mkdir -p sharpyuv/build 23 | cd sharpyuv/build 24 | 25 | echo "Build sharpyuv..." 26 | 27 | meson \ 28 | -Dsimd=enabled \ 29 | -Dthreads=enabled \ 30 | -Dlibsharpyuv=enabled \ 31 | -Dcwebp=disabled \ 32 | -Ddwebp=disabled \ 33 | -Dwebpmux=disabled \ 34 | -Dlibwebp=disabled \ 35 | -Dwebpinfo=disabled \ 36 | -Dlibwebpmux=disabled \ 37 | -Dlibwebpdemux=disabled \ 38 | -Dlibwebpdecoder=disabled \ 39 | .. 40 | 41 | ninja -j"$(nproc)" 42 | 43 | ninja install 44 | -------------------------------------------------------------------------------- /stages/45-vorbis.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S bash -euo pipefail 2 | 3 | echo "Download vorbis..." 4 | mkdir -p vorbis 5 | 6 | # renovate: datasource=github-releases depName=xiph/vorbis versioning=semver-coerced 7 | _tag='1.3.7' 8 | 9 | curl_tar "https://github.com/xiph/vorbis/releases/download/v${_tag}/libvorbis-${_tag}.tar.gz" vorbis 1 10 | 11 | # Remove some superfluous files 12 | rm -rf vorbis/{.github,symbian,install-sh,depcomp,macosx,Makefile.in,config.sub,aclocal.m4,config.guess,test,examples,vq,ltmain.sh,m4,configure,doc} 13 | 14 | # Backup source 15 | bak_src 'vorbis' 16 | 17 | mkdir -p vorbis/build 18 | cd vorbis/build 19 | 20 | echo "Build vorbis..." 21 | cmake \ 22 | -DBUILD_TESTING=Off \ 23 | -DINSTALL_CMAKE_PACKAGE_MODULE=On \ 24 | .. 25 | 26 | ninja -j"$(nproc)" 27 | 28 | ninja install 29 | -------------------------------------------------------------------------------- /stages/45-vvenc.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S bash -euo pipefail 2 | 3 | echo "Download vvenc..." 4 | mkdir -p vvenc 5 | 6 | # renovate: datasource=github-releases depName=fraunhoferhhi/vvenc 7 | _tag='1.13.1' 8 | 9 | curl_tar "https://github.com/fraunhoferhhi/vvenc/archive/refs/tags/v${_tag}.tar.gz" 'vvenc' 1 10 | 11 | sed -i '/add_subdirectory( "source\/App\/vvencapp" )/d' vvenc/CMakeLists.txt 12 | sed -i '/add_subdirectory( "source\/App\/vvencFFapp" )/d' vvenc/CMakeLists.txt 13 | sed -i '/add_subdirectory( "test\/vvenclibtest" )/d' vvenc/CMakeLists.txt 14 | sed -i '/add_subdirectory( "test\/vvencinterfacetest" )/d' vvenc/CMakeLists.txt 15 | sed -i '/if( NOT BUILD_SHARED_LIBS )/,/endif()/d' vvenc/CMakeLists.txt 16 | sed -i '/# set _WIN32_WINNT/,/endif()/d' vvenc/CMakeLists.txt 17 | sed -i '/include( cmake\/modules\/vvencTests.cmake )/d' vvenc/CMakeLists.txt 18 | 19 | case "$TARGET" in 20 | aarch64*) 21 | sed -i '/int src8tOff = cStride;/d' vvenc/source/Lib/CommonLib/arm/neon/InterpolationFilter_neon.cpp 22 | ;; 23 | esac 24 | 25 | # Remove some superfluous files 26 | rm -rf vvenc/{.*,cfg,test,source/App} 27 | 28 | # Backup source 29 | bak_src 'vvenc' 30 | 31 | mkdir -p vvenc/build 32 | cd vvenc/build 33 | 34 | echo "Build vvenc..." 35 | cmake \ 36 | -DVVENC_LIBRARY_ONLY=On \ 37 | -DVVENC_ENABLE_INSTALL=On \ 38 | -DVVENC_ENABLE_TRACING=Off \ 39 | -DVVENC_ENABLE_LINK_TIME_OPT="$([ "${LTO:-1}" -eq 1 ] && echo On || echo Off)" \ 40 | -DVVENC_USE_ADDRESS_SANITIZER=Off \ 41 | -DVVENC_ENABLE_THIRDPARTY_JSON=Off \ 42 | -DVVENC_INSTALL_FULLFEATURE_APP=Off \ 43 | -DVVENC_ENABLE_BUILD_TYPE_POSTFIX=Off \ 44 | -DVVENC_ENABLE_X86_SIMD="$(case "$TARGET" in x86_64*) echo 'On' ;; aarch64*) echo 'Off' ;; esac)" \ 45 | .. 46 | 47 | ninja -j"$(nproc)" 48 | 49 | ninja install 50 | 51 | sed -ri 's/^(Libs.private:.*)$/\1 -lstdc++/' "${PREFIX}/lib/pkgconfig/libvvenc.pc" 52 | -------------------------------------------------------------------------------- /stages/50-amf.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S bash -euo pipefail 2 | 3 | case "$TARGET" in 4 | *darwin* | *android* | aarch64-windows*) 5 | export UNSUPPORTED=1 6 | exit 1 7 | ;; 8 | esac 9 | 10 | echo "Download AMF..." 11 | 12 | mkdir -p amf 13 | 14 | curl_tar 'https://github.com/HandBrake/HandBrake-contribs/releases/download/contribs/AMF-1.4.33-slim.tar.gz' 'amf' 1 15 | 16 | # Remove some superfluous files 17 | rm -rf amf/{.github,amf/{doc,public/{make,props,proj,common,src,samples}}} 18 | 19 | # Backup source 20 | bak_src 'amf' 21 | 22 | # Install 23 | mkdir -p "${PREFIX}/include" 24 | mv 'amf/amf/public/include' "${PREFIX}/include/AMF" 25 | -------------------------------------------------------------------------------- /stages/50-lame.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S bash -euo pipefail 2 | 3 | echo "Download lame..." 4 | mkdir -p lambuild 5 | 6 | # TODO: Create patch for sse2neon on lame 7 | # Original link: https://sourceforge.net/projects/lame/files/lame/3.100/lame-3.100.tar.gz/download 8 | # But sourcefourge is very bad to download from, so we use the debian source instead 9 | curl_tar 'https://deb.debian.org/debian/pool/main/l/lame/lame_3.100.orig.tar.gz' lame 1 10 | 11 | # Add meson build support 12 | curl_tar 'https://github.com/mesonbuild/wrapdb/releases/download/lame_3.100-9/lame_3.100-9_patch.zip' lame 1 13 | 14 | # Fix warning on 64 bit machines. explicitly set variables as unsigned ints. 15 | curl 'https://sources.debian.org/data/main/l/lame/3.100-6/debian/patches/07-field-width-fix.patch' \ 16 | | patch -F5 -lp1 -d lame -t 17 | 18 | # Remove some superfluous files 19 | rm -rf lame/{acinclude.m4,config.h.in,testcase.mp3,install-sh,Makefile.MSVC,Makefile.unix,config.rpath,depcomp,Makefile.in,config.sub,configure.in,config.guess,testcase.wav,debian,macosx,Dll,misc,vc_solution,dshow,mac,ltmain.sh,doc,aclocal.m4,frontend,ACM,configure} 20 | 21 | # Backup source 22 | bak_src 'lame' 23 | 24 | mkdir -p lame/build 25 | cd lame/build 26 | 27 | echo "Build lame..." 28 | 29 | meson \ 30 | -Dtools=disabled \ 31 | -Ddecoder=false \ 32 | .. 33 | 34 | ninja -j"$(nproc)" 35 | 36 | ninja install 37 | 38 | cat <"${PREFIX}/lib/pkgconfig/lame.pc" 39 | prefix=$PREFIX 40 | exec_prefix=\${prefix} 41 | libdir=\${exec_prefix}/lib 42 | includedir=\${prefix}/include 43 | 44 | Name: lame 45 | Description: high quality MPEG Audio Layer III (MP3) encoder library 46 | Version: 3.100 47 | Libs: -L\${libdir} -lmp3lame 48 | Cflags: -I\${includedir}/lame 49 | EOF 50 | -------------------------------------------------------------------------------- /stages/50-nvenc.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S bash -euo pipefail 2 | 3 | if ! { 4 | [ "$(uname -m)" = "${TARGET%%-*}" ] && (case "$TARGET" in *android*) exit 1 ;; *linux* | x86_64-windows*) exit 0 ;; *) exit 1 ;; esac) 5 | } then 6 | export UNSUPPORTED=1 7 | exit 1 8 | fi 9 | 10 | echo "Download nvenv..." 11 | mkdir -p nvenv 12 | 13 | # FIX-ME: https://github.com/renovatebot/renovate/issues/27510 14 | # renovate: datasource=github-releases depName=FFmpeg/nv-codec-headers versioning=loose 15 | _tag='13.0.19.0' 16 | 17 | curl_tar "https://github.com/FFmpeg/nv-codec-headers/releases/download/n${_tag}/nv-codec-headers-${_tag}.tar.gz" nvenv 1 18 | 19 | # Backup source 20 | bak_src 'nvenv' 21 | 22 | cd nvenv 23 | 24 | echo "Copy nvenv headers..." 25 | make PREFIX="$PREFIX" install 26 | -------------------------------------------------------------------------------- /stages/50-onevpl.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S bash -euo pipefail 2 | 3 | case "$TARGET" in 4 | *darwin* | *android* | aarch64-windows*) 5 | export UNSUPPORTED=1 6 | exit 1 7 | ;; 8 | esac 9 | 10 | echo "Download oneVPL..." 11 | mkdir -p oneVPL 12 | 13 | # renovate: datasource=github-releases depName=intel/libvpl 14 | _tag='2.14.0' 15 | 16 | curl_tar "https://github.com/intel/libvpl/archive/refs/tags/v${_tag}.tar.gz" oneVPL 1 17 | 18 | sed -i '/add_subdirectory(examples)/d' oneVPL/CMakeLists.txt 19 | 20 | # Remove unused components 21 | rm -rf oneVPL/{.github,.style.yapf,.pylintrc,assets,script,doc,tools,examples} 22 | 23 | # Backup source 24 | bak_src 'oneVPL' 25 | 26 | mkdir -p oneVPL/build 27 | cd oneVPL/build 28 | 29 | echo "Build oneVPL..." 30 | cmake \ 31 | -DBUILD_DEV=On \ 32 | -DBUILD_TOOLS=Off \ 33 | -DBUILD_TESTS=Off \ 34 | -DBUILD_PREVIEW=Off \ 35 | -DBUILD_EXAMPLES=Off \ 36 | -DBUILD_DISPATCHER=On \ 37 | -DINSTALL_EXAMPLE_CODE=Off \ 38 | -DBUILD_TOOLS_ONEVPL_EXPERIMENTAL=Off \ 39 | -DBUILD_DISPATCHER_ONEVPL_EXPERIMENTAL=Off \ 40 | .. 41 | 42 | ninja -j"$(nproc)" 43 | 44 | ninja install 45 | -------------------------------------------------------------------------------- /stages/50-opus.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S bash -euo pipefail 2 | 3 | echo "Download opus..." 4 | mkdir -p opus 5 | 6 | # renovate: datasource=github-tags depName=xiph/opus versioning=semver-coerced 7 | _tag='1.5.2' 8 | 9 | curl_tar "https://downloads.xiph.org/releases/opus/opus-${_tag}.tar.gz" opus 1 10 | 11 | # Remove unused components 12 | rm -rf opus/{.github,CMakeLists.txt,config.sub,aclocal.m4,config.guess,cmake,doc,Makefile.in,tests,ltmain.sh,m4,configure} 13 | 14 | # Backup source 15 | bak_src 'opus' 16 | 17 | mkdir -p opus/build 18 | cd opus/build 19 | 20 | echo "Build opus..." 21 | meson \ 22 | -Dintrinsics=enabled \ 23 | -Ddocs=disabled \ 24 | -Dtests=disabled \ 25 | -Dcustom-modes=true \ 26 | -Dextra-programs=disabled \ 27 | "$( 28 | # Disable Run-time CPU detection on Windows ARM architecture 29 | # because libopus could not detect CPU machine type properly 30 | case "$TARGET" in 31 | aarch64-windows*) 32 | echo "-Drtcd=disabled" 33 | ;; 34 | esac 35 | )" \ 36 | .. 37 | 38 | ninja -j"$(nproc)" 39 | 40 | ninja install 41 | -------------------------------------------------------------------------------- /stages/50-soxr.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S bash -euo pipefail 2 | 3 | echo "Download soxr..." 4 | mkdir -p soxr 5 | 6 | # Original link: https://downloads.sourceforge.net/project/soxr/soxr-0.1.3-Source.tar.xz 7 | # But sourceforge is very bad to download from, so we use the debian source instead 8 | curl_tar 'https://deb.debian.org/debian/pool/main/libs/libsoxr/libsoxr_0.1.3.orig.tar.xz' soxr 1 9 | 10 | for patch in "$PREFIX"/patches/*; do 11 | patch -F5 -lp1 -d soxr -t <"$patch" 12 | done 13 | 14 | # Remove some superfluous files 15 | rm -rf soxr/{examples,lsr-tests,msvc,tests} 16 | 17 | # Backup source 18 | bak_src 'soxr' 19 | 20 | mkdir -p soxr/build 21 | cd soxr/build 22 | 23 | echo "Build soxr..." 24 | cmake \ 25 | -DBUILD_TESTS=Off \ 26 | -DINSTALL_DOCS=Off \ 27 | -DBUILD_EXAMPLES=Off \ 28 | -WITH_LSR_BINDINGS=On \ 29 | .. 30 | 31 | ninja -j"$(nproc)" 32 | 33 | ninja install 34 | -------------------------------------------------------------------------------- /stages/50-svt-av1.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S bash -euo pipefail 2 | 3 | echo "Download svt-av1..." 4 | mkdir -p svt-av1 5 | 6 | # renovate: datasource=gitlab-releases depName=AOMediaCodec/SVT-AV1 7 | _tag='2.3.0' 8 | 9 | curl_tar "https://gitlab.com/AOMediaCodec/SVT-AV1/-/archive/v${_tag}/SVT-AV1-v${_tag}.tar.gz" svt-av1 1 10 | 11 | case "$TARGET" in 12 | x86_64*) 13 | ENABLE_NASM=On 14 | ;; 15 | aarch64*) 16 | ENABLE_NASM=Off 17 | ;; 18 | esac 19 | 20 | # Remove some superfluous files 21 | rm -rf svt-av1/{Docs,Config,test,ffmpeg_plugin,gstreamer-plugin,.gitlab*} 22 | 23 | # Backup source 24 | bak_src 'svt-av1' 25 | 26 | mkdir -p svt-av1/build 27 | cd svt-av1/build 28 | 29 | echo "Build svt-av1..." 30 | cmake \ 31 | -DBUILD_ENC=On \ 32 | -DREPRODUCIBLE_BUILDS=On \ 33 | -DSVT_AV1_LTO="$([ "${LTO:-1}" -eq 1 ] && echo On || echo Off)" \ 34 | -DENABLE_NASM="${ENABLE_NASM}" \ 35 | -DCOVERAGE=Off \ 36 | -DBUILD_DEC=Off \ 37 | -DBUILD_APPS=Off \ 38 | -DBUILD_TESTING=Off \ 39 | .. 40 | 41 | ninja -j"$(nproc)" 42 | 43 | ninja install 44 | -------------------------------------------------------------------------------- /stages/50-theora.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S bash -euo pipefail 2 | 3 | echo "Download theora..." 4 | mkdir -p theora 5 | 6 | curl_tar 'https://downloads.xiph.org/releases/theora/libtheora-1.1.1.tar.bz2' theora 1 7 | 8 | # Add meson build support 9 | curl_tar 'https://github.com/mesonbuild/wrapdb/releases/download/theora_1.1.1-4/theora_1.1.1-4_patch.zip' theora 1 10 | 11 | sed -i "/subdir('doc')/d" theora/meson.build 12 | sed -i "/subdir('tests')/d" theora/meson.build 13 | 14 | # Remove some superfluous files 15 | rm -rf theora/{CHANGES,depcomp,missing,symbian,configure.ac,Makefile.in,config.sub,config.guess,m4,macosx,tests,ltmain.sh,examples,aclocal.m4,configure,doc} 16 | 17 | # Backup source 18 | bak_src 'theora' 19 | 20 | mkdir -p theora/build 21 | cd theora/build 22 | 23 | echo "Build theora..." 24 | 25 | meson \ 26 | -Dasm=enabled \ 27 | -Ddoc=disabled \ 28 | -Dspec=disabled \ 29 | -Dexamples=disabled \ 30 | .. 31 | 32 | ninja -j"$(nproc)" 33 | 34 | ninja install 35 | -------------------------------------------------------------------------------- /stages/50-va.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S bash -euo pipefail 2 | 3 | case "$TARGET" in 4 | *linux*) ;; 5 | *) 6 | export UNSUPPORTED=1 7 | exit 1 8 | ;; 9 | esac 10 | 11 | echo "Download va..." 12 | mkdir -p va 13 | 14 | # renovate: datasource=github-releases depName=intel/libva 15 | _tag='2.22.0' 16 | 17 | curl_tar "https://github.com/intel/libva/releases/download/${_tag}/libva-${_tag}.tar.bz2" va 1 18 | 19 | rm -rf va/{.github,doc} 20 | 21 | # Backup source 22 | bak_src 'va' 23 | 24 | mkdir -p va/build 25 | cd va/build 26 | 27 | echo "Build va..." 28 | if ! meson \ 29 | -Dwith_x11='no' \ 30 | -Dwith_glx='no' \ 31 | -Dwith_win32='no' \ 32 | -Dwith_wayland='no' \ 33 | -Denable_docs=false \ 34 | -Ddisable_drm=false \ 35 | ..; then 36 | cat meson-logs/meson-log.txt 37 | exit 1 38 | fi 39 | 40 | ninja -j"$(nproc)" 41 | 42 | ninja install 43 | -------------------------------------------------------------------------------- /stages/50-vpx.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S bash -euo pipefail 2 | 3 | echo "Download vpx..." 4 | mkdir -p vpx 5 | 6 | # renovate: depName=https://gitlab.freedesktop.org/gstreamer/meson-ports/libvpx.git 7 | _commit='ca06d4d4007685ea8e45c48d0ad3c6c704cdfde2' 8 | 9 | curl_tar "https://gitlab.freedesktop.org/gstreamer/meson-ports/libvpx/-/archive/${_commit}/libvpx.tar.gz" vpx 1 10 | 11 | # Delete lines related to xcrun tool usage, it is irrelevant for us 12 | sed -i '1183,1189d' vpx/meson.build 13 | # Remove xcrun tool check, it is irrelevant for us 14 | sed -i "/xcrun_exe = find_program('xcrun', required: true)/d" vpx/meson.build 15 | 16 | # Remove some superfluous files 17 | rm -rf vpx/{third_party/googletest,build_debug,test,tools,examples,examples.mk,configure,*.dox,.gitlab*} 18 | 19 | case "$TARGET" in 20 | *android*) 21 | mkdir -p vpx/cpu_features 22 | curl_tar 'https://github.com/spacedriveapp/ndk-sysroot/releases/download/2024.10.20/cpufeatures.tar.xz' vpx/cpu_features 0 23 | ;; 24 | esac 25 | 26 | # Backup source 27 | bak_src 'vpx' 28 | 29 | mkdir -p vpx/build 30 | cd vpx/build 31 | 32 | configs=() 33 | 34 | case "$TARGET" in 35 | *android*) configs+=(-Dcpu_features_path=cpu_features) ;; 36 | *) ;; 37 | esac 38 | 39 | echo "Build vpx..." 40 | 41 | meson \ 42 | "${configs[@]}" \ 43 | -Dvp8=enabled \ 44 | -Dvp9=enabled \ 45 | -Dlibs=enabled \ 46 | -Dvp8_decoder=enabled \ 47 | -Dvp9_decoder=enabled \ 48 | -Dvp8_encoder=enabled \ 49 | -Dvp9_encoder=enabled \ 50 | -Dmultithread=enabled \ 51 | -Dinstall_libs=enabled \ 52 | -Dvp9_highbitdepth=enabled \ 53 | -Dbetter_hw_compatibility=enabled \ 54 | -Ddocs=disabled \ 55 | -Dtools=disabled \ 56 | -Dgprof=disabled \ 57 | -Dexamples=disabled \ 58 | -Dinstall_docs=disabled \ 59 | -Dinstall_bins=disabled \ 60 | -Dunit_tests=disabled \ 61 | -Dinternal_stats=disabled \ 62 | -Ddecode_perf_tests=disabled \ 63 | -Dencode_perf_tests=disabled \ 64 | .. 65 | 66 | ninja -j"$(nproc)" 67 | 68 | ninja install 69 | -------------------------------------------------------------------------------- /stages/50-vulkan/45-vulkan.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S bash -euo pipefail 2 | 3 | case "$TARGET" in 4 | *darwin*) 5 | export UNSUPPORTED=1 6 | exit 1 7 | ;; 8 | esac 9 | 10 | echo "Download vulkan..." 11 | mkdir -p vulkan-headers 12 | 13 | curl_tar 'https://github.com/KhronosGroup/Vulkan-Headers/archive/refs/tags/vulkan-sdk-1.3.283.0.tar.gz' vulkan-headers 1 14 | 15 | VERSION="$( 16 | sed -nr \ 17 | 's/#define\s+VK_HEADER_VERSION_COMPLETE\s+VK_MAKE_API_VERSION\(\s*[0-9]+,\s*([0-9]+),\s*([0-9]+),\s*VK_HEADER_VERSION\)/\1.\2/p' \ 18 | vulkan-headers/include/vulkan/vulkan_core.h 19 | ).$( 20 | sed -nr \ 21 | 's/#define\s+VK_HEADER_VERSION\s+([0-9]+)/\1/p' \ 22 | vulkan-headers/include/vulkan/vulkan_core.h 23 | )" 24 | 25 | # Remove some superfluous files 26 | rm -rf vulkan-headers/{.reuse,.github,tests} 27 | 28 | # Backup source 29 | bak_src 'vulkan-headers' 30 | 31 | mkdir -p vulkan-headers/build 32 | cd vulkan-headers/build 33 | 34 | echo "Build vulkan..." 35 | cmake \ 36 | -DBUILD_TESTS=Off \ 37 | .. 38 | 39 | ninja -j"$(nproc)" 40 | 41 | ninja install 42 | 43 | cat >"$PREFIX"/lib/pkgconfig/vulkan.pc <>"${PREFIX}/lib/pkgconfig/shaderc_static.pc" 67 | echo "Libs: -lstdc++" >>"${PREFIX}/lib/pkgconfig/shaderc_combined.pc" 68 | 69 | # Ensure whomever links against shaderc uses the combined version, 70 | # which is a static library containing libshaderc and all of its dependencies. 71 | ln -sf shaderc_combined.pc "$PREFIX"/lib/pkgconfig/shaderc.pc 72 | -------------------------------------------------------------------------------- /stages/50-vulkan/55-spirv-cross.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S bash -euo pipefail 2 | 3 | case "$TARGET" in 4 | *darwin*) 5 | export UNSUPPORTED=1 6 | exit 1 7 | ;; 8 | esac 9 | 10 | echo "Download spirv..." 11 | mkdir -p spirv 12 | 13 | curl_tar 'https://github.com/KhronosGroup/SPIRV-Cross/archive/refs/tags/vulkan-sdk-1.3.283.0.tar.gz' spirv 1 14 | 15 | VERSION="$( 16 | grep -Po 'set\(spirv-cross-abi-major\s+\K\d+' spirv/CMakeLists.txt 17 | ).$( 18 | grep -Po 'set\(spirv-cross-abi-minor\s+\K\d+' spirv/CMakeLists.txt 19 | ).$( 20 | grep -Po 'set\(spirv-cross-abi-patch\s+\K\d+' spirv/CMakeLists.txt 21 | )" 22 | 23 | # Remove some superfluous files 24 | rm -rf spirv/{.github,.reuse,gn,reference,samples,shaders*,tests-other} 25 | 26 | # Backup source 27 | bak_src 'spirv' 28 | 29 | mkdir -p spirv/build 30 | cd spirv/build 31 | 32 | echo "Build spirv..." 33 | cmake \ 34 | -DSPIRV_CROSS_STATIC=On \ 35 | -DSPIRV_CROSS_FORCE_PIC=On \ 36 | -DSPIRV_CROSS_ENABLE_CPP=On \ 37 | -DSPIRV_CROSS_CLI=Off \ 38 | -DSPIRV_CROSS_SHARED=Off \ 39 | -DSPIRV_CROSS_ENABLE_TESTS=Off \ 40 | .. 41 | 42 | ninja -j"$(nproc)" 43 | 44 | ninja install 45 | 46 | cat >"${PREFIX}/lib/pkgconfig/spirv-cross-c-shared.pc" </#include /' zimg/src/zimg/common/arm/cpuinfo_arm.cpp 15 | ;; 16 | esac 17 | 18 | sed -i '/^dist_example_DATA/,/src\/testcommon\/win32_bitmap.h/d;' zimg/Makefile.am 19 | 20 | # Remove unused components 21 | rm -r zimg/{doc,_msvc,test,src/{testapp,testcommon}} 22 | 23 | # Backup source 24 | bak_src 'zimg' 25 | 26 | cd zimg 27 | 28 | echo "Build zimg..." 29 | 30 | ./autogen.sh 31 | 32 | # shellcheck disable=SC2046 33 | ./configure \ 34 | $( 35 | case "$TARGET" in 36 | *linux* | *windows*) 37 | echo "--host=${TARGET}" 38 | ;; 39 | x86_64-darwin*) 40 | echo "--host=${APPLE_TARGET}" 41 | ;; 42 | aarch64-darwin*) 43 | echo "--host=${APPLE_TARGET}" 44 | ;; 45 | esac 46 | ) \ 47 | --prefix="$PREFIX" \ 48 | --with-pic \ 49 | --enable-static \ 50 | --disable-debug \ 51 | --disable-shared \ 52 | --disable-testapp \ 53 | --disable-example \ 54 | --disable-unit-test 55 | 56 | make -j"$(nproc)" 57 | 58 | make install 59 | -------------------------------------------------------------------------------- /stages/99-ffmpeg.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S bash -euo pipefail 2 | 3 | echo "Download ffmpeg..." 4 | mkdir -p ffmpeg 5 | 6 | curl_tar 'https://github.com/FFmpeg/FFmpeg/archive/refs/tags/n7.1.tar.gz' ffmpeg 1 7 | 8 | # Handbreak patches 9 | for patch in \ 10 | 'https://github.com/HandBrake/HandBrake/raw/ed8cbd1/contrib/ffmpeg/A01-mov-read-name-track-tag-written-by-movenc.patch' \ 11 | 'https://github.com/HandBrake/HandBrake/raw/ed8cbd1/contrib/ffmpeg/A02-movenc-write-3gpp-track-titl-tag.patch' \ 12 | 'https://github.com/HandBrake/HandBrake/raw/ed8cbd1/contrib/ffmpeg/A03-mov-read-3gpp-udta-tags.patch' \ 13 | 'https://github.com/HandBrake/HandBrake/raw/ed8cbd1/contrib/ffmpeg/A04-movenc-write-3gpp-track-names-tags-for-all-available.patch' \ 14 | 'https://github.com/HandBrake/HandBrake/raw/ed8cbd1/contrib/ffmpeg/A05-avformat-mov-add-support-audio-fallback-track-ref.patch' \ 15 | 'https://github.com/HandBrake/HandBrake/raw/ed8cbd1/contrib/ffmpeg/A06-dvdsubdec-fix-processing-of-partial-packets.patch' \ 16 | 'https://github.com/HandBrake/HandBrake/raw/ed8cbd1/contrib/ffmpeg/A07-dvdsubdec-return-number-of-bytes-used.patch' \ 17 | 'https://github.com/HandBrake/HandBrake/raw/ed8cbd1/contrib/ffmpeg/A08-dvdsubdec-use-pts-of-initial-packet.patch' \ 18 | 'https://github.com/HandBrake/HandBrake/raw/ed8cbd1/contrib/ffmpeg/A09-dvdsubdec-add-an-option-to-output-subtitles-with-emp.patch' \ 19 | 'https://github.com/HandBrake/HandBrake/raw/ed8cbd1/contrib/ffmpeg/A10-ccaption_dec-fix-pts-in-real_time-mode.patch' \ 20 | 'https://github.com/HandBrake/HandBrake/raw/ed8cbd1/contrib/ffmpeg/A11-avformat-matroskaenc-return-error-if-aac-extradata-c.patch' \ 21 | 'https://github.com/HandBrake/HandBrake/raw/ed8cbd1/contrib/ffmpeg/A12-videotoolbox-disable-H.264-10-bit-on-Intel-macOS-it-.patch' \ 22 | 'https://github.com/HandBrake/HandBrake/raw/ed8cbd1/contrib/ffmpeg/A13-libswscale-fix-yuv420p-to-p01xle-color-conversion-bu.patch' \ 23 | 'https://github.com/HandBrake/HandBrake/raw/ed8cbd1/contrib/ffmpeg/A14-hevc_mp4toannexb.c-fix-qsv-decode-of-10bit-hdr.patch' \ 24 | 'https://github.com/HandBrake/HandBrake/raw/ed8cbd1/contrib/ffmpeg/A15-Expose-the-unmodified-Dolby-Vision-RPU-T35-buffers.patch' \ 25 | 'https://github.com/HandBrake/HandBrake/raw/ed8cbd1/contrib/ffmpeg/A16-avcodec-amfenc-Add-support-for-on-demand-key-frames.patch' \ 26 | 'https://github.com/HandBrake/HandBrake/raw/ed8cbd1/contrib/ffmpeg/A17-avcodec-amfenc-properly-set-primaries-transfer-and-m.patch' \ 27 | 'https://github.com/HandBrake/HandBrake/raw/ed8cbd1/contrib/ffmpeg/A18-Revert-avcodec-amfenc-GPU-driver-version-check.patch' \ 28 | 'https://github.com/HandBrake/HandBrake/raw/ed8cbd1/contrib/ffmpeg/A19-lavc-pgssubdec-Add-graphic-plane-and-cropping.patch' \ 29 | 'https://github.com/HandBrake/HandBrake/raw/ed8cbd1/contrib/ffmpeg/A28-enable-av1_mf-encoder.patch' \ 30 | 'https://github.com/HandBrake/HandBrake/raw/ed8cbd1/contrib/ffmpeg/A29-Revert-lavc-Check-codec_whitelist-early-in-avcodec_o.patch'; do 31 | curl "$patch" | patch -F5 -lp1 -d ffmpeg -t 32 | done 33 | 34 | if [ "$OS_IPHONE" -gt 0 ]; then 35 | # Patch to remove ffmpeg using non public API on iOS 36 | patch -F5 -lp1 -d ffmpeg -t <"$PREFIX"/patches/remove_lzma_apple_non_public_api.patch 37 | fi 38 | 39 | case "$TARGET" in 40 | *linux*) 41 | # Remove the usage of vaMapBuffer2 for mapping image due to incompatible with older libva 42 | # https://github.com/BtbN/FFmpeg-Builds/issues/457 43 | patch -R -F5 -lp1 -d ffmpeg -t <"$PREFIX"/patches/use-vaMapBuffer2-for-mapping-image.patch 44 | ;; 45 | esac 46 | 47 | # Backup source 48 | bak_src 'ffmpeg' 49 | 50 | cd ffmpeg 51 | 52 | echo "Build ffmpeg..." 53 | 54 | env_specific_arg=() 55 | 56 | # CUDA and NVENC 57 | if [ "$(uname -m)" = "${TARGET%%-*}" ] && (case "$TARGET" in *android*) exit 1 ;; *linux* | x86_64-windows*) exit 0 ;; *) exit 1 ;; esac) then 58 | # zig cc doesn't support compiling cuda code yet, so we use the host clang for it 59 | # Unfortunatly that means we only suport cuda in the same architecture as the host system 60 | # https://github.com/ziglang/zig/pull/10704#issuecomment-1023616464 61 | env_specific_arg+=( 62 | --nvcc="clang-17 -target ${TARGET}" 63 | --enable-cuda-llvm 64 | --enable-ffnvcodec 65 | --disable-cuda-nvcc 66 | ) 67 | else 68 | # There are no Nvidia GPU drivers for macOS or Windows on ARM 69 | env_specific_arg+=( 70 | --nvcc=false 71 | --disable-cuda-llvm 72 | --disable-ffnvcodec 73 | --disable-cuda-nvcc 74 | ) 75 | fi 76 | 77 | # Architecture specific flags 78 | case "$TARGET" in 79 | x86_64*) 80 | env_specific_arg+=( 81 | --x86asmexe=nasm 82 | --enable-x86asm 83 | ) 84 | ;; 85 | aarch64*) 86 | env_specific_arg+=( 87 | --x86asmexe=false 88 | --enable-vfp 89 | --enable-neon 90 | # M1 Doesn't support i8mm 91 | --disable-i8mm 92 | ) 93 | ;; 94 | esac 95 | 96 | case "$TARGET" in 97 | *darwin*) 98 | if [ "$OS_IPHONE" -eq 1 ]; then 99 | env_specific_arg+=(--sysroot="${IOS_SDKROOT:?Missing iOS SDK}") 100 | elif [ "$OS_IPHONE" -eq 2 ]; then 101 | env_specific_arg+=(--sysroot="${IOS_SIMULATOR_SDKROOT:?Missing iOS simulator SDK}") 102 | else 103 | env_specific_arg+=( 104 | --sysroot="${MACOS_SDKROOT:?Missing macOS SDK}" 105 | --disable-static 106 | --enable-shared 107 | ) 108 | fi 109 | env_specific_arg+=( 110 | # TODO: Metal suport is disabled because no open source compiler is available for it 111 | # TODO: Maybe try macOS own metal compiler under darling? https://github.com/darlinghq/darling/issues/326 112 | # TODO: Add support for vulkan (+ libplacebo) on macOS with MoltenVK 113 | --disable-metal 114 | --disable-vulkan 115 | --disable-w32threads 116 | --disable-libshaderc 117 | --disable-libplacebo 118 | --disable-mediafoundation 119 | --enable-pthreads 120 | --enable-coreimage 121 | --enable-videotoolbox 122 | --enable-avfoundation 123 | --enable-audiotoolbox 124 | ) 125 | ;; 126 | *linux*) 127 | env_specific_arg+=( 128 | --disable-dotprod 129 | --disable-coreimage 130 | --disable-w32threads 131 | --disable-videotoolbox 132 | --disable-avfoundation 133 | --disable-audiotoolbox 134 | --disable-mediafoundation 135 | --enable-vaapi 136 | --enable-libdrm 137 | --enable-vulkan 138 | --enable-pthreads 139 | --enable-libshaderc 140 | --enable-libplacebo 141 | ) 142 | 143 | if [ "$OS_ANDROID" -ne 1 ]; then 144 | env_specific_arg+=( 145 | --disable-static 146 | --enable-shared 147 | ) 148 | fi 149 | ;; 150 | *windows*) 151 | # FIX-ME: LTO breaks ffmpeg linking on windows target for some reason 152 | export LTO=0 153 | env_specific_arg+=( 154 | --disable-static 155 | --disable-dotprod 156 | --disable-pthreads 157 | --disable-coreimage 158 | --disable-videotoolbox 159 | --disable-avfoundation 160 | --disable-audiotoolbox 161 | --enable-vulkan 162 | --enable-w32threads 163 | --enable-libshaderc 164 | --enable-libplacebo 165 | --enable-mediafoundation 166 | --enable-shared 167 | ) 168 | ;; 169 | esac 170 | 171 | # Enable hardware acceleration 172 | case "$TARGET" in 173 | *darwin* | aarch64-windows*) ;; 174 | # Apple only support its own APIs for hardware (de/en)coding on macOS 175 | # Windows on ARM doesn't have external GPU support yet 176 | *android*) 177 | env_specific_arg+=( 178 | --enable-jni 179 | --enable-mediacodec 180 | ) 181 | ;; 182 | *) 183 | env_specific_arg+=( 184 | --enable-amf 185 | --enable-libvpl 186 | ) 187 | ;; 188 | esac 189 | 190 | _arch="${TARGET%%-*}" 191 | case "$TARGET" in 192 | aarch64-darwin*) 193 | _arch=arm64 194 | ;; 195 | esac 196 | 197 | if [ "${LTO:-1}" -eq 1 ]; then 198 | env_specific_arg+=(--enable-lto=thin) 199 | fi 200 | 201 | if ! ./configure \ 202 | --cpu="$_arch" \ 203 | --arch="$_arch" \ 204 | --prefix="$OUT" \ 205 | --target-os="$( 206 | case "$TARGET" in 207 | *android*) 208 | echo "android" 209 | ;; 210 | *linux*) 211 | echo "linux" 212 | ;; 213 | *darwin*) 214 | echo "darwin" 215 | ;; 216 | *windows*) 217 | echo "mingw64" 218 | ;; 219 | esac 220 | )" \ 221 | --cc=cc \ 222 | --nm=nm \ 223 | --ar=ar \ 224 | --cxx=c++ \ 225 | --strip=strip \ 226 | --ranlib=ranlib \ 227 | --host-cc=clang-17 \ 228 | --windres="windres" \ 229 | --pkg-config=pkg-config \ 230 | --pkg-config-flags="--static" \ 231 | --disable-debug \ 232 | --disable-doc \ 233 | --disable-htmlpages \ 234 | --disable-txtpages \ 235 | --disable-manpages \ 236 | --disable-podpages \ 237 | --disable-indevs \ 238 | --disable-outdevs \ 239 | --disable-parser=avs2 \ 240 | --disable-parser=avs3 \ 241 | --disable-postproc \ 242 | --disable-programs \ 243 | --disable-libwebp \ 244 | --disable-sdl2 \ 245 | --disable-metal \ 246 | --disable-opengl \ 247 | --disable-network \ 248 | --disable-openssl \ 249 | --disable-schannel \ 250 | --disable-securetransport \ 251 | --disable-xlib \ 252 | --disable-libxcb \ 253 | --disable-libxcb-shm \ 254 | --disable-libxcb-xfixes \ 255 | --disable-libxcb-shape \ 256 | --disable-libv4l2 \ 257 | --disable-v4l2-m2m \ 258 | --disable-xmm-clobber-test \ 259 | --disable-neon-clobber-test \ 260 | --enable-asm \ 261 | --enable-avcodec \ 262 | --enable-avfilter \ 263 | --enable-avformat \ 264 | --enable-bzlib \ 265 | --enable-cross-compile \ 266 | --enable-gpl \ 267 | --enable-inline-asm \ 268 | --enable-libdav1d \ 269 | --enable-libmp3lame \ 270 | --enable-libopus \ 271 | --enable-libsoxr \ 272 | --enable-libsvtav1 \ 273 | --enable-libtheora \ 274 | --enable-libvorbis \ 275 | --enable-libvpx \ 276 | --enable-libvvenc \ 277 | --enable-libx264 \ 278 | --enable-libx265 \ 279 | --enable-libzimg \ 280 | --enable-lzma \ 281 | --enable-optimizations \ 282 | --enable-pic \ 283 | --enable-postproc \ 284 | --enable-swscale \ 285 | --enable-version3 \ 286 | --enable-zlib \ 287 | $( 288 | # OpenCL is only available on iOS through a private framework 289 | if [ "$OS_IPHONE" -ge 1 ]; then 290 | echo '--disable-opencl' 291 | # A12 Bionic, which is the CPU for our lowest supported iOS device (iPhone XS/XR) doesn't support dotprod 292 | echo '--disable-dotprod' 293 | else 294 | echo '--enable-opencl' 295 | fi 296 | ) \ 297 | "${env_specific_arg[@]}"; then 298 | cat ffbuild/config.log >&2 299 | exit 1 300 | fi 301 | 302 | case "$TARGET" in 303 | *linux*) 304 | # Replace incorrect identifyed sysctl as enabled on linux 305 | sed -i 's/#define HAVE_SYSCTL 1/#define HAVE_SYSCTL 0/' config.h 306 | ;; 307 | esac 308 | 309 | make -j"$(nproc)" V=1 310 | 311 | make install 312 | 313 | case "$TARGET" in 314 | *windows*) 315 | # Move dll.a to lib 316 | find "${OUT}/lib" -type f -name '*.dll.a' -exec sh -euc \ 317 | 'for dlla in "$@"; do lib="$(basename "$dlla" .dll.a).lib" && lib="${lib#"lib"}" && if ! [ -f "$lib" ]; then mv "$dlla" "$(dirname "$dlla")/${lib}"; fi; done' \ 318 | sh {} + 319 | ;; 320 | esac 321 | 322 | # Copy static libs for iOS 323 | if [ "$OS_IPHONE" -gt 0 ] || [ "$OS_ANDROID" -eq 1 ]; then 324 | cp -r "$PREFIX"/lib/*.a "${OUT}/lib/" 325 | fi 326 | -------------------------------------------------------------------------------- /stages/99-heif.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S bash -euo pipefail 2 | 3 | echo "Download heif..." 4 | mkdir -p heif 5 | 6 | # renovate: datasource=github-releases depName=strukturag/libheif 7 | _tag='1.19.7' 8 | 9 | curl_tar "https://github.com/strukturag/libheif/releases/download/v${_tag}/libheif-${_tag}.tar.gz" heif 1 10 | 11 | case "$TARGET" in 12 | *windows*) 13 | sed -ie 's/__attribute__((__visibility__("default")))/__declspec(dllexport)/' heif/libheif/api/libheif/heif.h 14 | ;; 15 | esac 16 | 17 | # Remove unused components 18 | rm -r heif/{go,fuzzing,tests,examples} 19 | 20 | # Backup source 21 | bak_src 'heif' 22 | 23 | mkdir -p heif/build 24 | cd heif/build 25 | 26 | echo "Build heif..." 27 | 28 | env SHARED="$( 29 | if [ "$OS_IPHONE" -gt 0 ] || [ "$OS_ANDROID" -eq 1 ]; then 30 | echo "Off" 31 | else 32 | echo "On" 33 | fi 34 | )" PREFIX="$OUT" cmake \ 35 | -DWITH_DAV1D=On \ 36 | -DWITH_LIBDE265=On \ 37 | -DWITH_LIBSHARPYUV=On \ 38 | -DWITH_FFMPEG_DECODER=On \ 39 | -DWITH_UNCOMPRESSED_CODEC=On \ 40 | -DWITH_REDUCED_VISIBILITY=On \ 41 | -DWITH_HEADER_COMPRESSION=On \ 42 | -DCMAKE_C_VISIBILITY_PRESET=hidden \ 43 | -DCMAKE_CXX_VISIBILITY_PRESET=hidden \ 44 | -DENABLE_MULTITHREADING_SUPPORT=On \ 45 | -DCMAKE_VISIBILITY_INLINES_HIDDEN=On \ 46 | -DWITH_X265=Off \ 47 | -DWITH_RAV1E=Off \ 48 | -DWITH_SvtEnc=Off \ 49 | -DWITH_KVAZAAR=Off \ 50 | -DWITH_FUZZERS=Off \ 51 | -DWITH_EXAMPLES=Off \ 52 | -DBUILD_TESTING=Off \ 53 | -DWITH_GDK_PIXBUF=Off \ 54 | -DWITH_AOM_DECODER=Off \ 55 | -DWITH_AOM_ENCODER=Off \ 56 | -DWITH_JPEG_DECODER=Off \ 57 | -DWITH_JPEG_ENCODER=Off \ 58 | -DWITH_OpenJPEG_DECODER=Off \ 59 | -DWITH_OpenJPEG_ENCODER=Off \ 60 | -DENABLE_PLUGIN_LOADING=Off \ 61 | -DWITH_UNCOMPRESSED_CODEC=Off \ 62 | .. 63 | 64 | ninja -j"$(nproc)" 65 | 66 | case "$TARGET" in 67 | *windows*) 68 | cat <libheif.ver 69 | LIBHEIF_1 { 70 | global: 71 | heif_*; 72 | local: 73 | *; 74 | }; 75 | EOF 76 | 77 | # Generate def file 78 | find . -name '*.obj' -exec env EXTERN_PREFIX="" makedef ./libheif.ver {} + >heif-1.def 79 | 80 | # Generate lib file 81 | dlltool -m "$(case "$TARGET" in x86_64*) echo "i386:x86-64" ;; aarch64*) echo "arm64" ;; esac)" \ 82 | -d ./heif-1.def -l heif.lib -D ./libheif/libheif.dll 83 | ;; 84 | esac 85 | 86 | ninja install 87 | 88 | if [ -f "heif.lib" ]; then 89 | cp -at "${OUT}/lib/" heif.lib 90 | fi 91 | 92 | # Copy static libs for iOS 93 | if [ "$OS_IPHONE" -gt 0 ] || [ "$OS_ANDROID" -eq 1 ]; then 94 | cp -r "$PREFIX"/lib/*.a "${OUT}/lib/" 95 | fi 96 | -------------------------------------------------------------------------------- /stages/99-onnx.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S bash -euo pipefail 2 | 3 | echo "Download onnx..." 4 | mkdir -p onnx 5 | 6 | # renovate: datasource=github-releases depName=microsoft/onnxruntime 7 | _tag='1.19.2' 8 | 9 | case "$TARGET" in 10 | *windows*) 11 | # We just download the MS pre-compiled binaries which include the DirectML backend and are most likely better optimized than what we can build 12 | curl_tar "https://www.nuget.org/api/v2/package/Microsoft.ML.OnnxRuntime.DirectML/${_tag}" onnx 0 13 | 14 | # No src to backup here because we are downloading pre-compiled binaries 15 | 16 | mkdir -p "$OUT"/{bin,lib,include} 17 | 18 | mv onnx/build/native/include "${OUT}/include/onnxruntime" 19 | 20 | case "${TARGET%%-*}" in 21 | x86_64) 22 | cd onnx/runtimes/win-x64/native 23 | ;; 24 | aarch64) 25 | cd onnx/runtimes/win-arm64/native 26 | ;; 27 | esac 28 | 29 | mv onnxruntime.dll "${OUT}/bin/" 30 | mv onnxruntime.lib "${OUT}/lib/" 31 | 32 | exit 0 33 | ;; 34 | esac 35 | 36 | curl_tar "https://github.com/microsoft/onnxruntime/archive/refs/tags/v${_tag}.tar.gz" onnx 1 37 | 38 | # Patch to only include execinfo.h on supported environments 39 | sed -i 's/defined(__ANDROID__)/defined(__ANDROID__) \&\& (defined(__APPLE__) || defined(__GLIBC__) || defined(PLATFORM_IS_BSD))/g' onnx/onnxruntime/core/platform/posix/stacktrace.cc 40 | 41 | # Remove unused components 42 | rm -r onnx/{.*,requirements*.txt,*.py,cgmanifests,dockerfiles,objectivec,*.png,rust,samples,java,docs,orttraining,js,csharp,winml,onnxruntime/{wasm,test,tool,python,core/flatbuffers/ort_flatbuffers_py,contrib_ops/{js,rocm,cuda}}} 43 | 44 | # Backup source 45 | bak_src 'onnx' 46 | 47 | mkdir -p onnx/build 48 | cd onnx/build 49 | 50 | echo "Build onnx..." 51 | 52 | # Enable caching cmake downloaded deps 53 | mkdir -p "/root/.cache/onnx_deps/${TARGET}" 54 | ln -sf "/root/.cache/onnx_deps/${TARGET}" _deps 55 | 56 | args=( 57 | -DCMAKE_TLS_VERIFY=On 58 | -DBUILD_PKGCONFIG_FILES=Off 59 | -Donnxruntime_USE_XNNPACK=On 60 | -Donnxruntime_BUILD_SHARED_LIB="$( 61 | if [ "$OS_IPHONE" -gt 0 ] || [ "$OS_ANDROID" -eq 1 ]; then 62 | echo "Off" 63 | else 64 | echo "On" 65 | fi 66 | )" 67 | -Donnxruntime_CROSS_COMPILING=On 68 | -Donnxruntime_ENABLE_LTO="$([ "${LTO:-1}" -eq 1 ] && echo On || echo Off)" 69 | -DONNX_CUSTOM_PROTOC_EXECUTABLE=/usr/bin/protoc 70 | -DPython_EXECUTABLE=/usr/bin/python3 71 | -DPYTHON_EXECUTABLE=/usr/bin/python3 72 | -Donnxruntime_RUN_ONNX_TESTS=Off 73 | -Donnxruntime_USE_MPI=Off 74 | -Donnxruntime_USE_TELEMETRY=Off 75 | -DOnnxruntime_GCOV_COVERAGE=Off 76 | -Donnxruntime_BUILD_MS_EXPERIMENTAL_OPS=Off 77 | -Donnxruntime_BUILD_JAVA=Off 78 | -Donnxruntime_BUILD_OBJC=Off 79 | -Donnxruntime_BUILD_UNIT_TESTS=Off 80 | -Donnxruntime_BUILD_NODEJS=Off 81 | -Donnxruntime_BUILD_CSHARP=Off 82 | -Donnxruntime_BUILD_BENCHMARKS=Off 83 | -Donnxruntime_BUILD_APPLE_FRAMEWORK=Off 84 | -Donnxruntime_ENABLE_PYTHON=Off 85 | -Donnxruntime_ENABLE_MEMORY_PROFILE=Off 86 | -Donnxruntime_ENABLE_TRAINING=Off 87 | -Donnxruntime_GENERATE_TEST_REPORTS=Off 88 | -DFETCHCONTENT_QUIET=Off 89 | -DNSYNC_ENABLE_TESTS=Off 90 | -Dprotobuf_BUILD_TESTS=Off 91 | -Dprotobuf_BUILD_PROTOBUF_BINARIES=Off 92 | -Dprotobuf_BUILD_PROTOC_BINARIES=Off 93 | -DFLATBUFFERS_BUILD_TESTS=Off 94 | -DFLATBUFFERS_INSTALL=Off 95 | -DFLATBUFFERS_BUILD_FLATC=Off 96 | -DCPUINFO_BUILD_TOOLS=Off 97 | -DCPUINFO_BUILD_UNIT_TESTS=Off 98 | -DCPUINFO_BUILD_MOCK_TESTS=Off 99 | -DCPUINFO_BUILD_BENCHMARKS=Off 100 | -DCPUINFO_BUILD_PKG_CONFIG=Off 101 | -DEIGEN_BUILD_PKGCONFIG=Off 102 | ) 103 | 104 | case "$TARGET" in 105 | *darwin*) 106 | args+=( 107 | -Donnxruntime_USE_COREML="$(if [ "$OS_IPHONE" -eq 2 ]; then echo "Off"; else echo "On"; fi)" 108 | ) 109 | # Allow deprecated usage of ATOMIC_VAR_INIT by https://github.com/google/nsync 110 | # Allow deprecated usage of this capture by https://gitlab.com/libeigen/eigen 111 | export CXXFLAGS="${CXXFLAGS} -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS -Wno-deprecated-this-capture" 112 | ;; 113 | *android*) 114 | args+=( 115 | -Donnxruntime_USE_NNAPI_BUILTIN=On 116 | ) 117 | ;; 118 | esac 119 | 120 | # WARNING: Must not set Shared Library to On, or else it will fail to build. This is already handled above by onnx custom argument. 121 | env PREFIX="$OUT" cmake "${args[@]}" ../cmake 122 | 123 | case "$TARGET" in 124 | *linux*) 125 | # Fix google_nsync trying to compile C code as C++, which zig does not support 126 | sed -i 's/foreach (s IN ITEMS ${NSYNC_COMMON_SRC} ${NSYNC_OS_CPP_SRC})/foreach (s IN ITEMS ${NSYNC_COMMON_SRC} ${NSYNC_OS_CPP_SRC})\nget_filename_component(sle ${s} NAME_WLE)/g' _deps/google_nsync-src/CMakeLists.txt 127 | sed -i 's/cpp\/${s}/cpp\/${sle}.cc/g' _deps/google_nsync-src/CMakeLists.txt 128 | 129 | # Regenerate build files after cmake patches 130 | env PREFIX="$OUT" cmake "${args[@]}" ../cmake 131 | ;; 132 | esac 133 | 134 | ninja -j"$(nproc)" 135 | 136 | ninja install 137 | 138 | # Copy static libs for iOS and android 139 | if [ "$OS_IPHONE" -gt 0 ] || [ "$OS_ANDROID" -eq 1 ]; then 140 | cp -r "$PREFIX"/lib/*.a "${OUT}/lib/" 141 | fi 142 | -------------------------------------------------------------------------------- /stages/99-pdfium.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S bash -euo pipefail 2 | 3 | echo "Download pdfium..." 4 | mkdir -p pdfium 5 | 6 | # renovate: datasource=github-releases depName=bblanchon/pdfium-binaries versioning=semver-coerced 7 | _tag='7113' 8 | case "$TARGET" in 9 | x86_64-windows*) 10 | _name='win-x64' 11 | ;; 12 | aarch64-windows*) 13 | _name='win-arm64' 14 | ;; 15 | x86_64-linux-gnu) 16 | _name='linux-x64' 17 | ;; 18 | aarch64-linux-gnu) 19 | _name='linux-arm64' 20 | ;; 21 | x86_64-linux-musl) 22 | _name='linux-musl-x64' 23 | ;; 24 | aarch64-linux-musl) 25 | _name='linux-musl-arm64' 26 | ;; 27 | x86_64-linux-android) 28 | _name='android-x64' 29 | ;; 30 | aarch64-linux-android) 31 | _name='android-arm64' 32 | ;; 33 | x86_64-darwin*) 34 | if [ "$OS_IPHONE" -eq 0 ]; then 35 | _name='mac-x64' 36 | elif [ "$OS_IPHONE" -eq 1 ]; then 37 | echo "There is no libpdfium pre-built for iOS x64" >&2 38 | export UNSUPPORTED=1 39 | exit 1 40 | else 41 | _name='ios-simulator-x64' 42 | fi 43 | ;; 44 | aarch64-darwin*) 45 | if [ "$OS_IPHONE" -eq 0 ]; then 46 | _name='mac-arm64' 47 | elif [ "$OS_IPHONE" -eq 1 ]; then 48 | _name='ios-device-arm64' 49 | else 50 | echo "There is no libpdfium pre-built for iOS simulator arm64" >&2 51 | export UNSUPPORTED=1 52 | exit 1 53 | fi 54 | ;; 55 | esac 56 | 57 | curl_tar "https://github.com/bblanchon/pdfium-binaries/releases/download/chromium/${_tag}/pdfium-${_name}.tgz" pdfium 58 | 59 | # No src to backup here because we are downloading pre-compiled binaries 60 | 61 | cd pdfium 62 | 63 | # Install 64 | mkdir -p "$OUT"/{bin,lib,include} 65 | case "$TARGET" in 66 | *windows*) 67 | mv bin/* "${OUT}/bin" 68 | mv lib/pdfium.dll.lib lib/pdfium.lib 69 | ;; 70 | esac 71 | mv lib/* "${OUT}/lib/" 72 | mv include "${OUT}/include/libpdfium" 73 | -------------------------------------------------------------------------------- /stages/99-protoc.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S bash -euo pipefail 2 | 3 | if [ "$OS_ANDROID" -eq 1 ] || [ "$OS_IPHONE" -ge 1 ]; then 4 | export UNSUPPORTED=1 5 | exit 1 6 | fi 7 | 8 | echo "Download protobuf..." 9 | mkdir -p protobuf 10 | 11 | # renovate: datasource=github-releases depName=protocolbuffers/protobuf versioning=semver-coerced 12 | _tag='30.2' 13 | case "$TARGET" in 14 | x86_64-windows*) 15 | _suffix='win64' 16 | ;; 17 | aarch64-windows*) 18 | # There is no binary available for Windows on ARM, so we use the x86 executable 19 | # which should run fine under Windows x86 emulation layer 20 | # https://learn.microsoft.com/en-us/windows/arm/apps-on-arm-x86-emulation 21 | _suffix='win32' 22 | ;; 23 | x86_64-linux*) 24 | _suffix='linux-x86_64' 25 | ;; 26 | aarch64-linux*) 27 | _suffix='linux-aarch_64' 28 | ;; 29 | x86_64-darwin*) 30 | _suffix='osx-x86_64' 31 | ;; 32 | aarch64-darwin*) 33 | _suffix='osx-aarch_64' 34 | ;; 35 | esac 36 | 37 | curl_tar "https://github.com/protocolbuffers/protobuf/releases/download/v${_tag}/protoc-${_tag}-${_suffix}.zip" "$OUT" 0 38 | 39 | case "$TARGET" in 40 | *windows*) 41 | chmod 0755 "${OUT}/bin/protoc.exe" 42 | ;; 43 | *) 44 | chmod 0755 "${OUT}/bin/protoc" 45 | ;; 46 | esac 47 | 48 | rm "${OUT}/readme.txt" 49 | -------------------------------------------------------------------------------- /stages/99-yolov8.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env -S bash -euo pipefail 2 | 3 | echo "Download yolov8 model..." 4 | 5 | mkdir -p "$OUT"/{models,licenses} 6 | curl -o "${OUT}/models/yolov8s.onnx" "https://github.com/spacedriveapp/native-deps/releases/download/yolo-2024-02-07/yolov8s.onnx" 7 | curl -o "${OUT}/licenses/yolov8s.LICENSE" 'https://raw.githubusercontent.com/ultralytics/assets/main/LICENSE' 8 | --------------------------------------------------------------------------------