On Tue, 31 Dec 2024, Pjotr Prins <pjotr.publi...@thebird.nl> wrote:
> On Sat, Dec 28, 2024 at 01:48:02AM +0000, Divya Ranjan wrote:

[...]

> Sure, it may be worth creating a clean system. But I do note that both
> meson and cmake chose to handle the build through make or ninja. There
> must be a reason for that :)

Sorry for very late reply.  Last months were busy for me.

I'm not sure why build systems sometime choose to export to Makefile.
Maybe they don't want to implement a parallel DAG traversal or something
like that.  Maybe the reason is that you can distribute the project with
the Makefiles without needing cmake after that?

This is a case that could be interesting for my build system, e.g. for
supporting systems where Guile is not installed.  Distributing the
projet as a single Makefile and `config.mk' and all the core source
files.  However, I would argue to just install Guile on these systems
instead.  Unfortunately, there seems to be a witch-hunt against Guile in
some distros.

> Debian packagers tend to prefer meson, make and cmake (I don't know in
> what order of preference).
> 
> Wrt supporting other distros outside guix - the reality is that
> software authors need to distribute software. They will only adopt a
> build system if it allows targeting those too. 
>
> My simple needs as a software developer of tools that run everywhere are:
>
> 1- Clean and *fast* development build system on Guix
> 2- Allow generating reasonably clean builds for Debian, Conda etc.
> 3- Allow multi-language builds (think guile+zig or python+C++)

All of your points are checked for my build system (at the exception of
distros where Guile is not present), since I have the same needs.


Although I only added support for C/C++ and Guile for now since these
are my requirements, the build system is exensible through GOOPS, so it
is trivial to add something like Python.  As an example, consider the
following 65 LOC for supporting Guile:

--8<---------------cut here---------------start------------->8---
(define-module (project build guile)
  #:use-module (ice-9 exceptions)
  #:use-module (ice-9 string-fun)
  #:use-module (oop goops)
  #:use-module (project oop)
  #:use-module (project build)
  #:use-module (project file-system)
  #:use-module (project popen)
  #:use-module (srfi srfi-1)
  #:use-module (srfi srfi-26)
  #:export (<guile-module>
            guile-module
            current-guile-toolchain))

(define current-guile-toolchain (make-parameter "guild"))

(define (make-file-converter suffix)
  (lambda (file)
    (let ((k (string-rindex file #\.)))
      (string-append
       (substring/shared file 0 k)
       suffix))))

(define ->.go (make-file-converter ".go"))

(define-project-class <guile-module> (<buildable>)
  (load-paths
   #:getter guile-module-load-paths
   #:init-value '()
   #:init-keyword #:load-paths
   #:type list?))

(define (&no-source-file! this)
  (raise-exception
   (make-exception
    (make-programming-error)
    (make-exception-with-origin
     (object-source-origin this))
    (make-exception-with-irritants (inputs-of this))
    (make-exception-with-message
     "Could not find any source file in <guile-module> inputs."))))

(define-method (initialize (this <guile-module>) initargs)
  (next-method)
  (unless (output-of this)
    (let ((source-file (find string? (inputs-of this))))
      (if source-file
          (set! (output-of this)
                (string-replace-substring (->.go source-file)
                                          (srcdir) (builddir)))
          (&no-source-file! this)))))

(define-method (build (this <guile-module>))
  (let ((source-file (find string? (inputs-of this)))
        (output (output-of this)))
    (if source-file
        (invoke (string-append "GUILD\t" output)
                (list (current-guile-toolchain)
                      "compile"
                      (map (cut list "-L" <>)
                           (guile-module-load-paths this))
                      "-o" output
                      source-file)
                #:stdout the-null-port)
        (&no-source-file! this))))
--8<---------------cut here---------------end--------------->8---

Thanks,
Olivier

-- 
Olivier Dion
EfficiOS Inc.
https://www.efficios.com

Reply via email to