feat: unified binary

This commit is contained in:
Ilya Zlobintsev committed 2023-01-05 12:45:57 +02:00
1 parent 8db28b2608
commit de9786b59e
13 files changed
+92 -51

No files matched your search

Generated
+10
View File
@@ -691,6 +691,16 @@ version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440"
[[package]]
name = "lact"
version = "0.1.0"
dependencies = [
"anyhow",
"clap",
"lact-daemon",
"lact-gui",
]
[[package]]
name = "lact-cli"
version = "0.1.0"
+1 -1
View File
@@ -1,3 +1,3 @@
[workspace]
resolver = "2"
members = ["lact-*"]
members = ["lact*"]
+2 -6
View File
@@ -5,17 +5,13 @@ build-release:
cargo build --release
install:
install -Dm755 target/release/lact-daemon ${DESTDIR}/bin/lact-daemon
install -Dm755 target/release/lact-gui ${DESTDIR}/bin/lact-gui
install -Dm755 target/release/lact-cli ${DESTDIR}/bin/lact-cli
install -Dm755 target/release/lact ${DESTDIR}/bin/lact
install -Dm755 res/lactd.service ${DESTDIR}/lib/systemd/system/lactd.service
install -Dm755 res/lact.desktop ${DESTDIR}/share/applications/lact.desktop
install -Dm755 res/lact.png ${DESTDIR}/share/pixmaps/lact.png
uninstall:
rm ${DESTDIR}/bin/lact-daemon
rm ${DESTDIR}/bin/lact-gui
rm ${DESTDIR}/bin/lact-cli
rm ${DESTDIR}/bin/lact
rm ${DESTDIR}/lib/systemd/system/lactd.service
rm ${DESTDIR}/share/applications/lact.desktop
rm ${DESTDIR}/share/pixmaps/lact.png
+42
View File
@@ -0,0 +1,42 @@
mod config;
mod fork;
mod server;
mod socket;
use anyhow::Context;
use config::Config;
use server::Server;
use std::str::FromStr;
use tokio::{runtime, signal::ctrl_c};
use tracing::{debug_span, Instrument, Level};
pub fn run() -> anyhow::Result<()> {
let rt = runtime::Builder::new_current_thread()
.enable_all()
.build()
.expect("Could not initialize tokio runtime");
rt.block_on(async {
let config = Config::load_or_create()?;
let max_level = Level::from_str(&config.daemon.log_level).context("Invalid log level")?;
tracing_subscriber::fmt().with_max_level(max_level).init();
let server = Server::new(config).await?;
let handler = server.handler.clone();
tokio::spawn(async move {
ctrl_c().await.expect("Could not listen to shutdown signal");
async {
handler.cleanup().await;
socket::cleanup();
}
.instrument(debug_span!("shutdown_cleanup"))
.await;
std::process::exit(0);
});
server.run().await;
Ok(())
})
}
-37
View File
@@ -1,37 +0,0 @@
mod config;
mod fork;
mod server;
mod socket;
use anyhow::Context;
use config::Config;
use server::Server;
use std::str::FromStr;
use tokio::signal::ctrl_c;
use tracing::{debug_span, Instrument, Level};
#[tokio::main(flavor = "current_thread")]
async fn main() -> anyhow::Result<()> {
let config = Config::load_or_create()?;
let max_level = Level::from_str(&config.daemon.log_level).context("Invalid log level")?;
tracing_subscriber::fmt().with_max_level(max_level).init();
let server = Server::new(config).await?;
let handler = server.handler.clone();
tokio::spawn(async move {
ctrl_c().await.expect("Could not listen to shutdown signal");
async {
handler.cleanup().await;
socket::cleanup();
}
.instrument(debug_span!("shutdown_cleanup"))
.await;
std::process::exit(0);
});
server.run().await;
Ok(())
}
+1 -1
View File
@@ -157,7 +157,7 @@ impl App {
app.window.show();
}));
self.application.run();
self.application.run_with_args::<String>(&[]);
Ok(())
}
@@ -1,9 +1,6 @@
mod imp;
use std::borrow::Cow;
use gtk::glib::{self, Object};
use indexmap::IndexMap;
glib::wrapper! {
pub struct FeatureModel(ObjectSubclass<imp::FeatureModel>);
+1 -1
View File
@@ -6,7 +6,7 @@ use lact_client::DaemonClient;
use tracing::metadata::LevelFilter;
use tracing_subscriber::EnvFilter;
fn main() -> anyhow::Result<()> {
pub fn run() -> anyhow::Result<()> {
let env_filter = EnvFilter::builder()
.with_default_directive(LevelFilter::INFO.into())
.from_env_lossy();
+12
View File
@@ -0,0 +1,12 @@
[package]
name = "lact"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
lact-daemon = { path = "../lact-daemon" }
lact-gui = { path = "../lact-gui" }
anyhow = "1.0.68"
clap = { version = "4.0.32", features = ["derive"] }
+9
View File
@@ -0,0 +1,9 @@
use clap::Parser;
#[derive(Parser)]
pub enum Command {
/// Run the daemon
Daemon,
/// Run the GUI
Gui,
}
+12
View File
@@ -0,0 +1,12 @@
mod args;
use args::Command;
use clap::Parser;
fn main() -> anyhow::Result<()> {
let command = Command::parse();
match command {
Command::Daemon => lact_daemon::run(),
Command::Gui => lact_gui::run(),
}
}
+1 -1
View File
@@ -2,6 +2,6 @@
Type=Application
Name=LACT
GenericName=AMDGPU Control Application
Exec=lact-gui
Exec=lact gui
Icon=lact
Categories=System;
+1 -1
View File
@@ -3,7 +3,7 @@ Description=AMDGPU Control Daemon
After=multi-user.target
[Service]
ExecStart=lact-daemon
ExecStart=lact daemon
[Install]
WantedBy=graphical.target