1 ; CPU description file generator for CGEN cpu documentation
2 ; This is invoked to build: $arch.html.
3 ; Copyright (C) 2003, 2009 Doug Evans
4 ; This file is part of CGEN.
6 ; This is a standalone script, we don't load anything until we parse the
7 ; -s argument (keeps reliance off of environment variables, etc.).
9 ; Load the various support routines.
11 (define (load-files srcdir)
12 (load (string-append srcdir "/read.scm"))
13 (load (string-append srcdir "/desc.scm"))
14 (load (string-append srcdir "/desc-cpu.scm"))
15 (load (string-append srcdir "/html.scm"))
20 (list "-H" "file" "generate $arch.html in <file>"
22 (lambda (arg) (file-write arg cgen.html)))
23 (list "-I" "file" "generate $arch-insn.html in <file>"
25 (lambda (arg) (file-write arg cgen-insn.html)))
26 (list "-N" "file" "specify name of insn.html file"
28 (lambda (arg) (set! *insn-html-file-name* arg)))
32 ; Kept global so it's available to the other .scm files.
35 ; Scan argv for -s srcdir.
36 ; We can't process any other args until we find the cgen source dir.
37 ; The result is srcdir.
38 ; We assume "-s" isn't the argument to another option. Unwise, yes.
39 ; Alternatives are to require it to be the first argument or at least preceed
40 ; any option with a "-s" argument, or to put knowledge of the common argument
41 ; set and common argument parsing code in every top level file.
43 (define (find-srcdir argv)
44 (let loop ((argv argv))
46 (error "`-s srcdir' not present, can't load cgen"))
47 (if (string=? "-s" (car argv))
49 (if (null? (cdr argv))
50 (error "missing srcdir arg to `-s'"))
55 ; Main routine, parses options and calls generators.
57 (define (cgen-doc argv)
60 ; Find and set srcdir, then load all Scheme code.
61 ; Drop the first argument, it is the script name (i.e. argv[0]).
62 (set! srcdir (find-srcdir (cdr argv)))
63 (set! %load-path (cons srcdir %load-path))
70 #:arg-spec doc-arguments
73 #:analyze doc-analyze!)
77 (cgen-doc (program-arguments))