aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Letan <contact@thomasletan.fr>2019-08-07 17:37:11 +0200
committerThomas Letan <contact@thomasletan.fr>2019-08-07 17:37:11 +0200
commit66609334ef6cbaefa09757ebc65582445f71d134 (patch)
tree99533d6cca90b90748dba47c1a3ad3ec3f911e1c
parentrefactor: Provide a less cumbersome error handling (diff)
feature: In release mode, look for assets in `/usr/local'
There is currently no way to overload these files, e.g., you cannot specify your own font to be used for example. This might (probably will actually) change in the future.
-rw-r--r--Makefile20
-rw-r--r--src/main.rs13
2 files changed, 31 insertions, 2 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..998d513
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,20 @@
+TEMPLATES := $(wildcard templates/*)
+FONTS := $(wildcard fonts/*)
+
+release:
+ @cargo build --release
+
+install: release
+ @sudo -k # always ask user password
+ @sudo install -dv /usr/local/share/celtchar/templates \
+ /usr/local/share/celtchar/fonts
+ @sudo install -v ${TEMPLATES} /usr/local/share/celtchar/templates
+ @sudo install -v ${FONTS} /usr/local/share/celtchar/fonts
+ @sudo install -v target/release/celtchar /usr/local/bin/celtchar
+
+uninstall:
+ @sudo rm -rfv /usr/local/share/celtchar
+ @sudo rm -fv /usr/local/bin/celtchar
+
+
+.PHONY: install uninstall release
diff --git a/src/main.rs b/src/main.rs
index bcccad1..0e7ebca 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -47,6 +47,16 @@ pub fn build(assets : &PathBuf) -> Result<(), Error> {
Ok(())
}
+#[cfg(debug_assertions)]
+fn get_assets() -> Result<PathBuf, Error> {
+ current_dir().or_raise("cannot get current directory")
+}
+
+#[cfg(not(debug_assertions))]
+fn get_assets() -> Result<PathBuf, Error> {
+ Ok(PathBuf::from("/usr/local/share/celtchar"))
+}
+
fn main() -> Result<(), Error> {
let matches = App::new("celtchar")
.version("0.1")
@@ -60,8 +70,7 @@ fn main() -> Result<(), Error> {
let (subcommand, _args) = matches.subcommand();
- // TODO: in release mode, look for /usr/share/celtchar/assets
- let assets: PathBuf = current_dir().or_raise("cannot get current directory")?;
+ let assets: PathBuf = get_assets()?;
match subcommand {
"build" => build(&assets)?,