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
31 changes: 22 additions & 9 deletions crates/mctx/src/min_helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,25 @@ min_run() {
__min_rpc "run" "$@"
}

min_package() {
local subcmd="$1"
shift

case "$subcmd" in
patched-build)
min_patched_pkg "$@"
;;
build)
echo "error: 'build' subcommand not supported in mip sandbox." >&2
return 1
;;
*)
echo "error: unknown subcommand '$subcmd'. Expected 'patched-build'" >&2
return 1
Comment thread
twitchyliquid64 marked this conversation as resolved.
;;
esac
}

min_check() {
__min_rpc "check" "$@"
}
Expand All @@ -128,14 +147,8 @@ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
run)
min_run "$@"
;;
build)
min_run build
;;
test)
min_run test
;;
patched-pkg)
min_patched_pkg "$@"
package|pkg)
min_package "$@"
;;
check)
min_check "$@"
Expand All @@ -147,7 +160,7 @@ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
echo "Search for packages: min search <query>" >&2
echo "Check minimal configuration: min check" >&2
echo "Run a task: min run <task name>" >&2
echo "Try building a package (with potentially-stale dependencies): min patched-pkg <package name>" >&2
echo "Try building a package (with potentially-stale dependencies): min package patched-build <package name>" >&2
exit 1
;;
esac
Expand Down
32 changes: 20 additions & 12 deletions crates/minimald/src/env_min_helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,22 @@ min_run() {
__min_rpc "run" "$@"
}

min_build() {
__min_rpc "build" "$@"
min_package() {
local subcmd="$1"
shift

case "$subcmd" in
patched-build)
min_patched_pkg "$@"
;;
build)
__min_rpc "build" "$@"
;;
*)
echo "error: unknown subcommand '$subcmd'. Expected 'build' or 'patched-build'" >&2
return 1
Comment thread
twitchyliquid64 marked this conversation as resolved.
;;
esac
}

min_check() {
Expand All @@ -130,14 +144,8 @@ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
run)
min_run "$@"
;;
build)
min_build "$@"
;;
test)
min_run test
;;
patched-pkg)
min_patched_pkg "$@"
package|pkg)
min_package "$@"
;;
check)
min_check "$@"
Expand All @@ -149,8 +157,8 @@ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
echo "Search for packages: min search <query>" >&2
echo "Check minimal configuration: min check" >&2
echo "Run a task: min run <task name>" >&2
echo "Build packages: min build [packages]" >&2
echo "Try building a package (with potentially-stale dependencies): min patched-pkg <package name>" >&2
echo "Build packages: min package build <packages>" >&2
echo "Try building a package (with potentially-stale dependencies): min package patched-build <package name>" >&2
exit 1
;;
esac
Expand Down
40 changes: 37 additions & 3 deletions crates/mip/src/cmd_pkg.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,35 @@
use crate::cmd_pkg_build_plan::{PkgBuildPlanArgs, cmd_pkg_build_plan};
use crate::cmd_pkg_dep::{PkgDepArgs, cmd_pkg_dep};
use crate::cmd_pkg_patched_build::{PkgPatchedBuildArgs, cmd_pkg_patched_build};
use crate::cmd_pkg_upload_cache::{PkgUploadCacheArgs, cmd_pkg_upload_cache};
use futures::channel::mpsc;
use graph::Graph;
use mctx::{Cache, Context, Error};
use orchestrator::{BuildEvent, BuildLineKind, BuildRenderer};
use tracing::{info, trace};

#[derive(Debug, clap::Subcommand)]
pub enum PkgCmd {
/// Builds the specified package(s) in a clean room, making them available in the local cache.
Build(PkgBuildArgs),
/// Prints the build plan for the specified package(s)
#[clap(hide = !std::env::var("MINIMAL_SCIENCE_MODE").is_ok())]
BuildPlan(PkgBuildPlanArgs),
/// Generates Graphviz source code of the dependency graph
#[command(
long_about = "Generate an image of the dependency graph using graphviz's \"dot\" program.\n\n mip package dep --input-deps-depth=0 | dot -Tpng > deps.png"
)]
Dep(PkgDepArgs),
/// Executes the build for a package, using stale dependencies.
#[clap(hide = !std::env::var("MINIMAL_SCIENCE_MODE").is_ok())]
PatchedBuild(PkgPatchedBuildArgs),
/// Uploads the specified packages and their transitive needs to the cache.
#[clap(hide = !std::env::var("MINIMAL_SCIENCE_MODE").is_ok())]
UploadCache(PkgUploadCacheArgs),
}

