diff --git a/Makefile b/Makefile index 69ae8cd..8fe3e68 100644 --- a/Makefile +++ b/Makefile @@ -1,17 +1,16 @@ -SYSTEM_LIBRARY_SUBPATH:=compiled/native/$(shell racket -e '(display (path->string (system-library-subpath)))') -SYSTEM_LIBRARY_SUFFIX:=$(shell racket -e '(begin (require dynext/file) (display (path->string (append-extension-suffix "DUMMY"))))' | sed -e s:DUMMY::) +PACKAGENAME=ansi +COLLECTS=ansi -all: $(SYSTEM_LIBRARY_SUBPATH)/tty-raw-extension$(SYSTEM_LIBRARY_SUFFIX) +all: setup clean: - rm -rf compiled + find . -name compiled -type d | xargs rm -rf -$(SYSTEM_LIBRARY_SUBPATH): - mkdir -p $@ +setup: + raco setup $(COLLECTS) -$(SYSTEM_LIBRARY_SUBPATH)/%$(SYSTEM_LIBRARY_SUFFIX): %.c $(SYSTEM_LIBRARY_SUBPATH) - mzc --xform $*.c - mzc --3m --cc $*.3m.c - mzc --3m --ld $@ $*_3m.o - rm -f $*.3m.c - rm -f $*_3m.o +link: + raco pkg install --link -n $(PACKAGENAME) $$(pwd) + +unlink: + raco pkg remove $(PACKAGENAME) diff --git a/ansi.rkt b/ansi/ansi.rkt similarity index 100% rename from ansi.rkt rename to ansi/ansi.rkt diff --git a/ansi/info.rkt b/ansi/info.rkt new file mode 100644 index 0000000..4c88426 --- /dev/null +++ b/ansi/info.rkt @@ -0,0 +1,11 @@ +#lang setup/infotab + +(define name "ansi") +(define blurb + (list + `(p "ANSI and VT10x escape sequences."))) +(define homepage "https://github.com/tonyg/racket-ansi") +(define primary-file "main.rkt") + +(define pre-install-collection "private/install.rkt") +(define compile-omit-files '("private/install.rkt")) diff --git a/lcd-terminal.rkt b/ansi/lcd-terminal.rkt similarity index 99% rename from lcd-terminal.rkt rename to ansi/lcd-terminal.rkt index f7c54b9..473554a 100644 --- a/lcd-terminal.rkt +++ b/ansi/lcd-terminal.rkt @@ -149,7 +149,7 @@ )) (module+ main - (require "tty-raw-extension") + (require "private/tty-raw-extension") (tty-raw!) (let loop () (match (lex-lcd-input (current-input-port)) diff --git a/ansi/main.rkt b/ansi/main.rkt new file mode 100644 index 0000000..8174d4b --- /dev/null +++ b/ansi/main.rkt @@ -0,0 +1,7 @@ +#lang racket/base + +(require "ansi.rkt" + "lcd-terminal.rkt") + +(provide (all-from-out "ansi.rkt") + (all-from-out "lcd-terminal.rkt")) diff --git a/ansi/private/install.rkt b/ansi/private/install.rkt new file mode 100644 index 0000000..4a80d16 --- /dev/null +++ b/ansi/private/install.rkt @@ -0,0 +1,29 @@ +#lang racket/base + +(provide pre-installer) + +(require racket/file) +(require dynext/file) +(require dynext/compile) +(require dynext/link) + +(define (pre-installer collections-top-path collection-path) + (define private-path (build-path collection-path "private")) + (parameterize ((current-directory private-path)) + (define shared-object-target-path (build-path private-path + "compiled" + "native" + (system-library-subpath))) + (define shared-object-target (build-path shared-object-target-path + (append-extension-suffix "tty-raw-extension"))) + (when (not (file-exists? shared-object-target)) + (define c-source (build-path private-path "tty-raw-extension.c")) + (define object (build-path shared-object-target-path "tty-raw-extension.o")) + (make-directory* shared-object-target-path) + (compile-extension #f ;; not quiet + c-source + object + '()) + (link-extension #f ;; not quiet + (list object) + shared-object-target)))) diff --git a/tty-raw-extension.c b/ansi/private/tty-raw-extension.c similarity index 100% rename from tty-raw-extension.c rename to ansi/private/tty-raw-extension.c diff --git a/rope.rkt b/ansi/rope.rkt similarity index 100% rename from rope.rkt rename to ansi/rope.rkt diff --git a/test-ansi.rkt b/ansi/test-ansi.rkt similarity index 100% rename from test-ansi.rkt rename to ansi/test-ansi.rkt diff --git a/test-modes.rkt b/ansi/test-modes.rkt similarity index 100% rename from test-modes.rkt rename to ansi/test-modes.rkt diff --git a/test-raw.rkt b/ansi/test-raw.rkt similarity index 94% rename from test-raw.rkt rename to ansi/test-raw.rkt index b38894f..ff78afd 100644 --- a/test-raw.rkt +++ b/ansi/test-raw.rkt @@ -1,6 +1,6 @@ #lang racket/base -(require "tty-raw-extension") +(require "private/tty-raw-extension") (require "ansi.rkt") (define (main) diff --git a/all-escapes.txt b/doc/all-escapes.txt similarity index 100% rename from all-escapes.txt rename to doc/all-escapes.txt diff --git a/xterm_controls.txt b/doc/xterm_controls.txt similarity index 100% rename from xterm_controls.txt rename to doc/xterm_controls.txt diff --git a/info.rkt b/info.rkt new file mode 100644 index 0000000..53c9302 --- /dev/null +++ b/info.rkt @@ -0,0 +1,2 @@ +#lang setup/infotab +(define collection 'multi)