|
| 1 | +# SPDX-License-Identifier: LGPL-2.1-or-later |
| 2 | +# |
| 3 | +# This file is part of libnvme. |
| 4 | +# Copyright (c) 2025, Dell Technologies Inc. or its subsidiaries. |
| 5 | +# |
| 6 | +# Authors: Martin Belanger <[email protected]> |
| 7 | +# |
| 8 | +# Run generate-accessors to generate the setter/getter functions. |
| 9 | + |
| 10 | +# List of header files to parse for structs |
| 11 | +headers_to_scan = [ |
| 12 | + '../nvme/private.h', |
| 13 | +] |
| 14 | + |
| 15 | +# Append full path to each member of headers_to_scan |
| 16 | +headers_to_scan_full_path = [] |
| 17 | +foreach hdr : headers_to_scan |
| 18 | + headers_to_scan_full_path += join_paths(meson.current_source_dir(), hdr) |
| 19 | +endforeach |
| 20 | + |
| 21 | +# Generate accessors.c and accessors.h |
| 22 | +accessors_ch_custom_tgt = custom_target( |
| 23 | + 'accessors.[ch]', |
| 24 | + input: headers_to_scan_full_path, |
| 25 | + output: [ |
| 26 | + 'accessors.h', |
| 27 | + 'accessors.c', |
| 28 | + ], |
| 29 | + command: [ |
| 30 | + generate_accessors, |
| 31 | + '--h-out', '@OUTPUT0@', |
| 32 | + '--c-out', '@OUTPUT1@', |
| 33 | + '--incl', join_paths(meson.current_source_dir(), 'structs-to-include.txt'), |
| 34 | + '@INPUT@', |
| 35 | + ], |
| 36 | + build_by_default: true, |
| 37 | + install: true, |
| 38 | + install_dir: [ |
| 39 | + 'nvme', # Install @OUTPUT0@=='accessors.h' in this directory. |
| 40 | + false, # Do not install @OUTPUT1@=='accessors.c' |
| 41 | + ], |
| 42 | + install_mode: ['rw-r--r--', 0, 0], |
| 43 | +) |
| 44 | + |
| 45 | +generated_accessors_h = accessors_ch_custom_tgt[0] |
| 46 | +generated_accessors_c = accessors_ch_custom_tgt[1] |
| 47 | + |
| 48 | +if meson.version().version_compare('>=1.4.0') |
| 49 | + generated_accessors_h_path = generated_accessors_h.full_path() |
| 50 | +else |
| 51 | + generated_accessors_h_path = meson.current_build_dir() / 'accessors.h' |
| 52 | +endif |
| 53 | + |
| 54 | +generated_accessors_dep = declare_dependency( |
| 55 | + sources: [ |
| 56 | + accessors_ch_custom_tgt, |
| 57 | + ] |
| 58 | +) |
0 commit comments