Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support go core plugin on windows #2990

Merged
merged 2 commits into from
Nov 11, 2024
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
2 changes: 1 addition & 1 deletion docs/cli/generate.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# `mise generate`

- **Usage**: `mise generate <SUBCOMMAND>`
- **Aliases**: `g`
- **Aliases**: `gen`
- **Source code**: [`src/cli/generate.rs`](https://github.com/jdx/mise/blob/main/src/cli/generate.rs)

[experimental] Generate files for various tools/services
Expand Down
7 changes: 7 additions & 0 deletions e2e-win/go.Tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

Describe 'node' {
It 'executes go 1.23.3' {
mise x go@1.23.3 -- where go
mise x go@1.23.3 -- go version | Should -BeLike "go version go1.23.3 windows/*"
}
}
3 changes: 2 additions & 1 deletion mise.usage.kdl
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,8 @@ The "--" separates runtimes from the commands to pass along to the subprocess."#
arg "[COMMAND]..." help="Command string to execute (same as --command)" var=true
}
cmd "generate" subcommand_required=true help="[experimental] Generate files for various tools/services" {
alias "g"
alias "gen"
alias "g" hide=true
cmd "git-pre-commit" help="[experimental] Generate a git pre-commit hook" {
alias "pre-commit"
long_help r"[experimental] Generate a git pre-commit hook
Expand Down
2 changes: 1 addition & 1 deletion src/cli/generate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ mod task_docs;

/// [experimental] Generate files for various tools/services
#[derive(Debug, clap::Args)]
#[clap(visible_alias = "g")]
#[clap(visible_alias = "gen", alias = "g")]
pub struct Generate {
#[clap(subcommand)]
command: Commands,
Expand Down
18 changes: 15 additions & 3 deletions src/plugins/core/go.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl GoPlugin {

// Represents go binary path
fn go_bin(&self, tv: &ToolVersion) -> PathBuf {
tv.install_path().join("bin/go")
tv.install_path().join("bin").join("go")
}

// Represents GOPATH environment variable
Expand Down Expand Up @@ -93,7 +93,7 @@ impl GoPlugin {

fn download(&self, tv: &ToolVersion, pr: &dyn SingleReport) -> eyre::Result<PathBuf> {
let settings = Settings::get();
let filename = format!("go{}.{}-{}.tar.gz", tv.version, platform(), arch());
let filename = format!("go{}.{}-{}.{}", tv.version, platform(), arch(), ext());
let tarball_url = format!("{}/{}", &settings.go_download_mirror, &filename);
let tarball_path = tv.download_path().join(&filename);

Expand Down Expand Up @@ -126,7 +126,11 @@ impl GoPlugin {
.to_string_lossy();
pr.set_message(format!("installing {}", tarball));
let tmp_extract_path = tempdir_in(tv.install_path().parent().unwrap())?;
file::untar(tarball_path, tmp_extract_path.path())?;
if cfg!(windows) {
file::unzip(tarball_path, tmp_extract_path.path())?;
} else {
file::untar(tarball_path, tmp_extract_path.path())?;
}
file::remove_all(tv.install_path())?;
file::rename(tmp_extract_path.path().join("go"), tv.install_path())?;
Ok(())
Expand Down Expand Up @@ -239,3 +243,11 @@ fn arch() -> &'static str {
&ARCH
}
}

fn ext() -> &'static str {
if cfg!(windows) {
"zip"
} else {
"tar.gz"
}
}
11 changes: 2 additions & 9 deletions src/plugins/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,10 @@ use crate::plugins::core::bun::BunPlugin;
use crate::plugins::core::deno::DenoPlugin;
#[cfg(unix)]
use crate::plugins::core::erlang::ErlangPlugin;
#[cfg(unix)]
use crate::plugins::core::go::GoPlugin;
use crate::plugins::core::java::JavaPlugin;
use crate::plugins::core::node::NodePlugin;
#[cfg(unix)]
use crate::plugins::core::ruby::RubyPlugin;
#[cfg(windows)]
use crate::plugins::core::ruby_windows::RubyPlugin;
#[cfg(unix)]
use crate::plugins::core::zig::ZigPlugin;
use crate::plugins::{Plugin, PluginList, PluginType};
Expand All @@ -35,15 +31,12 @@ mod bun;
mod deno;
#[cfg(unix)]
mod erlang;
#[cfg(unix)]
mod go;
mod java;
mod node;
mod python;
#[cfg(unix)]
#[cfg_attr(windows, path = "ruby_windows.rs")]
mod ruby;
#[cfg(windows)]
mod ruby_windows;
#[cfg(unix)]
mod zig;

Expand All @@ -64,7 +57,7 @@ pub static CORE_PLUGINS: Lazy<BackendMap> = Lazy::new(|| {
// Arc::new(BunPlugin::new()),
Arc::new(DenoPlugin::new()),
// Arc::new(ErlangPlugin::new()),
// Arc::new(GoPlugin::new()),
Arc::new(GoPlugin::new()),
Arc::new(JavaPlugin::new()),
Arc::new(NodePlugin::new()),
Arc::new(PythonPlugin::new()),
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/core/python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ fn python_arch() -> &'static str {

fn ensure_not_windows() -> eyre::Result<()> {
if cfg!(windows) {
bail!("python can not currently be compiled on windows");
bail!("python can not currently be compiled on windows with core:python, use vfox:python instead");
}
Ok(())
}
Loading