aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDani Moncayo2014-11-08 15:55:09 +0100
committerDani Moncayo2014-11-08 15:55:09 +0100
commit7c86a2a7d82558206a96139bab73552003b3c28f (patch)
tree211df85fd9385ce2f3a28d1bd9663af7ca98dcfc
parentc936cbbc830b194dbb1cd7ff039ea9978a7ab607 (diff)
downloademacs-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--ChangeLog6
-rw-r--r--Makefile.in6
-rwxr-xr-xbuild-aux/msys-to-w32147
3 files changed, 56 insertions, 103 deletions
diff --git a/ChangeLog b/ChangeLog
index ee84be5a83d..b79cf6d2393 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
12014-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
12014-11-05 Glenn Morris <rgm@gnu.org> 72014-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').
344epaths-force-w32: 344epaths-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
22me=${0//*\//} 22me=${0//*\//}
23 23
24usage="usage: ${me} PATHLIST [MUSTEXIST] [SEPARATOR [SEPARATOR2]]" 24usage="usage: ${me} PATHLIST"
25 25
26help="$usage 26help="$usage
27 or: ${me} OPTION 27 or: ${me} OPTION
28 28
29Convert MSYS-compatible paths to MS-Windows native format. 29Convert a MSYS path list to Windows-native format.
30
31PATHLIST should be a colon-separated list of MSYS paths, which will be
32written to the standard output after performing these transformations:
30 33
31PATHLIST should be a list of paths separated by SEPARATOR. This list
32will be written to the standard output after performing the following
33transformations:
341. Discard empty paths. 341. Discard empty paths.
352. Replace backslashes with forward slashes. 352. Replace: '\' with '/', '//' with '/' and ':' with ';'.
363. Replace two consecutive slashes with single ones. 363. Translate each path to Windows-native format.
374. 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, 38Relative paths or paths starting with '%emacs_dir%' will be passed
39 except for root directories (e.g. 'c:/' or 'c:/foo'). Paths 39verbatim to the standard output.
40 starting with '%emacs_dir%' will not be translated. 40
415. Escape with backslashes every occurrence of SEPARATOR2 within the paths. 41Each non existing absolute paths will be translated by looking for its
426. Concatenate the translated paths with SEPARATOR2. 42deepest existing directory, which will be translated and the remainder
43 43will be appended.
44If MUSTEXIST is 'Y' or not supplied, then each path in PATHLIST must
45exist. Otherwise, only some part of each path is required to exist
46(the deepest existing subpath will be translated and the remainder
47concatenated to the translation).
48
49If SEPARATOR is not supplied, PATHLIST will be regarded as a single
50path.
51
52If SEPARATOR2 is not supplied, it will take the same value as
53SEPARATOR.
54 44
55Options: 45Options:
56 --help display this help and exit 46 --help display this help and exit
@@ -73,98 +63,55 @@ do
73 esac 63 esac
74done 64done
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}
80pathlist="$1"
81mustexist="${2:-Y}"
82separator="$3"
83separator2="${4:-${separator}}"
84
85# Split pathlist into its path components
86if test -n "$separator"
87then
88 IFS=${separator} patharray=( $pathlist )
89else
90 patharray=( "$pathlist" )
91fi
92 70
93w32pathlist="" 71w32pathlist=""
94 72
95for p in "${patharray[@]}" 73# Put each MSYS path in one positional parameter and iterate through
96do 74# them
97 # Skip empty paths 75IFS=:
98 test "$p" = "" && continue 76set -- $1
99 77
100 # Replace '\' with '/' and '//' with '/' 78for p
101 p="${p//\\//}" 79do
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
167done 115done
168 116
169# Write the translated pathlist to the standard output 117echo "${w32pathlist:1}"
170printf "%s" "${w32pathlist}"