* How to replace %output with #$output?
@ 2022-03-21 21:31 Mekeor Melire
2022-03-21 21:57 ` Tobias Geerinckx-Rice
0 siblings, 1 reply; 8+ messages in thread
From: Mekeor Melire @ 2022-03-21 21:31 UTC (permalink / raw)
To: help-guix
In the IRC-channel, I was told that the undocumented, magic %output
variable is deprecated. Instead, I should use #$output. But I couldn't
get this done. I always ran into strange errors.
How should I change the following snippet?
--8<---------------cut here---------------start------------->8---
(arguments
'(
#:tests? #f ; no tests
#:make-flags (list "CC=gcc")
#:phases
(modify-phases %standard-phases
(delete 'configure)
(add-after 'unpack 'patch-makefile
(lambda _
(substitute* "Makefile"
(("/usr/local") %output)))))))
--8<---------------cut here---------------end--------------->8---
The whole file is available here: http://ix.io/3T71/scm
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to replace %output with #$output?
2022-03-21 21:31 How to replace %output with #$output? Mekeor Melire
@ 2022-03-21 21:57 ` Tobias Geerinckx-Rice
2022-03-22 7:26 ` Mekeor Melire
0 siblings, 1 reply; 8+ messages in thread
From: Tobias Geerinckx-Rice @ 2022-03-21 21:57 UTC (permalink / raw)
To: help-guix, Mekeor Melire
Hi Mekeor,
Remove the quote after arguments (replace it with a plain LIST call) and add #~ before (modify-phases ...) to define a gexp.
Untested example:
(arguments
(list #:tests? #f ; no tests
#:make-flags (list "CC=gcc")
#:phases
#~(modify-phases %standard-phases
(delete 'configure)
(add-after 'unpack 'patch-makefile
(lambda _
(substitute* "Makefile"
(("/usr/local")
#$output)))))))
Also, newlines after ( make the baby Jesus cry.
So does hard-coding 'gcc' over using (cc-for-target).
Very strong opinions on Scheme coding style, that boy.
Kind regards,
T G-R
Sent on the go. Excuse or enjoy my brevity.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to replace %output with #$output?
2022-03-21 21:57 ` Tobias Geerinckx-Rice
@ 2022-03-22 7:26 ` Mekeor Melire
2022-03-22 7:59 ` Tobias Geerinckx-Rice
2022-03-22 8:16 ` Feng Shu
0 siblings, 2 replies; 8+ messages in thread
From: Mekeor Melire @ 2022-03-22 7:26 UTC (permalink / raw)
To: Tobias Geerinckx-Rice; +Cc: help-guix
2022-03-21 / 21:57 / me@tobias.gr:
> Remove the quote after arguments (replace it with a plain LIST call) and add #~ before (modify-phases ...) to define a gexp.
>
> Untested example:
>
> (arguments
> (list #:tests? #f ; no tests
> #:make-flags (list "CC=gcc")
> #:phases
> #~(modify-phases %standard-phases
> (delete 'configure)
> (add-after 'unpack 'patch-makefile
> (lambda _
> (substitute* "Makefile"
> (("/usr/local")
> #$output)))))))
With these changes I get this error:
Wrong type to apply: "CC=gcc"
> So does hard-coding 'gcc' over using (cc-for-target).
Yes, I would also prefer to use cc-for-target. But I wanted to simplify
my code first. Because in order to use cc-for-target, I have to use
backticks. If you have a suggestion for how to use both cc-for-target
and #$output, let me know.
> Very strong opinions on Scheme coding style, that boy.
Please don't assume gender. But yes, you can refer to me with the "he"
pronoun.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to replace %output with #$output?
2022-03-22 7:26 ` Mekeor Melire
@ 2022-03-22 7:59 ` Tobias Geerinckx-Rice
2022-03-22 8:24 ` Mekeor Melire
2022-03-22 8:16 ` Feng Shu
1 sibling, 1 reply; 8+ messages in thread
From: Tobias Geerinckx-Rice @ 2022-03-22 7:59 UTC (permalink / raw)
To: Mekeor Melire; +Cc: help-guix
On 22 March 2022 07:26:38 UTC, Mekeor Melire <mekeor@posteo.de> wrote:
> (list "CC=gcc")
>
>With these changes I get this error:
>
> Wrong type to apply: "CC=gcc"
That can happen only if you apply the string as a procedure, i.e. forgot the the LIST.
>> So does hard-coding 'gcc' over using (cc-for-target).
>
>Yes, I would also prefer to use cc-for-target. But I wanted to simplify
>my code first. Because in order to use cc-for-target, I have to use
>backticks.
Why? Backticks are just short for UNQUOTE. I don't see why you'd need or even want to use that here. If you insist, you could write:
`(,(string-append "CC=" (cc-for-target)))
but I'd much prefer you didn't as I think it's a step back from
(list (string-append "CC=" (cc-for-target)))
>> Very strong opinions on Scheme coding style, that boy.
>
>Please don't assume gender. But yes, you can refer to me with the "he"
>pronoun.
If you believe yourself to be the son of god, you have problems I can't help you fix. ;-)
Hi Mekeor,
Kind regards,
T G-R
Sent on the go. Excuse or enjoy my brevity.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to replace %output with #$output?
2022-03-22 7:59 ` Tobias Geerinckx-Rice
@ 2022-03-22 8:24 ` Mekeor Melire
2022-03-22 16:26 ` Tobias Geerinckx-Rice
0 siblings, 1 reply; 8+ messages in thread
From: Mekeor Melire @ 2022-03-22 8:24 UTC (permalink / raw)
To: Tobias Geerinckx-Rice; +Cc: help-guix
2022-03-22 / 07:59 / me@tobias.gr:
> On 22 March 2022 07:26:38 UTC, Mekeor Melire <mekeor@posteo.de> wrote:
>> (list "CC=gcc")
>>
>>With these changes I get this error:
>>
>> Wrong type to apply: "CC=gcc"
>
> That can happen only if you apply the string as a procedure, i.e.
> forgot the the LIST.
The `list` was present. As suggested by Feng Shu in another thread, it
works like this:
--8<---------------cut here---------------start------------->8---
(arguments
(list
#:tests? #f ; no tests
#:make-flags #~(list "CC=gcc")
#:phases
#~(modify-phases %standard-phases
(delete 'configure)
(add-after 'unpack 'patch-makefile
(lambda _
(substitute* "Makefile"
(("/usr/local") #$output)))))))
--8<---------------cut here---------------end--------------->8---
It also seems to work with:
#:make-flags '(list "CC=gcc")
>>> So does hard-coding 'gcc' over using (cc-for-target).
>>
>>Yes, I would also prefer to use cc-for-target. But I wanted to simplify
>>my code first. Because in order to use cc-for-target, I have to use
>>backticks.
>
> Why? Backticks are just short for UNQUOTE. I don't see why you'd need
> or even want to use that here. If you insist, you could write:
>
> `(,(string-append "CC=" (cc-for-target)))
>
> but I'd much prefer you didn't as I think it's a step back from
>
> (list (string-append "CC=" (cc-for-target)))
Do I have to import cc-for-target from (guix utils)?
In case of:
;; do not have (guix utils) imported
#:make-flags (list (string-append "CC=" (cc-for-target)))
I get this during build:
error: cc-for-target: unbound variable
In case of:
;; have (guix utils) imported
#:make-flags (list (string-append "CC=" (cc-for-target)))
I get this error:
Wrong type to apply: "CC=gcc"
In case of:
;; have (guix utils) imported
#:make-flags #~(list (string-append "CC=" (cc-for-target)))
I get this error:
Unbound variable: cc-for-target
In case of:
;; have (guix utils) imported
#:make-flags `(list (string-append "CC=" ,(cc-for-target)))
I get this error ... Oh, wait, it works!
So this is the working code:
--8<---------------cut here---------------start------------->8---
(arguments
(list
#:tests? #f ; no tests
#:make-flags `(list (string-append "CC=" ,(cc-for-target)))
#:phases
#~(modify-phases %standard-phases
(delete 'configure)
(add-after 'unpack 'patch-makefile
(lambda _
(substitute* "Makefile"
(("/usr/local") #$output)))))))
--8<---------------cut here---------------end--------------->8---
Putting the comma like this also seems to work:
#:make-flags `(list (string-append "CC=" ,(cc-for-target)))
>>> Very strong opinions on Scheme coding style, that boy.
>>
>>Please don't assume gender. But yes, you can refer to me with the "he"
>>pronoun.
>
> If you believe yourself to be the son of god, you have problems I
> can't help you fix. ;-)
I see. Sorry for misunderstanding :-)
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to replace %output with #$output?
2022-03-22 7:26 ` Mekeor Melire
2022-03-22 7:59 ` Tobias Geerinckx-Rice
@ 2022-03-22 8:16 ` Feng Shu
2022-03-22 8:51 ` Mekeor Melire
1 sibling, 1 reply; 8+ messages in thread
From: Feng Shu @ 2022-03-22 8:16 UTC (permalink / raw)
To: Mekeor Melire; +Cc: help-guix
Mekeor Melire <mekeor@posteo.de> writes:
> 2022-03-21 / 21:57 / me@tobias.gr:
>
>> Remove the quote after arguments (replace it with a plain LIST call) and add #~ before (modify-phases ...) to define a gexp.
>>
>> Untested example:
>>
>> (arguments
>> (list #:tests? #f ; no tests
>> #:make-flags (list "CC=gcc")
>> #:phases
>> #~(modify-phases %standard-phases
>> (delete 'configure)
>> (add-after 'unpack 'patch-makefile
>> (lambda _
>> (substitute* "Makefile"
>> (("/usr/local")
>> #$output)))))))
>
> With these changes I get this error:
>
> Wrong type to apply: "CC=gcc"
What about #~(list "CC=gcc") or '(list "CC=gcc") ?
>
>> So does hard-coding 'gcc' over using (cc-for-target).
>
> Yes, I would also prefer to use cc-for-target. But I wanted to simplify
> my code first. Because in order to use cc-for-target, I have to use
> backticks. If you have a suggestion for how to use both cc-for-target
> and #$output, let me know.
>
>> Very strong opinions on Scheme coding style, that boy.
>
> Please don't assume gender. But yes, you can refer to me with the "he"
> pronoun.
--
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to replace %output with #$output?
2022-03-22 8:16 ` Feng Shu
@ 2022-03-22 8:51 ` Mekeor Melire
0 siblings, 0 replies; 8+ messages in thread
From: Mekeor Melire @ 2022-03-22 8:51 UTC (permalink / raw)
To: Feng Shu; +Cc: help-guix
2022-03-22 / 16:16 / tumashu@163.com:
> Mekeor Melire <mekeor@posteo.de> writes:
>
>> 2022-03-21 / 21:57 / me@tobias.gr:
>>
>>> Remove the quote after arguments (replace it with a plain LIST call) and add #~ before (modify-phases ...) to define a gexp.
>>>
>>> Untested example:
>>>
>>> (arguments
>>> (list #:tests? #f ; no tests
>>> #:make-flags (list "CC=gcc")
>>> #:phases
>>> #~(modify-phases %standard-phases
>>> (delete 'configure)
>>> (add-after 'unpack 'patch-makefile
>>> (lambda _
>>> (substitute* "Makefile"
>>> (("/usr/local")
>>> #$output)))))))
>>
>> With these changes I get this error:
>>
>> Wrong type to apply: "CC=gcc"
>
> What about #~(list "CC=gcc") or '(list "CC=gcc") ?
It works. Thank you :)
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2022-03-22 16:27 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-21 21:31 How to replace %output with #$output? Mekeor Melire
2022-03-21 21:57 ` Tobias Geerinckx-Rice
2022-03-22 7:26 ` Mekeor Melire
2022-03-22 7:59 ` Tobias Geerinckx-Rice
2022-03-22 8:24 ` Mekeor Melire
2022-03-22 16:26 ` Tobias Geerinckx-Rice
2022-03-22 8:16 ` Feng Shu
2022-03-22 8:51 ` Mekeor Melire
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.