Commit 7e2a98ee authored by Raymond Toy's avatar Raymond Toy
Browse files

Allow disabling the use of git for the file-comment.

 * src/compiler/main.lisp:
   * Add *FILE-COMMENT-FROM-GIT* to control whether to use git to
     derive the file-comment.  Default is T.  Otherwise, the actual
     file-comment is used.
   * Update PROCESS-FILE-COMMENT to use *FILE-COMMENT-FROM-GIT*.

 * bin/build-all.sh
 * bin/build.sh
 * bin/build-world.sh
   * Add -G option to control whether file-comment's are derived from
     git.
parent 44abdb52
...@@ -35,12 +35,13 @@ usage () ...@@ -35,12 +35,13 @@ usage ()
echo " -P On the last build, (re)generate cmucl.pot and the" echo " -P On the last build, (re)generate cmucl.pot and the"
echo " translations" echo " translations"
echo " -R Force recompilation of C runtime" echo " -R Force recompilation of C runtime"
echo " -G Don't use git to fill file-comment information"
} }
CREATE_OPT="" CREATE_OPT=""
UPDATE_POT="-P" UPDATE_POT="-P"
while getopts "PRUB:b:v:C:o:8:?" arg while getopts "PRUGB:b:v:C:o:8:?" arg
do do
case $arg in case $arg in
b) BASE="$OPTARG" ;; b) BASE="$OPTARG" ;;
...@@ -53,6 +54,7 @@ do ...@@ -53,6 +54,7 @@ do
U) UPDATE_TRANS="-U" ;; U) UPDATE_TRANS="-U" ;;
P) UPDATE_POT="" ;; P) UPDATE_POT="" ;;
R) RECOMPILEC="-R" ;; R) RECOMPILEC="-R" ;;
G) GIT_FILE_COMMENT="-G" ;;
\?) usage; exit 1 ;; \?) usage; exit 1 ;;
esac esac
done done
...@@ -87,15 +89,15 @@ buildx86 () ...@@ -87,15 +89,15 @@ buildx86 ()
if [ -n "$OLD8" ]; then if [ -n "$OLD8" ]; then
# Build non-unicode versions # Build non-unicode versions
set -x set -x
$BINDIR/build.sh -f x87 -b ${BASE}-8bit $bootfiles ${VERSION:+-v "$VERSION"} -C "${CREATE_OPT}" ${UPDATE_TRANS} ${UPDATE_POT} ${RECOMPILEC} -o "$OLD8" $BINDIR/build.sh -f x87 -b ${BASE}-8bit $bootfiles ${VERSION:+-v "$VERSION"} -C "${CREATE_OPT}" ${UPDATE_TRANS} ${UPDATE_POT} ${RECOMPILEC} ${GIT_FILE_COMMENT} -o "$OLD8"
$BINDIR/build.sh -f sse2 -b ${BASE}-8bit $bootfiles ${VERSION:+-v "$VERSION"} -C "${CREATE_OPT}" ${UPDATE_TRANS} ${UPDATE_POT} ${RECOMPILEC} -o "$OLD8" $BINDIR/build.sh -f sse2 -b ${BASE}-8bit $bootfiles ${VERSION:+-v "$VERSION"} -C "${CREATE_OPT}" ${UPDATE_TRANS} ${UPDATE_POT} ${RECOMPILEC} ${GIT_FILE_COMMENT} -o "$OLD8"
set +x set +x
fi fi
# Build the unicode versions # Build the unicode versions
if [ -n "$OLDLISP" ]; then if [ -n "$OLDLISP" ]; then
set -x set -x
$BINDIR/build.sh -f x87 -b ${BASE} $bootfiles ${VERSION:+-v "$VERSION"} -C "${CREATE_OPT}" ${UPDATE_TRANS} ${UPDATE_POT} ${RECOMPILEC} -o "$OLDLISP" $BINDIR/build.sh -f x87 -b ${BASE} $bootfiles ${VERSION:+-v "$VERSION"} -C "${CREATE_OPT}" ${UPDATE_TRANS} ${UPDATE_POT} ${RECOMPILEC} ${GIT_FILE_COMMENT} -o "$OLDLISP"
$BINDIR/build.sh -f sse2 -b ${BASE} $bootfiles ${VERSION:+-v "$VERSION"} -C "${CREATE_OPT}" ${UPDATE_TRANS} ${UPDATE_POT} ${RECOMPILEC} -o "$OLDLISP" $BINDIR/build.sh -f sse2 -b ${BASE} $bootfiles ${VERSION:+-v "$VERSION"} -C "${CREATE_OPT}" ${UPDATE_TRANS} ${UPDATE_POT} ${RECOMPILEC} ${GIT_FILE_COMMENT} -o "$OLDLISP"
set +x set +x
fi fi
} }
...@@ -108,13 +110,13 @@ buildsun4 () ...@@ -108,13 +110,13 @@ buildsun4 ()
# Build non-unicode versions # Build non-unicode versions
if [ -n "$OLD8" ]; then if [ -n "$OLD8" ]; then
set -x set -x
$BINDIR/build.sh -b ${BASE}-8bit $bootfiles ${VERS} -C "$CREATE_OPT" ${UPDATE_TRANS} ${UPDATE_POT} ${RECOMPILEC} -o "$OLD8" $BINDIR/build.sh -b ${BASE}-8bit $bootfiles ${VERS} -C "$CREATE_OPT" ${UPDATE_TRANS} ${UPDATE_POT} ${RECOMPILEC} ${GIT_FILE_COMMENT} -o "$OLD8"
set +x set +x
fi fi
# Build the unicode version. # Build the unicode version.
if [ -n "$OLDLISP" ]; then if [ -n "$OLDLISP" ]; then
set -x set -x
$BINDIR/build.sh -b ${BASE} $bootfiles ${VERS} -C "$CREATE_OPT" ${UPDATE_TRANS} ${UPDATE_POT} ${RECOMPILEC} -o "$OLDLISP" $BINDIR/build.sh -b ${BASE} $bootfiles ${VERS} -C "$CREATE_OPT" ${UPDATE_TRANS} ${UPDATE_POT} ${RECOMPILEC} ${GIT_FILE_COMMENT} -o "$OLDLISP"
set +x set +x
fi fi
} }
......
...@@ -26,6 +26,12 @@ if [ -n "$MAKE_POT" ]; then ...@@ -26,6 +26,12 @@ if [ -n "$MAKE_POT" ]; then
SAVEPOT='(intl::dump-pot-files :output-directory "default:src/i18n/locale/")' SAVEPOT='(intl::dump-pot-files :output-directory "default:src/i18n/locale/")'
fi fi
if [ "$GIT_FILE_COMMENT" = "no" ]; then
GIT_FILE_COMMENT="(setf c::*file-comment-from-git* nil)"
else
GIT_FILE_COMMENT=
fi
$LISP "$@" -noinit -nositeinit <<EOF $LISP "$@" -noinit -nositeinit <<EOF
(in-package :cl-user) (in-package :cl-user)
...@@ -56,6 +62,8 @@ $LISP "$@" -noinit -nositeinit <<EOF ...@@ -56,6 +62,8 @@ $LISP "$@" -noinit -nositeinit <<EOF
(setq debug:*debug-print-level* nil) (setq debug:*debug-print-level* nil)
(setq debug:*debug-print-length* nil) (setq debug:*debug-print-length* nil)
$GIT_FILE_COMMENT
(load "target:tools/worldcom") (load "target:tools/worldcom")
#-(or no-compiler runtime) (load "target:tools/comcom") #-(or no-compiler runtime) (load "target:tools/comcom")
;; Compile at least new-genesis, so that genesis doesn't take ages ;; Compile at least new-genesis, so that genesis doesn't take ages
...@@ -64,7 +72,6 @@ $LISP "$@" -noinit -nositeinit <<EOF ...@@ -64,7 +72,6 @@ $LISP "$@" -noinit -nositeinit <<EOF
$GETFMT $GETFMT
$SAVEPOT $SAVEPOT
(setq *gc-verbose* t *interactive* t) (setq *gc-verbose* t *interactive* t)
(load "target:tools/worldbuild") (load "target:tools/worldbuild")
......
...@@ -45,6 +45,8 @@ BINDIR=bin ...@@ -45,6 +45,8 @@ BINDIR=bin
TOOLDIR=$BINDIR TOOLDIR=$BINDIR
OLDLISPFLAGS="-noinit -nositeinit" OLDLISPFLAGS="-noinit -nositeinit"
OLDLISP="cmulisp" OLDLISP="cmulisp"
GIT_FILE_COMMENT="yes"
export GIT_FILE_COMMENT
SKIPUTILS=no SKIPUTILS=no
...@@ -66,7 +68,7 @@ fi ...@@ -66,7 +68,7 @@ fi
usage () usage ()
{ {
echo "build.sh [-123obvuBCU?]" echo "build.sh [-123obvuBCUG?]"
echo " -1 Skip build 1" echo " -1 Skip build 1"
echo " -2 Skip build 2" echo " -2 Skip build 2"
echo " -3 Skip build 3" echo " -3 Skip build 3"
...@@ -96,6 +98,7 @@ usage () ...@@ -96,6 +98,7 @@ usage ()
echo " The flags always include -noinit -nositeinit" echo " The flags always include -noinit -nositeinit"
echo " -R Force recompiling the C runtime. Normally, just runs make to " echo " -R Force recompiling the C runtime. Normally, just runs make to "
echo " recompile anything that has changed." echo " recompile anything that has changed."
echo " -G Don't use git to fill file-comment information"
exit 1 exit 1
} }
...@@ -152,7 +155,7 @@ BUILDWORLD="$TOOLDIR/build-world.sh" ...@@ -152,7 +155,7 @@ BUILDWORLD="$TOOLDIR/build-world.sh"
BUILD_POT="yes" BUILD_POT="yes"
UPDATE_TRANS= UPDATE_TRANS=
while getopts "123PRo:b:v:uB:C:Ui:f:w:O:?" arg while getopts "123PRGo:b:v:uB:C:Ui:f:w:O:?" arg
do do
case $arg in case $arg in
1) ENABLE2="no" ;; 1) ENABLE2="no" ;;
...@@ -172,6 +175,7 @@ do ...@@ -172,6 +175,7 @@ do
U) UPDATE_TRANS="yes";; U) UPDATE_TRANS="yes";;
O) OLDLISPFLAGS="$OLDLISPFLAGS $OPTARG" ;; O) OLDLISPFLAGS="$OLDLISPFLAGS $OPTARG" ;;
R) REBUILD_LISP="yes";; R) REBUILD_LISP="yes";;
G) GIT_FILE_COMMENT="no";;
\?) usage \?) usage
;; ;;
esac esac
......
...@@ -1094,34 +1094,41 @@ ...@@ -1094,34 +1094,41 @@
;;; ;;;
;;; Stash file comment in the file-info structure. ;;; Stash file comment in the file-info structure.
;;; ;;;
(defvar *file-comment-from-git* t
"If non-Nil, use git to derive the file-comment. This info includes
the sha1 hash, the time and the author of the change. Otherwise,
just use the supplied file-comment.")
(defun process-file-comment (form) (defun process-file-comment (form)
(unless (and (= (length form) 2) (stringp (second form))) (unless (and (= (length form) 2) (stringp (second form)))
(compiler-error _N"Bad FILE-COMMENT form: ~S." form)) (compiler-error _N"Bad FILE-COMMENT form: ~S." form))
(let ((file (first (source-info-current-file *source-info*)))) (let ((file (first (source-info-current-file *source-info*))))
(labels (labels
((run-git (path) ((run-git (path)
(let ((cwd (default-directory)) (when *file-comment-from-git*
(new (make-pathname :directory (pathname-directory path)))) (let ((cwd (default-directory))
(unwind-protect (new (make-pathname :directory (pathname-directory path))))
(progn (unwind-protect
;; Cd to the directory containing the file so that (progn
;; git can find the git repo, if available. ;; Cd to the directory containing the file so that
(setf (default-directory) new) ;; git can find the git repo, if available.
;; Run git to get the info. Don't signal any (setf (default-directory) new)
;; errors if we can't find git and discard any ;; Run git to get the info. Don't signal any
;; error messages from git. We only use the ;; errors if we can't find git and discard any
;; result if git returns a zero exit code, anyway. ;; error messages from git. We only use the
(handler-case ;; result if git returns a zero exit code, anyway.
(run-program "git" (handler-case
(list "log" (run-program "git"
"-1" (list "log"
"--pretty=format:%h %ai %an" "-1"
(namestring path)) "--pretty=format:%h %ai %an"
:output :stream (namestring path))
:error nil) :output :stream
(error () :error nil)
nil))) (error ()
(setf (default-directory) cwd)))) nil)))
(setf (default-directory) cwd)))))
(generate-comment (file-info) (generate-comment (file-info)
(let* ((name (pathname (source-info-stream file-info))) (let* ((name (pathname (source-info-stream file-info)))
(proc (run-git name)) (proc (run-git name))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment