You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

93 lines
3.0 KiB

  1. /*
  2. * meli - build.rs
  3. *
  4. * Copyright 2020 Manos Pitsidianakis
  5. *
  6. * This file is part of meli.
  7. *
  8. * meli is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * meli is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with meli. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. extern crate proc_macro;
  22. extern crate quote;
  23. extern crate syn;
  24. mod config_macros;
  25. fn main() {
  26. println!("cargo:rerun-if-changed=build.rs");
  27. config_macros::override_derive(&[
  28. ("src/conf/pager.rs", "PagerSettings"),
  29. ("src/conf/listing.rs", "ListingSettings"),
  30. ("src/conf/notifications.rs", "NotificationsSettings"),
  31. ("src/conf/shortcuts.rs", "Shortcuts"),
  32. ("src/conf/composing.rs", "ComposingSettings"),
  33. ("src/conf/tags.rs", "TagsSettings"),
  34. ("src/conf/pgp.rs", "PGPSettings"),
  35. ]);
  36. #[cfg(feature = "cli-docs")]
  37. {
  38. const MANDOC_OPTS: &[&'static str] = &["-T", "utf8", "-I", "os=Generated by mandoc(1)"];
  39. use std::env;
  40. use std::fs::File;
  41. use std::io::prelude::*;
  42. use std::path::Path;
  43. use std::process::Command;
  44. let out_dir = env::var("OUT_DIR").unwrap();
  45. let mut out_dir_path = Path::new(&out_dir).to_path_buf();
  46. out_dir_path.push("meli.txt");
  47. let output = Command::new("mandoc")
  48. .args(MANDOC_OPTS)
  49. .arg("docs/meli.1")
  50. .output()
  51. .or_else(|_| Command::new("man").arg("-l").arg("docs/meli.1").output())
  52. .unwrap();
  53. let mut file = File::create(&out_dir_path).unwrap();
  54. file.write_all(&output.stdout).unwrap();
  55. out_dir_path.pop();
  56. out_dir_path.push("meli.conf.txt");
  57. let output = Command::new("mandoc")
  58. .args(MANDOC_OPTS)
  59. .arg("docs/meli.conf.5")
  60. .output()
  61. .or_else(|_| {
  62. Command::new("man")
  63. .arg("-l")
  64. .arg("docs/meli.conf.5")
  65. .output()
  66. })
  67. .unwrap();
  68. let mut file = File::create(&out_dir_path).unwrap();
  69. file.write_all(&output.stdout).unwrap();
  70. out_dir_path.pop();
  71. out_dir_path.push("meli-themes.txt");
  72. let output = Command::new("mandoc")
  73. .args(MANDOC_OPTS)
  74. .arg("docs/meli-themes.5")
  75. .output()
  76. .or_else(|_| {
  77. Command::new("man")
  78. .arg("-l")
  79. .arg("docs/meli-themes.5")
  80. .output()
  81. })
  82. .unwrap();
  83. let mut file = File::create(&out_dir_path).unwrap();
  84. file.write_all(&output.stdout).unwrap();
  85. }
  86. }