meson.build (1376B)
1 # Configuration file 2 conf = configuration_data() 3 conf.set_quoted('NAME', name) 4 conf.set_quoted('PKGNAME', meson.project_name()) 5 conf.set_quoted('APP_ID', application_id) 6 conf.set_quoted('PATH_ID', path_id) 7 conf.set_quoted('VERSION', meson.project_version()) 8 conf.set_quoted('PROFILE', profile) 9 conf.set_quoted('DATADIR', datadir) 10 11 configure_file( 12 input: 'config.rs.in', 13 output: 'config.rs', 14 configuration: conf 15 ) 16 17 run_command( 18 'cp', 19 join_paths(meson.project_build_root(), 'src', 'config.rs'), 20 join_paths(meson.project_source_root(), 'src', 'config.rs'), 21 check: true 22 ) 23 24 cargo_options = [ '--manifest-path', meson.project_source_root() / 'Cargo.toml' ] 25 cargo_options += [ '--target-dir', meson.project_build_root() / 'src' ] 26 27 if get_option('profile') == 'default' 28 cargo_options += [ '--release' ] 29 rust_target = 'release' 30 message('Building in release mode') 31 else 32 rust_target = 'debug' 33 message('Building in debug mode') 34 endif 35 36 cargo_env = [ 'CARGO_HOME=' + meson.project_build_root() / 'cargo-home' ] 37 38 cargo_build = custom_target( 39 'cargo-build', 40 build_by_default: true, 41 build_always_stale: true, 42 output: meson.project_name(), 43 console: true, 44 install: true, 45 install_dir: bindir, 46 command: [ 47 'env', 48 cargo_env, 49 cargo, 'build', 50 cargo_options, 51 '&&', 52 'cp', 'src' / rust_target / meson.project_name(), '@OUTPUT@', 53 ] 54 )