resources_header.pl 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #!/usr/bin/perl
  2. #
  3. # Copyright 2019, Cypress Semiconductor Corporation or a subsidiary of
  4. # Cypress Semiconductor Corporation. All Rights Reserved.
  5. #
  6. # This software, including source code, documentation and related
  7. # materials ("Software"), is owned by Cypress Semiconductor Corporation
  8. # or one of its subsidiaries ("Cypress") and is protected by and subject to
  9. # worldwide patent protection (United States and foreign),
  10. # United States copyright laws and international treaty provisions.
  11. # Therefore, you may use this Software only as provided in the license
  12. # agreement accompanying the software package from which you
  13. # obtained this Software ("EULA").
  14. # If no EULA applies, Cypress hereby grants you a personal, non-exclusive,
  15. # non-transferable license to copy, modify, and compile the Software
  16. # source code solely for use in connection with Cypress's
  17. # integrated circuit products. Any reproduction, modification, translation,
  18. # compilation, or representation of this Software except as specified
  19. # above is prohibited without the express written permission of Cypress.
  20. #
  21. # Disclaimer: THIS SOFTWARE IS PROVIDED AS-IS, WITH NO WARRANTY OF ANY KIND,
  22. # EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, NONINFRINGEMENT, IMPLIED
  23. # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Cypress
  24. # reserves the right to make changes to the Software without notice. Cypress
  25. # does not assume any liability arising out of the application or use of the
  26. # Software or any product or circuit described in the Software. Cypress does
  27. # not authorize its products for use in any products where a malfunction or
  28. # failure of the Cypress product may reasonably be expected to result in
  29. # significant property damage, injury or death ("High Risk Product"). By
  30. # including Cypress's product in a High Risk Product, the manufacturer
  31. # of such system or application assumes all risk of such use and in doing
  32. # so agrees to indemnify Cypress against all liability.
  33. #
  34. if (! $ARGV[0] )
  35. {
  36. print "Usage ./resources_header.pl <C file 1> <C file 2> ...";
  37. exit;
  38. }
  39. print "/* Auto-generated header file. Do not edit */\n";
  40. print "\n";
  41. print "#pragma once\n";
  42. print "\n";
  43. print "#include <stdint.h>\n";
  44. print "#include \"cy_abs_resource.h\"\n";
  45. print "\n";
  46. print "#ifdef __cplusplus\n";
  47. print "extern \"C\" {\n";
  48. print "#endif\n";
  49. print "\n";
  50. my $mem_resources = "";
  51. my $filesystem_resources = "";
  52. foreach $file (@ARGV)
  53. {
  54. #open the file
  55. open INFILE, $file or die "cant open " . $file;
  56. @file_cont_array = <INFILE>;
  57. close INFILE;
  58. $file_cont = join('',@file_cont_array);
  59. while ( $file_cont =~ m/(const cy_resource_handle_t \S+)/sgi )
  60. {
  61. $resources .= "extern $1;\n";
  62. }
  63. while ( $file_cont =~ m/(const uint8_t \S+\[\d+\])/sgi )
  64. {
  65. $resources .= "extern $1;\n";
  66. }
  67. }
  68. print "\n";
  69. print "$resources";
  70. print "\n";
  71. print "/* @} */\n";
  72. print "#ifdef __cplusplus\n";
  73. print "} /*extern \"C\" */\n";
  74. print "#endif\n";