summaryrefslogtreecommitdiffstats
path: root/build.rs
diff options
context:
space:
mode:
authorManos Pitsidianakis <el13635@mail.ntua.gr>2019-11-16 00:33:22 +0200
committerManos Pitsidianakis <el13635@mail.ntua.gr>2019-11-16 00:33:22 +0200
commit321be8555fe194d2e39a9f07342186fb23fb53a1 (patch)
tree77a287679c4abef6564f02ffff49e67452660b57 /build.rs
parentaeb9d046a27929158565c21399205b3f06767f41 (diff)
Cleanup startup error exit paths
Make startup methods return Results so that the main binary can exit cleanly instead of using std::process::exit from arbitrary positions, which exits the process immediately and doesn't run destructors.
Diffstat (limited to 'build.rs')
-rw-r--r--build.rs77
1 files changed, 0 insertions, 77 deletions
diff --git a/build.rs b/build.rs
deleted file mode 100644
index 6907b0d3..00000000
--- a/build.rs
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * meli - bin.rs
- *
- * Copyright 2019 Manos Pitsidianakis
- *
- * This file is part of meli.
- *
- * meli is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * meli is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with meli. If not, see <http://www.gnu.org/licenses/>.
- */
-use std::fs::File;
-use std::io::prelude::*;
-use std::io::BufWriter;
-use std::path::PathBuf;
-use std::process::Command;
-
-fn main() -> Result<(), std::io::Error> {
- if let Err(e) = std::fs::create_dir("src/manuals") {
- if e.kind() != std::io::ErrorKind::AlreadyExists {
- Err(e)?;
- }
- }
- let mut build_flag = false;
- let meli_1_metadata = std::fs::metadata("meli.1")?;
- if let Ok(metadata) = std::fs::metadata("src/manuals/meli.txt") {
- if metadata.modified()? < meli_1_metadata.modified()? {
- build_flag = true;
- }
- } else {
- /* Doesn't exist */
- build_flag = true;
- }
-
- if build_flag {
- let output = if let Ok(output) = Command::new("mandoc").args(&["meli.1"]).output() {
- output.stdout
- } else {
- b"mandoc was not found on your system. It's required in order to compile the manual pages into plain text for use with the --*manual command line flags.".to_vec()
- };
- let man_path = PathBuf::from("src/manuals/meli.txt");
- let file = File::create(&man_path)?;
- BufWriter::new(file).write_all(&output)?;
- }
-
- let mut build_flag = false;
- let meli_conf_5_metadata = std::fs::metadata("meli.conf.5")?;
- if let Ok(metadata) = std::fs::metadata("src/manuals/meli_conf.txt") {
- if metadata.modified()? < meli_conf_5_metadata.modified()? {
- build_flag = true;
- }
- } else {
- /* Doesn't exist */
- build_flag = true;
- }
-
- if build_flag {
- let output = if let Ok(output) = Command::new("mandoc").args(&["meli.conf.5"]).output() {
- output.stdout
- } else {
- b"mandoc was not found on your system. It's required in order to compile the manual pages into plain text for use with the --*manual command line flags.".to_vec()
- };
- let man_path = PathBuf::from("src/manuals/meli_conf.txt");
- let file = File::create(&man_path)?;
- BufWriter::new(file).write_all(&output)?;
- }
- Ok(())
-}