1nv_classes = [ 2 'cl902d', 3 'cl9039', 4 'cl906f', 5 'cl9097', 6 'cl90b5', 7 'cl90c0', 8 'cla040', 9 'cla0b5', 10 'cla097', 11 'cla140', 12 'cla297', 13 'clb097', 14 'clb0c0', 15 'clb197', 16 'clb1c0', 17 'clc097', 18 'clc1b5', 19 'cla0c0', 20 'clc0c0', 21 'clc397', 22 'clc3c0', 23 'clc597', 24 'clc5c0', 25 'clc697', 26 'clc6c0', 27 'clc797', 28 'clc7c0', 29] 30 31hwref_gens = [ 32 'maxwell/gm107', 33 'pascal/gp100', 34 'hopper/gh100', 35 'turing/tu102', 36] 37 38cl_generated = [] 39foreach cl : nv_classes 40 cl_generated += custom_target( 41 cl + '.h', 42 input : ['class_parser.py', 'nvidia/classes/'+cl+'.h'], 43 output : ['nv_push_'+cl+'.h', 'nv_push_'+cl+'.c'], 44 command : [prog_python, '@INPUT0@', '--in-h', '@INPUT1@', 45 '--out-h', '@OUTPUT0@', '--out-c', '@OUTPUT1@'], 46 ) 47endforeach 48 49_libnvidia_headers = static_library( 50 'nvidia_headers_c', 51 ['nv_push.c', cl_generated], 52 include_directories : ['.', 'nvidia/classes', inc_include, inc_src], 53 c_args : [no_override_init_args], 54 gnu_symbol_visibility : 'hidden', 55) 56 57idep_nvidia_headers = declare_dependency( 58 include_directories : include_directories('.', 'nvidia/classes'), 59 sources : cl_generated, 60 link_with : _libnvidia_headers, 61) 62 63executable( 64 'nv_push_dump', 65 'nv_push_dump.c', 66 dependencies : [ idep_mesautil, idep_nvidia_headers ], 67 build_by_default : with_tools.contains('nouveau'), 68 install : with_tools.contains('nouveau'), 69) 70 71# Only generate Rust bindings for NVK 72if with_nouveau_vk 73 cl_rs_generated = [] 74 foreach cl : nv_classes 75 cl_rs_generated += custom_target( 76 'nvh_classes_' + cl + '.rs', 77 input : ['class_parser.py', 'nvidia/classes/'+cl+'.h'], 78 output : ['nvh_classes_'+cl+'.rs'], 79 command : [prog_python, '@INPUT0@', '--in-h', '@INPUT1@', 80 '--out-rs', '@OUTPUT0@'], 81 ) 82 83 cl_rs_generated += custom_target( 84 'nvh_' + cl + '_mthd.rs', 85 input : ['class_parser.py', 'nvidia/classes/'+cl+'.h'], 86 output : ['nvh_classes_'+cl+'_mthd.rs'], 87 command : [prog_python, '@INPUT0@', '--in-h', '@INPUT1@', 88 '--out-rs-mthd', '@OUTPUT0@'], 89 ) 90 91 fs = import('fs') 92 if cl.endswith('c0') and fs.is_file('nvidia/classes/'+cl+'qmd.h') 93 cl_rs_generated += custom_target( 94 'nvh_classes_' + cl + '_qmd.rs', 95 input : ['struct_parser.py', 'nvidia/classes/'+cl+'qmd.h'], 96 output : ['nvh_classes_'+cl+'_qmd.rs'], 97 command : [prog_python, '@INPUT0@', '--in-h', '@INPUT1@', 98 '--out-rs', '@OUTPUT0@'] 99 ) 100 endif 101 102 if cl.endswith('97') 103 cl_rs_generated += custom_target( 104 'nvh_classes_' + cl + '_tex.rs', 105 input : ['struct_parser.py', 'nvidia/classes/'+cl+'tex.h'], 106 output : ['nvh_classes_'+cl+'_tex.rs'], 107 command : [prog_python, '@INPUT0@', '--in-h', '@INPUT1@', 108 '--out-rs', '@OUTPUT0@'] 109 ) 110 endif 111 112 if fs.is_file(f'nvidia/classes/@[email protected]') 113 cl_rs_generated += custom_target( 114 input : ['struct_parser.py', f'nvidia/classes/@[email protected]'], 115 output : [f'nvh_classes_@cl@_sph.rs'], 116 command : [prog_python, '@INPUT0@', '--in-h', '@INPUT1@', 117 '--out-rs', '@OUTPUT0@'] 118 ) 119 endif 120 endforeach 121 122 fs = import('fs') 123 foreach family_gen : hwref_gens 124 family = fs.parent(family_gen) 125 gen = fs.name(family_gen) 126 cl_rs_generated += rust.bindgen( 127 input : ['nvidia/hwref/'+family+'/'+gen+'/dev_mmu.h'], 128 output : 'nvh_hwref_'+gen+'_mmu.rs', 129 args : ['--allowlist-var', 'NV_MMU_.*'], 130 ) 131 endforeach 132 133 _nvidia_headers_lib_rs = custom_target( 134 'lib.rs', 135 input : ['lib_rs_gen.py'], 136 output : ['lib.rs'], 137 command : [prog_python, '@INPUT0@', '--out-rs', '@OUTPUT0@', 138 cl_rs_generated] 139 ) 140 141 _nvidia_headers_rs = static_library( 142 'nvidia_headers', 143 _nvidia_headers_lib_rs, 144 gnu_symbol_visibility : 'hidden', 145 rust_abi : 'rust', 146 ) 147 148 idep_nvidia_headers_rs = declare_dependency( 149 link_with : _nvidia_headers_rs, 150 ) 151 152 _libnv_push_rs = static_library( 153 'nv_push_rs', 154 files('nv_push_rs/lib.rs'), 155 gnu_symbol_visibility: 'hidden', 156 rust_abi: 'rust', 157 dependencies: [idep_nvidia_headers_rs], 158 ) 159 160 idep_nv_push_rs = declare_dependency( 161 link_with : _libnv_push_rs, 162 ) 163endif 164