🐝 My patches for macos etc...
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.

106 lines
3.6 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. use flate2::Compression;
  39. use flate2::GzBuilder;
  40. const MANDOC_OPTS: &[&'static str] = &["-T", "utf8", "-I", "os=Generated by mandoc(1)"];
  41. use std::env;
  42. use std::fs::File;
  43. use std::io::prelude::*;
  44. use std::path::Path;
  45. use std::process::Command;
  46. let out_dir = env::var("OUT_DIR").unwrap();
  47. let mut out_dir_path = Path::new(&out_dir).to_path_buf();
  48. out_dir_path.push("meli.txt.gz");
  49. let output = Command::new("mandoc")
  50. .args(MANDOC_OPTS)
  51. .arg("docs/meli.1")
  52. .output()
  53. .or_else(|_| Command::new("man").arg("-l").arg("docs/meli.1").output())
  54. .unwrap();
  55. let file = File::create(&out_dir_path).unwrap();
  56. let mut gz = GzBuilder::new()
  57. .comment(output.stdout.len().to_string().into_bytes())
  58. .write(file, Compression::default());
  59. gz.write_all(&output.stdout).unwrap();
  60. gz.finish().unwrap();
  61. out_dir_path.pop();
  62. out_dir_path.push("meli.conf.txt.gz");
  63. let output = Command::new("mandoc")
  64. .args(MANDOC_OPTS)
  65. .arg("docs/meli.conf.5")
  66. .output()
  67. .or_else(|_| {
  68. Command::new("man")
  69. .arg("-l")
  70. .arg("docs/meli.conf.5")
  71. .output()
  72. })
  73. .unwrap();
  74. let file = File::create(&out_dir_path).unwrap();
  75. let mut gz = GzBuilder::new()
  76. .comment(output.stdout.len().to_string().into_bytes())
  77. .write(file, Compression::default());
  78. gz.write_all(&output.stdout).unwrap();
  79. gz.finish().unwrap();
  80. out_dir_path.pop();
  81. out_dir_path.push("meli-themes.txt.gz");
  82. let output = Command::new("mandoc")
  83. .args(MANDOC_OPTS)
  84. .arg("docs/meli-themes.5")
  85. .output()
  86. .or_else(|_| {
  87. Command::new("man")
  88. .arg("-l")
  89. .arg("docs/meli-themes.5")
  90. .output()
  91. })
  92. .unwrap();
  93. let file = File::create(&out_dir_path).unwrap();
  94. let mut gz = GzBuilder::new()
  95. .comment(output.stdout.len().to_string().into_bytes())
  96. .write(file, Compression::default());
  97. gz.write_all(&output.stdout).unwrap();
  98. gz.finish().unwrap();
  99. }
  100. }