|
| 1 | +project( |
| 2 | + 'cxx', |
| 3 | + default_options: ['rust_std=2021'], |
| 4 | + license: 'MIT OR Apache-2.0', |
| 5 | + license_files: ['LICENSE-APACHE', 'LICENSE-MIT'], |
| 6 | + meson_version: '>= 1.3.0', |
| 7 | +) |
| 8 | + |
| 9 | +add_languages('rust', native: true) |
| 10 | +add_languages('rust', 'cpp', native: false) |
| 11 | + |
| 12 | +subdir('tools/meson') |
| 13 | +subdir('third-party') |
| 14 | + |
| 15 | +rust = import('rust') |
| 16 | + |
| 17 | +project_root = include_directories('.') |
| 18 | + |
| 19 | +cxx_core = static_library( |
| 20 | + 'cxx_core', |
| 21 | + implicit_include_directories: false, |
| 22 | + sources: files('src/cxx.cc'), |
| 23 | +) |
| 24 | + |
| 25 | +cxxbridge_macro = rust.proc_macro( |
| 26 | + 'cxxbridge_macro', |
| 27 | + dependencies: [ |
| 28 | + third_party['proc-macro2'], |
| 29 | + third_party['quote'], |
| 30 | + third_party['syn'], |
| 31 | + ], |
| 32 | + sources: files('macro/src/lib.rs'), |
| 33 | +) |
| 34 | + |
| 35 | +cxx_library = static_library( |
| 36 | + 'cxx', |
| 37 | + link_with: [cxx_core, cxxbridge_macro], |
| 38 | + rust_args: [ |
| 39 | + '--cfg=feature="alloc"', |
| 40 | + '--cfg=feature="default"', |
| 41 | + '--cfg=feature="std"', |
| 42 | + ], |
| 43 | + sources: files('src/lib.rs'), |
| 44 | +) |
| 45 | + |
| 46 | +cxxbridge_cmd = executable( |
| 47 | + 'cxxbridge', |
| 48 | + dependencies: [ |
| 49 | + third_party['clap'], |
| 50 | + third_party['codespan-reporting'], |
| 51 | + third_party['proc-macro2'], |
| 52 | + third_party['quote'], |
| 53 | + third_party['syn'], |
| 54 | + ], |
| 55 | + native: true, |
| 56 | + sources: files('gen/cmd/src/main.rs'), |
| 57 | +) |
| 58 | + |
| 59 | +cxxbridge_generator = generator( |
| 60 | + cxxbridge_cmd, |
| 61 | + arguments: ['@INPUT@', '-o', '@OUTPUT0@', '-o', '@OUTPUT1@'], |
| 62 | + |
| 63 | +) |
| 64 | + |
| 65 | +cxx_header = custom_target( |
| 66 | + 'cxx_header', |
| 67 | + command: ['bash', '-c', 'mkdir -p rust; cp @INPUT@ rust'], |
| 68 | + input: files('include/cxx.h'), |
| 69 | + output: 'rust', |
| 70 | +) |
| 71 | + |
| 72 | +subdir('demo') |
| 73 | +subdir('tests') |
0 commit comments