Patchwork Add scheme-bytestructures

login
register
mail settings
Submitter Amirouche Boubekki
Date Oct. 9, 2016, 10:38 a.m.
Message ID <CAL7_Mo9DMh9y--KOMMtNVqo=y_-JSKMaeHru2Mp-Omv-JXa8dg@mail.gmail.com>
Download mbox | patch
Permalink /patch/16366/
State New
Headers show

Comments

Amirouche Boubekki - Oct. 9, 2016, 10:38 a.m.
Warning: scheme-bytestructures works on various implementation of Scheme
but this patch adds it only for guile-2.0.

This is a pure scheme package there is no autotools that's why I use the
trivial-build-system.

This doesn't run the test suite, yet.
Kei Yamashita - Oct. 10, 2016, 5:51 p.m.
Amirouche Boubekki <amirouche.boubekki@gmail.com> writes:

> Warning: scheme-bytestructures works on various implementation of Scheme but this patch adds
> it only for guile-2.0.
>
> This is a pure scheme package there is no autotools that's why I use the trivial-build-system.
>
> This doesn't run the test suite, yet.
>
> From fb2eb7ffd88ec4fba09411195a54b59d67d9c137 Mon Sep 17 00:00:00 2001
> From: Amirouche <amirouche@hypermove.net>
> Date: Sun, 9 Oct 2016 12:31:20 +0200
> Subject: [PATCH] gnu: Add scheme-bytestructures
>
> * gnu/packages/guile.scm (scheme-bytestructures): New variable.
>
> diff --git a/gnu/packages/guile.scm b/gnu/packages/guile.scm
> index 0890f19..383990e 100644
> --- a/gnu/packages/guile.scm
> +++ b/gnu/packages/guile.scm
> @@ -1265,4 +1265,105 @@ is no support for parsing block and inline level HTML.")
>  (define-public guile2.2-commonmark
>    (package-for-guile-2.2 guile-commonmark))
>  
> +(define-public scheme-bytestructures
> +  (package
> +    (name "scheme-bytestructures")
> +    (version "20160726.53127f6")
> +    (source (origin
> +	      (method git-fetch)
> +	      (uri (git-reference
> +		    (url "https://github.com/TaylanUB/scheme-bytestructures")
> +		    (commit "53127f608caf64b34fa41c389b2743b546fbe9da")))
> +	      (file-name (string-append name "-" version "-checkout"))
> +	      (sha256
> +	       (base32
> +		"0l4nx1vp9fkrgrgwjiycj7nx6wfjfd39rqamv4pmq7issi8mrywq"))))
> +    (build-system trivial-build-system)
> +    (arguments
> +     `(#:modules ((guix build utils))
> +       #:builder
> +       (begin
> +	 (use-modules (guix build utils)
> +		      (ice-9 match)
> +		      (ice-9 popen)
> +		      (ice-9 rdelim))
> +
> +	 (let* ((out (assoc-ref %outputs "out"))
> +		(guile (assoc-ref %build-inputs "guile"))
> +		(effective (read-line
> +			    (open-pipe* OPEN_READ
> +					(string-append guile "/bin/guile")
> +					"-c" "(display (effective-version))")))
> +		(module-dir (string-append out "/share/guile/site/"
> +					   effective))
> +		(source (assoc-ref %build-inputs "source"))
> +		(doc (string-append out "/share/doc/scheme-bytestructures"))
> +		(scm-files (string-split "bytestructures/guile/explicit-endianness.scm
> +bytestructures/guile/numeric-metadata.scm
> +bytestructures/guile/ffi.scm
> +bytestructures/guile/vector.scm
> +bytestructures/guile/union.scm
> +bytestructures/guile/numeric-all.scm
> +bytestructures/guile/utils.scm
> +bytestructures/guile/pointer.scm
> +bytestructures/guile/base.scm
> +bytestructures/guile/numeric.scm
> +bytestructures/guile/struct.scm
> +bytestructures/guile/bitfields.scm
> +bytestructures/r6/bytevectors.scm
> +bytestructures/body/base.syntactic.scm
> +bytestructures/body/explicit-endianness.scm
> +bytestructures/body/vector.scm
> +bytestructures/body/union.scm
> +bytestructures/body/utils.scm
> +bytestructures/body/base.scm
> +bytestructures/body/numeric.scm
> +bytestructures/body/struct.scm
> +bytestructures/body/bitfields.scm
> +bytestructures/guile.scm"
> +					 #\newline))
> +		(guild (string-append (assoc-ref %build-inputs "guile")
> +				      "/bin/guild")))
> +	   ;; Make installation directories.
> +	   (mkdir-p (string-append module-dir "/bytestructures/guile"))
> +	   (mkdir-p (string-append module-dir "/bytestructures/r6"))
> +	   (mkdir-p (string-append module-dir "/bytestructures/body")) 
> +	   (mkdir-p doc)
> +
> +	   ;; Compile .scm files and install.
> +	   (chdir source)
> +	   (setenv "GUILE_AUTO_COMPILE" "0")
> +	   (for-each (lambda (file)
> +		       (let* ((dest-file (string-append module-dir "/"
> +							file))
> +			      (go-file (string-append module-dir "/"
> +						      (substring file 0
> +								 (string-rindex file #\.))
> +						      ".go")))
> +			 ;; Install source module.
> +			 (copy-file file dest-file)
> +			 ;; Install compiled module.
> +			 (unless (zero? (system* guild "compile"
> +						 "-L" source
> +						 "-o" go-file
> +						 file))
> +			   (error (format #f "Failed to compile ~s to ~s!"
> +					  file go-file)))))
> +		     scm-files)
> +
> +	   ;; Also copy over the README.
> +	   (install-file "README.md" doc)
> +	   #t))))
> +    (inputs
> +     `(("guile" ,guile-2.0)))
> +    (home-page "https://github.com/TaylanUB/scheme-bytestructures")
> +    (synopsis "Structured access to bytevector contents for Guile")
> +    (description
> +     "Scheme bytestructures offers a system imitating the type system
> +of the C programming language, to be used on bytevectors.  C's type
> +system works on raw memory, and Scheme works on bytevectors which are
> +an abstraction over raw memory.  It's also more powerful than the C
> +type system, elevating types to first-class status.")
> +    (license gpl3)))
> +
>  ;;; guile.scm ends here

Looks good for the most part. Just two things:

Formatting-wise, we use spaces rather than tabs; a simple fix.

I'm getting messages from "./pre-inst-env guix build --check --rounds=2
scheme-bytestructures" that the package derivation may not be
deterministic. However, other packages in guile.scm seem to have the
same issue, so perhaps someone more experienced with this file can
determine whether this is a cause for concern.
Ludovic Courtès - Oct. 10, 2016, 8:46 p.m.
Hi Amirouche,

Some comments to complement Kei’s.

Kei Kebreau <kei@openmailbox.org> skribis:

> Amirouche Boubekki <amirouche.boubekki@gmail.com> writes:
>
>> Warning: scheme-bytestructures works on various implementation of Scheme but this patch adds
>> it only for guile-2.0.
>>
>> This is a pure scheme package there is no autotools that's why I use the trivial-build-system.
>>
>> This doesn't run the test suite, yet.
>>
>> From fb2eb7ffd88ec4fba09411195a54b59d67d9c137 Mon Sep 17 00:00:00 2001
>> From: Amirouche <amirouche@hypermove.net>
>> Date: Sun, 9 Oct 2016 12:31:20 +0200
>> Subject: [PATCH] gnu: Add scheme-bytestructures
>>
>> * gnu/packages/guile.scm (scheme-bytestructures): New variable.
>>
>> diff --git a/gnu/packages/guile.scm b/gnu/packages/guile.scm
>> index 0890f19..383990e 100644
>> --- a/gnu/packages/guile.scm
>> +++ b/gnu/packages/guile.scm
>> @@ -1265,4 +1265,105 @@ is no support for parsing block and inline level HTML.")
>>  (define-public guile2.2-commonmark
>>    (package-for-guile-2.2 guile-commonmark))
>>  
>> +(define-public scheme-bytestructures
>> +  (package
>> +    (name "scheme-bytestructures")

I would suggest calling it “guile-scheme-bytestructures” (or
“guile-bytestructures”?) to distinguish this package from the same one
built for another implementation.

>> +		(scm-files (string-split "bytestructures/guile/explicit-endianness.scm
>> +bytestructures/guile/numeric-metadata.scm
>> +bytestructures/guile/ffi.scm
>> +bytestructures/guile/vector.scm
>> +bytestructures/guile/union.scm
>> +bytestructures/guile/numeric-all.scm
>> +bytestructures/guile/utils.scm
>> +bytestructures/guile/pointer.scm
>> +bytestructures/guile/base.scm
>> +bytestructures/guile/numeric.scm
>> +bytestructures/guile/struct.scm
>> +bytestructures/guile/bitfields.scm
>> +bytestructures/r6/bytevectors.scm
>> +bytestructures/body/base.syntactic.scm
>> +bytestructures/body/explicit-endianness.scm
>> +bytestructures/body/vector.scm
>> +bytestructures/body/union.scm
>> +bytestructures/body/utils.scm
>> +bytestructures/body/base.scm
>> +bytestructures/body/numeric.scm
>> +bytestructures/body/struct.scm
>> +bytestructures/body/bitfields.scm
>> +bytestructures/guile.scm"

Please let’s not list all the files.  :-)  Could it instead use
something like (find-files "bytestructures" "\\.scm$")?

>> +	   ;; Compile .scm files and install.
>> +	   (chdir source)
>> +	   (setenv "GUILE_AUTO_COMPILE" "0")
>> +	   (for-each (lambda (file)
>> +		       (let* ((dest-file (string-append module-dir "/"
>> +							file))
>> +			      (go-file (string-append module-dir "/"
>> +						      (substring file 0
>> +								 (string-rindex file #\.))
>> +						      ".go")))
>> +			 ;; Install source module.
>> +			 (copy-file file dest-file)
>> +			 ;; Install compiled module.
>> +			 (unless (zero? (system* guild "compile"
>> +						 "-L" source
>> +						 "-o" go-file
>> +						 file))
>> +			   (error (format #f "Failed to compile ~s to ~s!"
>> +					  file go-file)))))
>> +		     scm-files)

At some point we should factorize this in a new (guix build guile)
module or something.  Any takers?  :-)

>> +    (license gpl3)))

Probably ‘gpl3+’; could you check?

> I'm getting messages from "./pre-inst-env guix build --check --rounds=2
> scheme-bytestructures" that the package derivation may not be
> deterministic. However, other packages in guile.scm seem to have the
> same issue, so perhaps someone more experienced with this file can
> determine whether this is a cause for concern.

Yeah, this is due to a Guile issue: <http://bugs.gnu.org/20272>.

Thanks
Ludo’.
ludo@gnu.org (Ludovic Courtès) writes:

> Hi Amirouche,
>
> Some comments to complement Kei’s.
>
> Kei Kebreau <kei@openmailbox.org> skribis:
>
>> Amirouche Boubekki <amirouche.boubekki@gmail.com> writes:
>>
>>> Warning: scheme-bytestructures works on various implementation of Scheme but this patch adds
>>> it only for guile-2.0.
>>>
>>> This is a pure scheme package there is no autotools that's why I use the trivial-build-system.
>>>
>>> This doesn't run the test suite, yet.
>>>
>>> From fb2eb7ffd88ec4fba09411195a54b59d67d9c137 Mon Sep 17 00:00:00 2001
>>> From: Amirouche <amirouche@hypermove.net>
>>> Date: Sun, 9 Oct 2016 12:31:20 +0200
>>> Subject: [PATCH] gnu: Add scheme-bytestructures
>>>
>>> * gnu/packages/guile.scm (scheme-bytestructures): New variable.
>>>
>>> diff --git a/gnu/packages/guile.scm b/gnu/packages/guile.scm
>>> index 0890f19..383990e 100644
>>> --- a/gnu/packages/guile.scm
>>> +++ b/gnu/packages/guile.scm
>>> @@ -1265,4 +1265,105 @@ is no support for parsing block and inline level HTML.")
>>>  (define-public guile2.2-commonmark
>>>    (package-for-guile-2.2 guile-commonmark))
>>>  
>>> +(define-public scheme-bytestructures
>>> +  (package
>>> +    (name "scheme-bytestructures")
>
> I would suggest calling it “guile-scheme-bytestructures” (or
> “guile-bytestructures”?) to distinguish this package from the same one
> built for another implementation.

FWIW, second option sounds good to me (guile-bytestructures), speaking
as bytestructures author.

>>> +    (license gpl3)))
>
> Probably ‘gpl3+’; could you check?

The intention is gpl3+ so if any file implies otherwise that's an error
on my end.  I'm pretty sure I've used standard gpl3+ boilerplate
everywhere though.

Thanks all for doing this. :-)

Taylan
Amirouche Boubekki - Oct. 18, 2016, 1:14 p.m.
On Mon, Oct 10, 2016 at 10:46 PM Ludovic Courtès <ludo@gnu.org> wrote:

> Hi Amirouche,


[...]


> >> +            (scm-files (string-split
> "bytestructures/guile/explicit-endianness.scm
> >> +bytestructures/guile/numeric-metadata.scm
> >> +bytestructures/guile/ffi.scm
> >> +bytestructures/guile/vector.scm
> >> +bytestructures/guile/union.scm
> >> +bytestructures/guile/numeric-all.scm
> >> +bytestructures/guile/utils.scm
> >> +bytestructures/guile/pointer.scm
> >> +bytestructures/guile/base.scm
> >> +bytestructures/guile/numeric.scm
> >> +bytestructures/guile/struct.scm
> >> +bytestructures/guile/bitfields.scm
> >> +bytestructures/r6/bytevectors.scm
> >> +bytestructures/body/base.syntactic.scm
> >> +bytestructures/body/explicit-endianness.scm
> >> +bytestructures/body/vector.scm
> >> +bytestructures/body/union.scm
> >> +bytestructures/body/utils.scm
> >> +bytestructures/body/base.scm
> >> +bytestructures/body/numeric.scm
> >> +bytestructures/body/struct.scm
> >> +bytestructures/body/bitfields.scm
> >> +bytestructures/guile.scm"
>
> Please let’s not list all the files.  :-)  Could it instead use
> something like (find-files "bytestructures" "\\.scm$")?
>

The above is a subset of all files. Do you prefer to use `find-files` and
exclude some files?

Regards,

Amirouche
Ludovic Courtès - Oct. 18, 2016, 2:27 p.m.
Amirouche Boubekki <amirouche.boubekki@gmail.com> skribis:

> On Mon, Oct 10, 2016 at 10:46 PM Ludovic Courtès <ludo@gnu.org> wrote:
>
>> Hi Amirouche,
>
>
> [...]
>
>
>> >> +            (scm-files (string-split
>> "bytestructures/guile/explicit-endianness.scm
>> >> +bytestructures/guile/numeric-metadata.scm
>> >> +bytestructures/guile/ffi.scm
>> >> +bytestructures/guile/vector.scm
>> >> +bytestructures/guile/union.scm
>> >> +bytestructures/guile/numeric-all.scm
>> >> +bytestructures/guile/utils.scm
>> >> +bytestructures/guile/pointer.scm
>> >> +bytestructures/guile/base.scm
>> >> +bytestructures/guile/numeric.scm
>> >> +bytestructures/guile/struct.scm
>> >> +bytestructures/guile/bitfields.scm
>> >> +bytestructures/r6/bytevectors.scm
>> >> +bytestructures/body/base.syntactic.scm
>> >> +bytestructures/body/explicit-endianness.scm
>> >> +bytestructures/body/vector.scm
>> >> +bytestructures/body/union.scm
>> >> +bytestructures/body/utils.scm
>> >> +bytestructures/body/base.scm
>> >> +bytestructures/body/numeric.scm
>> >> +bytestructures/body/struct.scm
>> >> +bytestructures/body/bitfields.scm
>> >> +bytestructures/guile.scm"
>>
>> Please let’s not list all the files.  :-)  Could it instead use
>> something like (find-files "bytestructures" "\\.scm$")?
>>
>
> The above is a subset of all files. Do you prefer to use `find-files` and
> exclude some files?

Whichever is the most concise and most maintainable approach (I suspect
it’s ‘find-files’ + exclude specific files.)

Ludo’.

Patch

From fb2eb7ffd88ec4fba09411195a54b59d67d9c137 Mon Sep 17 00:00:00 2001
From: Amirouche <amirouche@hypermove.net>
Date: Sun, 9 Oct 2016 12:31:20 +0200
Subject: [PATCH] gnu: Add scheme-bytestructures

* gnu/packages/guile.scm (scheme-bytestructures): New variable.

diff --git a/gnu/packages/guile.scm b/gnu/packages/guile.scm
index 0890f19..383990e 100644
--- a/gnu/packages/guile.scm
+++ b/gnu/packages/guile.scm
@@ -1265,4 +1265,105 @@  is no support for parsing block and inline level HTML.")
 (define-public guile2.2-commonmark
   (package-for-guile-2.2 guile-commonmark))
 
+(define-public scheme-bytestructures
+  (package
+    (name "scheme-bytestructures")
+    (version "20160726.53127f6")
+    (source (origin
+	      (method git-fetch)
+	      (uri (git-reference
+		    (url "https://github.com/TaylanUB/scheme-bytestructures")
+		    (commit "53127f608caf64b34fa41c389b2743b546fbe9da")))
+	      (file-name (string-append name "-" version "-checkout"))
+	      (sha256
+	       (base32
+		"0l4nx1vp9fkrgrgwjiycj7nx6wfjfd39rqamv4pmq7issi8mrywq"))))
+    (build-system trivial-build-system)
+    (arguments
+     `(#:modules ((guix build utils))
+       #:builder
+       (begin
+	 (use-modules (guix build utils)
+		      (ice-9 match)
+		      (ice-9 popen)
+		      (ice-9 rdelim))
+
+	 (let* ((out (assoc-ref %outputs "out"))
+		(guile (assoc-ref %build-inputs "guile"))
+		(effective (read-line
+			    (open-pipe* OPEN_READ
+					(string-append guile "/bin/guile")
+					"-c" "(display (effective-version))")))
+		(module-dir (string-append out "/share/guile/site/"
+					   effective))
+		(source (assoc-ref %build-inputs "source"))
+		(doc (string-append out "/share/doc/scheme-bytestructures"))
+		(scm-files (string-split "bytestructures/guile/explicit-endianness.scm
+bytestructures/guile/numeric-metadata.scm
+bytestructures/guile/ffi.scm
+bytestructures/guile/vector.scm
+bytestructures/guile/union.scm
+bytestructures/guile/numeric-all.scm
+bytestructures/guile/utils.scm
+bytestructures/guile/pointer.scm
+bytestructures/guile/base.scm
+bytestructures/guile/numeric.scm
+bytestructures/guile/struct.scm
+bytestructures/guile/bitfields.scm
+bytestructures/r6/bytevectors.scm
+bytestructures/body/base.syntactic.scm
+bytestructures/body/explicit-endianness.scm
+bytestructures/body/vector.scm
+bytestructures/body/union.scm
+bytestructures/body/utils.scm
+bytestructures/body/base.scm
+bytestructures/body/numeric.scm
+bytestructures/body/struct.scm
+bytestructures/body/bitfields.scm
+bytestructures/guile.scm"
+					 #\newline))
+		(guild (string-append (assoc-ref %build-inputs "guile")
+				      "/bin/guild")))
+	   ;; Make installation directories.
+	   (mkdir-p (string-append module-dir "/bytestructures/guile"))
+	   (mkdir-p (string-append module-dir "/bytestructures/r6"))
+	   (mkdir-p (string-append module-dir "/bytestructures/body")) 
+	   (mkdir-p doc)
+
+	   ;; Compile .scm files and install.
+	   (chdir source)
+	   (setenv "GUILE_AUTO_COMPILE" "0")
+	   (for-each (lambda (file)
+		       (let* ((dest-file (string-append module-dir "/"
+							file))
+			      (go-file (string-append module-dir "/"
+						      (substring file 0
+								 (string-rindex file #\.))
+						      ".go")))
+			 ;; Install source module.
+			 (copy-file file dest-file)
+			 ;; Install compiled module.
+			 (unless (zero? (system* guild "compile"
+						 "-L" source
+						 "-o" go-file
+						 file))
+			   (error (format #f "Failed to compile ~s to ~s!"
+					  file go-file)))))
+		     scm-files)
+
+	   ;; Also copy over the README.
+	   (install-file "README.md" doc)
+	   #t))))
+    (inputs
+     `(("guile" ,guile-2.0)))
+    (home-page "https://github.com/TaylanUB/scheme-bytestructures")
+    (synopsis "Structured access to bytevector contents for Guile")
+    (description
+     "Scheme bytestructures offers a system imitating the type system
+of the C programming language, to be used on bytevectors.  C's type
+system works on raw memory, and Scheme works on bytevectors which are
+an abstraction over raw memory.  It's also more powerful than the C
+type system, elevating types to first-class status.")
+    (license gpl3)))
+
 ;;; guile.scm ends here
-- 
2.10.0