Skip to content

Commit 1014949

Browse files
committed
Add xtask to update upstream submodule
Every so often the upstream OpenVINO repository releases a new version. This new task, `cargo xtask update <tag>`, will run some Git commands to update Git submodule tracked by this repository. Since each release may slightly tweak the header files, this new task is expected to be used immediately prior to `cargo xtask codegen; cargo test`.
1 parent 190261d commit 1014949

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

crates/xtask/src/main.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66
mod bump;
77
mod codegen;
88
mod publish;
9+
mod update;
910
mod util;
1011

1112
use anyhow::Result;
1213
use bump::BumpCommand;
1314
use clap::{Parser, Subcommand};
1415
use codegen::CodegenCommand;
1516
use publish::PublishCommand;
17+
use update::UpdateCommand;
1618

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

3032
#[derive(Debug, Subcommand)]
3133
enum XtaskCommand {
34+
/// Update the upstream OpenVINO Git submodule.
35+
Update(UpdateCommand),
3236
/// Generate the Rust bindings for OpenVINO to use in the openvino-sys crate.
3337
Codegen(CodegenCommand),
3438
/// Increment the version of each of the publishable crates.
@@ -40,6 +44,7 @@ enum XtaskCommand {
4044
impl XtaskCommand {
4145
fn execute(&self) -> Result<()> {
4246
match self {
47+
Self::Update(update) => update.execute(),
4348
Self::Codegen(codegen) => codegen.execute(),
4449
Self::Bump(bump) => bump.execute(),
4550
Self::Publish(publish) => publish.execute(),

crates/xtask/src/update.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
use crate::util::{exec, path_to_crates};
2+
use anyhow::Result;
3+
use clap::Args;
4+
use std::process::Command;
5+
6+
#[derive(Debug, Args)]
7+
pub struct UpdateCommand {
8+
/// The upstream tag to update to; see https://github.com/openvinotoolkit/openvino/releases.
9+
#[arg(name = "TAG")]
10+
tag: String,
11+
}
12+
13+
impl UpdateCommand {
14+
/// Retrieve the requested tag and checkout the upstream submodule using `git`.
15+
pub fn execute(&self) -> Result<()> {
16+
let submodule = path_to_crates()?.join("openvino-sys/upstream");
17+
let submodule = submodule.to_string_lossy();
18+
exec(Command::new("git").args(["-C", &submodule, "fetch", "origin", "tag", &self.tag]))?;
19+
exec(Command::new("git").args(["-C", &submodule, "checkout", &self.tag]))?;
20+
println!("> to use the updated headers, run `cargo xtask codegen`");
21+
Ok(())
22+
}
23+
}

crates/xtask/src/util.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use toml::Value;
66

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

0 commit comments

Comments
 (0)