1 ; CPU description file generator for CGEN cpu documentation
2 ; This is invoked to build: $arch.html.
3 ; Copyright (C) 2003 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 ; Fix up Scheme to be what we use (guile is always in flux).
13 (primitive-load-path (string-append srcdir "/fixup.scm"))
15 (load (string-append srcdir "/read.scm"))
16 (load (string-append srcdir "/desc.scm"))
17 (load (string-append srcdir "/desc-cpu.scm"))
18 (load (string-append srcdir "/html.scm"))
23 (list '-H "file" "generate $arch.html in <file>"
24 (lambda (arg) (file-write arg cgen.html)))
25 ; can't use '-I because that gets interpreted as a complex number
26 (list (string->symbol "-I") "file" "generate $arch-insn.html in <file>"
27 (lambda (arg) (file-write arg cgen-insn.html)))
28 (list '-N "file" "specify name of insn.html file"
29 (lambda (arg) (set! *insn-html-file-name* arg)))
33 ; Kept global so it's available to the other .scm files.
36 ; Scan argv for -s srcdir.
37 ; We can't process any other args until we find the cgen source dir.
38 ; The result is srcdir.
39 ; We assume "-s" isn't the argument to another option. Unwise, yes.
40 ; Alternatives are to require it to be the first argument or at least preceed
41 ; any option with a "-s" argument, or to put knowledge of the common argument
42 ; set and common argument parsing code in every top level file.
44 (define (find-srcdir argv)
45 (let loop ((argv argv))
47 (error "`-s srcdir' not present, can't load cgen"))
48 (if (string=? "-s" (car argv))
50 (if (null? (cdr argv))
51 (error "missing srcdir arg to `-s'"))
56 ; Main routine, parses options and calls generators.
58 (define (cgen-doc argv)
61 ; Find and set srcdir, then load all Scheme code.
62 ; Drop the first argument, it is the script name (i.e. argv[0]).
63 (set! srcdir (find-srcdir (cdr argv)))
64 (set! %load-path (cons srcdir %load-path))
71 #:arg-spec doc-arguments
74 #:analyze doc-analyze!)
78 (cgen-doc (program-arguments))