rustc: Emit phony targets for inputs in dep-info

This helps protect against files being deleted to ensure that `make` won't emit
errors.

Closes #28735
This commit is contained in:
Alex Crichton 2015-09-30 10:17:07 -07:00
parent 8c963c07a8
commit 1741962271
3 changed files with 29 additions and 3 deletions

View File

@ -881,9 +881,16 @@ fn write_out_deps(sess: &Session, outputs: &OutputFilenames, id: &str) {
.collect();
let mut file = try!(fs::File::create(&deps_filename));
for path in &out_filenames {
try!(write!(&mut file,
try!(write!(file,
"{}: {}\n\n", path.display(), files.join(" ")));
}
// Emit a fake target for each input file to the compilation. This
// prevents `make` from spitting out an error if a file is later
// deleted. For more info see #28735
for path in files {
try!(writeln!(file, "{}:", path));
}
Ok(())
})();

View File

@ -7,9 +7,10 @@
ifneq ($(shell uname),FreeBSD)
ifndef IS_WINDOWS
all:
$(RUSTC) --emit dep-info,link --crate-type=lib lib.rs
cp *.rs $(TMPDIR)
$(RUSTC) --emit dep-info,link --crate-type=lib $(TMPDIR)/lib.rs
sleep 2
touch foo.rs
touch $(TMPDIR)/foo.rs
-rm -f $(TMPDIR)/done
$(MAKE) -drf Makefile.foo
sleep 2
@ -17,6 +18,11 @@ all:
pwd
$(MAKE) -drf Makefile.foo
rm $(TMPDIR)/done && exit 1 || exit 0
# When a source file is deleted `make` should still work
rm $(TMPDIR)/bar.rs
cp $(TMPDIR)/lib2.rs $(TMPDIR)/lib.rs
$(MAKE) -drf Makefile.foo
else
all:

View File

@ -0,0 +1,13 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![crate_name = "foo"]
pub mod foo;