From 0db627e3db58596441882c267260684ccbe6171a Mon Sep 17 00:00:00 2001 From: Olivier Wittek <57495944+owittek@users.noreply.github.com> Date: Sun, 16 Jul 2023 22:16:20 +0200 Subject: [PATCH] feat: add release build compilation --- README.md | 2 ++ src/config.rs | 2 ++ src/handlers/install_handler.rs | 22 ++++++++++++++++++++-- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fc1c961..bcb70d8 100644 --- a/README.md +++ b/README.md @@ -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//.local/share/bob`, windows: `C:\Users\\AppData\Local\bob` | | **installation_location** | The path in which the proxied neovim installation will be located in | unix: `/home//.local/share/bob/nvim-bin`, windows: `C:\Users\\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` | @@ -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 diff --git a/src/config.rs b/src/config.rs index f78011e..7e05f6b 100644 --- a/src/config.rs +++ b/src/config.rs @@ -7,6 +7,7 @@ use tokio::fs; #[derive(Serialize, Deserialize, Debug)] pub struct Config { pub enable_nightly_info: Option, + pub enable_release_build: Option, pub downloads_location: Option, pub installation_location: Option, pub version_sync_file_location: Option, @@ -24,6 +25,7 @@ pub async fn handle_config() -> Result { } Err(_) => Config { enable_nightly_info: None, + enable_release_build: None, downloads_location: None, installation_location: None, version_sync_file_location: None, diff --git a/src/handlers/install_handler.rs b/src/handlers/install_handler.rs index f3affee..c3d1dd5 100644 --- a/src/handlers/install_handler.rs +++ b/src/handlers/install_handler.rs @@ -61,7 +61,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? @@ -335,7 +345,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?; } }