@@ -94,15 +94,15 @@ func buildLibraryOrder() []*Library {
9494 }
9595
9696 var result []* Library
97- var ffmpegLib * Library
97+ ffmpegSeen := false
9898 for len (queue ) > 0 {
9999 // Pop from queue
100100 current := queue [0 ]
101101 queue = queue [1 :]
102102
103103 // Hold FFmpeg aside to add at the end
104- if current . Name == " ffmpeg" {
105- ffmpegLib = current
104+ if current == ffmpeg {
105+ ffmpegSeen = true
106106 } else {
107107 result = append (result , current )
108108 }
@@ -126,8 +126,8 @@ func buildLibraryOrder() []*Library {
126126 for _ , lib := range result {
127127 processed [lib ] = true
128128 }
129- if ffmpegLib != nil {
130- processed [ffmpegLib ] = true
129+ if ffmpegSeen {
130+ processed [ffmpeg ] = true
131131 }
132132
133133 fmt .Fprintf (os .Stderr , "\n Libraries stuck in cycle:\n " )
@@ -152,8 +152,8 @@ func buildLibraryOrder() []*Library {
152152 }
153153
154154 // Always add FFmpeg last as it depends on all other libraries
155- if ffmpegLib != nil {
156- result = append (result , ffmpegLib )
155+ if ffmpegSeen {
156+ result = append (result , ffmpeg )
157157 }
158158
159159 return result
@@ -616,15 +616,7 @@ var rav1e = &Library{
616616 // On macOS, add SDK library path for any native dependencies
617617 if runtime .GOOS == "darwin" {
618618 cgoCflags := os .Getenv ("CGO_CFLAGS" )
619- // Extract SDK path from CGO_CFLAGS (-isysroot <path>)
620- var sdkPath string
621- parts := strings .Fields (cgoCflags )
622- for i , p := range parts {
623- if p == "-isysroot" && i + 1 < len (parts ) {
624- sdkPath = parts [i + 1 ]
625- break
626- }
627- }
619+ sdkPath := extractSDKPath (cgoCflags )
628620
629621 if sdkPath != "" {
630622 sdkLibPath := filepath .Join (sdkPath , "usr" , "lib" )
@@ -840,28 +832,16 @@ var ffmpeg = &Library{
840832// CollectFFmpegEnables collects --enable-* flags from all enabled external libraries
841833// This must be called AFTER AllLibraries is initialized to inject the enables into ffmpeg's ConfigureArgs
842834func CollectFFmpegEnables () {
843- // Find the ffmpeg library
844- var ffmpegLib * Library
845- for _ , lib := range AllLibraries {
846- if lib .Name == "ffmpeg" {
847- ffmpegLib = lib
848- break
849- }
850- }
851- if ffmpegLib == nil {
852- return
853- }
854-
855835 // Wrap the original ConfigureArgs function
856- originalConfigureArgs := ffmpegLib .ConfigureArgs
857- ffmpegLib .ConfigureArgs = func (os string ) []string {
836+ originalConfigureArgs := ffmpeg .ConfigureArgs
837+ ffmpeg .ConfigureArgs = func (os string ) []string {
858838 // Get base args from original function
859839 args := originalConfigureArgs (os )
860840
861841 // Collect and add --enable-* flags from all enabled external libraries
862842 for _ , lib := range AllLibraries {
863843 // Skip ffmpeg itself and libraries that are disabled or shouldn't build on current platform
864- if lib . Name == " ffmpeg" || ! lib .ShouldBuild () {
844+ if lib == ffmpeg || ! lib .ShouldBuild () {
865845 continue
866846 }
867847 // Add all FFmpeg enable flags for this library
0 commit comments