-
Notifications
You must be signed in to change notification settings - Fork 4
Small fix to detect msys environment #5
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
base: master
Are you sure you want to change the base?
Conversation
|
I'm not sure you could use |
|
Yes cygpath is in msys, Note that I'm using the git-for-windows-sdk, with Vim 8.2.3582. but, I see that git-for-windows vanilla will have cygpath you can try, and vim. If you like to try, you can install that, and you also get a button for opening a Git-Bash tab in "Windows Terminal". I also have cygwin installed but I'm migrating to msys. |
|
I suspect we are working in the exact opposite scenario. Meaning I'm converting cygwin paths into windows paths, while you want to convert windows paths into msys paths. I guess that if you use Note: I'm mostly under Linux nowadays, I won't be able to test it before a few days. |
|
No rush, I'll be in a position to test more perhaps tomorrow or next week. It is the filtering technique that concerns me the most. It is already a PITA to have to do Your filter trick is neat, but it assumes make. Needs to be more general? |
I used to know Perl RE, nowadays, I'll have to search a little ^^'. Anyway, here, the main difference is that we are mainly in magic mode by default.
I'm afraid not as I test things like
You can use let &makeprg = 'set -o pipefail ; ninja -C ../build 2>&1 | the-future-win2msys-path-converter.dot.py.or.pl.or.sh'
With this plugin, you can already use ninja with
However, it'll not use the |
|
I don't think you could possibly auto-detect the build folder ... Thanks for the :let tip Maybe we need a non-vim specific bash script or other, to be put in the $PATH or $HOME/bin or wherever, |
|
Regarding auto detection of build directories. That's my situation as well. The heuristic is quite complex. First I try to follow compile_commands.json if it's a symbolic link. This would give a compilation directory, if there are sibling directories with Regarding other things like calling ninja. In BuildToolsWrapper new architecture, I can detect&load compilation chains. While I'm mainly focusing of CMake. I should be able to have some tweakings for ninja, which will be registered here |
|
wow |
|
What about the following that you could drop into #!/usr/bin/perl
# Author: Luc Hermitte <EMAIL:hermitte {at} free {dot} fr>
# <URL:http://hermitte.free.fr/vim>
# Purpose: Convert plain Winddows pathames to MSYS pathnames.
# Defined as a filter to use on make's result.
# Meant to be used by Vim.
# Created: 30th Jun 2022
# Last Update: 30th Jun 2022
### Code {{{1
## Includes {{{2
use strict ;
use File::Spec ; # splitpath()
## Globals {{{2
# Hash table for the paths already translated with ``realname'', or cygpath
my %h = () ;
## Functions {{{2
sub parent # {{{3
{
my ($path) = @_;
my ($vol,$dir,$file) = File::Spec->splitpath($path);
# print "vol: '$vol'; dir: '$dir'; file: '$file'\n";
return ("$vol$dir", $file);
}
# Proxy function: returns the realname of the path
# This function looks for converted paths into the hastable, if nothing is
# found in the table, the result is built and added into the table
# TODO: follow mounted things
sub UnixPath # {{{3
{
my ($path) = @_ ;
# print "testing $path\n";
if ( exists( $h{$path} ) ) {
return $h{$path} ;
} else {
# Get the real location of the file
my $upath = `realpath "$path"`;
chomp ($upath);
my ($dir, $file) = parent($upath);
if (exists( $h{$dir} )) {
my $udir = $h{$dir};
} else {
# Convert the dir to UNIX form
my $udir = `cygpath -u $dir`;
chomp($udir);
# Add the dir to the hash-table
$h{$dir} = $udir;
# print "cygpath '$dir' --> '$udir'\n";
}
$upath = File::Spec->catfile($h{$dir}, $file);
# Add the path into the hash-table
$h{$path} = $upath ;
return $upath ;
}
}
## Main {{{2
# Main loop: convert MsWindows paths into Unix paths
while (<>)
{
chop;
if ( m#^( *[A-Za-z]:[\\/].*?)(\:\d*\:?.*$)# ) {
printf UnixPath($1)."$2\n";
} else {
print "$_\n";
}
}
# ======================================================================
# vim600: set foldmethod=marker:
# vim:et:ts=4:tw=79:Given let s:file = substitute(expand('<sfile>:p:h'), ' ', '\\ ', 'g') " not sure about the need for substitute()
let g:BTW_filter_program_win2msys = s:file."/win2msys.pl"Then, with build-tools-wrapper you could simply use it with Otherwise, you just need to pipe ninja/make/cmake/... compilation results into this perl script let &makeprg = 'set -o pipefail ; ninja -C ../build 2>&1 | perl /path/to/win2msys.pl |
|
I'll check it out next week, got swamped |
Looks promising,
This doesn't solve all the problems,
ie the pattern match doesn't work when the output comes from CMake+Ninja (have not tested make),
Ninja looks like
101 C:\work\file.cpp:234: errormessageAnd I haven't tested cmake+MSVC yet.
I see there are a lot more patches on the 'project' branch, but that has a lot of errors when I tried to use it.
Note that I'm using with vim, importing with
But as you suggest in stackoverflow, I only really need that vim cygwin bit.