Skip to content

Commit

Permalink
use a multi-call binary ('uni') to have only one build step (#987)
Browse files Browse the repository at this point in the history
This increases installation size, but should decrease build time
as symbols and optimizations can be shared more.

Once deduplication of generics has happened, these wins should increase
even more.

However, as it probably increases compile times for CI as it will take longer
to build each binary with different compile time flags. Thus I just leave
the `uni.rs` file for reference.
  • Loading branch information
Byron committed Sep 2, 2023
1 parent 11b9c71 commit 4ef9a32
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ resolver = "2"

[[bin]]
name = "ein"
doc = false
path = "src/ein.rs"
doc = false
test = false
doctest = false

Expand Down
1 change: 0 additions & 1 deletion src/gix.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#![deny(unsafe_code, rust_2018_idioms)]

mod plumbing;
mod shared;

use anyhow::Result;

Expand Down
14 changes: 6 additions & 8 deletions src/plumbing/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,14 @@ use gitoxide_core as core;
use gitoxide_core::{pack::verify, repository::PathsOrPatterns};
use gix::bstr::{io::BufReadExt, BString};

use crate::{
plumbing::{
options::{
attributes, commit, commitgraph, config, credential, exclude, free, index, mailmap, odb, revision, tree,
Args, Subcommands,
},
show_progress,
use crate::plumbing::{
options::{
attributes, commit, commitgraph, config, credential, exclude, free, index, mailmap, odb, revision, tree, Args,
Subcommands,
},
shared::pretty::prepare_and_run,
show_progress,
};
use gitoxide::shared::pretty::prepare_and_run;

#[cfg(feature = "gitoxide-core-async-client")]
pub mod async_util {
Expand Down
28 changes: 28 additions & 0 deletions src/uni.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//! An experiment to see how a multi-call binary could look like.
//! For CI this would mean longer compile times though as it rebuilds `gix`
//! with varying compile flags, which also means that it recompiles all source or `ein`.
//!
//! However, doing this could be interesting for distribution if the files are hard-linked
//! instead of copied, which is why it is left here.
#![deny(unsafe_code, rust_2018_idioms)]

use anyhow::{bail, Result};

mod plumbing;
mod porcelain;

#[cfg(feature = "pretty-cli")]
fn main() -> Result<()> {
match std::env::current_exe()?
.file_stem()
.and_then(|stem| stem.to_str())
.unwrap_or("gix")
{
"gix" => plumbing::main(),
"ein" => porcelain::main(),
unknown => bail!("Executable named '{unknown}' cannot be launched. Exe must be named either `gix` or `ein`."),
}
}

#[cfg(not(feature = "pretty-cli"))]
compile_error!("Please set 'pretty-cli' feature flag");

0 comments on commit 4ef9a32

Please sign in to comment.