all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Jesse <dev@millwood.earth>
To: Carlo Zancanaro <carlo@zancanaro.id.au>
Cc: help-guix@gnu.org
Subject: Re: Help with channel build system and package
Date: Thu, 8 Feb 2024 09:32:44 -0500	[thread overview]
Message-ID: <77fd3fdc-d1cf-4abc-a9fd-a981c17510b0@millwood.earth> (raw)
In-Reply-To: <87v86zhbj0.fsf@zancanaro.id.au>

[-- Attachment #1: Type: text/plain, Size: 7002 bytes --]

Thanks for taking a look Carlo!

On 2/7/24 22:37, Carlo Zancanaro wrote:
> Hi Jesse,
>
> I know very little about what you're trying to do, but there's one thing
> that looked wrong to me:
>
> On Wed, Feb 07 2024, Jesse wrote:
>> ...
>>      (build-system crosstool-ng)
>> ...
> This isn't a build system, right? It's just the package? I think you may
> want crosstool-ng-build-system here.

You are totally correct here. I changed this to "(build-system 
crosstool-ng-build-system)" and I don't get the same error now. I also 
then realized I was missing "  #:use-module (embedded-dev build-system 
crosstool-ng)" from the list of modules in the package define-module 
expression in the packages/crosstool-ng.scm file. I also tracked down 
some other missing modules.

However, now I get this:

guix build -v3 -L embedded-dev ct-ng-riscv64-unknown-elf
guix build: warning: invalid argument list
guix build: warning: source expression failed to match any pattern
error: crosstool-ng-build-system: unbound variable
hint: Did you forget `(use-modules (embedded-dev build-system 
crosstool-ng))'?

guix build: error: ct-ng-riscv64-unknown-elf: unknown package

This confuses me a bit because it says that it is an unbound variable 
but it is defined in embedded-dev/build-system/crosstool-ng.scm. I 
believe I should be importing this module with the "#:use-module 
(embedded-dev build-system crosstool-ng)" line in the package file. The 
symbol should be exported with:

(define-module (embedded-dev build-system crosstool-ng)
   #:use-module (guix build-system)
   #:use-module (guix build-system gnu)
   #:export (%crosstool-ng-build-system-modules
             crosstool-ng-build
             crosstool-ng-build-system))

which is in the embedded-dev/build-system/crosstool-ng.scm file of my 
channel. I was mainly trying to follow some build-system setups like 
ruby where there are build/ruby-build-system.scm, which is used by 
build-system/ruby.scm, which defines and exports the ruby-build-system 
symbol, and that is used by the packages in packages/ruby.scm.

If I was to manually trace how the build system guile files are used 
from a package definition, it would look like this:

1. In packages/crosstool-ng.scm I have a package definition that uses
        (build-system crosstool-ng-build-system)

2. In that same file I have a line that should include the entry point 
to the crosstool-ng build system:
         #:use-module (embedded-dev build-system crosstool-ng)

3. That line should use the guile module located at 
embedded-dev/build-system/crosstool-ng.scm, since my build invocation 
looks like: "guix build -v3 -L embedded-dev ct-ng-riscv64-unknown-elf" 
and my channel is in a directory called "embedded-dev". So the fulll 
path would be embedded-dev/embedded-dev/build-system/crosstool-ng.scm

4. In build-system/crosstool-ng.scm the beginning is defined as:

(define-module (embedded-dev build-system crosstool-ng)
   #:use-module (guix build-system)
   #:use-module (guix build-system gnu)
   #:export (%crosstool-ng-build-system-modules
             crosstool-ng-build
             crosstool-ng-build-system))

(define %crosstool-ng-build-system-modules
   ;; Build-side modules imported by default.
   `((embedded-dev build crosstool-ng-build-system)
     ,@%gnu-build-system-modules))

