@@ -127,7 +127,7 @@ interface ProjectDescription {
127127 minor_define : string ;
128128 patch_define : string ;
129129 header_paths : string [ ] ;
130- header_filename : string ;
130+ header_filenames : string [ ] ;
131131 git_url : string ;
132132 repo_owner : string ;
133133 repo_name : string ;
@@ -140,17 +140,17 @@ export class VersionExtractor {
140140 minor_define : string ;
141141 patch_define : string ;
142142 header_paths : string [ ] ;
143- header_filename : string ;
143+ header_filenames : string [ ] ;
144144
145145 constructor ( desc : ProjectDescription ) {
146146 this . major_define = desc . major_define ;
147147 this . minor_define = desc . minor_define ;
148148 this . patch_define = desc . patch_define ;
149149 this . header_paths = desc . header_paths ;
150- this . header_filename = desc . header_filename ;
150+ this . header_filenames = desc . header_filenames ;
151151 }
152152
153- extract_from_header_path ( path : string ) : Version {
153+ extract_from_header_path ( path : string ) : Version | null {
154154 if ( ! fs . existsSync ( path ) ) {
155155 throw new SetupSdlError ( `Cannot find ${ path } ` ) ;
156156 }
@@ -161,23 +161,23 @@ export class VersionExtractor {
161161 new RegExp ( `#define[ \\t]+${ this . major_define } [ \\t]+([0-9]+)` ) ,
162162 ) ;
163163 if ( ! match_major ) {
164- throw new SetupSdlError ( `Unable to extract major version from ${ path } ` ) ;
164+ return null ;
165165 }
166166 const major_version = Number ( match_major [ 1 ] ) ;
167167
168168 const match_minor = contents . match (
169169 new RegExp ( `#define[ \\t]+${ this . minor_define } [ \\t]+([0-9]+)` ) ,
170170 ) ;
171171 if ( ! match_minor ) {
172- throw new SetupSdlError ( `Unable to extract minor version from ${ path } ` ) ;
172+ return null ;
173173 }
174174 const minor_version = Number ( match_minor [ 1 ] ) ;
175175
176176 const match_patch = contents . match (
177177 new RegExp ( `#define[ \\t]+${ this . patch_define } [ \\t]+([0-9]+)` ) ,
178178 ) ;
179179 if ( ! match_patch ) {
180- throw new SetupSdlError ( `Unable to extract patch version from ${ path } ` ) ;
180+ return null ;
181181 }
182182 const patch_version = Number ( match_patch [ 1 ] ) ;
183183
@@ -191,11 +191,17 @@ export class VersionExtractor {
191191 extract_from_install_prefix ( path : string ) : Version {
192192 const version = ( ( ) => {
193193 for ( const infix_path of this . header_paths ) {
194- const hdr_path = `${ path } /${ infix_path } /${ this . header_filename } ` ;
195- if ( ! fs . existsSync ( hdr_path ) ) {
196- continue ;
194+ for ( const header_filename of this . header_filenames ) {
195+ const hdr_path = `${ path } /${ infix_path } /${ header_filename } ` ;
196+ if ( ! fs . existsSync ( hdr_path ) ) {
197+ continue ;
198+ }
199+ const version = this . extract_from_header_path ( hdr_path ) ;
200+ if ( version == null ) {
201+ continue ;
202+ }
203+ return version ;
197204 }
198- return this . extract_from_header_path ( hdr_path ) ;
199205 }
200206 throw new SetupSdlError ( `Could not extract version from ${ path } .` ) ;
201207 } ) ( ) ;
@@ -212,9 +218,9 @@ export const project_descriptions: { [key in Project]: ProjectDescription } = {
212218 deps : [ ] ,
213219 major_define : "SDL_MAJOR_VERSION" ,
214220 minor_define : "SDL_MINOR_VERSION" ,
215- patch_define : "SDL_PATCHLEVEL" ,
221+ patch_define : "(?: SDL_PATCHLEVEL|SDL_MICRO_VERSION) " ,
216222 header_paths : [ "include/SDL3" , "include/SDL2" ] ,
217- header_filename : " SDL_version.h",
223+ header_filenames : [ "SDL.h" , " SDL_version.h"] ,
218224 git_url : "https://github.com/libsdl-org/SDL.git" ,
219225 repo_owner : "libsdl-org" ,
220226 repo_name : "SDL" ,
@@ -293,7 +299,7 @@ export const project_descriptions: { [key in Project]: ProjectDescription } = {
293299 minor_define : "SDL_IMAGE_MINOR_VERSION" ,
294300 patch_define : "SDL_IMAGE_PATCHLEVEL" ,
295301 header_paths : [ "include/SDL3_image" , "include/SDL2" ] ,
296- header_filename : "SDL_image.h" ,
302+ header_filenames : [ "SDL_image.h" ] ,
297303 git_url : "https://github.com/libsdl-org/SDL_image.git" ,
298304 repo_owner : "libsdl-org" ,
299305 repo_name : "SDL_image" ,
@@ -308,7 +314,7 @@ export const project_descriptions: { [key in Project]: ProjectDescription } = {
308314 minor_define : "SDL_MIXER_MINOR_VERSION" ,
309315 patch_define : "SDL_MIXER_PATCHLEVEL" ,
310316 header_paths : [ "include/SDL3_mixer" , "include/SDL2" ] ,
311- header_filename : "SDL_mixer.h" ,
317+ header_filenames : [ "SDL_mixer.h" ] ,
312318 git_url : "https://github.com/libsdl-org/SDL_mixer.git" ,
313319 repo_owner : "libsdl-org" ,
314320 repo_name : "SDL_mixer" ,
@@ -323,7 +329,7 @@ export const project_descriptions: { [key in Project]: ProjectDescription } = {
323329 minor_define : "SDL_NET_MINOR_VERSION" ,
324330 patch_define : "SDL_NET_PATCHLEVEL" ,
325331 header_paths : [ "include/SDL3_net" , "include/SDL2" , "include" ] ,
326- header_filename : "SDL_net.h" ,
332+ header_filenames : [ "SDL_net.h" ] ,
327333 git_url : "https://github.com/libsdl-org/SDL_net.git" ,
328334 repo_owner : "libsdl-org" ,
329335 repo_name : "SDL_net" ,
@@ -338,7 +344,7 @@ export const project_descriptions: { [key in Project]: ProjectDescription } = {
338344 minor_define : "SDL_RTF_MINOR_VERSION" ,
339345 patch_define : "SDL_RTF_PATCHLEVEL" ,
340346 header_paths : [ "include/SDL3_rtf" , "include/SDL2" , "include" ] ,
341- header_filename : "SDL_rtf.h" ,
347+ header_filenames : [ "SDL_rtf.h" ] ,
342348 git_url : "https://github.com/libsdl-org/SDL_rtf.git" ,
343349 repo_owner : "libsdl-org" ,
344350 repo_name : "SDL_rtf" ,
@@ -353,7 +359,7 @@ export const project_descriptions: { [key in Project]: ProjectDescription } = {
353359 minor_define : "SDL_TTF_MINOR_VERSION" ,
354360 patch_define : "SDL_TTF_PATCHLEVEL" ,
355361 header_paths : [ "include/SDL3_ttf" , "include/SDL2" ] ,
356- header_filename : "SDL_ttf.h" ,
362+ header_filenames : [ "SDL_ttf.h" ] ,
357363 git_url : "https://github.com/libsdl-org/SDL_ttf.git" ,
358364 repo_owner : "libsdl-org" ,
359365 repo_name : "SDL_ttf" ,
0 commit comments