Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions crates/xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
mod bump;
mod codegen;
mod publish;
mod update;
mod util;

use anyhow::Result;
use bump::BumpCommand;
use clap::{Parser, Subcommand};
use codegen::CodegenCommand;
use publish::PublishCommand;
use update::UpdateCommand;

fn main() -> Result<()> {
let cli = Cli::parse();
Expand All @@ -29,6 +31,8 @@ struct Cli {

#[derive(Debug, Subcommand)]
enum XtaskCommand {
/// Update the upstream OpenVINO Git submodule.
Update(UpdateCommand),
/// Generate the Rust bindings for OpenVINO to use in the openvino-sys crate.
Codegen(CodegenCommand),
/// Increment the version of each of the publishable crates.
Expand All @@ -40,6 +44,7 @@ enum XtaskCommand {
impl XtaskCommand {
fn execute(&self) -> Result<()> {
match self {
Self::Update(update) => update.execute(),
Self::Codegen(codegen) => codegen.execute(),
Self::Bump(bump) => bump.execute(),
Self::Publish(publish) => publish.execute(),
Expand Down
23 changes: 23 additions & 0 deletions crates/xtask/src/update.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
use crate::util::{exec, path_to_crates};
use anyhow::Result;
use clap::Args;
use std::process::Command;

#[derive(Debug, Args)]
pub struct UpdateCommand {
/// The upstream tag to update to; see <https://github.com/openvinotoolkit/openvino/releases>.
#[arg(name = "TAG")]
tag: String,
}

impl UpdateCommand {
/// Retrieve the requested tag and checkout the upstream submodule using `git`.
pub fn execute(&self) -> Result<()> {
let submodule = path_to_crates()?.join("openvino-sys/upstream");
let submodule = submodule.to_string_lossy();
exec(Command::new("git").args(["-C", &submodule, "fetch", "origin", "tag", &self.tag]))?;
exec(Command::new("git").args(["-C", &submodule, "checkout", &self.tag]))?;
println!("> to use the updated headers, run `cargo xtask codegen`");
Ok(())
}
}
1 change: 1 addition & 0 deletions crates/xtask/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use toml::Value;

/// Convenience wrapper for executing commands.
pub fn exec(command: &mut Command) -> Result<()> {
eprintln!("+ executing: {:?}", &command);
let status = command.status()?;
if status.success() {
Ok(())
Expand Down
Loading