@@ -74,6 +74,13 @@ def run(cmd: list[str], env=None) -> None:
7474 subprocess .run (cmd , check = True , env = env , stderr = subprocess .PIPE , text = True )
7575 except subprocess .CalledProcessError as e :
7676 print (f"stderr: { e .stderr } " )
77+ # Print config.log tail if it exists (for ffmpeg configure debugging)
78+ config_log = os .path .join (os .getcwd (), "ffbuild" , "config.log" )
79+ if os .path .exists (config_log ):
80+ print (f"\n === Tail of { config_log } ===" )
81+ with open (config_log , "r" ) as f :
82+ lines = f .readlines ()
83+ print ("" .join (lines [- 100 :]))
7784 raise e
7885
7986
@@ -204,20 +211,31 @@ def _build_with_autoconf(self, package: Package, for_builder: bool) -> None:
204211 env = self ._environment (for_builder = for_builder )
205212 prefix = self ._prefix (for_builder = for_builder )
206213 configure_args = [
207- "--disable-static" ,
208214 "--enable-shared" ,
209215 "--libdir=" + self ._mangle_path (os .path .join (prefix , "lib" )),
210216 "--prefix=" + self ._mangle_path (prefix ),
211217 ]
212218
219+ if package .name == "x264" :
220+ # Disable asm on Windows ARM64 (no nasm available)
221+ if platform .system () == "Windows" and platform .machine ().lower () in {"arm64" , "aarch64" }:
222+ configure_args .append ("--disable-asm" )
223+ # Specify host to ensure correct resource compiler target
224+ configure_args .append ("--host=aarch64-w64-mingw32" )
225+
213226 if package .name == "vpx" :
214227 if platform .system () == "Darwin" :
215228 if platform .machine () == "arm64" :
216229 configure_args += ["--target=arm64-darwin20-gcc" ]
217230 elif platform .machine () == "x86_64" :
218231 configure_args += ["--target=x86_64-darwin20-gcc" ]
219232 elif platform .system () == "Windows" :
220- configure_args += ["--target=x86_64-win64-gcc" ]
233+ if platform .machine ().lower () in {"arm64" , "aarch64" }:
234+ configure_args += ["--target=arm64-win64-gcc" ]
235+ # Link pthread for ARM64 Windows
236+ prepend_env (env , "LDFLAGS" , "-lpthread" )
237+ else :
238+ configure_args += ["--target=x86_64-win64-gcc" ]
221239 elif platform .system () == "Linux" :
222240 if "RUNNER_ARCH" in os .environ :
223241 prepend_env (env , "CFLAGS" , "-pthread" )
@@ -229,9 +247,24 @@ def _build_with_autoconf(self, package: Package, for_builder: bool) -> None:
229247 prepend_env (
230248 env ,
231249 "PKG_CONFIG_PATH" ,
232- "/c/msys64/usr/lib/pkgconfig" ,
233- separator = ":" ,
250+ "C:/msys64/usr/lib/pkgconfig" ,
251+ separator = ";" ,
252+ )
253+ # Debug: print pkg-config info
254+ print (f"PKG_CONFIG_PATH: { env .get ('PKG_CONFIG_PATH' )} " )
255+ print (f"PKG_CONFIG: { env .get ('PKG_CONFIG' )} " )
256+ import glob
257+ pc_files = glob .glob (os .path .join (prefix , "lib" , "pkgconfig" , "*.pc" ))
258+ print (f"PC files in { prefix } /lib/pkgconfig: { pc_files } " )
259+ # Test pkgconf directly
260+ import subprocess
261+ result = subprocess .run (
262+ ["pkgconf" , "--modversion" , "dav1d" ],
263+ env = env ,
264+ capture_output = True ,
265+ text = True
234266 )
267+ print (f"pkgconf dav1d test: returncode={ result .returncode } , stdout={ result .stdout } , stderr={ result .stderr } " )
235268
236269 # build package
237270 os .makedirs (package_build_path , exist_ok = True )
@@ -419,18 +452,34 @@ def _environment(self, *, for_builder: bool) -> dict[str, str]:
419452 prepend_env (
420453 env , "LDFLAGS" , "-L" + self ._mangle_path (os .path .join (prefix , "lib" ))
421454 )
455+ # Use ; as separator on Windows, : on Unix
456+ # Don't mangle PKG_CONFIG_PATH on Windows - pkgconf expects native paths
457+ pkg_config_sep = ";" if platform .system () == "Windows" else ":"
458+ pkg_config_path = os .path .join (prefix , "lib" , "pkgconfig" )
459+ if platform .system () != "Windows" :
460+ pkg_config_path = self ._mangle_path (pkg_config_path )
422461 prepend_env (
423462 env ,
424463 "PKG_CONFIG_PATH" ,
425- self . _mangle_path ( os . path . join ( prefix , "lib" , "pkgconfig" )) ,
426- separator = ":" ,
464+ pkg_config_path ,
465+ separator = pkg_config_sep ,
427466 )
428467
429468 if platform .system () == "Darwin" and not for_builder :
430469 arch_flags = os .environ ["ARCHFLAGS" ]
431470 for var in ["CFLAGS" , "CXXFLAGS" , "LDFLAGS" ]:
432471 prepend_env (env , var , arch_flags )
433472
473+ # Use clang on Windows ARM64 (CLANGARM64 environment)
474+ if platform .system () == "Windows" and platform .machine ().lower () in {"arm64" , "aarch64" }:
475+ env ["CC" ] = "clang"
476+ env ["CXX" ] = "clang++"
477+ # Use LLVM windres to compile Windows resources for ARM64
478+ env ["RC" ] = "llvm-windres"
479+ env ["WINDRES" ] = "llvm-windres"
480+ # Use MinGW pkgconf instead of MSYS pkg-config
481+ env ["PKG_CONFIG" ] = "pkgconf"
482+
434483 return env
435484
436485 def _mangle_path (self , path : str ) -> str :
0 commit comments