moz.build (7358B)
1 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- 2 # vim: set filetype=python: 3 # This Source Code Form is subject to the terms of the Mozilla Public 4 # License, v. 2.0. If a copy of the MPL was not distributed with this 5 # file, You can obtain one at http://mozilla.org/MPL/2.0/. 6 7 Library('dav1d') 8 9 LOCAL_INCLUDES += [ 10 '/third_party/dav1d', 11 '/third_party/dav1d/include', 12 '/third_party/dav1d/include/dav1d', 13 '/third_party/dav1d/src', 14 ] 15 16 EXPORTS.dav1d += [ 17 'config.h', 18 'version.h', 19 ] 20 21 # entrypoint source files 22 entrypoint_source_files = [ 23 '../../third_party/dav1d/src/lib.c', 24 '../../third_party/dav1d/src/thread_task.c', 25 ] 26 SOURCES += [f for f in entrypoint_source_files] 27 28 # Don't export DAV1D_API symbols from libxul 29 # see: third_party/dav1d/include/dav1d/common.h 30 DEFINES['DAV1D_API'] = '' 31 32 if CONFIG['MOZ_DAV1D_ASM']: 33 DIRS += ['asm'] 34 35 # Store the stack alignment that will be used. 36 stack_alignment = 0 37 38 # Default stack alignment can be 4 bytes on x86. 39 if CONFIG['TARGET_CPU'] == 'x86': 40 if CONFIG['OS_TARGET'] == 'WINNT': 41 # Allow the default to avoid crashes 42 stack_alignment = 4 43 else: 44 # Update stack alignment to 16 bytes. 45 stack_alignment = 16 46 if CONFIG['CC_TYPE'] == 'clang': 47 CFLAGS += ['-mstack-alignment=16'] 48 for ep in entrypoint_source_files: 49 SOURCES[ep].flags += ['-mstackrealign'] 50 elif CONFIG['CC_TYPE'] == 'gcc': 51 CFLAGS += ['-mpreferred-stack-boundary=4'] 52 for ep in entrypoint_source_files: 53 SOURCES[ep].flags += ['-mincoming-stack-boundary=2'] 54 elif CONFIG['TARGET_CPU'] == 'arm': 55 stack_alignment = 4 56 elif CONFIG['TARGET_CPU'] in ('x86_64', 'aarch64'): 57 # The default stack alignment is 16 bytes. 58 stack_alignment = 16 59 else: 60 error('Cpu arch %s is not expected' % CONFIG['TARGET_CPU']) 61 62 # Set the macro here instead of config.h 63 if stack_alignment == 0: 64 error('Stack alignment cannot be zero.') 65 DEFINES['STACK_ALIGNMENT'] = stack_alignment 66 67 if CONFIG['OS_TARGET'] == 'Linux': 68 # For fuzzing, We only support building on Linux currently. 69 include('/tools/fuzzing/libfuzzer-config.mozbuild') 70 if CONFIG['FUZZING_INTERFACES']: 71 TEST_DIRS += [ 72 'test/fuzztest' 73 ] 74 75 # common sources 76 SOURCES += [ 77 '../../third_party/dav1d/src/cdf.c', 78 '../../third_party/dav1d/src/cpu.c', 79 '../../third_party/dav1d/src/ctx.c', 80 '../../third_party/dav1d/src/data.c', 81 '../../third_party/dav1d/src/decode.c', 82 '../../third_party/dav1d/src/dequant_tables.c', 83 '../../third_party/dav1d/src/getbits.c', 84 '../../third_party/dav1d/src/intra_edge.c', 85 '../../third_party/dav1d/src/itx_1d.c', 86 '../../third_party/dav1d/src/lf_mask.c', 87 '../../third_party/dav1d/src/log.c', 88 '../../third_party/dav1d/src/mem.c', 89 '../../third_party/dav1d/src/msac.c', 90 '../../third_party/dav1d/src/obu.c', 91 '../../third_party/dav1d/src/pal.c', 92 '../../third_party/dav1d/src/picture.c', 93 '../../third_party/dav1d/src/qm.c', 94 '../../third_party/dav1d/src/ref.c', 95 '../../third_party/dav1d/src/refmvs.c', 96 '../../third_party/dav1d/src/scan.c', 97 '../../third_party/dav1d/src/tables.c', 98 '../../third_party/dav1d/src/warpmv.c', 99 '../../third_party/dav1d/src/wedge.c', 100 ] 101 102 # includes src 103 EXPORTS.dav1d.src += [ 104 '../../third_party/dav1d/src/cdf.h', 105 '../../third_party/dav1d/src/cpu.h', 106 '../../third_party/dav1d/src/ctx.h', 107 '../../third_party/dav1d/src/data.h', 108 '../../third_party/dav1d/src/decode.h', 109 '../../third_party/dav1d/src/dequant_tables.h', 110 '../../third_party/dav1d/src/filmgrain.h', 111 '../../third_party/dav1d/src/getbits.h', 112 '../../third_party/dav1d/src/intra_edge.h', 113 '../../third_party/dav1d/src/lf_mask.h', 114 '../../third_party/dav1d/src/log.h', 115 '../../third_party/dav1d/src/mem.h', 116 '../../third_party/dav1d/src/msac.h', 117 '../../third_party/dav1d/src/obu.h', 118 '../../third_party/dav1d/src/picture.h', 119 '../../third_party/dav1d/src/qm.h', 120 '../../third_party/dav1d/src/ref.h', 121 '../../third_party/dav1d/src/refmvs.h', 122 '../../third_party/dav1d/src/scan.h', 123 '../../third_party/dav1d/src/tables.h', 124 '../../third_party/dav1d/src/thread.h', 125 '../../third_party/dav1d/src/warpmv.h', 126 '../../third_party/dav1d/src/wedge.h', 127 ] 128 129 # common BITDEPTH 8, 16 130 # All the files here should be *_tmpl.c, and the should not appear in SOURCES, 131 # since they require BITDEPTH to be defined 132 relative_path = '../../third_party/dav1d/src/' 133 bitdepth_basenames = [ 134 'cdef_apply_tmpl.c', 135 'cdef_tmpl.c', 136 'fg_apply_tmpl.c', 137 'filmgrain_tmpl.c', 138 'ipred_prepare_tmpl.c', 139 'ipred_tmpl.c', 140 'itx_tmpl.c', 141 'lf_apply_tmpl.c', 142 'loopfilter_tmpl.c', 143 'looprestoration_tmpl.c', 144 'lr_apply_tmpl.c', 145 'mc_tmpl.c', 146 'recon_tmpl.c' 147 ] 148 149 generated_files = [] 150 151 for f in bitdepth_basenames: 152 file_bd16 = '16bd_%s' % f 153 file_bd8 = '8bd_%s' % f 154 155 GeneratedFile(file_bd16, 156 script='generate_source.py', 157 entry_point='add_define', 158 inputs=[relative_path + f], 159 flags=['BITDEPTH', '16']) 160 GeneratedFile(file_bd8, 161 script='generate_source.py', 162 entry_point='add_define', 163 inputs=[relative_path + f], 164 flags=['BITDEPTH', '8']) 165 166 generated_files += [file_bd16, file_bd8] 167 168 for p in generated_files: 169 if p.endswith('.c'): 170 SOURCES += ['!%s' % p] 171 172 EXPORTS.dav1d.src += [ 173 '../../third_party/dav1d/src/cdef.h', 174 '../../third_party/dav1d/src/cdef_apply.h', 175 '../../third_party/dav1d/src/fg_apply.h', 176 '../../third_party/dav1d/src/ipred.h', 177 '../../third_party/dav1d/src/ipred_prepare.h', 178 '../../third_party/dav1d/src/itx.h', 179 '../../third_party/dav1d/src/itx_1d.h', 180 '../../third_party/dav1d/src/lf_apply.h', 181 '../../third_party/dav1d/src/loopfilter.h', 182 '../../third_party/dav1d/src/looprestoration.h', 183 '../../third_party/dav1d/src/lr_apply.h', 184 '../../third_party/dav1d/src/mc.h', 185 '../../third_party/dav1d/src/recon.h', 186 ] 187 188 # include/common 189 EXPORTS.dav1d += [ 190 '../../third_party/dav1d/include/common/attributes.h', 191 '../../third_party/dav1d/include/common/bitdepth.h', 192 '../../third_party/dav1d/include/common/dump.h', 193 '../../third_party/dav1d/include/common/frame.h', 194 '../../third_party/dav1d/include/common/intops.h', 195 '../../third_party/dav1d/include/common/validate.h', 196 ] 197 198 # include/dav1d 199 EXPORTS.dav1d += [ 200 '../../third_party/dav1d/include/dav1d/common.h', 201 '../../third_party/dav1d/include/dav1d/data.h', 202 '../../third_party/dav1d/include/dav1d/dav1d.h', 203 '../../third_party/dav1d/include/dav1d/headers.h', 204 '../../third_party/dav1d/include/dav1d/picture.h', 205 ] 206 207 if CONFIG['OS_TARGET'] == 'WINNT': 208 SOURCES += [ 209 '../../third_party/dav1d/src/win32/thread.c' 210 ] 211 212 if CONFIG['CC_TYPE'] == 'gcc': 213 LOCAL_INCLUDES += ['../../third_party/dav1d/include/compat/gcc/'] 214 EXPORTS.dav1d += ['../../third_party/dav1d/include/compat/gcc/stdatomic.h'] 215 216 FINAL_LIBRARY = 'xul' 217 218 # We allow warnings for third-party code that can be updated from upstream. 219 AllowCompilerWarnings()