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