Last active
December 11, 2024 19:37
-
-
Save robertkirkman/1a4fcd1226090c4921eb2e6cf27a9c27 to your computer and use it in GitHub Desktop.
Revisions
-
robertkirkman revised this gist
Dec 2, 2023 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,6 +6,7 @@ 2. ```bash termux-setup-storage pkg install git make clang binutils git clone https://github.com/madler/zlib.git cd zlib/ git checkout 643e17b @@ -17,7 +18,7 @@ mv $PREFIX/lib/libz.a $PREFIX/lib/static/ cd git clone https://github.com/termux/termux-packages.git cd termux-packages/ (curl https://gist.github.com/robertkirkman/1a4fcd1226090c4921eb2e6cf27a9c27/raw/96a4e0e73780014e82711092e1d16fe379ef92bb/termux-packages-turnip-surfaceflinger-ondevice.patch && echo) | git apply -v ./scripts/setup-termux.sh pkg install bison pip install mako -
robertkirkman revised this gist
Dec 2, 2023 . 2 changed files with 2 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -17,7 +17,6 @@ mv $PREFIX/lib/libz.a $PREFIX/lib/static/ cd git clone https://github.com/termux/termux-packages.git cd termux-packages/ (curl https://gist.github.com/robertkirkman/1a4fcd1226090c4921eb2e6cf27a9c27/raw/40da8c792380d3e216bea6a71914214868a579c1/termux-packages-turnip-surfaceflinger-ondevice.patch && echo) | git apply -v ./scripts/setup-termux.sh pkg install bison This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -225,8 +225,8 @@ index 43d769ed6..4a026247b 100644 echo "strip = '$STRIP'" >> $TERMUX_MESON_CROSSFILE + echo "llvm-config = 'llvm-config'" >> $TERMUX_MESON_CROSSFILE if [ "$TERMUX_PACKAGE_LIBRARY" = "bionic" ]; then echo '' >> $TERMUX_MESON_CROSSFILE diff --git a/scripts/build/termux_step_extract_into_massagedir.sh b/scripts/build/termux_step_extract_into_massagedir.sh index 0df0b9e1e..2b4ffca10 100644 --- a/scripts/build/termux_step_extract_into_massagedir.sh -
robertkirkman revised this gist
Nov 28, 2023 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,5 @@ ## How to [build Mesa Turnip with `-Dplatforms=android`](https://docs.mesa3d.org/android.html) but without cross-compilation > Small warning: This will "mess up" your Termux installation's `zlib.pc` file, but if you do other compilations with really similar settings to this one, you're probably going to need it again before you "fix" it by reinstalling Termux's official `zlib` anyway. 1. Install [Termux](https://f-droid.org/en/packages/com.termux/) -
robertkirkman revised this gist
Nov 28, 2023 . 1 changed file with 5 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ ## How to [build Mesa Turnip with `-Dplatforms=android`](https://docs.mesa3d.org/android.html) but without cross-compilation 1. Install [Termux](https://f-droid.org/en/packages/com.termux/) 2. @@ -8,22 +10,22 @@ cd zlib/ git checkout 643e17b ./configure --static make install prefix=$PREFIX curl https://gist.github.com/robertkirkman/1a4fcd1226090c4921eb2e6cf27a9c27/raw/40da8c792380d3e216bea6a71914214868a579c1/zlib.pc > $PREFIX/lib/pkgconfig/zlib.pc mkdir -p $PREFIX/lib/static mv $PREFIX/lib/libz.a $PREFIX/lib/static/ cd git clone https://github.com/termux/termux-packages.git cd termux-packages/ git checkout bca967a (curl https://gist.github.com/robertkirkman/1a4fcd1226090c4921eb2e6cf27a9c27/raw/40da8c792380d3e216bea6a71914214868a579c1/termux-packages-turnip-surfaceflinger-ondevice.patch && echo) | git apply -v ./scripts/setup-termux.sh pkg install bison pip install mako # If this fails with anything like "E: Version '2.4.118' for 'libdrm' was not found... building instead" it means your current Termux mirror is outdated or the git commit of termux-packages repo is too old. Use termux-change-mirror to select different ones and rebase the patches on upstream termux-packages until the error disappears ./build-package.sh -I -f mesa ar x output/mesa-vulkan-icd-freedreno_24.0.0-1_aarch64.deb tar xvf data.tar.xz wget https://gist.github.com/robertkirkman/1a4fcd1226090c4921eb2e6cf27a9c27/raw/40da8c792380d3e216bea6a71914214868a579c1/meta.json pkg install p7zip ldd patchelf # Inspect the linkage of the binary for problems. Any instance of "com.termux" in this list probably means you used the wrong dependencies and need to adjust them, except that when I build on one of my devices for some reason it shows "com.termux/files/usr/lib/libc++_shared.so" here when builds on other devices don't, but when I proceed and test it anyway it seems to still work. I don't know why. ldd ./data/data/com.termux/files/usr/lib/libvulkan_freedreno.so -
robertkirkman created this gist
Nov 28, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ 1. Install [Termux](https://f-droid.org/en/packages/com.termux/) 2. ```bash termux-setup-storage git clone https://github.com/madler/zlib.git cd zlib/ git checkout 643e17b ./configure --static make install prefix=$PREFIX curl https://gist.github.com/robertkirkman/5054321db3d5082b2cc0251f4dd891b3/raw/29697ca1f83453d4ab8fd7c3f8b231e1791f070b/zlib.pc > $PREFIX/lib/pkgconfig/zlib.pc mkdir -p $PREFIX/lib/static mv $PREFIX/lib/libz.a $PREFIX/lib/static/ cd git clone https://github.com/termux/termux-packages.git cd termux-packages/ git checkout bca967a (curl https://gist.github.com/robertkirkman/5054321db3d5082b2cc0251f4dd891b3/raw/29697ca1f83453d4ab8fd7c3f8b231e1791f070b/termux-packages-turnip-surfaceflinger-ondevice.patch && echo) | git apply -v ./scripts/setup-termux.sh pkg install bison pip install mako # If this fails with anything like "E: Version '2.4.118' for 'libdrm' was not found... building instead" it means your current Termux mirror is outdated or the git commit of termux-packages repo is too old. Use termux-change-mirror to select different ones and rebase the patches on upstream termux-packages until the error disappears ./build-package.sh -I -f mesa ar x output/mesa-vulkan-icd-freedreno_24.0.0-1_aarch64.deb tar xvf data.tar.xz wget https://gist.github.com/robertkirkman/5054321db3d5082b2cc0251f4dd891b3/raw/29697ca1f83453d4ab8fd7c3f8b231e1791f070b/meta.json pkg install p7zip ldd patchelf # Inspect the linkage of the binary for problems. Any instance of "com.termux" in this list probably means you used the wrong dependencies and need to adjust them, except that when I build on one of my devices for some reason it shows "com.termux/files/usr/lib/libc++_shared.so" here when builds on other devices don't, but when I proceed and test it anyway it seems to still work. I don't know why. ldd ./data/data/com.termux/files/usr/lib/libvulkan_freedreno.so patchelf --set-soname libvulkan_freedreno_owokitty.so ./data/data/com.termux/files/usr/lib/libvulkan_freedreno.so mv ./data/data/com.termux/files/usr/lib/libvulkan_freedreno.so libvulkan_freedreno_owokitty.so 7z a turnip-24.0.0-devel-owokitty.adpkg.zip libvulkan_freedreno_owokitty.so meta.json cp turnip-24.0.0-devel-owokitty.adpkg.zip /storage/emulated/0 ``` This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ { "schemaVersion": 1, "name": "Mesa Turnip Adreno Driver v24.0.0-devel with -Dllvm=enabled.", "description": "Compiled from Mesa git main commit f843b14c.", "author": "owokitty", "packageVersion": "1", "vendor": "Mesa", "driverVersion": "1.3.270", "minApi": 24, "libraryName": "libvulkan_freedreno_owokitty.so" } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,242 @@ diff --git a/packages/mesa/0007-fix-build-for-lld-17.patch b/packages/mesa/0007-fix-build-for-lld-17.patch deleted file mode 100644 index 1c7126ade..000000000 --- a/packages/mesa/0007-fix-build-for-lld-17.patch +++ /dev/null @@ -1,61 +0,0 @@ -https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25551 - ---- a/src/gallium/targets/dri/dri.sym -+++ /dev/null -@@ -1,12 +0,0 @@ --{ -- global: -- __driDriverExtensions; -- __driDriverGetExtensions*; -- nouveau_drm_screen_create; -- radeon_drm_winsys_create; -- amdgpu_winsys_create; -- fd_drm_screen_create_renderonly; -- ac_init_shared_llvm_once; -- local: -- *; --}; ---- /dev/null -+++ b/src/gallium/targets/dri/dri.sym.in -@@ -0,0 +1,11 @@ -+{ -+ global: -+ __driDriverGetExtensions*; -+ @nouveau_drm_screen_create@ -+ @radeon_drm_winsys_create@ -+ @amdgpu_winsys_create@ -+ @fd_drm_screen_create_renderonly@ -+ @ac_init_shared_llvm_once@ -+ local: -+ *; -+}; ---- a/src/gallium/targets/dri/meson.build -+++ b/src/gallium/targets/dri/meson.build -@@ -28,9 +28,25 @@ gallium_dri_ld_args = [] - gallium_dri_link_depends = [] - gallium_dri_drivers = [] - -+dri_sym_config = configuration_data() -+ -+foreach d : [[with_gallium_r300 or with_gallium_radeonsi or with_gallium_r600, 'radeon_drm_winsys_create'], -+ [with_gallium_radeonsi, 'amdgpu_winsys_create'], -+ [with_gallium_nouveau, 'nouveau_drm_screen_create'], -+ [with_gallium_freedreno, 'fd_drm_screen_create_renderonly'], -+ [with_llvm and get_option('shared-llvm').allowed(), 'ac_init_shared_llvm_once']] -+ if d[0] -+ dri_sym_config.set(d[1], d[1] + ';') -+ else -+ dri_sym_config.set(d[1], '') -+ endif -+endforeach -+ -+dri_sym = configure_file(input : 'dri.sym.in', output : 'dri.sym', configuration : dri_sym_config) -+ - if with_ld_version_script -- gallium_dri_ld_args += ['-Wl,--version-script', join_paths(meson.current_source_dir(), 'dri.sym')] -- gallium_dri_link_depends += files('dri.sym') -+ gallium_dri_ld_args += ['-Wl,--version-script', join_paths(meson.current_build_dir(), 'dri.sym')] -+ gallium_dri_link_depends += dri_sym - endif - if with_ld_dynamic_list - gallium_dri_ld_args += ['-Wl,--dynamic-list', join_paths(meson.current_source_dir(), '../dri.dyn')] diff --git a/packages/mesa/build.sh b/packages/mesa/build.sh index e17f11217..4a7c61def 100644 --- a/packages/mesa/build.sh +++ b/packages/mesa/build.sh @@ -3,10 +3,10 @@ TERMUX_PKG_DESCRIPTION="An open-source implementation of the OpenGL specificatio TERMUX_PKG_LICENSE="MIT" TERMUX_PKG_LICENSE_FILE="docs/license.rst" TERMUX_PKG_MAINTAINER="@termux" -TERMUX_PKG_VERSION="23.2.1" +TERMUX_PKG_VERSION="24.0.0" TERMUX_PKG_REVISION=1 -TERMUX_PKG_SRCURL=https://archive.mesa3d.org/mesa-${TERMUX_PKG_VERSION}.tar.xz -TERMUX_PKG_SHA256=64de0616fc2d801f929ab1ac2a4f16b3e2783c4309a724c8a259b20df8bbc1cc +TERMUX_PKG_SRCURL=https://gitlab.freedesktop.org/mesa/mesa/-/archive/f843b14c171299e1696ca6d971ccaa496f60c3ab/mesa-f843b14c171299e1696ca6d971ccaa496f60c3ab.tar.gz +TERMUX_PKG_SHA256=fd681705c021d853d68c9747ea29e2fba597ffce1cfb6888d00bb6bc43d48e06 TERMUX_PKG_AUTO_UPDATE=true TERMUX_PKG_DEPENDS="libandroid-shmem, libc++, libdrm, libglvnd, libwayland, libx11, libxext, libxfixes, libxshmfence, libxxf86vm, ncurses, vulkan-loader, zlib, zstd" TERMUX_PKG_SUGGESTS="mesa-dev" @@ -17,28 +17,21 @@ TERMUX_PKG_REPLACES="libmesa" TERMUX_PKG_EXTRA_CONFIGURE_ARGS=" --cmake-prefix-path $TERMUX_PREFIX -Dcpp_rtti=false --Dgbm=enabled --Dopengl=true --Degl=enabled --Degl-native-platform=x11 --Dgles1=disabled --Dgles2=enabled --Ddri3=enabled --Dglx=dri -Dllvm=enabled +-Dvulkan-beta=true -Dshared-llvm=disabled --Dplatforms=x11,wayland --Dgallium-drivers=swrast,virgl,zink --Dosmesa=true --Dglvnd=true +-Dplatforms=android +-Dplatform-sdk-version=$(getprop ro.build.version.sdk) +-Dgallium-drivers= -Dxmlconfig=disabled +-Dandroid-stub=true +-Dzstd=false " termux_step_pre_configure() { termux_setup_cmake - CPPFLAGS+=" -D__USE_GNU" - LDFLAGS+=" -landroid-shmem" + CPPFLAGS+=" -D__USE_GNU -D__ANDROID_API__=$(getprop ro.build.version.sdk)" _WRAPPER_BIN=$TERMUX_PKG_BUILDDIR/_wrapper/bin mkdir -p $_WRAPPER_BIN @@ -56,8 +49,8 @@ termux_step_pre_configure() { export PATH=$_WRAPPER_BIN:$PATH if [ $TERMUX_ARCH = "arm" ] || [ $TERMUX_ARCH = "aarch64" ]; then - TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" -Dvulkan-drivers=swrast,freedreno" - TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" -Dfreedreno-kmds=msm,kgsl" + TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" -Dvulkan-drivers=freedreno" + TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" -Dfreedreno-kmds=kgsl" elif [ $TERMUX_ARCH = "i686" ] || [ $TERMUX_ARCH = "x86_64" ]; then TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" -Dvulkan-drivers=swrast" else @@ -89,6 +82,4 @@ termux_step_post_make_install() { done # Create symlinks - ln -sf libEGL_mesa.so ${TERMUX_PREFIX}/lib/libEGL_mesa.so.0 - ln -sf libGLX_mesa.so ${TERMUX_PREFIX}/lib/libGLX_mesa.so.0 } diff --git a/packages/mesa/the-usual.patch b/packages/mesa/the-usual.patch new file mode 100644 index 000000000..dda8e7f95 --- /dev/null +++ b/packages/mesa/the-usual.patch @@ -0,0 +1,59 @@ +diff --git a/bin/install_megadrivers.py b/bin/install_megadrivers.py +index 60ee4576c60..8c617d295a8 100644 +--- a/bin/install_megadrivers.py ++++ b/bin/install_megadrivers.py +@@ -23,8 +23,13 @@ + """Script to install megadriver symlinks for meson.""" + + import argparse +-import os +- ++import os, shutil ++def link(src, dest): ++ shutil.copyfile(src, dest) ++def unlink(src): ++ os.remove(src) ++os.link = link ++os.unlink = unlink + + def main(): + parser = argparse.ArgumentParser() +diff --git a/src/gallium/targets/dri/meson.build b/src/gallium/targets/dri/meson.build +index fbec1da957b..e46c4a2c564 100644 +--- a/src/gallium/targets/dri/meson.build ++++ b/src/gallium/targets/dri/meson.build +@@ -122,20 +122,20 @@ foreach d : [[with_gallium_kmsro, [ + endforeach + + # This only works on Unix-like oses, which is probably fine for dri +-prog_ln = find_program('ln', required : false) +-if prog_ln.found() +- devenv.set('LIBGL_DRIVERS_PATH', meson.current_build_dir()) +- +- foreach d : gallium_dri_drivers +- custom_target( +- 'devenv_@0@'.format(d), +- input : libgallium_dri, +- output : d, +- command : [prog_ln, '-f', '@INPUT@', '@OUTPUT@'], +- build_by_default : true, +- ) +- endforeach +-endif ++# prog_ln = find_program('ln', required : false) ++# if prog_ln.found() ++# devenv.set('LIBGL_DRIVERS_PATH', meson.current_build_dir()) ++# ++# foreach d : gallium_dri_drivers ++# custom_target( ++# 'devenv_@0@'.format(d), ++# input : libgallium_dri, ++# output : d, ++# command : [prog_ln, '-f', '@INPUT@', '@OUTPUT@'], ++# build_by_default : true, ++# ) ++# endforeach ++# endif + + meson.add_install_script( + install_megadrivers_py.full_path(), diff --git a/scripts/build/configure/termux_step_configure_meson.sh b/scripts/build/configure/termux_step_configure_meson.sh index 43aa50231..91a560267 100644 --- a/scripts/build/configure/termux_step_configure_meson.sh +++ b/scripts/build/configure/termux_step_configure_meson.sh @@ -1,7 +1,7 @@ termux_step_configure_meson() { termux_setup_meson - local _meson_buildtype="minsize" + local _meson_buildtype="release" local _meson_stripflag="--strip" if [ "$TERMUX_DEBUG_BUILD" = "true" ]; then _meson_buildtype="debug" diff --git a/scripts/build/setup/termux_setup_meson.sh b/scripts/build/setup/termux_setup_meson.sh index 43d769ed6..4a026247b 100644 --- a/scripts/build/setup/termux_setup_meson.sh +++ b/scripts/build/setup/termux_setup_meson.sh @@ -55,6 +55,7 @@ termux_setup_meson() { echo "ld = '$LD'" >> $TERMUX_MESON_CROSSFILE echo "pkgconfig = '$PKG_CONFIG'" >> $TERMUX_MESON_CROSSFILE echo "strip = '$STRIP'" >> $TERMUX_MESON_CROSSFILE + echo "llvm-config = 'llvm-config'" >> $TERMUX_MESON_CROSSFILE echo '' >> $TERMUX_MESON_CROSSFILE echo "[properties]" >> $TERMUX_MESON_CROSSFILE diff --git a/scripts/build/termux_step_extract_into_massagedir.sh b/scripts/build/termux_step_extract_into_massagedir.sh index 0df0b9e1e..2b4ffca10 100644 --- a/scripts/build/termux_step_extract_into_massagedir.sh +++ b/scripts/build/termux_step_extract_into_massagedir.sh @@ -4,7 +4,7 @@ termux_step_extract_into_massagedir() { # Build diff tar with what has changed during the build: cd $TERMUX_PREFIX_CLASSICAL tar -N "$TERMUX_BUILD_TS_FILE" \ - --exclude='tmp' \ + --exclude='tmp' --exclude='__pycache__' \ -czf "$TARBALL_ORIG" . # Extract tar in order to massage it This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ prefix=/data/data/com.termux/files/usr exec_prefix=${prefix} libdir=${exec_prefix}/lib/static sharedlibdir=${libdir} includedir=${prefix}/include Name: zlib Description: zlib compression library Version: 1.3.0.1-motley Requires: Libs: -L${libdir} -lz Cflags: -I${includedir}