Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use --always-make when running make -n, where possible #3247

Closed
NobodyXu opened this issue Jul 26, 2020 · 7 comments
Closed

Use --always-make when running make -n, where possible #3247

NobodyXu opened this issue Jul 26, 2020 · 7 comments

Comments

@NobodyXu
Copy link

Motivation:

Suppose you have a complex project that you'd like to enable ale_c_parse_makefile.

Now after editing the file, you run make then run the executable, and find the result to be unsatisfactory.

Then you enter vim again to edit the file, only to find there is plenty of errors due to the fact that make -n no longer "run" the recipe for the source file.

Solution:

A simple solution will be to run make -n -W % instead of make -n to ensure that recipe for the source file is always "run".

This would fix the confusing behavior after make.

@NobodyXu NobodyXu changed the title Use '-W %' to run Makefile parsing Use '-W %' for Makefile parsing Jul 31, 2020
@w0rp
Copy link
Member

w0rp commented Aug 29, 2020

How does make -n -W % work? What does it do? The arguments for make and the syntax Makefiles themselves are very esoteric.

@NobodyXu
Copy link
Author

NobodyXu commented Aug 29, 2020

make -W % would pretend that source file % is not up-to-date, even when it is already up-to-date.

Suppose that there is two file, a.c and Makefile.

Using the Makefile, a.o is built. Due to the fact that a.o is updated, make -n outputs nothing and thus ale cannot use make -n to auto-detect the compiler flags.

Supplying -W a.c would make make -n output what if a.o is outdated and prints out the recipe for building it, thus making ale able to collect the compiler flags used to build a.c.

@NobodyXu NobodyXu changed the title Use '-W %' for Makefile parsing Use '-W' for Makefile parsing Aug 29, 2020
@NobodyXu NobodyXu changed the title Use '-W' for Makefile parsing Use '-W %' for Makefile parsing Aug 29, 2020
@NobodyXu
Copy link
Author

ale can take advantage of this feature, run make -n -W % to extract the compiler flags, where % is the filename of the current buffer.

@w0rp
Copy link
Member

w0rp commented Aug 29, 2020

I understand the issue, though I don't think what you've suggested will work. If I run make -n | grep /bin/cc for my xmms2-mpris project, I see this at first.

/usr/bin/cc  -I/usr/include/xmms2 -I/usr/include/gio-unix-2.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include   -o CMakeFiles/xmms2-mpris.dir/src/xmms2-mpris.c.o   -c /home/w0rp/git/xmms2-mpris/src/xmms2-mpris.c
/usr/bin/cc  -I/usr/include/xmms2 -I/usr/include/gio-unix-2.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include   -o CMakeFiles/xmms2-mpris.dir/src/mpris-object.c.o   -c /home/w0rp/git/xmms2-mpris/src/mpris-object.c
...

If I run make and then make -n | grep /bin/cc again, I get nothing. If I run make -n -W src/xmms2-mpris.c | grep /bin/cc, I still get nothing. make -Bn | grep /bin/cc, however, will provide output. This old pull request was created a while ago, which used that flag, and at the time I asked for it to be tested on BSD, as -B has a completely different meaning on BSD.

If there's a way to detect if the system is Linux instead of BSD in Vim, without a synchronous system call, we can use -B on Linux.

@w0rp
Copy link
Member

w0rp commented Aug 29, 2020

I think I'm just going to use -B if the OS is a Unix variant, but isn't Mac OSX, which is easy to detect, and offer an option to turn it off for the extreme minority of users that use a BSD OS.

@NobodyXu
Copy link
Author

That sounds quite good for me.

@w0rp w0rp reopened this Aug 29, 2020
@w0rp w0rp changed the title Use '-W %' for Makefile parsing Use --always-make when running make -n, where possible Aug 29, 2020
@w0rp w0rp mentioned this issue Aug 29, 2020
12 tasks
@w0rp w0rp closed this as completed in 7e0cdb5 Aug 29, 2020
@w0rp
Copy link
Member

w0rp commented Aug 29, 2020

--always-make is used by default on Linux and BSD now. BSD users will probably have to use let g:ale_c_always_make = 0 for make -n parsing to work. There's no way to avoid breaking BSD make without making ALE worse on all other systems. If you use BSD, just set that option too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants