-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Copy config files to output directory
- Loading branch information
Showing
3 changed files
with
62 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,43 @@ | ||
use std::env; | ||
use std::path::PathBuf; | ||
use clap_complete::shells; | ||
|
||
include!("src/cli.rs"); | ||
|
||
|
||
fn main() { | ||
let outdir = env::var_os("CARGO_TARGET_DIR") | ||
let outdir: PathBuf = env::var_os("CARGO_TARGET_DIR") | ||
.or_else(|| env::var_os("OUT_DIR")) | ||
.unwrap(); | ||
.unwrap() | ||
.into(); | ||
|
||
let rootdir = env::current_dir().unwrap(); | ||
let rootdir = rootdir | ||
.parent().unwrap(); | ||
|
||
println!("{rootdir:?}"); | ||
|
||
// generate shell completions | ||
let mut app = app(); | ||
clap_complete::generate_to(shells::Bash, &mut app, "surface-dtx-daemon", &outdir).unwrap(); | ||
clap_complete::generate_to(shells::Zsh, &mut app, "surface-dtx-daemon", &outdir).unwrap(); | ||
clap_complete::generate_to(shells::Fish, &mut app, "surface-dtx-daemon", &outdir).unwrap(); | ||
|
||
// copy config files | ||
let files = [ | ||
"etc/dbus/org.surface.dtx.conf", | ||
"etc/dtx/attach.sh", | ||
"etc/dtx/detach.sh", | ||
"etc/dtx/surface-dtx-daemon.conf", | ||
"etc/systemd/surface-dtx-daemon.service", | ||
"etc/udev/40-surface_dtx.rules", | ||
]; | ||
|
||
for file in files { | ||
let src = rootdir.join(file); | ||
let tgt = outdir.join(file); | ||
|
||
std::fs::create_dir_all(tgt.parent().unwrap()).unwrap(); | ||
std::fs::copy(src, tgt).unwrap(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,39 @@ | ||
use std::env; | ||
use std::path::PathBuf; | ||
use clap_complete::shells; | ||
|
||
include!("src/cli.rs"); | ||
|
||
|
||
fn main() { | ||
let outdir = env::var_os("CARGO_TARGET_DIR") | ||
let outdir: PathBuf = env::var_os("CARGO_TARGET_DIR") | ||
.or_else(|| env::var_os("OUT_DIR")) | ||
.unwrap(); | ||
.unwrap() | ||
.into(); | ||
|
||
let rootdir = env::current_dir().unwrap(); | ||
let rootdir = rootdir | ||
.parent().unwrap(); | ||
|
||
println!("{rootdir:?}"); | ||
|
||
// generate shell completions | ||
let mut app = app(); | ||
clap_complete::generate_to(shells::Bash, &mut app, "surface-dtx-userd", &outdir).unwrap(); | ||
clap_complete::generate_to(shells::Zsh, &mut app, "surface-dtx-userd", &outdir).unwrap(); | ||
clap_complete::generate_to(shells::Fish, &mut app, "surface-dtx-userd", &outdir).unwrap(); | ||
|
||
// copy config files | ||
let files = [ | ||
"etc/dtx/surface-dtx-userd.conf", | ||
"etc/systemd/surface-dtx-userd.service", | ||
]; | ||
|
||
for file in files { | ||
let src = rootdir.join(file); | ||
let tgt = outdir.join(file); | ||
|
||
std::fs::create_dir_all(tgt.parent().unwrap()).unwrap(); | ||
std::fs::copy(src, tgt).unwrap(); | ||
} | ||
} |