[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Guix-based build tool

From: Ricardo Wurmus
Subject: Re: Guix-based build tool
Date: Fri, 20 Apr 2018 22:13:49 +0200
User-agent: mu4e 1.0; emacs 25.3.1

Hi Catonano,

> I am experimenting with this line
> (system* "guile" "-c" "(use-modules (commonmark)) (exit ((lambda () 0)))")
> If it finds the module it returns 0
> Otherwise it returns a different number
> I copied some bits for a configure script for a Guile project instrumented
> with the Autotools
> I could use an example of usage of "status:Exit-val"
> The Guile manual says:
>      Return the exit status value, as would be set if a process ended
>      normally through a call to ‘exit’ or ‘_exit’, if any, otherwise
>      ‘#f’.
> this is not enouhg for me to understand
> In which scenario is thhis function supposed to be used ? In order to do
> what ?
> An example would be of great help

With this procedure you can obtain the return status for “system*”.
Here’s an example:

--8<---------------cut here---------------start------------->8---
(display "Checking for commonmarl...")
(let ((status
       (parameterize ((current-error-port  (%make-void-port "w")))
         (status:exit-val (system* "guile" "-c"
                                   "(begin (use-modules (commonmarl))
                (exit 0))")))))
  (display (if (zero? status)
               "Oh no!"))
--8<---------------cut here---------------end--------------->8---

> Anyway: Is this the idiomatic way ?
> Or maybe I should use some try catch form wrapping some module loading
> instruction ?
> Without launching a different guile process ?

There are advantages to spawning a new guile process.  One is that
whatever modules you may have loaded for your tool won’t affect the
check.  It’s possible that your tool bundles a bunch of modules, but
when Guile is spawned in a pure environment it won’t be able to load
these modules.  You may want to fail the configure test then.

On the other hand, it’s ugly to pass a Guile programme as a string to
system*, when you could do that instead with pure Guile.  I haven’t
thought enough about this to give a recommendation either way.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]