From ea21c50a7b079288d225f2756c616fa73a0a426e Mon Sep 17 00:00:00 2001 From: Frankie Dintino Date: Wed, 8 Nov 2023 22:06:29 -0500 Subject: [PATCH] fixup --- setup.py | 15 +++++++- wheelbuild/config.sh | 3 +- winbuild/Findrav1e.cmake | 8 ++++ winbuild/build_prepare.py | 77 ++++++++++++++++++--------------------- 4 files changed, 58 insertions(+), 45 deletions(-) create mode 100644 winbuild/Findrav1e.cmake diff --git a/setup.py b/setup.py index 0d1f4b9..098fab6 100644 --- a/setup.py +++ b/setup.py @@ -28,6 +28,19 @@ def readme(): IS_DEBUG = hasattr(sys, "gettotalrefcount") PLATFORM_MINGW = os.name == "nt" and "GCC" in sys.version +libraries = ["avif"] +if sys.platform == "win32": + libraries.extend( + [ + "advapi32", + "bcrypt", + "ntdll", + "userenv", + "ws2_32", + "kernel32", + ] + ) + setup( name="pillow-avif-plugin", description="A pillow plugin that adds avif support via libavif", @@ -39,7 +52,7 @@ def readme(): "pillow_avif._avif", ["src/pillow_avif/_avif.c"], depends=["avif/avif.h"], - libraries=["avif"], + libraries=libraries, ), ], package_data={"": ["README.rst"]}, diff --git a/wheelbuild/config.sh b/wheelbuild/config.sh index 16c307d..b6beeec 100644 --- a/wheelbuild/config.sh +++ b/wheelbuild/config.sh @@ -4,8 +4,7 @@ set -eo pipefail CONFIG_DIR=$(abspath $(dirname "${BASH_SOURCE[0]}")) ARCHIVE_SDIR=pillow-avif-plugin-depends -LIBAVIF_VERSION=bef0bcb9613769ca3706b82c0c9e477b7711f42e -DAV1D_VERSION=1.2.1 +LIBAVIF_VERSION=0014b9a89524c4c503bde2ce03face83640902b8 RAV1E_VERSION=p20231003 CCACHE_VERSION=4.7.1 SCCACHE_VERSION=0.3.0 diff --git a/winbuild/Findrav1e.cmake b/winbuild/Findrav1e.cmake new file mode 100644 index 0000000..7d018b9 --- /dev/null +++ b/winbuild/Findrav1e.cmake @@ -0,0 +1,8 @@ +file(TO_CMAKE_PATH "${AVIF_RAV1E_ROOT}" RAV1E_ROOT_PATH) +add_library(rav1e STATIC IMPORTED GLOBAL) +set_target_properties(rav1e PROPERTIES + IMPORTED_LOCATION "${RAV1E_ROOT_PATH}/lib/rav1e.lib" + AVIF_LOCAL ON + INTERFACE_INCLUDE_DIRECTORIES "${RAV1E_ROOT_PATH}/inc/rav1e" +) +add_library(rav1e::rav1e ALIAS rav1e) diff --git a/winbuild/build_prepare.py b/winbuild/build_prepare.py index 27dd90d..7711f4b 100644 --- a/winbuild/build_prepare.py +++ b/winbuild/build_prepare.py @@ -180,54 +180,46 @@ def cmd_msbuild( }, "libavif": { "url": ( - "https://github.com/AOMediaCodec/libavif/archive/" - "a7a404cccc50dc3e25d684dfb1251bac0c1cf0aa.zip" + "https://github.com/fdintino/libavif/archive/" + "0014b9a89524c4c503bde2ce03face83640902b8.zip" ), - "filename": "libavif-a7a404cccc50dc3e25d684dfb1251bac0c1cf0aa.zip", - "dir": "libavif-a7a404cccc50dc3e25d684dfb1251bac0c1cf0aa", + "filename": "libavif-0014b9a89524c4c503bde2ce03face83640902b8.zip", + "dir": "libavif-0014b9a89524c4c503bde2ce03face83640902b8", "license": "LICENSE", "build": [ - cmd_mkdir(r"ext\rav1e\build.libavif\usr"), - cmd_xcopy(r"..\rav1e-windows-msvc-sdk", r"ext\rav1e\build.libavif\usr"), - cmd_cd("ext"), - "@echo ::group::Building SVT-AV1", - cmd_rmdir("SVT-AV1"), - "cmd.exe /c svt.cmd", - "@echo ::endgroup::", - "@echo ::group::Building aom", - cmd_rmdir("aom"), - 'cmd.exe /c "aom.cmd"', - "@echo ::endgroup::", - "@echo ::group::Building dav1d", - cmd_rmdir("dav1d"), - 'cmd.exe /c "dav1d.cmd"', - "@echo ::endgroup::", - "@echo ::group::Building libyuv", - cmd_rmdir("libyuv"), - 'cmd.exe /c "libyuv.cmd"', - "@echo ::endgroup::", - "@echo ::group::Building libsharpyuv", - cmd_rmdir("libsharpyuv"), - 'cmd.exe /c "libsharpyuv.cmd"', - "@echo ::endgroup::", - "@echo ::group::Building libavif", - cmd_cd(".."), - *cmds_cmake( - "avif", - "-DBUILD_SHARED_LIBS=OFF", - "-DAVIF_CODEC_AOM=ON", - "-DAVIF_LOCAL_AOM=ON", - "-DAVIF_LOCAL_LIBYUV=ON", - "-DAVIF_LOCAL_LIBSHARPYUV=ON", - "-DAVIF_CODEC_RAV1E=ON", - "-DAVIF_CODEC_DAV1D=ON", - "-DAVIF_LOCAL_DAV1D=ON", - "-DAVIF_CODEC_SVT=ON", - "-DAVIF_LOCAL_SVT=ON", + cmd_mkdir("build.pillow"), + cmd_cd("build.pillow"), + " ".join( + [ + "{cmake}", + "-DCMAKE_BUILD_TYPE=Release", + "-DCMAKE_VERBOSE_MAKEFILE=ON", + "-DCMAKE_RULE_MESSAGES:BOOL=OFF", # for NMake + "-DCMAKE_C_COMPILER=cl.exe", # for Ninja + "-DCMAKE_CXX_COMPILER=cl.exe", # for Ninja + "-DCMAKE_C_FLAGS=-nologo", + "-DCMAKE_CXX_FLAGS=-nologo", + "-DBUILD_SHARED_LIBS=OFF", + "-DAVIF_CODEC_AOM=ON", + "-DAVIF_LOCAL_AOM=ON", + "-DAVIF_LOCAL_LIBYUV=ON", + "-DAVIF_LOCAL_LIBSHARPYUV=ON", + "-DAVIF_CODEC_RAV1E=ON", + "-DAVIF_RAV1E_ROOT={build_dir}", + "-DCMAKE_MODULE_PATH={winbuild_dir_cmake}", + "-DAVIF_CODEC_DAV1D=ON", + "-DAVIF_LOCAL_DAV1D=ON", + "-DAVIF_CODEC_SVT=ON", + "-DAVIF_LOCAL_SVT=ON", + '-G "Ninja"', + "..", + ] ), + "ninja -v", + cmd_cd(".."), cmd_xcopy("include", "{inc_dir}"), ], - "libs": [r"avif.lib"], + "libs": [r"build.pillow\avif.lib"], }, } @@ -562,6 +554,7 @@ def install_meson(): # Pillow paths "pillow_dir": pillow_dir, "winbuild_dir": winbuild_dir, + "winbuild_dir_cmake": winbuild_dir.replace("\\", "/"), # Build paths "build_dir": args.build_dir, "inc_dir": inc_dir,