quickjs-tart

quickjs-based runtime for wallet-core logic
Log | Files | Refs | README | LICENSE

mk-unity.pl (2219B)


      1 #!/usr/bin/env perl
      2 #***************************************************************************
      3 #                                  _   _ ____  _
      4 #  Project                     ___| | | |  _ \| |
      5 #                             / __| | | | |_) | |
      6 #                            | (__| |_| |  _ <| |___
      7 #                             \___|\___/|_| \_\_____|
      8 #
      9 # Copyright (C) Viktor Szakats
     10 #
     11 # This software is licensed as described in the file COPYING, which
     12 # you should have received as part of this distribution. The terms
     13 # are also available at https://curl.se/docs/copyright.html.
     14 #
     15 # You may opt to use, copy, modify, merge, publish, distribute and/or sell
     16 # copies of the Software, and permit persons to whom the Software is
     17 # furnished to do so, under the terms of the COPYING file.
     18 #
     19 # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
     20 # KIND, either express or implied.
     21 #
     22 # SPDX-License-Identifier: curl
     23 #
     24 ###########################################################################
     25 
     26 # Helper script for "unity"-like support in autotools and to bundle up tests
     27 # for both autotools and cmake. It generates the umbrella C source that
     28 # includes the individual source files and tests.
     29 
     30 use strict;
     31 use warnings;
     32 
     33 if(!@ARGV) {
     34     die "Usage: $0 [--test <tests>] [--include <include-c-sources>]\n";
     35 }
     36 
     37 my @src;
     38 my %include;
     39 my $in_include = 0;
     40 my $any_test = 0;
     41 foreach my $src (@ARGV) {
     42     if($src eq "--test") {
     43         $in_include = 0;
     44     }
     45     elsif($src eq "--include") {
     46         $in_include = 1;
     47     }
     48     elsif($in_include) {
     49         $include{$src} = 1;
     50         push @src, $src;
     51     }
     52     else {
     53         push @src, $src;
     54         $any_test = 1;
     55     }
     56 }
     57 
     58 print "/* !checksrc! disable COPYRIGHT all */\n\n";
     59 if($any_test) {
     60     print "#include \"first.h\"\n\n";
     61 }
     62 
     63 my $tlist = "";
     64 
     65 foreach my $src (@src) {
     66     if($src =~ /([a-z0-9_]+)\.c$/) {
     67         my $name = $1;
     68         print "#include \"$src\"\n";
     69         if(not exists $include{$src}) {  # register test entry function
     70             $tlist .= "  {\"$name\", test_$name},\n";
     71         }
     72     }
     73 }
     74 
     75 if($any_test) {
     76     print "\nconst struct entry_s s_entries[] = {\n$tlist  {NULL, NULL}\n};\n";
     77     print "\n#include \"first.c\"\n";
     78 }