diff --git a/Cargo.toml b/Cargo.toml index 64f2aef..721bb1a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ edition = "2021" anyhow = "1.0.75" clap = { version = "4.4.2", features = ["derive"] } futures = "0.3.30" -git2 = "0.20.0" +git2 = { version = "0.20.0", optional = true } lazy-regex = "3.1.0" rbx_asset = { path = "rbx_asset", features = ["gzip", "rustls-tls"], default-features = false } rbx_binary = "1.0.0" @@ -21,6 +21,10 @@ rox_compiler = { path = "rox_compiler" } serde_json = "1.0.111" tokio = { version = "1.35.1", features = ["macros", "rt-multi-thread", "fs"] } +[features] +default = [] +git = ["dep:git2"] + [profile.release] #lto = true strip = true diff --git a/src/main.rs b/src/main.rs index 18a2e0f..43f7fb7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,6 +8,7 @@ use rbx_asset::cookie::{Cookie,Context as CookieContext,AssetVersion,CreationsIt type AssetID=u64; type AssetIDFileMap=Vec<(AssetID,PathBuf)>; +#[cfg(feature="git")] const CONCURRENT_DECODE:usize=8; const CONCURRENT_REQUESTS:usize=32; const CONCURRENT_FS:usize=64; @@ -43,7 +44,9 @@ enum Commands{ CompileUploadAsset(CompileUploadAssetSubcommand), CompileUploadPlace(CompileUploadPlaceSubcommand), Decompile(DecompileSubcommand), + #[cfg(feature="git")] DecompileHistoryIntoGit(DecompileHistoryIntoGitSubcommand), + #[cfg(feature="git")] DownloadAndDecompileHistoryIntoGit(DownloadAndDecompileHistoryIntoGitSubcommand), RunLuau(RunLuauSubcommand), } @@ -739,6 +742,7 @@ async fn main()->AResult<()>{ write_models:subcommand.write_models.unwrap_or(false), write_scripts:subcommand.write_scripts.unwrap_or(true), }).await, + #[cfg(feature="git")] Commands::DecompileHistoryIntoGit(subcommand)=>decompile_history_into_git(DecompileHistoryConfig{ git_committer_name:subcommand.git_committer_name, git_committer_email:subcommand.git_committer_email, @@ -749,6 +753,7 @@ async fn main()->AResult<()>{ write_models:subcommand.write_models.unwrap_or(false), write_scripts:subcommand.write_scripts.unwrap_or(true), }).await, + #[cfg(feature="git")] Commands::DownloadAndDecompileHistoryIntoGit(subcommand)=>download_and_decompile_history_into_git(DownloadAndDecompileHistoryConfig{ git_committer_name:subcommand.git_committer_name, git_committer_email:subcommand.git_committer_email, @@ -1712,6 +1717,7 @@ async fn download_decompile(config:DownloadDecompileConfig)->AResult<()>{ Ok(()) } +#[cfg(feature="git")] struct WriteCommitConfig{ git_committer_name:String, git_committer_email:String, @@ -1722,6 +1728,7 @@ struct WriteCommitConfig{ write_scripts:bool, } +#[cfg(feature="git")] async fn write_commit(config:WriteCommitConfig,b:Result,tokio::task::JoinError>,repo:&git2::Repository)->AResult<()>{ let (asset_version,context)=b??; println!("writing files for version {}",asset_version.assetVersionNumber); @@ -1803,6 +1810,7 @@ async fn write_commit(config:WriteCommitConfig,b:ResultAResult<()>{ //use prexisting versions list let mut versions_path=config.input_folder.clone(); @@ -1852,6 +1861,7 @@ async fn decompile_history_into_git(config:DecompileHistoryConfig)->AResult<()>{ Ok(()) } +#[cfg(feature="git")] struct DownloadAndDecompileHistoryConfig{ cookie:Cookie, asset_id:AssetID, @@ -1864,6 +1874,7 @@ struct DownloadAndDecompileHistoryConfig{ write_scripts:bool, } +#[cfg(feature="git")] async fn download_and_decompile_history_into_git(config:DownloadAndDecompileHistoryConfig)->AResult<()>{ let context=CookieContext::new(config.cookie);