summaryrefslogtreecommitdiff
path: root/src/apps/common/meson.build
AgeCommit message (Expand)Author
2022-10-24apps: Share common source between applicationsLaurent Pinchart
/a> 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
# SPDX-License-Identifier: CC0-1.0

libcamera_include_dir = 'libcamera' / 'libcamera'

libcamera_public_headers = files([
    'camera.h',
    'camera_manager.h',
    'color_space.h',
    'controls.h',
    'fence.h',
    'framebuffer.h',
    'framebuffer_allocator.h',
    'geometry.h',
    'logging.h',
    'orientation.h',
    'pixel_format.h',
    'request.h',
    'stream.h',
    'transform.h',
])

subdir('base')
subdir('internal')
subdir('ipa')

install_headers(libcamera_public_headers,
                subdir : libcamera_include_dir)

#
# Generate headers from templates.
#

libcamera_headers_install_dir = get_option('includedir') / libcamera_include_dir

controls_map = {
    'controls': {
        'core': 'control_ids_core.yaml',
        'debug': 'control_ids_debug.yaml',
        'draft': 'control_ids_draft.yaml',
        'rpi/vc4': 'control_ids_rpi.yaml',
    },

    'properties': {
        'draft': 'property_ids_draft.yaml',
        'core': 'property_ids_core.yaml',
    }
}

control_headers = []
controls_files = []
controls_files_names = []
properties_files = []
properties_files_names = []

foreach mode, entry : controls_map
    files_list = []
    input_files = []
    foreach vendor, header : entry
        if vendor not in ['core', 'debug', 'draft']
            if vendor not in pipelines
                continue
            endif
        endif

        if header in files_list
            continue
        endif

        files_list += header
        input_files += files('../../src/libcamera/' + header)
    endforeach

    outfile = ''
    if mode == 'controls'
        outfile = 'control_ids.h'
        controls_files += input_files
        controls_files_names += files_list
    else
        outfile = 'property_ids.h'
        properties_files += input_files
        properties_files_names += files_list
    endif

    template_file = files('control_ids.h.in')
    ranges_file = files('../../src/libcamera/control_ranges.yaml')
    control_headers += custom_target(header + '_h',
                                     input : input_files,
                                     output : outfile,
                                     command : [gen_controls, '-o', '@OUTPUT@',
                                                '--mode', mode, '-t', template_file,
                                                '-r', ranges_file, '@INPUT@'],
                                     env : py_build_env,
                                     install : true,
                                     install_dir : libcamera_headers_install_dir)
endforeach

libcamera_public_headers += control_headers

# formats.h
formats_h = custom_target('formats_h',
                          input : files(
                              '../../src/libcamera/formats.yaml',
                              'formats.h.in',
                              '../linux/drm_fourcc.h'
                          ),
                          output : 'formats.h',
                          command : [gen_formats, '-o', '@OUTPUT@', '@INPUT@'],
                          install : true,
                          install_dir : libcamera_headers_install_dir)
libcamera_public_headers += formats_h

# version.h
version = libcamera_version.split('.')
libcamera_version_config = configuration_data()
libcamera_version_config.set('LIBCAMERA_VERSION_MAJOR', version[0])
libcamera_version_config.set('LIBCAMERA_VERSION_MINOR', version[1])
libcamera_version_config.set('LIBCAMERA_VERSION_PATCH', version[2])

version_h = configure_file(input : 'version.h.in',
                           output : 'version.h',
                           configuration : libcamera_version_config,
                           install_dir : libcamera_headers_install_dir)
libcamera_public_headers += version_h

# libcamera.h
libcamera_h = custom_target('gen-header',
                            input : 'meson.build',
                            output : 'libcamera.h',
                            command : [gen_header, '@OUTPUT@', libcamera_public_headers],
                            install : true,
                            install_dir : libcamera_headers_install_dir)

libcamera_public_headers += libcamera_h