Skip to content

Commit 2b29272

Browse files
authored
fix(toolchain): support build-from-source tier-3 toolchains (#2572)
* fix(toolchain): support build-from-source tier-3 toolchains Two gaps blocked build-from-source toolchains (e.g. ruby_tool, which compiles via ruby-build) from installing: 1. supports_tier_3() only recognized download_prebuilt/native_install, so moon never scheduled a SetupToolchain action for source-only tools. Add build_instructions to the check (proto's build-from-source install path). 2. setup_toolchain() called proto's Manager::install with a default InstallOptions, so strategy defaulted to prebuilt and errored (prebuilt_unsupported). Pass the tool's declared default_install_strategy. * bump starbase_console for new `with_reporter` api
1 parent 9f0e030 commit 2b29272

6 files changed

Lines changed: 33 additions & 8 deletions

File tree

Cargo.lock

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ starbase_archive = { version = "0.13.2", default-features = false, features = [
7070
"zip-all",
7171
] }
7272
starbase_args = { version = "0.1.11" }
73-
starbase_console = { version = "0.6.29", features = ["miette"] }
73+
starbase_console = { version = "0.6.31", features = ["miette"] }
7474
starbase_id = { version = "0.3.3", features = ["miette", "schematic"] }
7575
starbase_sandbox = "0.11.1"
76-
starbase_shell = "0.12.5"
76+
starbase_shell = "0.12.6"
7777
starbase_styles = { version = "0.6.1", features = ["relative-path"] }
7878
starbase_utils = { version = "0.13.8", default-features = false, features = [
7979
"editor-config",

crates/actions/src/actions/setup_toolchain.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use moon_env_var::GlobalEnvBag;
99
use moon_hash::fingerprint;
1010
use moon_pdk_api::SetupToolchainInput;
1111
use moon_toolchain::is_using_global_toolchain;
12+
use proto_core::reporter::{ProtoReporter, ReporterFormat};
1213
use std::sync::Arc;
1314
use tracing::{debug, instrument};
1415

@@ -90,6 +91,9 @@ pub async fn setup_toolchain(
9091
);
9192

9293
let setup_op = Operation::setup_operation(action.get_prefix())?;
94+
let proto_console = app_context
95+
.console
96+
.with_reporter(ProtoReporter::new(ReporterFormat::Text));
9397
let output = toolchain
9498
.setup_toolchain(
9599
SetupToolchainInput {
@@ -98,6 +102,7 @@ pub async fn setup_toolchain(
98102
toolchain_config: app_context.toolchain_registry.create_config(&toolchain.id),
99103
version: None,
100104
},
105+
Some(proto_console),
101106
|| {
102107
app_context.console.print_checkpoint(
103108
Checkpoint::Setup,

crates/toolchain-plugin/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ futures = { workspace = true }
2626
indexmap = { workspace = true }
2727
miette = { workspace = true }
2828
proto_core = { workspace = true }
29+
proto_pdk_api = { workspace = true }
2930
rustc-hash = { workspace = true }
3031
scc = { workspace = true }
3132
starbase_utils = { workspace = true, features = ["glob", "json"] }

crates/toolchain-plugin/src/toolchain_plugin.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@ use proto_core::flow::install::InstallOptions;
99
use proto_core::flow::locate::Locator;
1010
use proto_core::flow::manage::Manager;
1111
use proto_core::flow::resolve::Resolver;
12+
use proto_core::reporter::ProtoConsole;
13+
use proto_core::utils::log::LogWriter;
1214
use proto_core::{
1315
PluginLocator, PluginType as ProtoPluginType, Tool, ToolContext, ToolSpec,
1416
UnresolvedVersionSpec, locate_plugin,
1517
};
18+
use proto_pdk_api::InstallStrategy;
1619
use scc::hash_map::Entry;
1720
use starbase_utils::glob::{self, GlobSet};
1821
use std::fmt;
@@ -150,7 +153,8 @@ impl ToolchainPlugin {
150153
self.has_func("setup_toolchain").await
151154
|| self.tool.is_some()
152155
&& (self.has_func("download_prebuilt").await
153-
|| self.has_func("native_install").await)
156+
|| self.has_func("native_install").await
157+
|| self.has_func("build_instructions").await)
154158
}
155159

156160
#[instrument(skip(self))]
@@ -511,6 +515,7 @@ impl ToolchainPlugin {
511515
pub async fn setup_toolchain(
512516
&self,
513517
mut input: SetupToolchainInput,
518+
console: Option<ProtoConsole>,
514519
on_setup: impl FnOnce() -> miette::Result<()>,
515520
) -> miette::Result<SetupToolchainOutput> {
516521
let mut output = SetupToolchainOutput::default();
@@ -529,6 +534,16 @@ impl ToolchainPlugin {
529534
if !tool.is_installed(&spec) {
530535
on_setup()?;
531536

537+
// Honor the tool's declared install strategy (e.g. Ruby
538+
// builds from source); otherwise proto defaults to a
539+
// prebuilt download and errors for source-only tools.
540+
let strategy = tool.metadata.default_install_strategy;
541+
542+
// Only the build-from-source path routes through proto's
543+
// Builder, which requires a console + log writer. Prebuilt
544+
// installs don't, so leave them `None` to avoid the
545+
// allocation and any change to prebuilt logging behavior.
546+
let building = matches!(strategy, InstallStrategy::BuildFromSource);
532547
let mut manager = Manager::new(&mut tool);
533548

534549
output.installed = manager
@@ -537,6 +552,9 @@ impl ToolchainPlugin {
537552
InstallOptions {
538553
skip_prompts: true,
539554
skip_ui: true,
555+
strategy,
556+
console: building.then_some(console).flatten(),
557+
log_writer: building.then(LogWriter::default),
540558
..Default::default()
541559
},
542560
)

crates/toolchain-plugin/src/toolchain_registry_actions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ impl ToolchainRegistry {
377377
"setup_toolchain",
378378
self.get_plugin_ids(),
379379
input_factory,
380-
|toolchain, input| async move { toolchain.setup_toolchain(input, || Ok(())).await },
380+
|toolchain, input| async move { toolchain.setup_toolchain(input, None, || Ok(())).await },
381381
true,
382382
)
383383
.await

0 commit comments

Comments
 (0)