mk-unity.pl 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. # Helper script for "unity"-like support in autotools, to generate the umbrella
  26. # C source that includes the individual source files. Reads Makefile.inc and
  27. # accepts the variable name containing all the source files to include. Also
  28. # allow a list of exceptions that are to be excluded from the generated file.
  29. use strict;
  30. use warnings;
  31. if(!@ARGV) {
  32. die "Usage: $0 [<c-sources>] [--exclude <exclude-c-sources>]\n";
  33. }
  34. # Specific sources to exclude or add as an extra source file
  35. my @src;
  36. my %exclude;
  37. my $in_exclude = 0;
  38. foreach my $src (@ARGV) {
  39. if($in_exclude) {
  40. $exclude{$src} = 1;
  41. }
  42. elsif($src eq "--exclude") {
  43. $in_exclude = 1;
  44. }
  45. else {
  46. push @src, $src;
  47. }
  48. }
  49. print <<HEADER
  50. /* !checksrc! disable COPYRIGHT all */
  51. HEADER
  52. ;
  53. foreach my $src (@src) {
  54. if($src =~ /\.c$/g && !exists $exclude{$src}) {
  55. print "#include \"$src\"\n";
  56. }
  57. }