meson.build (1452B)
1 global_conf = configuration_data() 2 global_conf.set_quoted('APP_ID', application_id) 3 global_conf.set_quoted('PKGDATADIR', pkgdatadir) 4 global_conf.set_quoted('PROFILE', profile) 5 global_conf.set_quoted('VERSION', version + version_suffix) 6 global_conf.set_quoted('GETTEXT_PACKAGE', gettext_package) 7 global_conf.set_quoted('LOCALEDIR', localedir) 8 config = configure_file( 9 input: 'config.rs.in', 10 output: 'config.rs', 11 configuration: global_conf 12 ) 13 # Copy the config.rs output to the source directory. 14 run_command( 15 'cp', 16 meson.project_build_root() / 'src' / 'config.rs', 17 meson.project_source_root() / 'src' / 'config.rs', 18 check: true 19 ) 20 21 cargo_options = [ '--manifest-path', meson.project_source_root() / 'Cargo.toml' ] 22 cargo_options += [ '--target-dir', meson.project_build_root() / 'src' ] 23 24 if get_option('profile') == 'default' 25 cargo_options += [ '--release' ] 26 rust_target = 'release' 27 message('Building in release mode') 28 else 29 rust_target = 'debug' 30 message('Building in debug mode') 31 endif 32 33 cargo_env = [ 'CARGO_HOME=' + meson.project_build_root() / 'cargo-home' ] 34 35 cargo_build = custom_target( 36 'cargo-build', 37 build_by_default: true, 38 build_always_stale: true, 39 output: meson.project_name(), 40 console: true, 41 install: true, 42 install_dir: bindir, 43 depends: resources, 44 command: [ 45 'env', 46 cargo_env, 47 cargo, 'build', 48 cargo_options, 49 '&&', 50 'cp', 'src' / rust_target / meson.project_name(), '@OUTPUT@', 51 ] 52 )