Robert Bieber | 81ba38e | 2010-07-22 08:22:20 +0000 | [diff] [blame] | 1 | #!/usr/bin/php -q |
| 2 | <?php |
| 3 | /*************************************************************************** |
| 4 | * __________ __ ___. |
| 5 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 6 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 7 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 8 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 9 | * \/ \/ \/ \/ \/ |
| 10 | * $Id$ |
| 11 | * |
| 12 | * Copyright (C) 2010 Robert Bieber |
| 13 | * |
| 14 | * This program is free software; you can redistribute it and/or |
| 15 | * modify it under the terms of the GNU General Public License |
| 16 | * as published by the Free Software Foundation; either version 2 |
| 17 | * of the License, or (at your option) any later version. |
| 18 | * |
| 19 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 20 | * KIND, either express or implied. |
| 21 | * |
| 22 | ****************************************************************************/ |
| 23 | |
Robert Bieber | e1e51f9 | 2010-07-25 21:16:37 +0000 | [diff] [blame] | 24 | // Printing the do-not-modify warning |
| 25 | echo "# ----------------------------------------------------------- #\n"; |
| 26 | echo "# ----------------------------------------------------------- #\n"; |
| 27 | echo "# --- This file automatically generated, do not modify! --- #\n"; |
Robert Bieber | e1e51f9 | 2010-07-25 21:16:37 +0000 | [diff] [blame] | 28 | echo "# ----------------------------------------------------------- #\n"; |
| 29 | echo "# ----------------------------------------------------------- #\n\n"; |
| 30 | |
Robert Bieber | d73c81f | 2010-07-30 20:47:25 +0000 | [diff] [blame] | 31 | // Importing the target array |
| 32 | system('./includetargets.pl'); |
| 33 | require('./targets.php'); |
| 34 | unlink('./targets.php'); |
Robert Bieber | 81ba38e | 2010-07-22 08:22:20 +0000 | [diff] [blame] | 35 | |
| 36 | // Looping through all the targets |
| 37 | foreach($targets as $target => $plaintext) |
| 38 | { |
| 39 | // Opening a cpp process |
| 40 | $configfile = '../../firmware/export/config/' . $target . '.h'; |
Robert Bieber | d73c81f | 2010-07-30 20:47:25 +0000 | [diff] [blame] | 41 | if(!file_exists($configfile)) |
| 42 | continue; |
Robert Bieber | 81ba38e | 2010-07-22 08:22:20 +0000 | [diff] [blame] | 43 | $descriptor = array( 0 => array("pipe", "r"), //stdin |
| 44 | 1 => array("pipe", "w") //stdout |
| 45 | ); |
| 46 | |
| 47 | $proc = proc_open('cpp', $descriptor, $pipes); |
| 48 | |
| 49 | if($proc == false) |
| 50 | die("Failed to open process"); |
| 51 | |
| 52 | // Feeding the input to cpp |
| 53 | $input = "#include \"$configfile\"\n"; |
| 54 | $input .= <<<STR |
| 55 | lcd |
| 56 | LCD_WIDTH |
| 57 | LCD_HEIGHT |
| 58 | LCD_DEPTH |
| 59 | remote |
| 60 | #ifdef HAVE_REMOTE_LCD |
| 61 | LCD_REMOTE_WIDTH |
| 62 | LCD_REMOTE_HEIGHT |
| 63 | LCD_REMOTE_DEPTH |
| 64 | #endif |
| 65 | tuner |
| 66 | #ifdef CONFIG_TUNER |
| 67 | yes |
| 68 | #endif |
| 69 | recording |
| 70 | #ifdef HAVE_RECORDING |
| 71 | yes |
| 72 | #endif |
| 73 | unused |
| 74 | STR; |
| 75 | |
| 76 | fwrite($pipes[0], $input); |
| 77 | fclose($pipes[0]); |
| 78 | |
| 79 | $results = stream_get_contents($pipes[1]); |
| 80 | fclose($pipes[1]); |
| 81 | $results = explode("\n", $results); |
| 82 | |
Robert Bieber | d73c81f | 2010-07-30 20:47:25 +0000 | [diff] [blame] | 83 | $base = 0; |
| 84 | while($results[$base] != 'lcd') |
| 85 | $base++; |
| 86 | |
Robert Bieber | 81ba38e | 2010-07-22 08:22:20 +0000 | [diff] [blame] | 87 | // Header for the target |
| 88 | echo $target . "\n{\n"; |
| 89 | echo ' name : ' . $plaintext . "\n"; |
| 90 | |
| 91 | // Writing the LCD dimensions |
Robert Bieber | d73c81f | 2010-07-30 20:47:25 +0000 | [diff] [blame] | 92 | echo ' screen : ' . $results[$base + 1] . ' x ' . $results[$base + 2] . ' @ '; |
| 93 | if($results[$base + 3] == 1) |
Robert Bieber | 81ba38e | 2010-07-22 08:22:20 +0000 | [diff] [blame] | 94 | echo 'mono'; |
Robert Bieber | d73c81f | 2010-07-30 20:47:25 +0000 | [diff] [blame] | 95 | else if($results[$base + 3] == 2) |
Robert Bieber | 81ba38e | 2010-07-22 08:22:20 +0000 | [diff] [blame] | 96 | echo 'grey'; |
| 97 | else |
| 98 | echo 'rgb'; |
| 99 | echo "\n"; |
| 100 | |
| 101 | // Writing the remote dimensions if necessary |
| 102 | echo ' remote : '; |
Robert Bieber | d73c81f | 2010-07-30 20:47:25 +0000 | [diff] [blame] | 103 | if($results[$base + 6] == 0) |
Robert Bieber | 81ba38e | 2010-07-22 08:22:20 +0000 | [diff] [blame] | 104 | { |
| 105 | echo 'no'; |
| 106 | } |
| 107 | else |
| 108 | { |
Robert Bieber | d73c81f | 2010-07-30 20:47:25 +0000 | [diff] [blame] | 109 | echo $results[$base + 6] . ' x ' .$results[$base + 7] . ' @ '; |
| 110 | if($results[$base + 8] == 1) |
Robert Bieber | 81ba38e | 2010-07-22 08:22:20 +0000 | [diff] [blame] | 111 | echo 'mono'; |
Robert Bieber | d73c81f | 2010-07-30 20:47:25 +0000 | [diff] [blame] | 112 | else if($results[$base + 8] == 2) |
Robert Bieber | 81ba38e | 2010-07-22 08:22:20 +0000 | [diff] [blame] | 113 | echo 'grey'; |
| 114 | else |
| 115 | echo 'rgb'; |
| 116 | } |
| 117 | echo "\n"; |
| 118 | |
| 119 | // Writing FM capability |
| 120 | echo ' fm : '; |
Robert Bieber | d73c81f | 2010-07-30 20:47:25 +0000 | [diff] [blame] | 121 | if($results[$base + 12] == 'yes') |
Robert Bieber | 81ba38e | 2010-07-22 08:22:20 +0000 | [diff] [blame] | 122 | echo 'yes'; |
| 123 | else |
| 124 | echo 'no'; |
| 125 | echo "\n"; |
| 126 | |
| 127 | // Writing record capability |
| 128 | echo ' record : '; |
Robert Bieber | d73c81f | 2010-07-30 20:47:25 +0000 | [diff] [blame] | 129 | if($results[$base + 16] == 'yes') |
Robert Bieber | 81ba38e | 2010-07-22 08:22:20 +0000 | [diff] [blame] | 130 | echo 'yes'; |
| 131 | else |
| 132 | echo 'no'; |
| 133 | echo "\n"; |
| 134 | |
| 135 | // Closing the target |
| 136 | echo "}\n\n"; |
| 137 | |
| 138 | proc_close($proc); |
| 139 | } |
| 140 | |
| 141 | ?> |