Skip to content

Commit

Permalink
uapi,meson: add install crates
Browse files Browse the repository at this point in the history
deploy crates to local registry if specified.
  • Loading branch information
fvalette-ledger committed Dec 2, 2024
1 parent d36f55b commit 921002f
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
2 changes: 2 additions & 0 deletions meson.options
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ option('dts', type: 'string', description: 'Top level DTS file', yield: true)
option('dts-include-dirs', type: 'array', value: ['dts'], yield: true,
description: 'Directories to add to resolution path for dtsi inclusion')
option('rust-channel', type: 'string', value: '1.82.0', description: 'rustup channel to use for Rust toolchain')
option('cargo-registry', type: 'string', description: 'cargo local registry')
option('with-install-crates', type: 'boolean', value: false, description: 'install crate(s) to specified registry')
50 changes: 49 additions & 1 deletion uapi/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ rust_edition = '2021'
uapi_rust_std = 'rust_std=' + rust_edition
uapi_manifest = files('Cargo.toml')

cargo_install = get_option('with-install-crates')

subdir('include/uapi')
subdir('src')

cargo = find_program('cargo', required: true)
cargo_fmt = find_program('cargo-fmt', required: false)
cargo_clippy = find_program('cargo-clippy', required: false)
cargo_index = find_program('cargo-index', required: false)
cargo_index = find_program('cargo-index', required: cargo_install)

if with_doc_opt
uapi_doc = custom_target(
Expand Down Expand Up @@ -126,6 +128,52 @@ rustargs_file = configure_file(
install_tag: 'data',
)

summary(
{
'install crates': cargo_install,
},
section: 'Cargo',
bool_yn: true,
)

if cargo_install
fs = import('fs')
cargo_local_registry = fs.expanduser(get_option('cargo-registry'))

if not fs.is_absolute(cargo_local_registry)
error('cargo local registry must be an absolute path')
endif

if not fs.is_dir(cargo_local_registry)
error('cargo local registry must exist and be a directory')
endif

cargo_local_registry_index = join_paths(cargo_local_registry, 'index')

meson.add_install_script(
cargo,
'index',
'add',
'--force',
'--manifest-path=' + uapi_manifest[0].full_path(),
'--index=' + cargo_local_registry_index,
'--index-url=file://' + cargo_local_registry_index,
'--upload=' + cargo_local_registry,
'--',
'--no-verify',
install_tag: 'devel',
)

summary(
{
'cargo local registry': cargo_local_registry,
},
section: 'Cargo',
bool_yn: true,
)

endif # with install crates

install_data(
'task.Kconfig',
install_dir : get_option('datadir') / 'configs',
Expand Down

0 comments on commit 921002f

Please sign in to comment.