all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dmitry@gutov.dev>
To: Ergus <spacibba@aol.com>
Cc: emacs-devel@gnu.org
Subject: Re: Project out of sources compilation
Date: Sun, 17 Mar 2024 04:53:42 +0200	[thread overview]
Message-ID: <5e04b699-6a0a-45ef-92cc-2115b58a869e@gutov.dev> (raw)
In-Reply-To: <4wwljrdnra3bsloehioa46y24ozxajajmvf2elvskxxq3mhtg2@pyv2z5snot6h>

Hi!

On 16/03/2024 15:12, Ergus wrote:

> These days I have been working with cmake projects here and there and in
> spite of I could handle most of the work from emacs, it required a lot
> of extra time to make it more or less comfortable.
> 
> I wrote a couple of simple functions to manage my needs, but at the end
> I think that there are some small piece missing to handle common
> workflows and glue everything (with the users in mind of course):
> 
> 1. Out of sources compilation.
> 
> Most of projects now prefer to do out-of sources compilation. Either to
> keep source code clean or to keep multiple compilations at the same time
> (i.e Debug/Release/win32)
> 
> The project.el package has already some compilation commands, but they
> assume that the compilation will be executed in the project's
> root... which is not true most of the time.
> 
> Maybe we may add an extra custom variable that could be specified in the
> dir-locals.el in order specify where the compilation command must be
> executed.
> 
> Some more heuristics here is possible, but I would settle for at least
> something simpler.

project.el has just one, very simple command, where the only thing that 
it does it switch to the root first. How will you customize it? With a 
hook, where the user would write a function "determine a directory for 
compilation"? They might as well define a new command - or redefine this 
one. Or just an option with relative directory name?

> 2. Eglot compilations database place.
> 
> When compilation is out of sources the cmake generated
> compile_commands.json also goes in that directory by default.
> 
> This issue can be managed with a line in dir-locals, or just manually
> coping the database.
> 
> ((eglot-workspace-configuration
>        . (:clangd (:initializationOptions (:compilationDatabasePath
>        "build")))))
> 
> Probably some simple slight integration of Eglot with Project may help.

That seems like it can be a Eglot user option. Again, just storing a 
file name relative to the project root?

>    2.1 This mixes with the previous one because if we change the
>    compilation directory the line with initializationOptions is not
>    updated and requires manual intervention
> 
> 3. Projects multiple backends
> 
> This one is tricky because at the moment I have gtags-mode, that
> includes a backend for project.el, there is the default backend, but
> also we could add something called cmake-backend (i.e looks for
> CMakeLists.txt that includes a 'project' entry)
> 
> In that case emacs cannot use all the information form the three even if
> it is not contradictory, so the user ends up opening the terminal and
> doing things manually.

Indeed, project.el doesn't "merge" backends. Is there an obvious 
algorithm for merging backends which would be understandable to an 
average user?

If the only thing you wanted combined is the root detection, I suggest 
reusing the variable project-vc-extra-root-markers, automatically or 
manually (just have the user set it). If its data structure is now 
powerful enough, it can be updated. For example, if the logic both looks 
for CMakeLists.txt and checks its contents, 
project-vc-extra-root-markers could support cons entries like (MARKER . 
CHECK-FN).

> 4. Flymake integration
> 
> Even without eglot, flymake should be capable to work very easily with
> cmake projects.
> 
> This step is also a stage before doing a proper plugin integration of
> tools like cppcheck for flymake.

Is there something particular that is required?

> 5. Project local variables (a man can dream, a man can dream)
> 
> There are some situations where we want to have variables shared among a
> project. (i.e some output directory, logging option when executing,
> flags, environment variables).
> 
> At the moment these options work partially by using directory
> variables. If we have the concept of a "project", maybe it is logical to
> have some sort of project scope concept, specially for projects sharing
> a common root.
> 
> For example vs-code adds a subdirectory with project variables that the
> user (but also any plugin) can refer to in the project's scope.

Does such subdirectory in VS Code affect the project residing its its 
parent directory, or some other projects as well? Your description above 
sounds more like our .dir-locals.el.

And the directory locals facility in Emacs also has the less well-known 
capability called "directory class", see the bottom of 
https://www.gnu.org/software/emacs/manual/html_node/emacs/Directory-Variables.html. 
I think it should work okay for sharing variables between projects.

