diff options
| author | Dani Moncayo | 2014-11-08 15:55:09 +0100 |
|---|---|---|
| committer | Dani Moncayo | 2014-11-08 15:55:09 +0100 |
| commit | 7c86a2a7d82558206a96139bab73552003b3c28f (patch) | |
| tree | 211df85fd9385ce2f3a28d1bd9663af7ca98dcfc | |
| parent | c936cbbc830b194dbb1cd7ff039ea9978a7ab607 (diff) | |
| download | emacs-7c86a2a7d82558206a96139bab73552003b3c28f.tar.gz emacs-7c86a2a7d82558206a96139bab73552003b3c28f.zip | |
build-aux/msys-to-w32: simplify the initial interface.
* build-aux/msys-to-w32: simplify the initial over-engineered
interface, and the implementation.
* Makefile.in (epaths-force-w32): Update for the above.
| -rw-r--r-- | ChangeLog | 6 | ||||
| -rw-r--r-- | Makefile.in | 6 | ||||
| -rwxr-xr-x | build-aux/msys-to-w32 | 147 |
3 files changed, 56 insertions, 103 deletions
| @@ -1,3 +1,9 @@ | |||
| 1 | 2014-11-08 Dani Moncayo <dmoncayo@gmail.com> | ||
| 2 | |||
| 3 | * build-aux/msys-to-w32: simplify the initial over-engineered | ||
| 4 | interface, and the implementation. | ||
| 5 | * Makefile.in (epaths-force-w32): Update for the above. | ||
| 6 | |||
| 1 | 2014-11-05 Glenn Morris <rgm@gnu.org> | 7 | 2014-11-05 Glenn Morris <rgm@gnu.org> |
| 2 | 8 | ||
| 3 | * Makefile.in (QUIET_SUBMAKE): Remove. | 9 | * Makefile.in (QUIET_SUBMAKE): Remove. |
diff --git a/Makefile.in b/Makefile.in index 0c11828deb2..5dbe514e22a 100644 --- a/Makefile.in +++ b/Makefile.in | |||
| @@ -343,11 +343,11 @@ msys_sed_sh_escape=sed -e 's/[];$$*.^[]/\\\\&/g' | |||
| 343 | # '/foo/bar'). | 343 | # '/foo/bar'). |
| 344 | epaths-force-w32: | 344 | epaths-force-w32: |
| 345 | @(w32srcdir=`${srcdir}/build-aux/msys-to-w32 "${srcdir}"`; \ | 345 | @(w32srcdir=`${srcdir}/build-aux/msys-to-w32 "${srcdir}"`; \ |
| 346 | w32prefix=`${srcdir}/build-aux/msys-to-w32 "${prefix}" N`; \ | 346 | w32prefix=`${srcdir}/build-aux/msys-to-w32 "${prefix}"`; \ |
| 347 | w32prefixpattern=`echo "$${w32prefix}" | ${msys_sed_sh_escape}` ; \ | 347 | w32prefixpattern=`echo "$${w32prefix}" | ${msys_sed_sh_escape}` ; \ |
| 348 | w32locallisppath=`${srcdir}/build-aux/msys-to-w32 "${locallisppath}" N ":" "\\;" | ${msys_w32prefix_subst}` ; \ | 348 | w32locallisppath=`${srcdir}/build-aux/msys-to-w32 "${locallisppath}" | ${msys_w32prefix_subst}` ; \ |
| 349 | sed < ${srcdir}/nt/epaths.nt > epaths.h.$$$$ \ | 349 | sed < ${srcdir}/nt/epaths.nt > epaths.h.$$$$ \ |
| 350 | -e 's;\(#.*PATH_SITELOADSEARCH\).*$$;\1 "'"$${w32locallisppath}"'";' \ | 350 | -e 's;\(#.*PATH_SITELOADSEARCH\).*$$;\1 "'"$${w32locallisppath//;/\\;}"'";' \ |
| 351 | -e '/^.*#/s/@VER@/${version}/g' \ | 351 | -e '/^.*#/s/@VER@/${version}/g' \ |
| 352 | -e '/^.*#/s/@CFG@/${configuration}/g' \ | 352 | -e '/^.*#/s/@CFG@/${configuration}/g' \ |
| 353 | -e "/^.*#/s|@SRC@|$${w32srcdir}|g") && \ | 353 | -e "/^.*#/s|@SRC@|$${w32srcdir}|g") && \ |
diff --git a/build-aux/msys-to-w32 b/build-aux/msys-to-w32 index 4c92cc91a3d..cc64ce722b7 100755 --- a/build-aux/msys-to-w32 +++ b/build-aux/msys-to-w32 | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | #!/bin/sh | 1 | #!/bin/bash |
| 2 | # Take a list of MSYS-compatible paths and convert them to native | 2 | # Take a list of MSYS-compatible paths and convert them to native |
| 3 | # MS-Windows format. | 3 | # MS-Windows format. |
| 4 | # Status is zero if successful, nonzero otherwise. | 4 | # Status is zero if successful, nonzero otherwise. |
| @@ -21,36 +21,26 @@ | |||
| 21 | # Take only the basename from the full pathname | 21 | # Take only the basename from the full pathname |
| 22 | me=${0//*\//} | 22 | me=${0//*\//} |
| 23 | 23 | ||
| 24 | usage="usage: ${me} PATHLIST [MUSTEXIST] [SEPARATOR [SEPARATOR2]]" | 24 | usage="usage: ${me} PATHLIST" |
| 25 | 25 | ||
| 26 | help="$usage | 26 | help="$usage |
| 27 | or: ${me} OPTION | 27 | or: ${me} OPTION |
| 28 | 28 | ||
| 29 | Convert MSYS-compatible paths to MS-Windows native format. | 29 | Convert a MSYS path list to Windows-native format. |
| 30 | |||
| 31 | PATHLIST should be a colon-separated list of MSYS paths, which will be | ||
| 32 | written to the standard output after performing these transformations: | ||
| 30 | 33 | ||
| 31 | PATHLIST should be a list of paths separated by SEPARATOR. This list | ||
| 32 | will be written to the standard output after performing the following | ||
| 33 | transformations: | ||
| 34 | 1. Discard empty paths. | 34 | 1. Discard empty paths. |
| 35 | 2. Replace backslashes with forward slashes. | 35 | 2. Replace: '\' with '/', '//' with '/' and ':' with ';'. |
| 36 | 3. Replace two consecutive slashes with single ones. | 36 | 3. Translate each path to Windows-native format. |
| 37 | 4. Translate to Windows-native format those paths that are not in such | 37 | |
| 38 | format already. The translated paths will not end with a slash, | 38 | Relative paths or paths starting with '%emacs_dir%' will be passed |
| 39 | except for root directories (e.g. 'c:/' or 'c:/foo'). Paths | 39 | verbatim to the standard output. |
| 40 | starting with '%emacs_dir%' will not be translated. | 40 | |
| 41 | 5. Escape with backslashes every occurrence of SEPARATOR2 within the paths. | 41 | Each non existing absolute paths will be translated by looking for its |
| 42 | 6. Concatenate the translated paths with SEPARATOR2. | 42 | deepest existing directory, which will be translated and the remainder |
| 43 | 43 | will be appended. | |
| 44 | If MUSTEXIST is 'Y' or not supplied, then each path in PATHLIST must | ||
| 45 | exist. Otherwise, only some part of each path is required to exist | ||
| 46 | (the deepest existing subpath will be translated and the remainder | ||
| 47 | concatenated to the translation). | ||
| 48 | |||
| 49 | If SEPARATOR is not supplied, PATHLIST will be regarded as a single | ||
| 50 | path. | ||
| 51 | |||
| 52 | If SEPARATOR2 is not supplied, it will take the same value as | ||
| 53 | SEPARATOR. | ||
| 54 | 44 | ||
| 55 | Options: | 45 | Options: |
| 56 | --help display this help and exit | 46 | --help display this help and exit |
| @@ -73,98 +63,55 @@ do | |||
| 73 | esac | 63 | esac |
| 74 | done | 64 | done |
| 75 | 65 | ||
| 76 | { test $# -ge 1 && test $# -le 4; } || | 66 | [ $# -eq 1 ] || { |
| 77 | { echo "${me}: $usage" >&2; exit 1; } | 67 | echo "${me}: $usage" >&2 |
| 78 | 68 | exit 1 | |
| 79 | # Arguments | 69 | } |
| 80 | pathlist="$1" | ||
| 81 | mustexist="${2:-Y}" | ||
| 82 | separator="$3" | ||
| 83 | separator2="${4:-${separator}}" | ||
| 84 | |||
| 85 | # Split pathlist into its path components | ||
| 86 | if test -n "$separator" | ||
| 87 | then | ||
| 88 | IFS=${separator} patharray=( $pathlist ) | ||
| 89 | else | ||
| 90 | patharray=( "$pathlist" ) | ||
| 91 | fi | ||
| 92 | 70 | ||
| 93 | w32pathlist="" | 71 | w32pathlist="" |
| 94 | 72 | ||
| 95 | for p in "${patharray[@]}" | 73 | # Put each MSYS path in one positional parameter and iterate through |
| 96 | do | 74 | # them |
| 97 | # Skip empty paths | 75 | IFS=: |
| 98 | test "$p" = "" && continue | 76 | set -- $1 |
| 99 | 77 | ||
| 100 | # Replace '\' with '/' and '//' with '/' | 78 | for p |
| 101 | p="${p//\\//}" | 79 | do |
| 102 | p="${p//\/\///}" | 80 | [ -z "$p" ] && continue |
| 103 | 81 | ||
| 104 | if test "${p:0:11}" = "%emacs_dir%" | 82 | if [ "${p:0:11}" = "%emacs_dir%" ] |
| 83 | then | ||
| 84 | w32p=$p | ||
| 85 | elif [ "${p:0:1}" != "/" ] | ||
| 105 | then | 86 | then |
| 106 | # Paths starting with "%emacs_dir%" will not be translated | ||
| 107 | w32p=$p | 87 | w32p=$p |
| 108 | elif test -d "$p" | 88 | elif [ -d "$p" ] |
| 109 | then | 89 | then |
| 110 | # The path exists, so just translate it | 90 | w32p=$(cd "$p" && pwd -W) |
| 111 | w32p=`cd "$p" && pwd -W` | ||
| 112 | else | 91 | else |
| 113 | # The path does not exist. So, try to guess the | 92 | # Make some cleanup in the path and look for its deepest |
| 114 | # Windows-native translation, by looking for the deepest | 93 | # existing directory |
| 115 | # existing directory in this path, and then translating the | ||
| 116 | # existing part and concatenating the remainder. | ||
| 117 | 94 | ||
| 118 | test "${mustexist}" = "Y" && | 95 | p=${p//\\//} |
| 119 | { echo "${me}: invalid path: $p" >&2; exit 1; } | 96 | p=${p//\/\///} |
| 97 | p=${p%/} | ||
| 120 | 98 | ||
| 121 | p1=$p | 99 | p1=$p |
| 122 | IFS=/ pcomponents=( $p ) | 100 | while : |
| 123 | |||
| 124 | for (( i=${#pcomponents[@]}-1 ; i>=0 ; i-- )) | ||
| 125 | do | 101 | do |
| 126 | 102 | p1=${p1%/*} | |
| 127 | if test "${pcomponents[i]}" = "" | 103 | [ -z "$p1" ] && p1="/" && break |
| 128 | then | 104 | [ -d "$p1" ] && break |
| 129 | # The path component is empty. This can only mean | ||
| 130 | # that the path starts with "/" and all components | ||
| 131 | # have been stripped out already. So in this case we | ||
| 132 | # want to test with the MSYS root directory | ||
| 133 | p1="/" | ||
| 134 | else | ||
| 135 | p1="${p1%/}" | ||
| 136 | p1="${p1%${pcomponents[i]}}" | ||
| 137 | fi | ||
| 138 | |||
| 139 | if test -d "${p1}" | ||
| 140 | then | ||
| 141 | |||
| 142 | # Existing path found | ||
| 143 | |||
| 144 | # Translate the existing part and concatenate the | ||
| 145 | # remainder (ensuring that only one slash is used in | ||
| 146 | # the join, and no trailing slash is left) | ||
| 147 | w32p1=`cd "${p1}" && pwd -W` | ||
| 148 | remainder="${p#${p1}}" | ||
| 149 | remainder="${remainder#/}" | ||
| 150 | remainder="${remainder%/}" | ||
| 151 | w32p="${w32p1%/}/${remainder}" | ||
| 152 | |||
| 153 | break | ||
| 154 | fi | ||
| 155 | |||
| 156 | done | 105 | done |
| 157 | 106 | ||
| 158 | # If no existing directory was found, error out | 107 | # translate the existing part and append the rest |
| 159 | test -e "${p1}" || | 108 | w32p=$(cd "${p1}" && pwd -W) |
| 160 | { echo "${me}: invalid path: ${p}" >&2; exit 1; } | 109 | remainder=${p#$p1} |
| 110 | w32p+=/${remainder#/} | ||
| 161 | fi | 111 | fi |
| 162 | 112 | ||
| 163 | # Concatenate the translated path to the translated pathlist | 113 | w32pathlist="${w32pathlist};${w32p}" |
| 164 | test "${w32pathlist}" = "" || w32pathlist="${w32pathlist}${separator2}" | ||
| 165 | w32pathlist="${w32pathlist}${w32p//${separator2}/\\${separator2}}" | ||
| 166 | 114 | ||
| 167 | done | 115 | done |
| 168 | 116 | ||
| 169 | # Write the translated pathlist to the standard output | 117 | echo "${w32pathlist:1}" |
| 170 | printf "%s" "${w32pathlist}" | ||