#!/usr/bin/env perl1#***************************************************************************2# _ _ ____ _3# Project ___| | | | _ \| |4# / __| | | | |_) | |5# | (__| |_| | _ <| |___6# \___|\___/|_| \_\_____|7#8# Copyright (C) Viktor Szakats9#10# This software is licensed as described in the file COPYING, which11# you should have received as part of this distribution. The terms12# are also available at https://curl.se/docs/copyright.html.13#14# You may opt to use, copy, modify, merge, publish, distribute and/or sell15# copies of the Software, and permit persons to whom the Software is16# furnished to do so, under the terms of the COPYING file.17#18# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY19# KIND, either express or implied.20#21# SPDX-License-Identifier: curl22#23###########################################################################2425# Helper script for "unity"-like support in autotools and to bundle up tests26# for both autotools and cmake. It generates the umbrella C source that27# includes the individual source files and tests.2829use strict;30use warnings;3132if(!@ARGV) {33die "Usage: $0 [--test <tests>] [--include <include-c-sources>]\n";34}3536my @src;37my %include;38my $in_include = 0;39my $any_test = 0;40foreach my $src (@ARGV) {41if($src eq "--test") {42$in_include = 0;43}44elsif($src eq "--include") {45$in_include = 1;46}47elsif($in_include) {48$include{$src} = 1;49push @src, $src;50}51else {52push @src, $src;53$any_test = 1;54}55}5657print "/* !checksrc! disable COPYRIGHT all */\n\n";58if($any_test) {59print "#include \"first.h\"\n\n";60}6162my $tlist = "";6364foreach my $src (@src) {65if($src =~ /([a-z0-9_]+)\.c$/) {66my $name = $1;67print "#include \"$src\"\n";68if(not exists $include{$src}) { # register test entry function69$tlist .= " {\"$name\", test_$name},\n";70}71}72}7374if($any_test) {75print "\nconst struct entry_s s_entries[] = {\n$tlist {NULL, NULL}\n};\n";76print "\n#include \"first.c\"\n";77}787980