Skip to content

Commit

Permalink
Merge pull request #146 from owittek/master
Browse files Browse the repository at this point in the history
  • Loading branch information
MordechaiHadad authored Aug 17, 2023
2 parents 279eb86 + 0db627e commit 771cce1
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ Example: `export BOB_CONFIG=/path/to/config/config.json`
| Property | Description | Default Value |
| -------------------------------| ---------------------------------------------------------------------------------------------------------------------------------------------------------------| --------------------------------------------------------------------------------------------------------------|
| **enable_nightly_info** | Will show new commits associated with new nightly release if enabled | `true` |
| **enable_release_build** | Compile neovim nightly or a certain hash version as a release build (slightly improved performance, no debug info) | `false` |
| **downloads_location** | The folder in which neovim versions will be downloaded to, bob will error if this option is specified but the folder doesn't exist | unix: `/home/<username>/.local/share/bob`, windows: `C:\Users\<username>\AppData\Local\bob` |
| **installation_location** | The path in which the proxied neovim installation will be located in | unix: `/home/<username>/.local/share/bob/nvim-bin`, windows: `C:\Users\<username>\AppData\Local\bob\nvim-bin` |
| **version_sync_file_location** | The path to a file that will hold the neovim version string, useful for config version tracking, bob will error if the specified file is not a valid file path | `Disabled by default` |
Expand All @@ -203,6 +204,7 @@ Example: `export BOB_CONFIG=/path/to/config/config.json`
// /home/user/.config/bob/config.json
{
"enable_nightly_info": true, // Will show new commits associated with new nightly release if enabled
"enable_release_build": false, // Compile neovim nightly or a certain hash version as a release build (slightly improved performance, no debug info)
"downloads_location": "$HOME/.local/share/bob", // The folder in which neovim versions will be installed too, bob will error if this option is specified but the folder doesn't exist
"installation_location": "/home/user/.local/share/bob/nvim-bin", // The path in which the used neovim version will be located in
"version_sync_file_location": "/home/user/.config/nvim/nvim.version", // The path to a file that will hold the neovim version string, useful for config version tracking, bob will error if the specified file is not a valid file path
Expand Down
2 changes: 2 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use tokio::fs;
#[derive(Serialize, Deserialize, Debug)]
pub struct Config {
pub enable_nightly_info: Option<bool>,
pub enable_release_build: Option<bool>,
pub downloads_location: Option<String>,
pub installation_location: Option<String>,
pub version_sync_file_location: Option<String>,
Expand All @@ -24,6 +25,7 @@ pub async fn handle_config() -> Result<Config> {
}
Err(_) => Config {
enable_nightly_info: None,
enable_release_build: None,
downloads_location: None,
installation_location: None,
version_sync_file_location: None,
Expand Down
22 changes: 20 additions & 2 deletions src/handlers/install_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,17 @@ pub async fn start(
}
}

let downloaded_file = download_version(client, version, root, config).await?;
let downloaded_file = match version.version_type {
VersionType::Normal | VersionType::Latest => download_version(client, version, root, config).await,
VersionType::Nightly => {
if config.enable_release_build == Some(true) {
handle_building_from_source(version, config).await
} else {
download_version(client, version, root, config).await
}
}
VersionType::Hash => handle_building_from_source(version, config).await,
}?;

if let PostDownloadVersionType::Standard(downloaded_file) = downloaded_file {
unarchive::start(downloaded_file).await?
Expand Down Expand Up @@ -337,7 +347,15 @@ async fn handle_building_from_source(
"CMAKE_INSTALL_PREFIX={}",
downloads_location.to_string_lossy()
);
handle_subprocess(Command::new("make").arg(&location_arg).arg("CMAKE_BUILD_TYPE=RelWithDebInfo")).await?;

let build_type = match config.enable_release_build {
Some(true) => "Release",
_ => "RelWithDebInfo",
};

let build_arg = format!("CMAKE_BUILD_TYPE={}", build_type);

handle_subprocess(Command::new("make").arg(&location_arg).arg(&build_arg)).await?;
handle_subprocess(Command::new("make").arg("install")).await?;
}
}
Expand Down

0 comments on commit 771cce1

Please sign in to comment.