Skip to content

Commit bbfdea7

Browse files
committed
Make it easier to use but-server in place of tauri
Tauri rebuilds too much which is a huge waste of time. This shouldn't happen with the server setup, all it takes is a server restart, the UI can stay up as well.
1 parent 7c35da5 commit bbfdea7

File tree

5 files changed

+47
-3
lines changed

5 files changed

+47
-3
lines changed

Cargo.lock

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ incremental = false
114114

115115
# Assure that `gix` is always fast so debug builds aren't unnecessarily slow.
116116
[profile.dev.package]
117+
gix = { opt-level = 3 }
117118
gix-object = { opt-level = 3 }
118119
gix-ref = { opt-level = 3 }
119120
gix-pack = { opt-level = 3 }

apps/desktop/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,12 @@ This builds the **web** target, points it to the but-server on `http://localhost
3636
#### 3. Go to the browser
3737

3838
Open Chrome (let's not kid ourselves) and got to `http://localhost:1420` and enjoy
39+
40+
41+
### Development
42+
43+
#### Auto-build the server on Rust changes
44+
45+
```bash
46+
watchexec -w crates -r -- cargo run -p but-server
47+
```

crates/but-server/Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ but-broadcaster.workspace = true
3535
but-path.workspace = true
3636
but-settings.workspace = true
3737
but-feedback.workspace = true
38-
gitbutler-user.workspace = true
3938
gitbutler-project.workspace = true
4039
gitbutler-watcher.workspace = true
40+
tracing.workspace = true
41+
tracing-subscriber.workspace = true
42+
tracing-forest = { version = "0.2.0" }
43+
gitbutler-secret.workspace = true

crates/but-server/src/main.rs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,32 @@
11
#[tokio::main]
2-
async fn main() {
2+
async fn main() -> anyhow::Result<()> {
3+
trace::init()?;
4+
// On macOS, in dev mode with debug assertions, we encounter popups each time
5+
// the binary is rebuilt. To counter that, use a git-credential based implementation.
6+
// This isn't an issue for actual release build (i.e. nightly, production),
7+
// hence the specific condition.
8+
if cfg!(debug_assertions) && cfg!(target_os = "macos") {
9+
gitbutler_secret::secret::git_credentials::setup().ok();
10+
}
311
but_server::run().await;
12+
Ok(())
13+
}
14+
15+
mod trace {
16+
use tracing::metadata::LevelFilter;
17+
use tracing_subscriber::Layer;
18+
use tracing_subscriber::layer::SubscriberExt;
19+
use tracing_subscriber::util::SubscriberInitExt;
20+
21+
pub fn init() -> anyhow::Result<()> {
22+
tracing_subscriber::registry()
23+
.with(
24+
tracing_forest::ForestLayer::from(
25+
tracing_forest::printer::PrettyPrinter::new().writer(std::io::stderr),
26+
)
27+
.with_filter(LevelFilter::DEBUG),
28+
)
29+
.init();
30+
Ok(())
31+
}
432
}

0 commit comments

Comments
 (0)