Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

windows support #76

Open
pcerman opened this issue Nov 30, 2021 · 2 comments
Open

windows support #76

pcerman opened this issue Nov 30, 2021 · 2 comments

Comments

@pcerman
Copy link

pcerman commented Nov 30, 2021

Hi. I am mostly using your project on linux machines but I need to use it also on windows machine. Unfortunately there is problem with the naming files and folders. Any name in the windows file system does not allow to use character ':'. I have some idea how to use it on windows machine. Loading this file on start of chez scheme allows to map any not supported characters. It maps ':' symbol's character into "%3a" string in this example.

;;;
;;; define windows specific "library-search-handler"
;;;

(define restore-library-search-handler #f)
(define windows-library-search-handler #f)

(let ((*old-library-search-handler* #f))
  (define chars-map '((#\: #\% #\3 #\a)))

  (define (symbol-subst sym)
    (if (not (symbol? sym)) sym
        (let loop ((lst (string->list (symbol->string sym))) (new-lst '()) (changed #f))
          (if (null? lst)
              (if (not changed) sym
                  (string->symbol (list->string (reverse new-lst))))
              (let ((ap (assoc (car lst) chars-map)))
                (cond ((not ap)
                       (loop (cdr lst) (cons (car lst) new-lst) changed))
                      ((pair? (cdr ap))
                       (loop (cdr lst) (append (reverse (cdr ap)) new-lst) #t))
                      (else
                       (loop (cdr lst) (cons (cdr ap) new-lst) #t))))))))

  (define (wlsh who lib dir* ext*)
    (*old-library-search-handler* who (map symbol-subst lib) dir* ext*))

  (set! restore-library-search-handler
        (lambda ()
          (when *old-library-search-handler*
            (library-search-handler *old-library-search-handler*)
            (set! *old-library-search-handler* #f))))

  (set! windows-library-search-handler
        (lambda ()
          (when (not *old-library-search-handler*)
            (set! *old-library-search-handler* (library-search-handler))
            (library-search-handler wlsh))))

  (windows-library-search-handler))

Of course it requires to write the library installator for windows too. Maybe I have something overlooked and there is simpler way to use it on windows. This is only idea, not implementation. Any comment is welcome.

@arcfide
Copy link
Owner

arcfide commented Nov 30, 2021

When using this stuff on Windows I normally load the libraries explicitly and then compile my application with a build script of some sort. The above code feels a little unidiomatic at first glance, as I'm not familiar with these features (they were not around when I started the project), but I'm open to a solution in this vein.

@akce
Copy link

akce commented Dec 1, 2021

Of course it requires to write the library installator for windows too.

If by this you mean the install script, then that's almost definately going to be removed soon after i get around to writing some docs and raising a PR. Unless someone argues for keeping it.

I don't have Windows, but the transparently importing percent encoded files portion of this task sounds interesting and could be useful to other platforms too.

I originally wanted to chime in on only the install part, but here's some random (and untested) thoughts on dynamically resolving percent files. Buyer beware..

include/resolve also needs to support finding these lib files (for those srfi's that import implementation code this way). Maybe by creating a Chez scheme specific version that uses library-search-handler.

Actually, a chezscheme specific include file might be a good place to put all these functions. eg, private/include.chezscheme.sls.

Write windows-library-search-handler using translate-name from link-dirs. It could then be a generic percent-encoded-library-search-handler.

Don't track previous library search handler value. Leave that up to client code. If anything, add an install-percent-encoded-library-search-handler that returns the previous handler. That way clients could do something like:

(import (chezscheme))
(import (srfi private include))

(define old-library-search-handler
  (meta-cond
    [(memq (machine-type) '(ti3nt ta6nt))     ; on Windows
     (install-percent-encoded-library-search-handler)]
    [else
      #f]))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants