#lang racket
(require framework
racket/gui/base)
(provide get-executable-path
prompt-and-set-executable-path)
(define *acl2-loc-key* 'acl2-executable-location)
(preferences:set-default *acl2-loc-key* (build-path "~") path?)
(preferences:set-un/marshall *acl2-loc-key*
path->string
build-path)
(define (get-executable-path)
(let* ([path (preferences:get *acl2-loc-key*)])
(if (looks-like-acl2? path)
path
(prompt-and-set-executable-path))))
(define (prompt-and-set-executable-path)
(set-path-preference (prompt-for-path)))
(define (set-path-preference path)
(preferences:set *acl2-loc-key* path)
path)
(define (prompt-for-path)
(let* ([path (or (finder:get-file #f "Please select an ACL2 Executable")
(preferences:get *acl2-loc-key*))])
(unless (looks-like-acl2? path)
(message-box "That is not ACL2"
"The path you provided does not seem to point to an ACL2 executable."))
path))
(define (looks-like-acl2? path)
(let* ([path (cond [(string? path) (string->path path)]
[else path])])
(and (path? path)
(file-exists? path))))