Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use cmds_cmake #9

Merged
merged 4 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .github/workflows/test-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,6 @@ jobs:
if: steps.build-cache.outputs.cache-hit != 'true'
run: "& winbuild\\build\\build_dep_libpng.cmd"

- name: Build dependencies / meson
if: steps.build-cache.outputs.cache-hit != 'true'
run: "& winbuild\\build\\install_meson.cmd"

- name: Build dependencies / libavif
if: steps.build-cache.outputs.cache-hit != 'true'
run: "& winbuild\\build\\build_dep_libavif.cmd"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/wheels-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ function build_harfbuzz {
function build_libavif {
if [ -e libavif-stamp ]; then return; fi

if [[ -z "$IS_MACOS" ]] && ([[ "$MB_ML_VER" == 2014 ]] || [[ "$PLAT" == "aarch64" ]]); then
if [[ "$MB_ML_VER" == 2014 ]] || [[ "$PLAT" == "aarch64" ]]; then
# Once Amazon 2 is EOL on 30 June 2025, manylinux2014 will no longer be needed
# Once GitHub Actions supports aarch64 without emulation, this will no longer needed as building will be faster
if [[ "$PLAT" == "aarch64" ]]; then
Expand Down
1 change: 1 addition & 0 deletions depends/install_libavif.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ fi

cmake -G Ninja -S . -B build \
-DCMAKE_INSTALL_PREFIX=$PREFIX \
-DAVIF_LIBSHARPYUV=LOCAL \
-DAVIF_LIBYUV=LOCAL \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_NAME_DIR=$PREFIX/lib \
Expand Down
72 changes: 18 additions & 54 deletions winbuild/build_prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ def cmd_msbuild(
"TIFF": "4.6.0",
"XZ": "5.6.3",
"ZLIB": "1.3.1",
"MESON": "1.6.0",
"LIBAVIF": "1.1.1",
}
V["LIBPNG_DOTLESS"] = V["LIBPNG"].replace(".", "")
Expand Down Expand Up @@ -405,35 +404,20 @@ def cmd_msbuild(
"dir": f"libavif-{V['LIBAVIF']}",
"license": "LICENSE",
"build": [
cmd_mkdir("build.pillow"),
cmd_cd("build.pillow"),
" ".join(
[
"{cmake}",
"-DCMAKE_BUILD_TYPE=Release",
"-DCMAKE_VERBOSE_MAKEFILE=ON",
"-DCMAKE_RULE_MESSAGES:BOOL=OFF",
"-DCMAKE_C_COMPILER=cl.exe",
"-DCMAKE_CXX_COMPILER=cl.exe",
"-DCMAKE_C_FLAGS=-nologo",
"-DCMAKE_CXX_FLAGS=-nologo",
"-DBUILD_SHARED_LIBS=OFF",
"-DAVIF_CODEC_AOM=LOCAL",
"-DAVIF_LIBYUV=LOCAL",
"-DAVIF_LIBSHARPYUV=LOCAL",
"-DAVIF_CODEC_RAV1E=LOCAL",
"-DCMAKE_MODULE_PATH={winbuild_dir_cmake}",
"-DAVIF_CODEC_DAV1D=LOCAL",
"-DAVIF_CODEC_SVT=LOCAL",
'-G "Ninja"',
"..",
]
f"{sys.executable} -m pip install meson",
*cmds_cmake(
"avif_static",
"-DBUILD_SHARED_LIBS=OFF",
"-DAVIF_CODEC_AOM=LOCAL",
"-DAVIF_LIBYUV=LOCAL",
"-DAVIF_LIBSHARPYUV=LOCAL",
"-DAVIF_CODEC_RAV1E=LOCAL",
"-DAVIF_CODEC_DAV1D=LOCAL",
"-DAVIF_CODEC_SVT=LOCAL",
),
"ninja -v",
cmd_cd(".."),
cmd_xcopy("include", "{inc_dir}"),
],
"libs": [r"build.pillow\avif.lib"],
"libs": ["avif.lib"],
},
}

Expand Down Expand Up @@ -663,19 +647,13 @@ def build_dep_all(disabled: list[str], prefs: dict[str, str], verbose: bool) ->
if dep_name in disabled:
print(f"Skipping disabled dependency {dep_name}")
continue

scripts = []
if dep_name == "libavif":
scripts.append("install_meson.cmd")
scripts.append(build_dep(dep_name, prefs, verbose))

for script in scripts:
if gha_groups:
lines.append(f"@echo ::group::Running {script}")
lines.append(rf'cmd.exe /c "{{build_dir}}\{script}"')
lines.append("if errorlevel 1 echo Build failed! && exit /B 1")
if gha_groups:
lines.append("@echo ::endgroup::")
script = build_dep(dep_name, prefs, verbose)
if gha_groups:
lines.append(f"@echo ::group::Running {script}")
lines.append(rf'cmd.exe /c "{{build_dir}}\{script}"')
lines.append("if errorlevel 1 echo Build failed! && exit /B 1")
if gha_groups:
lines.append("@echo ::endgroup::")
print()
lines.append("@echo All Pillow dependencies built successfully!")
write_script("build_dep_all.cmd", lines, prefs, verbose)
Expand Down Expand Up @@ -796,7 +774,6 @@ def main() -> None:
**arch_prefs,
# Pillow paths
"winbuild_dir": winbuild_dir,
"winbuild_dir_cmake": winbuild_dir.replace("\\", "/"),
# Build paths
"bin_dir": bin_dir,
"build_dir": args.build_dir,
Expand All @@ -818,19 +795,6 @@ def main() -> None:
print()

write_script(".gitignore", ["*"], prefs, args.verbose)
if "libavif" not in disabled:
write_script(
"install_meson.cmd",
[
r'call "{build_dir}\build_env.cmd"',
"@echo " + ("=" * 70),
f"@echo ==== {'Building meson':<60} ====",
"@echo " + ("=" * 70),
f"{sys.executable} -m pip install meson=={V['MESON']}",
],
prefs,
args.verbose,
)
build_env(prefs, args.verbose)
build_dep_all(disabled, prefs, args.verbose)

Expand Down
Loading