diff --git a/.gitignore b/.gitignore index 76aaef7..90d57b5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ target/ +build/ Makefile diff --git a/Makefile.in b/Makefile.in index 3cf251d..3b67f2d 100644 --- a/Makefile.in +++ b/Makefile.in @@ -45,7 +45,7 @@ persistent = $(if $(filter $(enable_persistent),yes),True,False) all: $(builddir) $(outputs) clean: - rm -rf $(outdir) + rm -rf $(outdir) $(builddir) distprep: $(distdir) cp -a configure $(distdir) @@ -53,7 +53,7 @@ distprep: $(distdir) cp -a LICENSE $(distdir) cp -a README.md $(distdir) cp -a VERSION $(distdir) - cp -a src $(distdir) + cp -a src $(distdir) dist: $(tarball) @@ -63,20 +63,7 @@ test: all cargo test build: all - cargo build --release - cp -a target/release/systemd-crontab-generator \ - target/release/crontab \ - target/release/remove-stale-stamps \ - target/release/mail-on-failure \ - target/release/boot-delay \ - $(builddir)/bin/ - cp -a target/release/build/systemd-crontab-generator-*/out/*.target \ - target/release/build/systemd-crontab-generator-*/out/*.service \ - target/release/build/systemd-crontab-generator-*/out/*.timer \ - target/release/build/systemd-crontab-generator-*/out/*.path \ - $(builddir)/units/ - cp -a target/release/build/systemd-crontab-generator-*/out/*.[1578] \ - $(builddir)/man/ + cargo install --path . --root $(builddir) install: build install -m2755 -g `getent group cron || echo root` -s -D $(builddir)/bin/crontab $(DESTDIR)$(bindir)/crontab diff --git a/build.rs b/build.rs index 10d0996..4861770 100644 --- a/build.rs +++ b/build.rs @@ -3,7 +3,7 @@ extern crate rustc_serialize; use std::env; use std::path::Path; -use std::fs::{self, File}; +use std::fs::{self, File, create_dir_all}; use std::io::{Read, Write}; use std::collections::BTreeMap; @@ -15,7 +15,11 @@ static MAN_DIR: &'static str = "man"; fn main() { let out_dir = env::var("OUT_DIR").unwrap(); - let output = Path::new(&*out_dir); + let units_out_dir = env::var("CARGO_MANIFEST_DIR").unwrap(); + let output = Path::new(&*units_out_dir).join("out").join("build"); + + create_dir_all(output.join("units")).unwrap(); + create_dir_all(output.join("man")).unwrap(); let data = build_render_data(); @@ -33,15 +37,15 @@ fn main() { for schedule_unit in [ "target", "timer", "service" ].iter() { compile_template( format!("{}/cron-schedule.{}.in", UNITS_DIR, schedule_unit), - output.join(format!("cron-{}.{}", schedule, schedule_unit)), + output.join("units").join(format!("cron-{}.{}", schedule, schedule_unit)), &data); } } data.as_object_mut().unwrap().insert("schedules".to_owned(), schedules.to_json()); - compile_templates(UNITS_DIR, output, &data); - compile_templates(MAN_DIR, output, &data); + compile_templates(UNITS_DIR, output.join("units"), &data); + compile_templates(MAN_DIR, output.join("man"), &data); } fn compile_template, T: AsRef>(source_file: S, target_file: T, data: &Json) {