run-program: support I/O redirection to binary streams on win32.
[sbcl.git] / src / cold / slam.lisp
blob9f8ff9368859cf677c6ba5fb779ce2d278811121
1 ;;;; crude selective re-cross-compilation of the target system, like
2 ;;;; Unix make(1), but much flakier because we don't keep track of the
3 ;;;; (many!) dependencies between files
5 ;;;; This software is part of the SBCL system. See the README file for
6 ;;;; more information.
7 ;;;;
8 ;;;; This software is derived from the CMU CL system, which was
9 ;;;; written at Carnegie Mellon University and released into the
10 ;;;; public domain. The software is in the public domain and is
11 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
12 ;;;; files for more information.
14 (in-package :sb-cold)
16 ;;; (This file is intended to be loaded into an after-xc.lisp core, so
17 ;;; we don't need to LOAD any machinery (e.g. "src/cold/shared.lisp")
18 ;;; which was already loaded in the course of setting up the system
19 ;;; state which was frozen into that core.)
21 ;;; basic test for up-to-date-ness of output with respect to input in
22 ;;; the sense of Unix make(1)
23 (defun output-up-to-date-wrt-input-p (output input)
24 (and (probe-file output)
25 ;; (Strict #'> and lax #'>= each have problems here, which
26 ;; could become more noticeable as computation speed
27 ;; accelerates while Common Lisp's 1-second granularity remains
28 ;; the same. We use #'> because it's safer sometimes to
29 ;; recompile unnecessarily than sometimes bogusly to assume
30 ;; up-to-date-ness.)
31 (> (file-write-date output)
32 (file-write-date input))))
34 ;;; One possible use-case for slam.sh is to generate a trace-file for
35 ;;; a file that is suddenly of interest, but was not of interest
36 ;;; before. In order for this to work, we need to reload the stems
37 ;;; and flags from build-order.lisp-expr, the user needs to have added
38 ;;; :trace-file as a flag.
39 (setf *stems-and-flags* (read-from-file "build-order.lisp-expr"))
41 (do-stems-and-flags (stem flags)
42 (unless (position :not-target flags)
43 (let ((srcname (stem-source-path stem))
44 (objname (stem-object-path stem flags :target-compile)))
45 (when (or (member :slam-forcibly flags)
46 (not (output-up-to-date-wrt-input-p objname srcname))
47 ;; Back to our "new-trace-file" case, also build if
48 ;; a trace file is desired but is out-of-date.
49 (and (position :trace-file flags)
50 (not (output-up-to-date-wrt-input-p
51 (concatenate 'string (stem-remap-target stem)
52 ".trace")
53 srcname))))
54 (target-compile-stem stem flags)))))
55 (save-initial-symbol-values)