[m-rev.] for review: use xargs in mmake

Peter Ross peter.ross at miscrit.be
Fri Feb 15 20:36:31 AEDT 2002


On Fri, Feb 15, 2002 at 07:00:58PM +1100, Fergus Henderson wrote:
> Please fix the XXX ;-)
> 

===================================================================


Estimated hours taken: 1.5
Branches: main

Avoid problems with very long command lines by using xargs.

compiler/modules.m:
    Use xargs to rm all the files for the clean and realclean targets.

scripts/mmake.in:
    Use xargs to cat the .d and .dv files.


Index: compiler/modules.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/modules.m,v
retrieving revision 1.216
diff -u -r1.216 modules.m
--- compiler/modules.m	15 Feb 2002 08:30:57 -0000	1.216
+++ compiler/modules.m	15 Feb 2002 09:23:16 -0000
@@ -3886,6 +3886,12 @@
 	% If you change the clean targets below, please also update the
 	% documentation in doc/user_guide.texi.
 	%
+	% XXX The use of xargs in the clean targets doesn't handle
+	% special characters in the file names correctly.  This is
+	% currently not a problem in practice as we never generate
+	% names containing special characters, any fix for this problem
+	% will also require a fix in `mmake.in'.
+	%
 
 	module_name_to_file_name(SourceModuleName, ".clean", no,
 				CleanTargetName),
@@ -3895,24 +3901,27 @@
 	io__write_strings(DepStream, [
 		".PHONY : ", CleanTargetName, "\n",
 		CleanTargetName, " :\n",
-		"\t-rm -rf $(", MakeVarName, ".dirs)\n",
-		"\t-rm -f $(", MakeVarName, ".cs) ", InitCFileName, "\n",
-		"\t-rm -f $(", MakeVarName, ".all_ss) ", InitAsmFileName, "\n",
-		"\t-rm -f $(", MakeVarName, ".all_pic_ss) ",
-					InitAsmFileName, "\n",
-		"\t-rm -f $(", MakeVarName, ".all_os) ", InitObjFileName, "\n",
-		"\t-rm -f $(", MakeVarName, ".all_pic_os) ",
-					InitPicObjFileName, "\n",
-		"\t-rm -f $(", MakeVarName, ".c_dates)\n",
-		"\t-rm -f $(", MakeVarName, ".il_dates)\n",
-		"\t-rm -f $(", MakeVarName, ".all_s_dates)\n",
-		"\t-rm -f $(", MakeVarName, ".all_pic_s_dates)\n",
-		"\t-rm -f $(", MakeVarName, ".useds)\n",
-		"\t-rm -f $(", MakeVarName, ".ils)\n",
-		"\t-rm -f $(", MakeVarName, ".profs)\n",
-		"\t-rm -f $(", MakeVarName, ".errs)\n",
-		"\t-rm -f $(", MakeVarName, ".foreign_cs)\n",
-		"\t-rm -f $(", MakeVarName, ".schemas)\n"
+		"\t-echo $(", MakeVarName, ".dirs) | xargs rm -rf \n",
+		"\t-echo $(", MakeVarName, ".cs) ", InitCFileName,
+				" | xargs rm -f\n",
+		"\t-echo $(", MakeVarName, ".all_ss) ", InitAsmFileName,
+				" | xargs rm -f\n",
+		"\t-echo $(", MakeVarName, ".all_pic_ss) ",
+					InitAsmFileName, " | xargs rm -f\n",
+		"\t-echo $(", MakeVarName, ".all_os) ", InitObjFileName,
+				" | xargs rm -f\n",
+		"\t-echo $(", MakeVarName, ".all_pic_os) ",
+					InitPicObjFileName, " | xargs rm -f\n",
+		"\t-echo $(", MakeVarName, ".c_dates) | xargs rm -f\n",
+		"\t-echo $(", MakeVarName, ".il_dates) | xargs rm -f\n",
+		"\t-echo $(", MakeVarName, ".all_s_dates) | xargs rm -f\n",
+		"\t-echo $(", MakeVarName, ".all_pic_s_dates) | xargs rm -f\n",
+		"\t-echo $(", MakeVarName, ".useds) | xargs rm -f\n",
+		"\t-echo $(", MakeVarName, ".ils) | xargs rm -f\n",
+		"\t-echo $(", MakeVarName, ".profs) | xargs rm -f\n",
+		"\t-echo $(", MakeVarName, ".errs) | xargs rm -f\n",
+		"\t-echo $(", MakeVarName, ".foreign_cs) | xargs rm -f\n",
+		"\t-echo $(", MakeVarName, ".schemas) | xargs rm -f\n"
 	]),
 
 	io__write_string(DepStream, "\n"),
@@ -3925,21 +3934,21 @@
 	io__write_strings(DepStream, [
 		".PHONY : ", RealCleanTargetName, "\n",
 		RealCleanTargetName, " : ", CleanTargetName, "\n",
-		"\t-rm -f $(", MakeVarName, ".dates)\n",
-		"\t-rm -f $(", MakeVarName, ".date0s)\n",
-		"\t-rm -f $(", MakeVarName, ".date3s)\n",
-		"\t-rm -f $(", MakeVarName, ".optdates)\n",
-		"\t-rm -f $(", MakeVarName, ".trans_opt_dates)\n",
-		"\t-rm -f $(", MakeVarName, ".ints)\n",
-		"\t-rm -f $(", MakeVarName, ".int0s)\n",
-		"\t-rm -f $(", MakeVarName, ".int3s)\n",
-		"\t-rm -f $(", MakeVarName, ".opts)\n",
-		"\t-rm -f $(", MakeVarName, ".trans_opts)\n",
-		"\t-rm -f $(", MakeVarName, ".ds)\n",
-		"\t-rm -f $(", MakeVarName, ".all_hs)\n",
-		"\t-rm -f $(", MakeVarName, ".dlls)\n",
-		"\t-rm -f $(", MakeVarName, ".foreign_dlls)\n",
-		"\t-rm -f $(", MakeVarName, ".rlos)\n"
+		"\t-echo $(", MakeVarName, ".dates) | xargs rm -f\n",
+		"\t-echo $(", MakeVarName, ".date0s) | xargs rm -f\n",
+		"\t-echo $(", MakeVarName, ".date3s) | xargs rm -f\n",
+		"\t-echo $(", MakeVarName, ".optdates) | xargs rm -f\n",
+		"\t-echo $(", MakeVarName, ".trans_opt_dates) | xargs rm -f\n",
+		"\t-echo $(", MakeVarName, ".ints) | xargs rm -f\n",
+		"\t-echo $(", MakeVarName, ".int0s) | xargs rm -f\n",
+		"\t-echo $(", MakeVarName, ".int3s) | xargs rm -f\n",
+		"\t-echo $(", MakeVarName, ".opts) | xargs rm -f\n",
+		"\t-echo $(", MakeVarName, ".trans_opts) | xargs rm -f\n",
+		"\t-echo $(", MakeVarName, ".ds) | xargs rm -f\n",
+		"\t-echo $(", MakeVarName, ".all_hs) | xargs rm -f\n",
+		"\t-echo $(", MakeVarName, ".dlls) | xargs rm -f\n",
+		"\t-echo $(", MakeVarName, ".foreign_dlls) | xargs rm -f\n",
+		"\t-echo $(", MakeVarName, ".rlos) | xargs rm -f\n"
 	]),
 	io__write_strings(DepStream, [
 		"\t-rm -f ",
Index: scripts/mmake.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/mmake.in,v
retrieving revision 1.36
diff -u -r1.36 mmake.in
--- scripts/mmake.in	27 Jul 2001 17:06:17 -0000	1.36
+++ scripts/mmake.in	15 Feb 2002 09:23:20 -0000
@@ -287,7 +287,7 @@
 	echo MERCURY_DEFAULT_GRADE=$MERCURY_DEFAULT_GRADE
 	echo export MERCURY_DEFAULT_GRADE
 	echo cat ${MMAKE_VARS} $dvs $ds $include_makefile $mmake $deps \
-		${MMAKE_RULES} ">>" $tmp
+		${MMAKE_RULES}">>" $tmp
 	echo ${MMAKE_MAKE} ${MMAKE_MAKE_OPTS} -f $tmp -r ${set_target_asm} "$@"
 fi
 export MMAKE
@@ -295,7 +295,17 @@
 export MMAKE_USE_SUBDIRS
 export MERCURY_INT_DIR
 export MERCURY_DEFAULT_GRADE
-cat ${MMAKE_VARS} $dvs $ds $include_makefile $mmake $deps ${MMAKE_RULES} > $tmp
+# XXX The $dvs and $ds variables can be so long as to overflow the
+# command line size limits, so we use xargs.  However echo doesn't quote
+# the file names correctly, but this is not a problem in practice because
+# the way the file names are constructed no special characters are
+# included currently.  If fixed, the fix needs to be replicated in
+# `modules.m'.
+{
+cat ${MMAKE_VARS}
+echo $dvs $ds | xargs cat
+cat $include_makefile $mmake $deps ${MMAKE_RULES}
+} > $tmp
 case $# in
 	# Note that we can't use `exec' here, because if we did that,
 	# that `trap' code which removes $tmp would never get executed.

--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list