add --fresh-auto-compile
authorAndy Wingo <wingo@pobox.com>
Fri, 15 Apr 2011 09:27:27 +0000 (11:27 +0200)
committerAndy Wingo <wingo@pobox.com>
Fri, 15 Apr 2011 09:27:27 +0000 (11:27 +0200)
* doc/ref/api-evaluation.texi (Compilation): Add discussion of
  --fresh-auto-compile.
* doc/ref/scheme-scripts.texi (Invoking Guile): Add --fresh-auto-compile
  option.

* NEWS: Add entry.

* libguile/load.c: Define %fresh-auto-compile.
  (scm_primitive_load_path): Use it here.
  (scm_init_load_should_auto_compile): Init from GUILE_AUTO_COMPILE env
  var, with a value of "fresh".

* module/ice-9/boot-9.scm (load-in-vicinity): Auto-compilation cache is
  stale if %fresh-auto-compile is true.

* module/ice-9/command-line.scm (compile-shell-switches): Parse out
  --fresh-auto-compile.

NEWS
doc/ref/api-evaluation.texi
doc/ref/scheme-scripts.texi
libguile/load.c
module/ice-9/boot-9.scm
module/ice-9/command-line.scm

diff --git a/NEWS b/NEWS
index cd12f60..4f0c220 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -128,6 +128,11 @@ interpreted as starting an R6RS hex escape.  This is backward compatible
 because the symbol printer would never produce a "\x" before.  The
 printer also works better too.
 
+** Added --force-auto-compile option
+
+This allows a user to invalidate the auto-compilation cache.  It's
+usually not needed.  See "Compilation" in the manual, for a discussion.
+
 * Manual updates
 
 ** GOOPS documentation updates
index 682e844..9430c74 100644 (file)
@@ -586,6 +586,15 @@ computation are fulfilled by macros and closures. Of course one good
 counterexample is the REPL itself, or any code that reads expressions
 from a port.)
 
+Automatic compilation generally works transparently, without any need
+for user intervention.  However Guile does not yet do proper dependency
+tracking, so that if file @file{@var{a}.scm} uses macros from
+@file{@var{b}.scm}, and @var{@var{b}.scm} changes, @code{@var{a}.scm}
+would not be automatically recompiled.  To forcibly invalidate the
+auto-compilation cache, pass the @code{--fresh-auto-compile} option to
+Guile, or set the @code{GUILE_AUTO_COMPILE} environment variable to
+@code{fresh} (instead of to @code{0} or @code{1}).
+
 For more information on the compiler itself, see @ref{Compiling to the
 Virtual Machine}. For information on the virtual machine, see @ref{A
 Virtual Machine for Guile}.
index 0ad1bec..c7d22a4 100644 (file)
@@ -227,6 +227,11 @@ development.
 @item --auto-compile
 Compile source files automatically (default behavior).
 
+@vnew{2.0.1}
+
+@item --fresh-auto-compile
+Treat the auto-compilation cache as invalid, forcing recompilation.
+
 @vnew{2.0}
 
 @item --no-auto-compile
index 701b34b..b0137a1 100644 (file)
@@ -210,6 +210,9 @@ static SCM *scm_loc_load_compiled_extensions;
 /* Whether we should try to auto-compile. */
 static SCM *scm_loc_load_should_auto_compile;
 
+/* Whether to treat all auto-compiled files as stale. */
+static SCM *scm_loc_fresh_auto_compile;
+
 /* The fallback path for auto-compilation */
 static SCM *scm_loc_compile_fallback_path;
 
