tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

meson.build (12690B)


      1 # Copyright © 2018-2019, VideoLAN and dav1d authors
      2 # All rights reserved.
      3 #
      4 # Redistribution and use in source and binary forms, with or without
      5 # modification, are permitted provided that the following conditions are met:
      6 #
      7 # 1. Redistributions of source code must retain the above copyright notice, this
      8 #    list of conditions and the following disclaimer.
      9 #
     10 # 2. Redistributions in binary form must reproduce the above copyright notice,
     11 #    this list of conditions and the following disclaimer in the documentation
     12 #    and/or other materials provided with the distribution.
     13 #
     14 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
     15 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     16 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     17 # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
     18 # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     19 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     20 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
     21 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     22 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
     23 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     24 
     25 #
     26 # Build definition for the dav1d library
     27 #
     28 
     29 # libdav1d source files
     30 libdav1d_sources = files(
     31    'cdf.c',
     32    'cpu.c',
     33    'ctx.c',
     34    'data.c',
     35    'decode.c',
     36    'dequant_tables.c',
     37    'getbits.c',
     38    'intra_edge.c',
     39    'itx_1d.c',
     40    'lf_mask.c',
     41    'lib.c',
     42    'log.c',
     43    'mem.c',
     44    'msac.c',
     45    'obu.c',
     46    'pal.c',
     47    'picture.c',
     48    'qm.c',
     49    'ref.c',
     50    'refmvs.c',
     51    'scan.c',
     52    'tables.c',
     53    'thread_task.c',
     54    'warpmv.c',
     55    'wedge.c',
     56 )
     57 
     58 # libdav1d bitdepth source files
     59 # These files are compiled for each bitdepth with
     60 # `BITDEPTH` defined to the currently built bitdepth.
     61 libdav1d_tmpl_sources = files(
     62    'cdef_apply_tmpl.c',
     63    'cdef_tmpl.c',
     64    'fg_apply_tmpl.c',
     65    'filmgrain_tmpl.c',
     66    'ipred_prepare_tmpl.c',
     67    'ipred_tmpl.c',
     68    'itx_tmpl.c',
     69    'lf_apply_tmpl.c',
     70    'loopfilter_tmpl.c',
     71    'looprestoration_tmpl.c',
     72    'lr_apply_tmpl.c',
     73    'mc_tmpl.c',
     74    'recon_tmpl.c',
     75 )
     76 
     77 libdav1d_arch_tmpl_sources = {}
     78 
     79 libdav1d_bitdepth_objs = []
     80 
     81 # ASM specific sources
     82 libdav1d_asm_objs = []
     83 # Arch-specific flags
     84 arch_flags = {}
     85 if is_asm_enabled
     86    if (host_machine.cpu_family() == 'aarch64' or
     87        host_machine.cpu_family().startswith('arm'))
     88 
     89        libdav1d_sources += files(
     90            'arm/cpu.c',
     91        )
     92        if (host_machine.cpu_family() == 'aarch64' or
     93            host_machine.cpu() == 'arm64')
     94            libdav1d_sources_asm = files(
     95                # itx.S is used for both 8 and 16 bpc.
     96                'arm/64/itx.S',
     97                'arm/64/looprestoration_common.S',
     98                'arm/64/msac.S',
     99                'arm/64/refmvs.S',
    100            )
    101 
    102            if dav1d_bitdepths.contains('8')
    103                libdav1d_sources_asm += files(
    104                    'arm/64/cdef.S',
    105                    'arm/64/filmgrain.S',
    106                    'arm/64/ipred.S',
    107                    'arm/64/loopfilter.S',
    108                    'arm/64/looprestoration.S',
    109                    'arm/64/mc.S',
    110                    'arm/64/mc_dotprod.S',
    111                )
    112            endif
    113 
    114            if dav1d_bitdepths.contains('16')
    115                libdav1d_sources_asm += files(
    116                    'arm/64/cdef16.S',
    117                    'arm/64/filmgrain16.S',
    118                    'arm/64/ipred16.S',
    119                    'arm/64/itx16.S',
    120                    'arm/64/loopfilter16.S',
    121                    'arm/64/looprestoration16.S',
    122                    'arm/64/mc16.S',
    123                    'arm/64/mc16_sve.S',
    124                )
    125            endif
    126        elif host_machine.cpu_family().startswith('arm')
    127            libdav1d_sources_asm = files(
    128                # itx.S is used for both 8 and 16 bpc.
    129                'arm/32/itx.S',
    130                'arm/32/looprestoration_common.S',
    131                'arm/32/msac.S',
    132                'arm/32/refmvs.S',
    133            )
    134 
    135            if dav1d_bitdepths.contains('8')
    136                libdav1d_sources_asm += files(
    137                    'arm/32/cdef.S',
    138                    'arm/32/filmgrain.S',
    139                    'arm/32/ipred.S',
    140                    'arm/32/loopfilter.S',
    141                    'arm/32/looprestoration.S',
    142                    'arm/32/mc.S',
    143                )
    144            endif
    145 
    146            if dav1d_bitdepths.contains('16')
    147                libdav1d_sources_asm += files(
    148                    'arm/32/cdef16.S',
    149                    'arm/32/filmgrain16.S',
    150                    'arm/32/ipred16.S',
    151                    'arm/32/itx16.S',
    152                    'arm/32/loopfilter16.S',
    153                    'arm/32/looprestoration16.S',
    154                    'arm/32/mc16.S',
    155                )
    156            endif
    157        endif
    158 
    159        if use_gaspp
    160            libdav1d_asm_objs = gaspp_gen.process(libdav1d_sources_asm)
    161        else
    162            libdav1d_sources += libdav1d_sources_asm
    163        endif
    164    elif host_machine.cpu_family().startswith('x86')
    165 
    166        libdav1d_sources += files(
    167            'x86/cpu.c',
    168        )
    169 
    170        # NASM source files
    171        libdav1d_sources_asm = files(
    172            'x86/cpuid.asm',
    173            'x86/msac.asm',
    174            'x86/pal.asm',
    175            'x86/refmvs.asm',
    176            'x86/itx_avx512.asm',
    177            'x86/cdef_avx2.asm',
    178            'x86/itx_avx2.asm',
    179            'x86/cdef_sse.asm',
    180            'x86/itx_sse.asm',
    181        )
    182 
    183        if dav1d_bitdepths.contains('8')
    184            libdav1d_sources_asm += files(
    185                'x86/cdef_avx512.asm',
    186                'x86/filmgrain_avx512.asm',
    187                'x86/ipred_avx512.asm',
    188                'x86/loopfilter_avx512.asm',
    189                'x86/looprestoration_avx512.asm',
    190                'x86/mc_avx512.asm',
    191                'x86/filmgrain_avx2.asm',
    192                'x86/ipred_avx2.asm',
    193                'x86/loopfilter_avx2.asm',
    194                'x86/looprestoration_avx2.asm',
    195                'x86/mc_avx2.asm',
    196                'x86/filmgrain_sse.asm',
    197                'x86/ipred_sse.asm',
    198                'x86/loopfilter_sse.asm',
    199                'x86/looprestoration_sse.asm',
    200                'x86/mc_sse.asm',
    201            )
    202        endif
    203 
    204        if dav1d_bitdepths.contains('16')
    205            libdav1d_sources_asm += files(
    206                'x86/cdef16_avx512.asm',
    207                'x86/filmgrain16_avx512.asm',
    208                'x86/ipred16_avx512.asm',
    209                'x86/itx16_avx512.asm',
    210                'x86/loopfilter16_avx512.asm',
    211                'x86/looprestoration16_avx512.asm',
    212                'x86/mc16_avx512.asm',
    213                'x86/cdef16_avx2.asm',
    214                'x86/filmgrain16_avx2.asm',
    215                'x86/ipred16_avx2.asm',
    216                'x86/itx16_avx2.asm',
    217                'x86/loopfilter16_avx2.asm',
    218                'x86/looprestoration16_avx2.asm',
    219                'x86/mc16_avx2.asm',
    220                'x86/cdef16_sse.asm',
    221                'x86/filmgrain16_sse.asm',
    222                'x86/ipred16_sse.asm',
    223                'x86/itx16_sse.asm',
    224                'x86/loopfilter16_sse.asm',
    225                'x86/looprestoration16_sse.asm',
    226                'x86/mc16_sse.asm',
    227            )
    228        endif
    229 
    230        # Compile the ASM sources with NASM
    231        libdav1d_asm_objs = nasm_gen.process(libdav1d_sources_asm)
    232    elif host_machine.cpu_family().startswith('loongarch')
    233        libdav1d_sources += files(
    234            'loongarch/cpu.c',
    235        )
    236 
    237        libdav1d_arch_tmpl_sources += {'default': files(
    238            'loongarch/looprestoration_inner.c',
    239        )}
    240 
    241        libdav1d_sources_asm = files(
    242            'loongarch/cdef.S',
    243            'loongarch/ipred.S',
    244            'loongarch/mc.S',
    245            'loongarch/loopfilter.S',
    246            'loongarch/looprestoration.S',
    247            'loongarch/msac.S',
    248            'loongarch/refmvs.S',
    249            'loongarch/itx.S',
    250        )
    251        libdav1d_asm_objs += libdav1d_sources_asm
    252    elif host_machine.cpu() == 'ppc64le'
    253        arch_flags += {'vsx': ['-maltivec', '-mvsx', '-DDAV1D_VSX']}
    254        libdav1d_sources += files(
    255            'ppc/cpu.c',
    256        )
    257        libdav1d_arch_tmpl_sources += {'vsx': files(
    258            'ppc/cdef_tmpl.c',
    259            'ppc/looprestoration_tmpl.c',
    260        )}
    261        arch_flags += {'pwr9': ['-mcpu=power9', '-DDAV1D_PWR9']}
    262        libdav1d_arch_tmpl_sources += {'pwr9': files(
    263            'ppc/itx_tmpl.c',
    264            'ppc/loopfilter_tmpl.c',
    265            'ppc/mc_tmpl.c',
    266        )}
    267    elif host_machine.cpu_family().startswith('riscv')
    268        libdav1d_sources += files(
    269            'riscv/cpu.c',
    270        )
    271        if host_machine.cpu_family() == 'riscv64'
    272            libdav1d_sources += files(
    273                'riscv/64/cpu.S',
    274                'riscv/64/pal.S',
    275            )
    276 
    277            if dav1d_bitdepths.contains('8')
    278                libdav1d_sources += files(
    279                    'riscv/64/cdef.S',
    280                    'riscv/64/ipred.S',
    281                    'riscv/64/itx.S',
    282                    'riscv/64/mc.S',
    283                )
    284            endif
    285 
    286            if dav1d_bitdepths.contains('16')
    287                libdav1d_sources += files(
    288                    'riscv/64/cdef16.S',
    289                    'riscv/64/ipred16.S',
    290                    'riscv/64/mc16.S',
    291                )
    292            endif
    293        endif
    294    endif
    295 endif
    296 
    297 
    298 
    299 libdav1d_rc_obj = []
    300 libdav1d_flags = []
    301 api_export_flags = []
    302 
    303 #
    304 # Windows .rc file and API export flags
    305 #
    306 
    307 if host_machine.system() == 'windows'
    308    if get_option('default_library') != 'static'
    309        rc_file = configure_file(
    310            input : 'dav1d.rc.in',
    311            output : 'dav1d.rc',
    312            configuration : rc_data
    313        )
    314 
    315        libdav1d_rc_obj = winmod.compile_resources(rc_file)
    316 
    317        api_export_flags = ['-DDAV1D_BUILDING_DLL']
    318    endif
    319 
    320    if (host_machine.cpu_family() == 'x86_64' and cc.get_id() == 'gcc')
    321        # We don't expect to reference data members from other DLLs without
    322        # dllimport attributes. Set the -mcmodel=small flag, which avoids
    323        # generating indirection via .refptr.<symname> for all potentially
    324        # dllimported variable references.
    325        libdav1d_flags += '-mcmodel=small'
    326    endif
    327 endif
    328 
    329 
    330 
    331 #
    332 # Library definitions
    333 #
    334 
    335 # Helper library for each bitdepth
    336 libdav1d_bitdepth_objs = []
    337 foreach bitdepth : dav1d_bitdepths
    338    libdav1d_bitdepth_objs += static_library(
    339        'dav1d_bitdepth_@0@'.format(bitdepth),
    340        libdav1d_tmpl_sources, config_h_target,
    341        include_directories: dav1d_inc_dirs,
    342        dependencies : [stdatomic_dependencies],
    343        c_args : ['-DBITDEPTH=@0@'.format(bitdepth)] + libdav1d_flags,
    344        install : false,
    345        build_by_default : false,
    346    ).extract_all_objects(recursive: true)
    347 endforeach
    348 
    349 # Helper library for each bitdepth and architecture-specific flags
    350 foreach bitdepth : dav1d_bitdepths
    351    foreach subarch : libdav1d_arch_tmpl_sources.keys()
    352        libdav1d_bitdepth_objs += static_library(
    353            'dav1d_arch_bitdepth_@0@_@1@'.format(bitdepth,subarch),
    354            libdav1d_arch_tmpl_sources[subarch], config_h_target,
    355            include_directories: dav1d_inc_dirs,
    356            dependencies : [stdatomic_dependencies],
    357            c_args : ['-DBITDEPTH=@0@'.format(bitdepth)] + libdav1d_flags + arch_flags.get(subarch, []),
    358            install : false,
    359            build_by_default : false,
    360        ).extract_all_objects(recursive: true)
    361    endforeach
    362 endforeach
    363 
    364 # The final dav1d library
    365 if host_machine.system() == 'windows'
    366    dav1d_soversion = ''
    367 else
    368    dav1d_soversion = dav1d_api_version_major
    369 endif
    370 
    371 libdav1d = library('dav1d',
    372    libdav1d_sources,
    373    libdav1d_asm_objs,
    374    libdav1d_rc_obj,
    375    rev_target,
    376    config_h_target,
    377 
    378    objects : [
    379        libdav1d_bitdepth_objs,
    380        ],
    381 
    382    include_directories : dav1d_inc_dirs,
    383    dependencies : [
    384        stdatomic_dependencies,
    385        thread_dependency,
    386        thread_compat_dep,
    387        libdl_dependency,
    388        ],
    389    c_args : [libdav1d_flags, api_export_flags],
    390    version : dav1d_soname_version,
    391    soversion : dav1d_soversion,
    392    install : true,
    393 )
    394 
    395 dav1d_dep = declare_dependency(link_with: libdav1d,
    396    include_directories : include_directories('../include')
    397 )
    398 
    399 #
    400 # Generate pkg-config .pc file
    401 #
    402 pkg_mod = import('pkgconfig')
    403 pkg_mod.generate(libraries: libdav1d,
    404    version: meson.project_version(),
    405    name: 'libdav1d',
    406    filebase: 'dav1d',
    407    description: 'AV1 decoding library'
    408 )