msys path conversion (or cygpath for msys?)

前端 未结 7 2083
心在旅途
心在旅途 2020-12-02 17:15

I need to pass /DEF:c:\\filepath\\myLib.def\" command line option from a bash script to MS compiler/linker. The path is generated as part of build process by a bash script.

相关标签:
7条回答
  • 2020-12-02 17:53

    MSYS cygpath

    Program

    This program convert a DOS path to a UNIX path and vice versa

    #!/bin/env perl
    # DOS to UNIX path conversion
    # © John S. Peterson. License GNU GPL 3.
    use strict;
    use Getopt::Std;
    
    # usage
    if ($#ARGV == -1) {
        print 'Usage: cygpath (-w) NAME...
    
    Convert Unix and Windows format paths
    
    Output type options:
    
      -w, --windows         print Windows form of NAMEs (C:\WINNT)
    ';
        exit 0;
    }
    
    # option
    my %opt;
    getopts('w', \%opt);
    
    # convert path
    my @r;
    foreach my $e (@ARGV) {
        if ($opt{w}) {
            # add drive letter suffix
            $e =~ s,^\/([A-Za-z])\/,\1:\/,;
            $e =~ s,\/,\\,g;
    
        } else {
            $e =~ s,\\,\/,g;
            # add leading slash
            $e = "/$e";
            # remove drive letter suffix
            $e =~ s,:,,;
        }
    
        push @r, $e;
    }
    
    print join("\n", @r);
    

    Compared to Cygwin cygpath

    The output from this program is better than the output from Cygwin cygpath in MSYS because

    • Cygwin cygpath remove the Cygwin home from a converted path, f.e.
    cygpath "$CYGWIN/usr/local/bin"
    /usr/local/bin
    

    which is a problem because

    • it's sometimes useful to convert a DOS Cygwin path to a UNIX path for the purpose of copying files from Cygwin to MSYS

    This program doesn't remove the Cygwin home

    cygpath "$CYGWIN/usr/local/bin"
    /c/file/program/cygwin/usr/local/bin
    

    Compared to automatic MSYS path conversion

    Manual path conversion has a use in MSYS because

    • the automatic path conversion is inadequate

    for f.e.

    • devkitPro make
    0 讨论(0)
提交回复
热议问题