added first real command line interface
This commit is contained in:
parent
3d90d39924
commit
e45e9a6b0d
|
@ -46,30 +46,102 @@ For testing load this at a scsh prompt
|
||||||
;;; real work in static-heap-linker1
|
;;; real work in static-heap-linker1
|
||||||
;;; argl is a list of the command line arguments
|
;;; argl is a list of the command line arguments
|
||||||
(define (static-heap-linker argl)
|
(define (static-heap-linker argl)
|
||||||
(cond ((not (= (length argl) 3))
|
(let ((temp-dir-arg #f)
|
||||||
(format #t
|
(cc-command-arg #f)
|
||||||
"usage: ~a input-image-file output-executible-file"
|
(ld-flags-arg #f)
|
||||||
(car argl))
|
(libraries-arg #f)
|
||||||
(exit 1)))
|
(input-image-arg #f)
|
||||||
(let ((temp-dir ; place for intermediate .c .o files
|
(output-executible-arg #f))
|
||||||
(or (getenv "TMPDIR")
|
(let loop ((args (cdr argl)))
|
||||||
"@TMPDIR@"))
|
(cond ((null? args)
|
||||||
(cc-command ; command to compile a .c file
|
(cond ((not output-executible-arg)
|
||||||
(or (getenv "CC")
|
(display "error: -o is a required argument")
|
||||||
"@CC@ @CFLAGS@"))
|
(newline)
|
||||||
(ld-flags ; flags needed to link executible
|
(usage (car argl)))
|
||||||
(or (getenv "LDFLAGS")
|
((not input-image-arg)
|
||||||
"@LDFLAGS@"))
|
(display "error: -i is a required argument")
|
||||||
(libraries ; linbraries need to link executible
|
(newline)
|
||||||
(or (getenv "LIBS")
|
(usage (car argl)))))
|
||||||
"@LIBS@"))
|
((equal? (car args) "-o")
|
||||||
(input-image ; the input scheme image file
|
(cond ((not (null? (cdr args)))
|
||||||
(cadr argl))
|
(set! output-executible-arg (cadr args))
|
||||||
(output-executible ; the output executible file
|
(loop (cddr args)))
|
||||||
(caddr argl)))
|
(else
|
||||||
(static-heap-linker1 input-image temp-dir output-executible
|
(display "error: -o requires argument") (newline)
|
||||||
cc-command ld-flags libraries)
|
(usage (car argl)))))
|
||||||
(exit 0)))
|
((equal? (car args) "-i")
|
||||||
|
(cond ((not (null? (cdr args)))
|
||||||
|
(set! input-executible-arg (cadr args))
|
||||||
|
(loop (cddr args)))
|
||||||
|
(else
|
||||||
|
(display "error: -i requires argument") (newline)
|
||||||
|
(usage (car argl)))))
|
||||||
|
((equal? (car args) "--temp")
|
||||||
|
(cond ((not (null? (cdr args)))
|
||||||
|
(set! temp-dir-arg (cadr args))
|
||||||
|
(loop (cddr args)))
|
||||||
|
(else
|
||||||
|
(display "error: --temp requires argument") (newline)
|
||||||
|
(usage (car argl)))))
|
||||||
|
((equal? (car args) "--cc")
|
||||||
|
(cond ((not (null? (cdr args)))
|
||||||
|
(set! cc-command-arg (cadr args))
|
||||||
|
(loop (cddr args)))
|
||||||
|
(else
|
||||||
|
(display "error: --cc requires argument") (newline)
|
||||||
|
(usage (car argl)))))
|
||||||
|
((equal? (car args) "--ld")
|
||||||
|
(cond ((not (null? (cdr args)))
|
||||||
|
(set! ld-command-arg (cadr args))
|
||||||
|
(loop (cddr args)))
|
||||||
|
(else
|
||||||
|
(display "error: --ld requires argument") (newline)
|
||||||
|
(usage (car argl)))))
|
||||||
|
((equal? (car args) "--libs")
|
||||||
|
(cond ((not (null? (cdr args)))
|
||||||
|
(set! libraries-arg (cadr args))
|
||||||
|
(loop (cddr args)))
|
||||||
|
(else
|
||||||
|
(display "error: --libs requires argument") (newline)
|
||||||
|
(usage (car argl)))))
|
||||||
|
(else
|
||||||
|
(format #t "error: unknown argument ~a" (car args))
|
||||||
|
(newline)
|
||||||
|
(usage (car argl)))))
|
||||||
|
(let ((temp-dir ; place for intermediate .c .o files
|
||||||
|
(or temp-dir-arg
|
||||||
|
(getenv "TMPDIR")
|
||||||
|
"@TMPDIR@"))
|
||||||
|
(cc-command ; command to compile a .c file
|
||||||
|
(or cc-command-arg
|
||||||
|
(getenv "CC")
|
||||||
|
"@CC@ @CFLAGS@"))
|
||||||
|
(ld-flags ; flags needed to link executible
|
||||||
|
(or ld-flags-arg
|
||||||
|
(getenv "LDFLAGS")
|
||||||
|
"@LDFLAGS@"))
|
||||||
|
(libraries ; linbraries need to link executible
|
||||||
|
(or libraries-arg
|
||||||
|
(getenv "LIBS")
|
||||||
|
"@LIBS@"))
|
||||||
|
(input-image ; the input scheme image file
|
||||||
|
(cadr argl))
|
||||||
|
(output-executible ; the output executible file
|
||||||
|
(caddr argl)))
|
||||||
|
(static-heap-linker1 input-image temp-dir output-executible
|
||||||
|
cc-command ld-flags libraries)
|
||||||
|
(exit 0))))
|
||||||
|
|
||||||
|
(define (usage program-name)
|
||||||
|
(format #t
|
||||||
|
(string-append
|
||||||
|
"usage: ~a -i image -o executible~%"
|
||||||
|
" [--temp directory]~%"
|
||||||
|
" [--cc command]~%"
|
||||||
|
" [--ld command]~%"
|
||||||
|
" [--libs libraries]~%")
|
||||||
|
program-name)
|
||||||
|
(exit 1))
|
||||||
|
|
||||||
;;; heap structure
|
;;; heap structure
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
Loading…
Reference in New Issue