Make verbosity an integer instead of two flags
This commit is contained in:
parent
0a30f1d23a
commit
d37cabe98e
14
README.md
14
README.md
@ -51,10 +51,8 @@ command-line arguments. The command-line arguments are the following,
|
||||
displays help
|
||||
-v, --version
|
||||
displays the version number of this script
|
||||
-q, --quiet
|
||||
use a terse output format
|
||||
-V, --verbose
|
||||
use a verbose output format
|
||||
-V [0,1,2,3], --verbosity=[0,1,2,3]
|
||||
choose the verbosity of the output
|
||||
-e, --environment
|
||||
environment variables are converted to makevars
|
||||
-E, --elevate-environment
|
||||
@ -91,7 +89,7 @@ it with specific command line arguments, like the example below. The
|
||||
first string is the name of the script, and then any combination of
|
||||
flags, macro assignments and targets may follow.
|
||||
|
||||
(initialize '("makefile.scm" "--verbose" "CC=gcc" "all"))
|
||||
(initialize '("makefile.scm" "--verbosity=3" "CC=gcc" "all"))
|
||||
|
||||
If you call initialize with an empty list as below, it will guess the
|
||||
script name from the command-line arguements, but, will ignore all
|
||||
@ -200,7 +198,7 @@ recipe, it causes the recipe not to end execution, even if an error is
|
||||
signaled.
|
||||
|
||||
`silent-compose` (aka `~@`) is like string-compose, but, it does not
|
||||
print the resulting string to the output port, except in verbose mode.
|
||||
print the resulting string to the output port, except with verbose output.
|
||||
|
||||
`always-execute-compose` (aka `~+`) is like compose, but, it forces
|
||||
the line to always be executed, even if the `--no-execution` option
|
||||
@ -394,8 +392,8 @@ The library provides the following procedures for makevars
|
||||
|
||||
> *IMPORTANT!* If it is not found, an empty string is returned. This
|
||||
> is because it is a common practice in makefiles to use makevars that
|
||||
> may or may not be defined by environment variables. In `--verbose`
|
||||
> mode, a warning will be printed when a key cannot be found.
|
||||
> may or may not be defined by environment variables. With verbose output,
|
||||
> a warning will be printed when a key cannot be found.
|
||||
|
||||
> If the value was stored using `lazy-assign` and is a *promise*, this
|
||||
> procedure is *forced* to return a string. Also, the value in the
|
||||
|
@ -62,7 +62,8 @@
|
||||
;; If the -t option was specified, make shall write to standard
|
||||
;; output a message for each file that was touched.
|
||||
|
||||
(define %opt-terse #f)
|
||||
;; Verbosity is 0 = silent, 1 = terse, 2 = default, 3 = verbose
|
||||
(define %verbosity 2)
|
||||
(define %opt-verbose #f)
|
||||
(define %opt-ignore-errors #f)
|
||||
(define %opt-continue-on-error #f)
|
||||
@ -72,17 +73,16 @@
|
||||
(define (critical spec . args)
|
||||
(apply format (append (list #t spec) args)))
|
||||
(define (print spec . args)
|
||||
(unless %opt-terse
|
||||
(when (>= %verbosity 2)
|
||||
(apply format (append (list #t spec) args))))
|
||||
(define (debug spec . args)
|
||||
(when %opt-verbose
|
||||
(when (>= %verbosity 3)
|
||||
(apply format (append (list #t spec) args))))
|
||||
|
||||
(define option-spec
|
||||
'((help (single-char #\h) (value #f))
|
||||
(version (single-char #\v) (value #f))
|
||||
(terse (single-char #\q) (value #f))
|
||||
(verbose (single-char #\V) (value #f))
|
||||
(verbosity (single-char #\V) (value #t))
|
||||
(environment (single-char #\e) (value #f))
|
||||
(elevate-environment (single-char #\E) (value #f))
|
||||
(builtins (single-char #\b) (value #f))
|
||||
@ -97,8 +97,8 @@
|
||||
(format #t "~A [-hvqVeEbn] [KEY=VALUE ...] [targets ...]~%" argv0)
|
||||
(format #t " -h, --help print help and exit~%")
|
||||
(format #t " -v, --version print version and exit~%")
|
||||
(format #t " -q, --terse use terse output~%")
|
||||
(format #t " -V, --verbose use verbose output~%")
|
||||
(format #t " -V 0..3, --verbosity=0..3~%")
|
||||
(format #t " set output level from 0=silent to 3=verbose~%")
|
||||
(format #t " -e, --environment use environment variables~%")
|
||||
(format #t " -E, --elevate-environment~%")
|
||||
(format #t " use environment variables and let~%")
|
||||
@ -190,11 +190,9 @@ arguments."
|
||||
(when mf
|
||||
(let ((tokens (string-tokenize mf)))
|
||||
(when (member "terse" tokens)
|
||||
(set! %opt-terse #t)
|
||||
(set! %opt-verbose #f))
|
||||
(set! %verbosity 1))
|
||||
(when (member "verbose" tokens)
|
||||
(set! %opt-verbose #t)
|
||||
(set! %opt-terse #f))
|
||||
(set! %verbosity 3))
|
||||
(when (member "builtins" tokens)
|
||||
(set! %opt-builtins #t))
|
||||
(when (member "ascii" tokens)
|
||||
@ -209,12 +207,10 @@ arguments."
|
||||
(set! %opt-no-execution #t))))))
|
||||
|
||||
;; Now the bulk of the command-line options.
|
||||
(when (option-ref options 'terse #f)
|
||||
(set! %opt-terse #t)
|
||||
(set! %opt-verbose #f))
|
||||
(when (option-ref options 'verbose #f)
|
||||
(set! %opt-verbose #t)
|
||||
(set! %opt-terse #f))
|
||||
(when (option-ref options 'verbosity #f)
|
||||
(let ((verbosity (string->number (option-ref options 'verbosity #f))))
|
||||
(when verbosity
|
||||
(set! %verbosity verbosity))))
|
||||
(when (option-ref options 'builtins #f)
|
||||
(set! %opt-builtins #t))
|
||||
(when (option-ref options 'elevate-environment #f)
|
||||
@ -239,7 +235,7 @@ arguments."
|
||||
%opt-elevate-environment
|
||||
%opt-builtins
|
||||
%opt-strict
|
||||
%opt-verbose
|
||||
%verbosity
|
||||
%opt-ascii)
|
||||
;; The remaining command-line words are the build targets that
|
||||
;; we're going to tackle.
|
||||
@ -249,8 +245,7 @@ arguments."
|
||||
%opt-ignore-errors
|
||||
%opt-continue-on-error
|
||||
%opt-no-execution
|
||||
%opt-terse
|
||||
%opt-verbose
|
||||
%verbosity
|
||||
%opt-ascii)
|
||||
(set! %initialized #t)
|
||||
%targets
|
||||
@ -283,10 +278,6 @@ targets listed on the parsed command-line are used."
|
||||
(rest (cdr targets)))
|
||||
(print "Attempting to run target “~A”.~%" target)
|
||||
(if (not (build target))
|
||||
;; %opt-ignore-errors
|
||||
;; %opt-continue-on-error
|
||||
;; %opt-terse
|
||||
;; %opt-verbose))
|
||||
(begin
|
||||
(print "The recipe for “~A” has failed.~%" target))
|
||||
;; else
|
||||
|
@ -187,12 +187,12 @@ the value of MAKEFLAGS or SHELL."
|
||||
elevate-environment?
|
||||
builtins?
|
||||
strict?
|
||||
verbose?
|
||||
verbosity
|
||||
ascii?)
|
||||
(set! %elevate-environment? elevate-environment?)
|
||||
(set! %makevars (make-hash-table))
|
||||
(set! %strict strict?)
|
||||
(set! %verbose? verbose?)
|
||||
(set! %verbose? (= verbosity 3))
|
||||
(set! %ascii? ascii?)
|
||||
(when builtins?
|
||||
(makevars-add-builtins))
|
||||
|
@ -35,8 +35,7 @@
|
||||
(define %ignore-errors? #f)
|
||||
(define %continue-on-error? #f)
|
||||
(define %no-execution? #f)
|
||||
(define %terse? #f)
|
||||
(define %verbose? #f)
|
||||
(define %verbosity 2)
|
||||
(define %ascii? #f)
|
||||
(define %top-level-targets '())
|
||||
|
||||
@ -67,7 +66,6 @@ it is evaluated."
|
||||
(effective-arg #f))
|
||||
(cond
|
||||
((procedure? arg)
|
||||
(format #t "BLAMMO ~s ~s ~%" arg (arg))
|
||||
(set! effective-arg (arg))
|
||||
|
||||
(unless (string? effective-arg)
|
||||
@ -154,7 +152,7 @@ it is evaluated."
|
||||
(define* (target-rule name #:optional (prerequisites '()) #:rest recipes)
|
||||
"Register a new target rule"
|
||||
|
||||
(when %verbose?
|
||||
(when (>= %verbosity 3)
|
||||
(format #t "Defining target rule: ~A ~A ~A~%" prerequisites (right-arrow) name))
|
||||
;; If any recipes are raw strings, we need to make them into
|
||||
;; (cons 'default string)
|
||||
@ -208,7 +206,7 @@ it is evaluated."
|
||||
"Register a suffix rule"
|
||||
|
||||
;; FIXME: Typecheck
|
||||
(when %verbose?
|
||||
(when (>= %verbosity 3)
|
||||
(format #t "Defining suffix rule: ~A ~A ~A~%" source (right-arrow) target))
|
||||
;; If any recipes are raw strings, we need to make them into
|
||||
;; (cons 'default string)
|
||||
@ -600,15 +598,14 @@ failure condition happens, mark the node as having failed."
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; LET'S GO!
|
||||
|
||||
(define (initialize-rules targets builtins? ignore-errors? continue-on-error? no-execution? terse? verbose? ascii?)
|
||||
(define (initialize-rules targets builtins? ignore-errors? continue-on-error? no-execution? verbosity ascii?)
|
||||
(set! %target-rules '())
|
||||
(set! %suffix-rules '())
|
||||
(set! %top-level-targets targets)
|
||||
(set! %ignore-errors? ignore-errors?)
|
||||
(set! %continue-on-error? continue-on-error?)
|
||||
(set! %no-execution? no-execution?)
|
||||
(set! %terse? terse?)
|
||||
(set! %verbose? verbose?)
|
||||
(set! %verbosity verbosity)
|
||||
(set! %ascii? ascii?)
|
||||
(when builtins?
|
||||
(add-builtins)))
|
||||
|
Loading…
Reference in New Issue
Block a user