From fcc0e7621575caed5844b80074a7884805ae0cb4 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Mon, 19 Feb 2018 21:18:38 +0100 Subject: [PATCH] makefiles: Add a helper to split large file remove commands. Signed-off-by: Alexandre Julliard --- tools/makedep.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/tools/makedep.c b/tools/makedep.c index 8cd355923e6..779d60a28ab 100644 --- a/tools/makedep.c +++ b/tools/makedep.c @@ -497,6 +497,31 @@ static void output_filenames( struct strarray array ) } +/******************************************************************* + * output_rm_filenames + */ +static void output_rm_filenames( struct strarray array ) +{ + static const unsigned int max_cmdline = 30000; /* to be on the safe side */ + unsigned int i, len; + + if (!array.count) return; + output( "\trm -f" ); + for (i = len = 0; i < array.count; i++) + { + if (len > max_cmdline) + { + output( "\n" ); + output( "\trm -f" ); + len = 0; + } + output_filename( array.str[i] ); + len += strlen( array.str[i] ) + 1; + } + output( "\n" ); +} + + /******************************************************************* * get_extension */ @@ -3323,9 +3348,7 @@ static void output_subdirs( struct makefile *make ) output_filenames( makefile_deps ); output( ":\n" ); output( "distclean::\n"); - output( "\trm -f" ); - output_filenames( distclean_files ); - output( "\n" ); + output_rm_filenames( distclean_files ); strarray_add( &make->phony_targets, "distclean" ); if (build_deps.count)