Subversion Repositories DevTools

Rev

Rev 249 | Rev 261 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 249 Rev 257
Line 175... Line 175...
175
#.. Generic Copy/Remove the specified file
175
#.. Generic Copy/Remove the specified file
176
#
176
#
177
#   Usage:      $(call CopyFile,Text,dest,file,path,fmode)
177
#   Usage:      $(call CopyFile,Text,dest,file,path,fmode)
178
#               $(call UncopyFile,Text,file)
178
#               $(call UncopyFile,Text,file)
179
#
179
#
-
 
180
#   Notes:
180
#		Note: dest, file and path
181
#       dest, file and path
181
#		    may have spaces in them
182
#	May have spaces in them
182
#		    These will have been escaped with a'\' which will
183
#		These will have been escaped with a '\' which will
-
 
184
#		need to be removed. The '\ ' is required to keep make
183
#		    need to be removed.
185
#		happy elsewhere.
184
#
186
#
185
#		    May have '$' in themwhich we will need to escape
187
#	May have '$' in them which we will need to escape
186
#
188
#
-
 
189
#       Windows copy has limitations.
-
 
190
#		Abs path length must < 260
-
 
191
#		Passing a relative path does not solve the problem
-
 
192
#		Moreover, if the relative path contains one or more ../
-
 
193
#		sequences, then the 'cp' command creates a complete path
-
 
194
#		before removing the zzz/.. sequences - and this must not exceed
-
 
195
#		259 characters.
-
 
196
#
-
 
197
#		At the moment we get the most out of the windows 'cp' by
-
 
198
#		passing it a clean absolute pathname, but there is still
-
 
199
#		a limit of ~259 characters. This affects many programs, not just
-
 
200
#		cp but make, rm, chmod ...
-
 
201
#
-
 
202
#
-
 
203
#	Nice Macros
-
 
204
#	AbsName	- convert a '\ ' pathname into an absolute path with plain spaces
-
 
205
#                 and $ escaped with a \.
-
 
206
#		  In the process 'spaces' need to be replaced with something to
-
 
207
#		  keep abspath from splitting on space.
-
 
208
#	NiceName - convert a '\ ' pathname into an string with plain spaces
-
 
209
#                 and $ escaped with a \.
-
 
210
#
-
 
211
AbsName = $(subst $$,\$$,$(subst $(spacealt),$(space),$(abspath $(subst \$(space),$(spacealt),$1))))
-
 
212
NiceName = $(subst $$,\$$,$(subst \$(space),$(space),$1))
-
 
213
 
187
define CopyFile
214
define CopyFile
-
 
215
	(\
-
 
216
        udest="$(call NiceName,$2)"; \
188
	@(dest="$(subst \$(space),$(space),$(subst $$,\$$,$(2)))"; \
217
        dest="$(call AbsName,$2)"; \
189
        file="$(subst \$(space),$(space),$(subst $$,\$$,$(3)))"; \
218
        file="$(call NiceName,$3)"; \
190
        path="$(subst \$(space),$(space),$(subst $$,\$$,$(4)))"; \
219
        path="$(call AbsName,$4)"; \
191
        fmode="$(5)"; \
220
        fmode="$(5)"; \
192
	echo ------ "$1 $$dest"; \
221
	echo "------ $1 $$udest"; \
193
        if [ ! -f "$$file" ] ; then echo "$1 source file not found: $$file" ; exit 1; fi;\
222
        if [ ! -f "$$file" ] ; then echo "$1 source file not found: $$file" ; exit 1; fi;\
194
	if [ ! -d "$$path" ] ; then $(mkdir) -p "$$path"; fi; \
223
	if [ ! -d "$$path" ] ; then $(mkdir) -p "$$path"; fi; \
195
	if [ -f "$$dest" -a ! -w "$$dest" ]; then $(chmod) -f +w "$$dest"; fi; \
224
	if [ -f "$$dest" -a ! -w "$$dest" ]; then $(chmod) -f +w "$$dest"; fi; \
196
	$(rm) -f "$$dest"; \
225
	$(rm) -f "$$dest"; \
197
        $(cp) "$$file" "$$dest" ;\
226
        $(cp) "$$file" "$$dest" ;\
Line 200... Line 229...
200
        if [ ! -f "$$dest" ] ; then echo "$1 file not found after copy: $$dest" ; exit 1; fi; \
229
        if [ ! -f "$$dest" ] ; then echo "$1 file not found after copy: $$dest" ; exit 1; fi; \
201
        );
230
        );
202
endef
231
endef
203
 
232
 
204
define UncopyFile
233
define UncopyFile
-
 
234
	$(AA_PRE)(\
205
	@(file="$(subst \$(space),$(space),$(subst $$,\$$,$(2)))"; \
235
        udest="$(call NiceName,$2)"; \
-
 
236
        file="$(call AbsName,$2)"; \
206
        echo ------ $1 "$$file"; \
237
	echo "------ $1 $$udest"; \
207
	if [ -f "$$file" ]; then \
238
	if [ -f "$$file" ]; then \
208
		if [ ! -w "$$file" ]; then $(chmod) -f +w "$$file"; fi; \
239
		if [ ! -w "$$file" ]; then $(chmod) -f +w "$$file"; fi; \
209
		$(rm) -f "$$file"; \
240
		$(rm) -f "$$file"; \
210
	fi);
241
	fi);
211
endef
242
endef