Compare commits

...

10 Commits

7 changed files with 149 additions and 37 deletions

1
.gitignore vendored
View File

@ -63,3 +63,4 @@ stamp-h[0-9]
tmp
/.version
/doc/stamp-[0-9]
/.envrc

View File

@ -1,4 +1,45 @@
# -*- mode: org; coding: utf-8; -*-
#+TITLE: README for Guile-Nrepl
#+TITLE: README for Guile-nREPL
* Description
nREPL server implementation for guile.
* Spells for working with the project
If you have guix and org-mode, the src blocks in this section can be executed directly from this doc.
** Building
To build the project, you need hall, autoconf, guile, and automake. If you are running guix, you just need to run a =guix shell= to get all the requirements.
#+begin_src shell
guix shell -m manifest.scm -f guix.scm # Skip if you do not use guix
hall build -x
autoreconf -vif
./configure
make
#+end_src
** Testing
After the project is built, test the project via:
#+BEGIN_SRC shell
make check
#+END_SRC
** Cleaning
To get back to a clean state, run:
#+BEGIN_SRC shell
hall clean -x
#+END_SRC
** Misc Incantations
Other things that may be useful.
*** Load shell in direnv
If you use direnv, you can drop into the shell automatically with:
#+BEGIN_SRC shell
echo 'eval $(guix shell --search-paths -m manifest.scm -f guix.scm)' > .envrc
direnv allow
#+END_SRC

31
guile-nrepl/bencode.scm Normal file
View File

@ -0,0 +1,31 @@
(define-module (guile-nrepl bencode)
#:use-module (ice-9 format)
#:export (string->bencode
integer->bencode
list->bencode
pair->bencode))
(define (string->bencode input-str)
(when (string? input-str)
(format #f "~d:~a" (string-length input-str) input-str)))
(define (integer->bencode input-int)
(when (integer? input-int)
(format #f "i~de" input-int)))
(define (list->bencode input-list)
(when (list? input-list)
(format #f "l~ae" (apply string-append (map bencode-encode-dispatch input-list)))))
(define (pair->bencode input-pair)
(when (pair? input-pair)
(format #f "d~a~ae"
(bencode-encode-dispatch (car input-pair))
(bencode-encode-dispatch (cdr input-pair)))))
(define (bencode-encode-dispatch input-value)
(cond
((string? input-value) (string->bencode input-value))
((integer? input-value) (integer->bencode input-value))
((list? input-value) (list->bencode input-value))
((pair? input-value) (pair->bencode input-value))))

View File

@ -1,30 +1,48 @@
(use-modules
(guix packages)
((guix licenses) #:prefix license:)
(guix download)
(guix build-system gnu)
(gnu packages)
(gnu packages autotools)
(gnu packages guile)
(gnu packages guile-xyz)
(gnu packages pkg-config)
(gnu packages texinfo))
(package
(name "guile-nrepl")
(version "0.1")
(source "./guile-nrepl-0.1.tar.gz")
(build-system gnu-build-system)
(arguments `())
(native-inputs
`(("autoconf" ,autoconf)
("automake" ,automake)
("pkg-config" ,pkg-config)
("texinfo" ,texinfo)))
(inputs `(("guile" ,guile-3.0)))
(propagated-inputs `())
(synopsis "")
(description "")
(home-page "")
(license license:gpl3+))
(guix gexp)
(guix packages)
((guix licenses) #:prefix license:)
(guix download)
(guix git-download)
(guix build-system gnu)
(gnu packages)
(gnu packages autotools)
(gnu packages guile)
(gnu packages guile-xyz)
(gnu packages pkg-config)
(gnu packages texinfo))
(let ((%source-dir (dirname (current-filename))))
(package
(name "guile-nrepl")
(version "0.1")
(source (local-file %source-dir
#:recursive? #t
#:select? (git-predicate %source-dir)))
(build-system gnu-build-system)
(arguments
(list
#:make-flags
#~(list "GUILE_AUTO_COMPILE=0")
#:phases
#~(modify-phases %standard-phases
(delete 'strip)
(add-before 'configure 'hall-build
(lambda _
(system* "hall" "build" "-x")))
(add-after 'hall-build 'autoreconf
(lambda _
(system* "autoreconf" "-vif"))))))
(native-inputs
(list autoconf
automake
guile-hall
pkg-config
texinfo))
(inputs (list guile-3.0))
(propagated-inputs (list guile-config
guile-torrent))
(synopsis "???")
(description "???")
(home-page "???")
(license license:gpl3+)))

View File

@ -2,22 +2,24 @@
(name "guile-nrepl")
(prefix "")
(version "0.1")
(author "")
(author "TakeV")
(copyright (2023))
(synopsis "")
(description "")
(description "An nREPL implementation in guile")
(home-page "")
(license gpl3+)
(dependencies `())
(dependencies
`(("guile-config" ,guile-config)
("guile-torrent" ,guile-torrent)))
(skip ())
(files (libraries
((scheme-file "guile-nrepl")
(directory "guile-nrepl" ())))
(tests ((directory "tests" ())))
((directory
"guile-nrepl"
((scheme-file "bencode")))))
(tests ((directory "tests" ((scheme-file "bencode")))))
(programs ((directory "scripts" ())))
(documentation
((org-file "README")
(symlink "README" "README.org")
((symlink "README" "README.org")
(text-file "HACKING")
(text-file "COPYING")
(directory "doc" ((texi-file "guile-nrepl")))))

9
manifest.scm Normal file
View File

@ -0,0 +1,9 @@
;; What follows is a "manifest" equivalent to the command line you gave.
;; You can store it in a file that you may then pass to any 'guix' command
;; that accepts a '--manifest' (or '-m') option.
(concatenate-manifests
(list (specifications->manifest
(list "guile-hall" "guile-torrent"))
(package->development-manifest
(specification->package "guile-hall"))))

10
tests/bencode.scm Normal file
View File

@ -0,0 +1,10 @@
(define-module (tests bencode)
#:use-module (srfi srfi-64)
#:use-module (guile-nrepl bencode))
(test-group "bencode"
(test-group "encode"
(test-group "string->bencode"
(test-equal "empty string case" "0:" (string->bencode ""))
(test-equal "test word serializes" "5:takev" (string->bencode "takev"))
#;(test-assert "number input returns false" (list? (string->bencode 15))))))