@@ -824,6 +827,7 @@ SCM_DEFINE (scm_primitive_load_path, "primitive-load-path", 0, 0, 1,
   if (scm_is_false (compiled_filename)
       && scm_is_true (full_filename)
       && scm_is_true (*scm_loc_compile_fallback_path)
+      && scm_is_false (*scm_loc_fresh_auto_compile)
       && scm_is_pair (*scm_loc_load_compiled_extensions)
       && scm_is_string (scm_car (*scm_loc_load_compiled_extensions)))
     {
@@ -857,6 +861,7 @@ SCM_DEFINE (scm_primitive_load_path, "primitive-load-path", 0, 0, 1,
 
   if (!compiled_is_fallback
       && scm_is_true (*scm_loc_compile_fallback_path)
+      && scm_is_false (*scm_loc_fresh_auto_compile)
       && scm_is_pair (*scm_loc_load_compiled_extensions)
       && scm_is_string (scm_car (*scm_loc_load_compiled_extensions)))
     {
@@ -971,6 +976,8 @@ scm_init_load ()
     = SCM_VARIABLE_LOC (scm_c_define ("%compile-fallback-path", SCM_BOOL_F));
   scm_loc_load_should_auto_compile
     = SCM_VARIABLE_LOC (scm_c_define ("%load-should-auto-compile", SCM_BOOL_F));
+  scm_loc_fresh_auto_compile
+    = SCM_VARIABLE_LOC (scm_c_define ("%fresh-auto-compile", SCM_BOOL_F));
 
   the_reader = scm_make_fluid ();
   scm_fluid_set_x (the_reader, SCM_BOOL_F);
@@ -988,8 +995,24 @@ scm_init_load ()
 void
 scm_init_load_should_auto_compile ()
 {
-  *scm_loc_load_should_auto_compile =
-    scm_from_bool (scm_getenv_int ("GUILE_AUTO_COMPILE", 1));
+  char *auto_compile = getenv ("GUILE_AUTO_COMPILE");
+
+  if (auto_compile && strcmp (auto_compile, "0") == 0)
+    {
+      *scm_loc_load_should_auto_compile = SCM_BOOL_F;
+      *scm_loc_fresh_auto_compile = SCM_BOOL_F;
+    }
+  /* Allow "freshen" also.  */
+  else if (auto_compile && strncmp (auto_compile, "fresh", 5) == 0)
+    {
+      *scm_loc_load_should_auto_compile = SCM_BOOL_T;
+      *scm_loc_fresh_auto_compile = SCM_BOOL_T;
+    }
+  else
+    {
+      *scm_loc_load_should_auto_compile = SCM_BOOL_T;
+      *scm_loc_fresh_auto_compile = SCM_BOOL_F;
+    }
 }
   
   
index 800410c..84e76bd 100644 (file)
@@ -3290,7 +3290,8 @@ module '(ice-9 q) '(make-q q-length))}."
     (catch #t
       (lambda ()
         (let* ((scmstat (stat name))
-               (gostat  (stat go-path #f)))
+               (gostat  (and (not %fresh-auto-compile)
+                             (stat go-path #f))))
           (if (and gostat
                    (or (> (stat:mtime gostat) (stat:mtime scmstat))
                        (and (= (stat:mtime gostat) (stat:mtime scmstat))
index 9797364..a34c9a6 100644 (file)
@@ -127,7 +127,8 @@ If FILE begins with `-' the -s switch is mandatory.
                  Default is to enable debugging for interactive
                  use, but not for `-s' and `-c'.
   --auto-compile compile source files automatically
-  --no-auto-compile disable automatic source file compilation
+  --fresh-auto-compile  invalidate auto-compilation cache
+  --no-auto-compile  disable automatic source file compilation
                  Default is to enable auto-compilation of source
                  files.
   --listen[=P]   Listen on a local port or a path for REPL clients.
@@ -295,6 +296,11 @@ If FILE begins with `-' the -s switch is mandatory.
             (set! %load-should-auto-compile #t)
             (parse args out))
 
+           ((string=? arg "--fresh-auto-compile")
+            (set! %load-should-auto-compile #t)
+            (set! %fresh-auto-compile #t)
+            (parse args out))
+
            ((string=? arg "--no-auto-compile")
             (set! %load-should-auto-compile #f)
             (parse args out))