#[derive(Debug, clap::Args)]
pub struct PkgArgs {
pub struct PkgBuildArgs {
/// Whether to log stdout/stderr during the build
#[arg(short, long, default_value_t = false)]
verbose: bool,
Expand All @@ -18,8 +42,18 @@ pub struct PkgArgs {
packages: Vec<String>,
}

pub async fn cmd_pkg(args: PkgArgs, ctx: &mut Context) -> Result<(), Error> {
trace!("cmd_pkg");
pub async fn cmd_pkg(sub_command: PkgCmd, ctx: &mut Context) -> Result<(), Error> {
match sub_command {
PkgCmd::Build(args) => cmd_pkg_build(args, ctx).await,
PkgCmd::BuildPlan(args) => cmd_pkg_build_plan(args, ctx).await,
PkgCmd::Dep(args) => cmd_pkg_dep(args, ctx).await,
PkgCmd::PatchedBuild(args) => cmd_pkg_patched_build(args, ctx).await,
PkgCmd::UploadCache(args) => cmd_pkg_upload_cache(args, ctx).await,
}
}

pub async fn cmd_pkg_build(args: PkgBuildArgs, ctx: &mut Context) -> Result<(), Error> {
trace!("cmd_pkg_build");
let graph = if !args.packages.is_empty() {
ctx.graph_from_package_names(args.packages.clone())?
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ use lcache::CacheBinProvider;
use mctx::{Cache, Context, Error};
use rcache::RemoteBinProvider;

#[derive(clap::Args)]
pub struct PlanArgs {
#[derive(Debug, clap::Args)]
pub struct PkgBuildPlanArgs {
/// Packages to plan
#[arg(trailing_var_arg = true, allow_hyphen_values = true, num_args=0..)]
packages: Vec<String>,
}

pub async fn cmd_plan(args: PlanArgs, ctx: &mut Context) -> Result<(), Error> {
pub async fn cmd_pkg_build_plan(args: PkgBuildPlanArgs, ctx: &mut Context) -> Result<(), Error> {
let graph = if !args.packages.is_empty() {
ctx.graph_from_package_names(args.packages.clone())?
} else {
Expand Down
10 changes: 5 additions & 5 deletions crates/mip/src/cmd_dep.rs → crates/mip/src/cmd_pkg_dep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ enum OutputFormat {

/// CLI options to control what goes in the generated graph
#[derive(Debug, clap::Args)]
pub struct DepArgs {
pub struct PkgDepArgs {
/// Packages left out of graph and not traversed. Overrides matching package entries
#[arg(short, long, alias="exclude", value_delimiter=',', num_args=0..)]
excludes: Option<Vec<String>>,
Expand Down Expand Up @@ -332,7 +332,7 @@ fn pgraph_copy_subset(
graph: &Graph,
pgraph: &DiGraph<NodeData, EdgeData>,
bsname_to_node_index: &HashMap<String, NodeIndex>,
args: &DepArgs,
args: &PkgDepArgs,
) -> Result<DiGraph<NodeData, EdgeData>, Error> {
// if the listest packages with -p reduce to just those node indices
let node_indices = if !args.packages.is_empty() {
Expand Down Expand Up @@ -372,7 +372,7 @@ fn pgraph_copy_subset(
fn pgraph_copy_subset_for_node(
graph: &Graph,
pgraph: &DiGraph<NodeData, EdgeData>,
args: &DepArgs,
args: &PkgDepArgs,
node_index: NodeIndex,
bsr: &BuildSpecRef,
state: &TraversalState,
Expand Down Expand Up @@ -539,7 +539,7 @@ fn prune_edgeless(pgraph: &mut DiGraph<NodeData, EdgeData>) {
}

/// Prints graphviz DOT or Mermaid for the dependency graph as constrained by the CLI args to stdout.
pub async fn cmd_dep(args: DepArgs, ctx: &mut Context) -> Result<(), Error> {
pub async fn cmd_pkg_dep(args: PkgDepArgs, ctx: &mut Context) -> Result<(), Error> {
let graph = if args.packages.is_empty() {
ctx.graph_from_all_packages()
} else {
Expand Down Expand Up @@ -810,7 +810,7 @@ mod tests {
runtime_deps_depth: i32,
excludes: Option<Vec<String>>,
) -> DiGraph<NodeData, EdgeData> {
let args = DepArgs {
let args = PkgDepArgs {
excludes,
build_spec_deps,
source_deps: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ use anyhow::anyhow;
use op::{PatchedBuild, Runnable};

#[derive(Debug, clap::Args)]
pub struct PatchedBuildArgs {
pub struct PkgPatchedBuildArgs {
package: String,
}

pub async fn cmd_patched_build(args: PatchedBuildArgs, ctx: &mut Context) -> Result<(), Error> {
pub async fn cmd_pkg_patched_build(
args: PkgPatchedBuildArgs,
ctx: &mut Context,
) -> Result<(), Error> {
crate::enforce_science_mode()?;

let graph = ctx.graph_from_package_names([args.package])?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ use ot::OpTracker;
use std::sync::mpsc::channel;
use tracing::info;

#[derive(clap::Args)]
pub struct UploadArgs {
#[derive(Debug, clap::Args)]
pub struct PkgUploadCacheArgs {
#[arg(trailing_var_arg = true, allow_hyphen_values = true, num_args=0..)]
packages: Vec<String>,
}

pub async fn cmd_upload_cache(args: UploadArgs, ctx: &mut Context) -> Result<(), Error> {
pub async fn cmd_pkg_upload_cache(
args: PkgUploadCacheArgs,
ctx: &mut Context,
) -> Result<(), Error> {
let op_root = ctx.op_tracker();
let graph = if !args.packages.is_empty() {
ctx.graph_from_package_names(args.packages.clone())?
Expand Down
Loading