Theme Editor: Wrote buildtargetdb.php to automatically generate a targetdb file from...
[kugel-rb.git] / utils / themeeditor / buildtargetdb.php
blobbe372e1489d96b565580fe46de4780d1ee9654a3
1 #!/usr/bin/php -q
2 <?php
3 /***************************************************************************
4 * __________ __ ___.
5 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
6 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
7 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
8 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
9 * \/ \/ \/ \/ \/
10 * $Id$
12 * Copyright (C) 2010 Robert Bieber
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.
19 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 * KIND, either express or implied.
22 ****************************************************************************/
24 // This is the array of targets, with the target id as the key and the
25 // plaintext name of the target as the value
26 $targets = array( 'ipod1g2g' => 'iPod 1st/2nd Gen',
27 'ipodcolor' => 'iPod Color',
28 'ipodmini2g' => 'iPod Mini 2nd Gen',
29 'mrobe500' => 'm%:robe 500'
32 // Looping through all the targets
33 foreach($targets as $target => $plaintext)
35 // Opening a cpp process
36 $configfile = '../../firmware/export/config/' . $target . '.h';
37 $descriptor = array( 0 => array("pipe", "r"), //stdin
38 1 => array("pipe", "w") //stdout
41 $proc = proc_open('cpp', $descriptor, $pipes);
43 if($proc == false)
44 die("Failed to open process");
46 // Feeding the input to cpp
47 $input = "#include \"$configfile\"\n";
48 $input .= <<<STR
49 lcd
50 LCD_WIDTH
51 LCD_HEIGHT
52 LCD_DEPTH
53 remote
54 #ifdef HAVE_REMOTE_LCD
55 LCD_REMOTE_WIDTH
56 LCD_REMOTE_HEIGHT
57 LCD_REMOTE_DEPTH
58 #endif
59 tuner
60 #ifdef CONFIG_TUNER
61 yes
62 #endif
63 recording
64 #ifdef HAVE_RECORDING
65 yes
66 #endif
67 unused
68 STR;
70 fwrite($pipes[0], $input);
71 fclose($pipes[0]);
73 $results = stream_get_contents($pipes[1]);
74 fclose($pipes[1]);
75 $results = explode("\n", $results);
77 // Header for the target
78 echo $target . "\n{\n";
79 echo ' name : ' . $plaintext . "\n";
81 // Writing the LCD dimensions
82 echo ' screen : ' . $results[7] . ' x ' . $results[8] . ' @ ';
83 if($results[9] == 1)
84 echo 'mono';
85 else if($results[10] == 2)
86 echo 'grey';
87 else
88 echo 'rgb';
89 echo "\n";
91 // Writing the remote dimensions if necessary
92 echo ' remote : ';
93 if($results[12] == 0)
95 echo 'no';
97 else
99 echo $results[12] . ' x ' .$results[13] . ' @ ';
100 if($results[14] == 1)
101 echo 'mono';
102 else if($results[14] == 2)
103 echo 'grey';
104 else
105 echo 'rgb';
107 echo "\n";
109 // Writing FM capability
110 echo ' fm : ';
111 if($results[18] == 'yes')
112 echo 'yes';
113 else
114 echo 'no';
115 echo "\n";
117 // Writing record capability
118 echo ' record : ';
119 if($results[22] == 'yes')
120 echo 'yes';
121 else
122 echo 'no';
123 echo "\n";
125 // Closing the target
126 echo "}\n\n";
128 proc_close($proc);