build: Update script help and usage.

* doc/mes.texi (Invoking mesar): New section.
* mes/module/mes/boot-0.scm: Add one line help description.
* module/mescc.scm (parse-opts): Likewise.
* scripts/diff.scm (main): Add -h,--help, -v,--version.
* scripts/mesar.in: Likewise.
This commit is contained in:
Jan Nieuwenhuizen 2019-11-04 23:56:15 +01:00
parent 6a5619de9a
commit c6cceb47f3
No known key found for this signature in database
GPG key ID: F3C1A0D9C1D65273
5 changed files with 111 additions and 11 deletions

View file

@ -85,6 +85,7 @@ Bootstrapping
* The Mes Bootstrap Process:: How Mes will make you yogurt from pure milk.
* Invoking Mes:: Running Mes, a minimalist Guile lookalike.
* Invoking MesCC:: Running the MesCC bootstrap compiler.
* Invoking mesar::
Invoking Mes
@ -98,6 +99,7 @@ Contributing
* Building from Git:: The latest and greatest.
* Running Mes From the Source Tree:: Hacker tricks.
* Porting GNU Mes:: Teach Mes about your platform.
* The Perfect Setup:: The right tools.
* Coding Style:: Hygiene of the contributor.
* Submitting Patches:: Share your work.
@ -585,6 +587,7 @@ responsibility.
* The Mes Bootstrap Process:: How Mes will make you yogurt from pure milk.
* Invoking Mes:: Running Mes, a minimalist Guile lookalike.
* Invoking MesCC:: Running the MesCC bootstrap compiler.
* Invoking mesar::
@end menu
@node The Mes Bootstrap Process
@ -874,7 +877,7 @@ preprocess and compile only; do not assemble or link
@item --std=STANDARD
assume that the input sources are for STANDARD
@item -v, --version
@item -V,--version
display version and exit
@item -w,--write=TYPE
@ -918,6 +921,34 @@ during the parsing phase.
@end table
@node Invoking mesar
@section Invoking mesar
@example
mesar @var{option}@dots{} @var{command} @file{ARCHIVE-FILE} @file{FILE}@dots{}
@end example
The @var{command} is ignored for compatibility with @file{ar}
@example
r[ab][f][u] - replace existing or insert new file(s) into the archive
[c] - do not warn if the library had to be created
[D] - use zero for timestamps and uids/gids (default)
@end example
and assumed to be @var{crD}.
The @var{option}s can be among the following:
@table @code
@item -h, --help
display this help and exit
@item -V,--version
display version and exit
@end table
@c *********************************************************************
@node Contributing

View file

@ -213,6 +213,7 @@
(load-path (single-char #\L) (value #t))
(main (single-char #\e) (value #t))
(source (single-char #\s) (value #t))
(version (single-char #\v))
(version (single-char #\V)))))
(getopt-long args option-spec #:stop-at-first-non-option #t)))
(define (source-arg? o)
@ -234,8 +235,9 @@
(exit 0))
(and (or help? usage?)
(display "Usage: mes [OPTION]... [FILE]...
Evaluate code with Mes, interactively or from a script.
Scheme interpreter for bootstrapping the GNU system.
Options:
[-s] FILE load source code from FILE, and exit
-c EXPR evalute expression EXPR, and exit
-- stop scanning arguments; run interactively

View file

@ -92,6 +92,9 @@
(and (or help? usage?)
(format (or (and usage? (current-error-port)) (current-output-port)) "\
Usage: mescc [OPTION]... FILE...
C99 compiler in Scheme for bootstrapping the GNU system.
Options:
--align align globals
--arch=ARCH compile for ARCH [~a]
-dumpmachine display the compiler's target machine
@ -112,7 +115,7 @@ Usage: mescc [OPTION]... FILE...
-O LEVEL use optimizing LEVEL
-S preprocess and compile only; do not assemble or link
--std=STANDARD assume that the input sources are for STANDARD
-v, --version display version and exit
-V,--version display version and exit
-w,--write=TYPE dump Nyacc AST using TYPE {pretty-print,write}
-x LANGUAGE specify LANGUAGE of the following input files

View file

@ -113,10 +113,28 @@ exec ${MES-mes} -L ${0%/*} -e '(diff)' -s "$0" "$@"
(cdr a-lines) (cdr b-lines))))))))))
(define (main args)
(let* ((files (cdr args))
(files (if (string-prefix? "-" (car files)) (cdr files) files))
(hunks (apply diff-files (list-head files 2))))
(when (pair? hunks)
(display (string-join (append-map hunk->lines hunks) "\n"))
(newline)
(exit 1))))
(let ((files (cdr args)))
(when (or (null? files)
(equal? (car files) "-h")
(equal? (car files) "--help"))
(display "
Usage: diff.scm [OPTION]... FILES
Compare FILES line by line.
Options:
-u,--unified display unified diff (default)
-h,--help display this help and exit
-V,--version display version information and exit
")
(exit (if (null? files) 2 0)))
(when (or (equal? (car files) "-V")
(equal? (car files) "--version"))
(display "
diff.scm (GNU Mes) 0.20
"))
(let* ((files (if (string-prefix? "-" (car files)) (cdr files) files))
(hunks (apply diff-files (list-head files 2))))
(when (pair? hunks)
(display (string-join (append-map hunk->lines hunks) "\n"))
(newline)
(exit 1)))))

View file

@ -22,10 +22,56 @@ if [ "$V" = 2 ]; then
set -x
fi
# parse arguments
while [ $# -gt 0 ]; do
case $1 in
(-h|--help)
cat <<EOF
Usage: mesar [OPTION]... COMMAND ARCHIVE-FILE FILE...
Archiver for MesCC.
Commands:
r[ab][f][u] - replace existing or insert new file(s) into the archive
[c] - do not warn if the library had to be created
[D] - use zero for timestamps and uids/gids (default)
are ignored and assumed to be "crD".
Options:
-h,--help display this help and exit
-V,--version display version information and exit
EOF
exit 0
;;
(-V|--version)
cat <<EOF
mesar (GNU Mes) @VERSION@
EOF
exit 0
;;
-*) shift
;;
*) break
;;
esac
done
command=$1
archive=$2
shift
if [ -z "$command" ]; then
echo "AR: Usage error: missing command." 1>&2
exit 2
fi
archive=$1
shift
if [ -z "$archive" ]; then
echo "AR: Usage error: missing archive" 1>&2
exit 2
fi
if [ $# -eq 0 ]; then
echo "AR: Usage error: missing object files" 1>&2
exit 2
fi
M1_archive=$(dirname "$archive")/$(basename "$archive" .a).s
for o in "$@"; do
s=$(dirname "$o")/$(basename "$o" .o).s