emacs-devel
[Top][All Lists]
Advanced

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

Re: [PROPOSAL] Builder, a build system integration for Emacs


From: Dirk-Jan C. Binnema
Subject: Re: [PROPOSAL] Builder, a build system integration for Emacs
Date: Wed, 24 May 2023 09:09:28 +0300
User-agent: mu4e 1.11.6; emacs 29.0.91

On Tuesday May 23 2023, Augustin Chéneau (BTuin) wrote:

> Le 23/05/2023 à 02:44, Po Lu a écrit :
>> "Augustin Chéneau (BTuin)" <btuin@mailo.com> writes:
>> 
>>> Oh I didn't mean a simple toggle, I meant an arbitrary command
>>> variant. For instance with Builder you can define a "debug2",
>>> "compile_arm" or any other command.
>> I don't understand how this works; before you can change targets, you
>> need to regenerate the build system for your program by running
>> configure.
>> Are you saying that in Builder, `configure' is an extra step, run each
>> time the target changes?
>> 
>
> Yes, it is.
>
> Let's illustrate with an hypothetical workflow: you work on Emacs, and you 
> want
> to easily switch between multiple configurations, say "minimal" which enable
> very few features to ease debugging and "regular" which enable many features,
> such as pgtk, json, native compilation... (and possibly many other variants,
> there is no limit of number).
>
> First, you execute `builder-configure' which detects the build system, finds
> Autotools and asks you to chose between "minimal", "regular", and others.  
> Once
> you've chosen, the minibuffer is filled with the "minimal" command (for 
> example
> `../configure --without-threads --without-toolkit-scroll-bars`.  You press
> enter, the command is executed in a compile buffer.
>
> Then, you need to compile.  You call `builder-compile', and you may have to
> chose between multiple targets, for example "default" with the value "make" 
> and
> "parallel" with the value "make -jN", N being the number of cores on you
> processor.  Once you've chosen, the same as for configure happens, the command
> is executed in a compilation buffer.
>
> If you want to change to the "regular" configuration target, you call
> `builder-configure` and select this target.  Then, you call `builder-compile` 
> to
> compile the project.
>
> So each time you want to change the target you call `builder-configure`.   But
> with out of tree builds, it could be possible to create one build directory 
> for
> each configuration, which would remove the need to execute the configuration
> step each time you want to change.  It's not yet available as it is really not
> trivial to implement, but I'll try to find a satisfying solution.

Sounds useful!

I did some experiments in this area; I'm using some (private for now)
code to do something like that; it does some detection (e.g a ´cargo' or
a 'meson' project, 'autotools' project), and generates an alist per
project-type, which maps 'verbs' like 'build', 'run', 'test' to
project-type-specific commands, e.g. this specifies detection of a
rust project and the accompanying verbs.

--8<---------------cut here---------------start------------->8---
(defvar breeze-cargo-project
  ((and (fboundp 'rust-mode) (locate-dominating-file "." "Cargo.toml")) .
   ((build . rust-compile)
    (run   . rust-run)
    (test  . rust-test)))
  "A project we can build with cargo/rust-mode?")
--8<---------------cut here---------------end--------------->8---

and I can now map a common key binding for building or testing etc. the
current project. In many cases _ultimately_ it's just a fancy way to
fill `compile-command', but depending on the project it can be anything.

Some of my projects don't quite fit the generic type, so I allow for
overriding on a per-project basis; e.g. when there are a few different
things to build, I use a transient as the build command:

--8<---------------cut here---------------start------------->8---
  (transient-define-prefix build-my-special-targets()
    "Transient for special build commands."
    [:class transient-columns
            ["Build"
             ("a" "Build A" (lambda ()
               (interactive) (build-special "a")))
             ("b" "Build B" (lambda ()
               (interactive) (build-special "b")))  
             ("c" "Build C" (lambda ()
               (interactive) (build-special "c")))   ]])
--8<---------------cut here---------------end--------------->8---

so I get some nice menu.

It'd  be great to have such a facility in emacs.

Kind regards,
Dirk.

-- 
Dirk-Jan C. Binnema                  Helsinki, Finland
e:djcb@djcbsoftware.nl           w:www.djcbsoftware.nl
gpg: 6987 9CED 1745 9375 0F14 DA98 11DD FEA9 DCC4 A036



reply via email to

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