(define (default-crosstool-ng )
   "Return the default crosstool-ng package"
   (let ((crosstool-ng (resolve-interface '(embedded-dev packages 
crosstool-ng))))
     (module-ref crosstool-ng 'crosstool-ng)))


Here I should be exporting the "crosstool-ng-build-system" symbol to be 
used by a guile script that uses it. The 
crosstool-ng-build-system-modules should be looking at 
embedded-dev/build/crosstool-ng-build-system.scm, again taking 
inspiration from other build system files like the ones associated with 
ruby. The default-crosstool-ng symbol should be grabbing from the 
embedded-dev/packages/crosstool-ng.scm file.

5. Later in that file I pass the crosstool-ng-build-system-modules 
symbol to the crosstool-ng-build function as well as the module located 
at embedded-dev/build/crosstool-ng-build-system.scm

(define* (crosstool-ng-build name inputs
                              #:key (sample "unknown")
                              (test-target "test")
                              (tests? #t)
                              (phases '%standard-phases)
                              (outputs '("out"))
                              (search-paths '())
                              (system (%current-system))
                              (guile #f)
                              (imported-modules 
%crosstool-ng-build-system-modules)
                              (modules '((embedded-dev build 
crosstool-ng-build-system)
                                         (guix build utils)))
                              )

6. Then the actual build system symbol that is exported from the top is 
defined at the bottom of this file:

(define crosstool-ng-build-system
   (build-system
     (name 'crosstool-ng)
     (description "Crosstool-ng build system")
     (lower lower)))

It all seems just as threaded together as the ones in the guix source. I 
must be missing something small here.

I'm also confused about the "guix build: warning: invalid argument 
list". It looks like I'm invoking the build command properly.

Is there something else you have to do when setting up a channel to pull 
in the build and build-system directories? I thought that by adding my 
channel to the load path with "-L", the elements passed to use-module 
were essentially directory paths.

>
> That might be what's causing the error:
>
>> ...
>> In guix/build-system.scm:
>>       94:2  3 (make-bag _ _ #:source _ #:inputs _ #:native-inputs _ # …)
>> In ice-9/boot-9.scm:
>>    1685:16  2 (raise-exception _ #:continuable? _)
>>    1685:16  1 (raise-exception _ #:continuable? _)
>>    1685:16  0 (raise-exception _ #:continuable? _)
>>
>> ice-9/boot-9.scm:1685:16: In procedure raise-exception:
>> Throw to key `match-error' with args `("match" "no matching pattern"
>> #<package crosstool-ng@1.26.0
>> embedded-dev/embedded-dev/packages/crosstool-ng.scm:26
>> 7fd09cb334d0>)'.
> Looking in make-bag (in guix/build-system.scm), the first think it does
> it pattern match on the build system expecting a record of the
> <build-system> type. Your package doesn't match that pattern, so this
> error is raised.
Thanks for pointing this out, I didn't dig in enough.
>
> Carlo

I've attached the version with the changes mentioned.

Thanks,

Jesse

[-- Attachment #2: embedded-dev.tar.gz --]
[-- Type: application/gzip, Size: 2874 bytes --]

  reply	other threads:[~2024-02-08 14:33 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-08  3:27 Help with channel build system and package Jesse
2024-02-08  3:37 ` Carlo Zancanaro
2024-02-08 14:32   ` Jesse [this message]
2024-02-08 17:00     ` Marek Paśnikowski
2024-02-08 18:33       ` Jesse Millwood
2024-02-08 18:52         ` Marek Paśnikowski
2024-02-15 13:23           ` Jesse
2024-03-08  2:35             ` Jesse Millwood
2024-03-08 10:43               ` Marek Paśnikowski
2024-03-09 14:44                 ` Jesse Millwood
2024-03-09  3:39               ` Richard Sent
2024-03-09 15:02                 ` Jesse Millwood
2024-03-16 21:47                   ` Jesse Millwood
2024-03-16 22:50                     ` Jesse Millwood

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=77fd3fdc-d1cf-4abc-a9fd-a981c17510b0@millwood.earth \
    --to=dev@millwood.earth \
    --cc=carlo@zancanaro.id.au \
    --cc=help-guix@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.