Perhaps it's less user-friendly than one had hoped, I don't know. Some 
improvements for related UIs would be welcome.

Just creating a parallel built-in way to set variables inside 
directories but for projects sounds a bit much. Also, we don't always 
detect a buffer's project before the user asks for it. So I'm not sure 
what hooks could be added, even if we wanted.

> I could try to implement some of this with your help; but I need some
> feedback on which of them are desired and which are not. Or which ones
> are maybe better to put as feature requests for a more skilled lisper or
> package maintainer.

Patches are welcome, but see above.

Cheers,
Dmitry.



  parent reply	other threads:[~2024-03-17  2:53 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <4wwljrdnra3bsloehioa46y24ozxajajmvf2elvskxxq3mhtg2.ref@pyv2z5snot6h>
2024-03-16 13:12 ` Project out of sources compilation Ergus
2024-03-16 16:50   ` Konstantin Kharlamov
2024-03-16 19:00     ` Ergus
2024-03-16 20:56       ` Konstantin Kharlamov
2024-03-17  2:53   ` Dmitry Gutov [this message]
2024-03-17  7:22     ` Ergus
2024-03-17  8:45       ` Eli Zaretskii
2024-03-17 17:33         ` Ergus
2024-03-17 17:38           ` Eli Zaretskii
2024-03-17 17:58             ` Ergus
2024-03-17 11:36   ` Augusto Stoffel
2024-03-17 17:47     ` Ergus
2024-03-19 18:36       ` Ergus
2024-03-27 16:38         ` [PATCH] " Ergus
2024-03-31  2:41           ` Dmitry Gutov
2024-03-31 21:07             ` Ergus
2024-04-01  7:49               ` Dirk-Jan C. Binnema
2024-04-01 13:52                 ` Ergus
2024-04-01 15:09                   ` Dirk-Jan C. Binnema
2024-04-01 17:18                     ` Ergus
2024-04-02 23:23                   ` Dmitry Gutov
2024-04-03 19:47                     ` Ergus
2024-04-06  2:05                     ` Ergus
2024-04-14  1:44                       ` Dmitry Gutov
2024-04-16 14:56                         ` Ergus
2024-04-22 17:05                         ` Ergus
2024-04-22 18:48                           ` Ergus
2024-04-22 21:20                             ` Mohsin Kaleem
2024-04-23 15:17                               ` Ergus
2024-04-23 19:26                                 ` Mohsin Kaleem
2024-04-26  0:47                               ` Dmitry Gutov
2024-04-02 21:39               ` Richard Stallman
2024-04-02 22:43                 ` Dr. Arne Babenhauserheide
2024-04-05 21:40                   ` Richard Stallman
2024-04-03 10:40                 ` Konstantin Kharlamov
2024-04-03 11:45                   ` Eli Zaretskii
2024-04-03 13:31                     ` Konstantin Kharlamov
2024-04-03 14:11                       ` Eli Zaretskii
2024-04-03 15:00                         ` Konstantin Kharlamov
2024-04-03 15:47                           ` Eli Zaretskii
2024-04-03 17:27                             ` Konstantin Kharlamov
2024-04-03 18:22                               ` Eli Zaretskii
2024-04-03 19:08                                 ` Konstantin Kharlamov
2024-04-03 20:12                                   ` Ergus
2024-04-04  5:26                                     ` Eli Zaretskii
2024-04-04  9:59                                       ` Ergus
2024-04-04 11:59                                         ` Eli Zaretskii
2024-04-04 12:34                                           ` Ergus
2024-04-04 13:02                                             ` Eli Zaretskii
2024-04-04 14:27                                               ` Ergus
2024-04-04 14:41                                                 ` Eli Zaretskii
2024-04-04 18:15                                                   ` Ergus
2024-04-04 18:56                                                     ` Eli Zaretskii
2024-04-04 20:16                                                   ` Konstantin Kharlamov
2024-04-05  5:11                                                     ` Eli Zaretskii
2024-04-04  5:07                                   ` Eli Zaretskii
     [not found]                               ` <87jzlefgi9.fsf@dick>
2024-04-03 18:44                                 ` Konstantin Kharlamov

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=5e04b699-6a0a-45ef-92cc-2115b58a869e@gutov.dev \
    --to=dmitry@gutov.dev \
    --cc=emacs-devel@gnu.org \
    --cc=spacibba@aol.com \
    /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/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.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.