|
| 1 | +# Files that are not directly tied to loaders |
| 2 | +src = files('IMG.c', 'IMG_WIC.c', 'IMG_stb.c') |
| 3 | + |
| 4 | +if use_imageio_backend |
| 5 | + add_languages( |
| 6 | + 'objc', |
| 7 | + native: false, |
| 8 | + ) |
| 9 | + src += files('IMG_ImageIO.m') |
| 10 | + deps += dependency( |
| 11 | + 'appleframeworks', |
| 12 | + modules: ['ApplicationServices'], |
| 13 | + ) |
| 14 | + |
| 15 | + imageio_provided_formats = ['png', 'jpg', 'tif', 'gif', 'tga'] |
| 16 | + if not get_option('force_builtin_bmp') |
| 17 | + imageio_provided_formats += 'bmp' |
| 18 | + endif |
| 19 | + |
| 20 | + foreach format_name : imageio_provided_formats |
| 21 | + if format_name not in backend_provided_loaders |
| 22 | + feature_args += '-D@0@_USES_IMAGEIO'.format(format_name.to_upper()) |
| 23 | + endif |
| 24 | + endforeach |
| 25 | + |
| 26 | + backend_provided_loaders += imageio_provided_formats |
| 27 | +endif |
| 28 | + |
| 29 | +if not use_imageio_backend and host_machine.system() == 'darwin' |
| 30 | + feature_args += '-DSDL_IMAGE_USE_COMMON_BACKEND' |
| 31 | +endif |
| 32 | + |
| 33 | +if use_wic_backend |
| 34 | + feature_args += '-DSDL_IMAGE_USE_WIC_BACKEND' |
| 35 | + deps += cc.find_library('windowscodecs') |
| 36 | + backend_provided_loaders += ['png', 'jpg', 'tif'] |
| 37 | +endif |
| 38 | + |
| 39 | +summary( |
| 40 | + { |
| 41 | + 'stb_image': use_stbimage_backend, |
| 42 | + 'Image I/O': use_imageio_backend, |
| 43 | + 'Windows Imaging Component': use_wic_backend, |
| 44 | + }, |
| 45 | + section: 'Backends', |
| 46 | +) |
| 47 | + |
| 48 | +# Loaders that don't depend on anything |
| 49 | +self_contained_loaders = [ |
| 50 | + 'bmp', |
| 51 | + 'gif', |
| 52 | + 'lbm', |
| 53 | + 'pcx', |
| 54 | + 'pnm', |
| 55 | + 'qoi', |
| 56 | + 'svg', |
| 57 | + 'tga', |
| 58 | + 'xcf', |
| 59 | + 'xpm', |
| 60 | + 'xv', |
| 61 | +] |
| 62 | + |
| 63 | +foreach format_name : self_contained_loaders |
| 64 | + src += files('IMG_@0@.c'.format(format_name)) |
| 65 | + if get_option(format_name).allowed() |
| 66 | + feature_args += '-DLOAD_@0@'.format(format_name.to_upper()) |
| 67 | + summary( |
| 68 | + format_name, |
| 69 | + format_name in backend_provided_loaders ? 'handled by backend' : 'built-in loader', |
| 70 | + section: 'Formats', |
| 71 | + ) |
| 72 | + else |
| 73 | + summary( |
| 74 | + format_name, |
| 75 | + 'disabled', |
| 76 | + section: 'Formats', |
| 77 | + ) |
| 78 | + endif |
| 79 | +endforeach |
| 80 | + |
| 81 | +# Loaders that depend on external libraries |
| 82 | +external_dep_loaders = { |
| 83 | + 'avif': ['libavif'], |
| 84 | + 'jpg': ['libjpeg'], |
| 85 | + 'jxl': ['libjxl'], |
| 86 | + 'png': ['libpng'], |
| 87 | + 'tif': ['libtiff-4'], |
| 88 | + 'webp': ['libwebp', 'libwebpdemux'], |
| 89 | +} |
| 90 | + |
| 91 | +foreach format_name, library_names : external_dep_loaders |
| 92 | + src += files('IMG_@0@.c'.format(format_name)) |
| 93 | + if format_name in backend_provided_loaders |
| 94 | + if get_option(format_name).allowed() |
| 95 | + feature_args += '-DLOAD_@0@'.format(format_name.to_upper()) |
| 96 | + summary( |
| 97 | + format_name, |
| 98 | + 'handled by backend', |
| 99 | + section: 'Formats', |
| 100 | + ) |
| 101 | + else |
| 102 | + summary( |
| 103 | + format_name, |
| 104 | + 'disabled', |
| 105 | + section: 'Formats', |
| 106 | + ) |
| 107 | + endif |
| 108 | + else |
| 109 | + summary_name = format_name |
| 110 | + summary_value = 'handled by ' + ', '.join(library_names) |
| 111 | + |
| 112 | + foreach lib_name : library_names |
| 113 | + loader_library = dependency( |
| 114 | + lib_name, |
| 115 | + required: get_option(format_name), |
| 116 | + ) |
| 117 | + if loader_library.found() |
| 118 | + deps += loader_library |
| 119 | + feature_args += '-DLOAD_@0@'.format(format_name.to_upper()) |
| 120 | + else |
| 121 | + summary_value = 'disabled' |
| 122 | + endif |
| 123 | + endforeach |
| 124 | + summary( |
| 125 | + summary_name, |
| 126 | + summary_value, |
| 127 | + section: 'Formats', |
| 128 | + ) |
| 129 | + endif |
| 130 | +endforeach |
| 131 | + |
| 132 | +jpg_save_support = get_option('jpg_save').allowed() |
| 133 | +feature_args += '-DSDL_IMAGE_SAVE_JPG=@0@'.format(jpg_save_support.to_int()) |
| 134 | + |
| 135 | +png_save_support = get_option('png_save').allowed() |
| 136 | +feature_args += '-DSDL_IMAGE_SAVE_PNG=@0@'.format(png_save_support.to_int()) |
| 137 | + |
| 138 | +avif_save_support = get_option('avif_save').allowed() |
| 139 | +feature_args += '-DSDL_IMAGE_SAVE_AVIF=@0@'.format(png_save_support.to_int()) |
| 140 | + |
| 141 | +summary( |
| 142 | + { |
| 143 | + 'jpg': jpg_save_support, |
| 144 | + 'png': png_save_support, |
| 145 | + 'avif': avif_save_support, |
| 146 | + }, |
| 147 | + section: 'Image saving support', |
| 148 | +) |
0 commit comments