quickjs-tart

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

extract-unit-protos (2778B)


      1 #!/usr/bin/env perl
      2 #***************************************************************************
      3 #                                  _   _ ____  _
      4 #  Project                     ___| | | |  _ \| |
      5 #                             / __| | | | |_) | |
      6 #                            | (__| |_| |  _ <| |___
      7 #                             \___|\___/|_| \_\_____|
      8 #
      9 # Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
     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 sub scanfile {
     27     my ($file) = @_;
     28     open(F, "<$file") || die "$file failed";
     29     while(<F>) {
     30         if($_ =~ /^UNITTEST .*\);/) {
     31             push @proto, $_;
     32             $inc{$file} = 1;
     33         }
     34     }
     35     close(F);
     36 }
     37 
     38 foreach my $f (@ARGV) {
     39     scanfile($f);
     40 }
     41 
     42 print <<HEAD
     43 #ifndef UNITTESTPROTOS_H
     44 #define UNITTESTPROTOS_H
     45 /***************************************************************************
     46  *                                  _   _ ____  _
     47  *  Project                     ___| | | |  _ \\| |
     48  *                             / __| | | | |_) | |
     49  *                            | (__| |_| |  _ <| |___
     50  *                             \\___|\\___/|_| \\_\\_____|
     51  *
     52  * Copyright (C) Daniel Stenberg, <daniel\@haxx.se>, et al.
     53  *
     54  * This software is licensed as described in the file COPYING, which
     55  * you should have received as part of this distribution. The terms
     56  * are also available at https://curl.se/docs/copyright.html.
     57  *
     58  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
     59  * copies of the Software, and permit persons to whom the Software is
     60  * furnished to do so, under the terms of the COPYING file.
     61  *
     62  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
     63  * KIND, either express or implied.
     64  *
     65  * SPDX-License-Identifier: curl
     66  *
     67  * Generated-by: extract-unit-protos
     68  *
     69  ***************************************************************************/
     70 HEAD
     71     ;
     72 
     73 for my $f (sort keys %inc) {
     74     # convert to suitable header file
     75     $f =~ s/\.c/.h/; # .h extension
     76 
     77     if(-f $f) {
     78         $f =~ s/.*\///; # cut the path off
     79         print "#include \"$f\"\n";
     80     }
     81 }
     82 
     83 for my $p (@proto) {
     84     print $p;
     85 }
     86 
     87 print <<FOOT
     88 #endif /* UNITTESTPROTOS_H */
     89 FOOT
     90     ;