Browse Source

Make kmap.h build more resilient

Building with missing php resulted in empty kmap.h
master
Ondrej Jirman 7 months ago
parent
commit
af4009e3bf
  1. 2
      Makefile
  2. 17
      keymaps/map-to-c.php

2
Makefile

@ -16,7 +16,7 @@ $(OUT)ppkb-usb-debugger: usb-debugger.c common.c @@ -16,7 +16,7 @@ $(OUT)ppkb-usb-debugger: usb-debugger.c common.c
$(OUT)kmap.h: keymaps/physical-map.txt keymaps/factory-keymap.txt
@mkdir -p $(OUT)
php keymaps/map-to-c.php $^ > $@
php keymaps/map-to-c.php $^ $@
$(OUT)ppkb-i2c-inputd: i2c-inputd.c $(OUT)kmap.h common.c
@mkdir -p $(OUT)

17
keymaps/map-to-c.php

@ -20,9 +20,23 @@ @@ -20,9 +20,23 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
set_error_handler(function($severity, $message, $file, $line) {
if (!(error_reporting() & $severity))
return;
throw new ErrorException($message, 0, $severity, $file, $line);
});
if (count($argv) != 4) {
echo "Usage: $argv[0] <physmap> <keymap> <output>\n";
exit(1);
}
$pmap = file_get_contents($argv[1]);
$kmap = file_get_contents($argv[2]);
ob_start();
// high nibble = row, low nibble col
$el_phys_map = [];
foreach (explode("\n", $pmap) as $ln) {
@ -100,3 +114,6 @@ function kmap_to_code($name, $map) { @@ -100,3 +114,6 @@ function kmap_to_code($name, $map) {
kmap_to_code("keymap_base", $phys_key_base);
kmap_to_code("keymap_fn", $phys_key_fn);
kmap_to_code("keymap_pine", $phys_key_pine);
file_put_contents($argv[3], ob_get_contents());
ob_end_clean();

Loading…
Cancel
Save