| 1 |
|
| 2 |
from misc.utility.scons_hints import * |
| 3 |
|
| 4 |
Import("env") |
| 5 |
Import("env_modules") |
| 6 |
|
| 7 |
env_jpg = env_modules.Clone() |
| 8 |
|
| 9 |
thirdparty_obj = [] |
| 10 |
|
| 11 |
if env["builtin_libjpeg_turbo"]: |
| 12 |
thirdparty_dir = "#thirdparty/libjpeg-turbo" |
| 13 |
|
| 14 |
thirdparty_sources_common = [ |
| 15 |
"jaricom.c", |
| 16 |
"jcapimin.c", |
| 17 |
"jcarith.c", |
| 18 |
"jchuff.c", |
| 19 |
"jcicc.c", |
| 20 |
"jcinit.c", |
| 21 |
"jcmarker.c", |
| 22 |
"jcmaster.c", |
| 23 |
"jcomapi.c", |
| 24 |
"jcparam.c", |
| 25 |
"jcphuff.c", |
| 26 |
"jctrans.c", |
| 27 |
"jdapimin.c", |
| 28 |
"jdarith.c", |
| 29 |
"jdatadst.c", |
| 30 |
"jdatadst-tj.c", |
| 31 |
"jdatasrc.c", |
| 32 |
"jdatasrc-tj.c", |
| 33 |
"jdhuff.c", |
| 34 |
"jdicc.c", |
| 35 |
"jdinput.c", |
| 36 |
"jdmarker.c", |
| 37 |
"jdmaster.c", |
| 38 |
"jdphuff.c", |
| 39 |
"jdtrans.c", |
| 40 |
"jerror.c", |
| 41 |
"jfdctflt.c", |
| 42 |
"jmemmgr.c", |
| 43 |
"jmemnobs.c", |
| 44 |
"jpeg_nbits.c", |
| 45 |
"transupp.c", |
| 46 |
"turbojpeg.c", |
| 47 |
] |
| 48 |
|
| 49 |
thirdparty_sources_bit_dependent = [ |
| 50 |
"jcapistd.c", |
| 51 |
"jccoefct.c", |
| 52 |
"jccolor.c", |
| 53 |
"jcdctmgr.c", |
| 54 |
"jcmainct.c", |
| 55 |
"jcprepct.c", |
| 56 |
"jcsample.c", |
| 57 |
"jdcoefct.c", |
| 58 |
"jdcolor.c", |
| 59 |
"jdapistd.c", |
| 60 |
"jddctmgr.c", |
| 61 |
"jdmainct.c", |
| 62 |
"jdmerge.c", |
| 63 |
"jdpostct.c", |
| 64 |
"jdsample.c", |
| 65 |
"jfdctfst.c", |
| 66 |
"jfdctint.c", |
| 67 |
"jidctflt.c", |
| 68 |
"jidctfst.c", |
| 69 |
"jidctint.c", |
| 70 |
"jidctred.c", |
| 71 |
"jutils.c", |
| 72 |
"jquant1.c", |
| 73 |
"jquant2.c", |
| 74 |
] |
| 75 |
|
| 76 |
thirdparty_sources_by_bits = { |
| 77 |
8: list(thirdparty_sources_bit_dependent), |
| 78 |
12: list(thirdparty_sources_bit_dependent), |
| 79 |
} |
| 80 |
|
| 81 |
def source_paths(files): |
| 82 |
return [thirdparty_dir + "/src/" + f for f in files] |
| 83 |
|
| 84 |
env_jpg.Prepend(CPPPATH=[thirdparty_dir + "/src"]) |
| 85 |
|
| 86 |
def add_bit_depth(bit_depth: int): |
| 87 |
env_bit_depth = env_jpg.Clone() |
| 88 |
env_bit_depth.disable_warnings() |
| 89 |
env_bit_depth["OBJSUFFIX"] = f"_{bit_depth}{env_bit_depth['OBJSUFFIX']}" |
| 90 |
env_bit_depth.Append(CPPDEFINES=[f"BITS_IN_JSAMPLE={bit_depth}"]) |
| 91 |
env_bit_depth.add_source_files(thirdparty_obj, source_paths(thirdparty_sources_by_bits[bit_depth])) |
| 92 |
|
| 93 |
add_bit_depth(8) |
| 94 |
add_bit_depth(12) |
| 95 |
|
| 96 |
env_thirdparty = env_jpg.Clone() |
| 97 |
env_thirdparty.disable_warnings() |
| 98 |
env_thirdparty.add_source_files(thirdparty_obj, source_paths(thirdparty_sources_common)) |
| 99 |
env.modules_sources += thirdparty_obj |
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
module_obj = [] |
| 105 |
|
| 106 |
env_jpg.add_source_files(module_obj, "*.cpp") |
| 107 |
env.modules_sources += module_obj |
| 108 |
|
| 109 |
|
| 110 |
env.Depends(module_obj, thirdparty_obj) |