From 78c5df6f26f0eb5676437e6c86cfbb374fa3547e Mon Sep 17 00:00:00 2001 From: Diomidis Spinellis Date: Sat, 3 Aug 2024 22:35:40 +0300 Subject: [PATCH] Add workspace split command --- src/cssplit.awk | 68 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100755 src/cssplit.awk diff --git a/src/cssplit.awk b/src/cssplit.awk new file mode 100755 index 0000000..0ddbdb0 --- /dev/null +++ b/src/cssplit.awk @@ -0,0 +1,68 @@ +#!/usr/bin/env awk -f +# +# (C) Copyright 2024 Diomidis Spinellis +# +# This file is part of CScout. +# +# CScout is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# CScout is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with CScout. If not, see . +# +# Split CScout processing input into files containing the specified number +# of compilation units (CUs). +# + +function begin_project() { + outfile = sprintf("file-%04d.cs", ++file_number) + print "#pragma project \"cssplit\"" >outfile + print "#pragma block_enter" >outfile +} + +function end_project() { + print "#pragma block_exit" >outfile + close(outfile) +} + +BEGIN { + if (ARGC < 2) { + print "Usage: cssplit N" > "/dev/stderr" + exit 1 + } + + N = ARGV[1] + ARGV[1] = "" +} + +# CU processing path name starts with a / +/#pragma echo "Processing \// { + if (cu_count % N == 0) { + if (cu_count > 0) + end_project(); + begin_project(); + } + in_cu = 1; + cu_count++ +} + +in_cu { + print $0 >outfile +} + +# CU processing path name starts with a / +/#pragma echo "Done processing \// { + in_cu = 0 +} + +END { + if (cu_count > 0) + end_project(); +}