]> git.donarmstrong.com Git - qmk_firmware.git/commitdiff
Prevent clang-format messing up placeholder tokens within keyboard templates (#6790)
authorfauxpark <fauxpark@gmail.com>
Thu, 10 Oct 2019 10:48:37 +0000 (21:48 +1100)
committerJoel Challis <git@zvecr.com>
Thu, 10 Oct 2019 10:48:37 +0000 (11:48 +0100)
* Use .template file extension for keyboard template files

* Filter out .template files completely before passing to clang-format

* Undo file extension stuff; just ignore quantum/template dir

12 files changed:
quantum/template/avr/config.h
quantum/template/avr/keyboard.c [new file with mode: 0644]
quantum/template/avr/template.c [deleted file]
quantum/template/base/keyboard.h [new file with mode: 0644]
quantum/template/base/keymaps/default/keymap.c
quantum/template/base/keymaps/default/readme.md
quantum/template/base/template.h [deleted file]
quantum/template/ps2avrgb/config.h
quantum/template/ps2avrgb/keyboard.c [new file with mode: 0644]
quantum/template/ps2avrgb/template.c [deleted file]
util/new_keyboard.sh
util/travis_compiled_push.sh

index 713d6be3a505c0025bc0d1001b3e992e6b422b18..304a54ae59a958d91ec562d306b025304a868f3c 100644 (file)
@@ -23,8 +23,8 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #define VENDOR_ID 0xFEED
 #define PRODUCT_ID 0x0000
 #define DEVICE_VER 0x0001
-#define MANUFACTURER % YOUR_NAME %
-#define PRODUCT % KEYBOARD %
+#define MANUFACTURER %YOUR_NAME%
+#define PRODUCT %KEYBOARD%
 #define DESCRIPTION A custom keyboard
 
 /* key matrix size */
@@ -41,10 +41,8 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *                  ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode)
  *
  */
-#define MATRIX_ROW_PINS \
-    { D0, D5 }
-#define MATRIX_COL_PINS \
-    { F1, F0, B0 }
+#define MATRIX_ROW_PINS { D0, D5 }
+#define MATRIX_COL_PINS { F1, F0, B0 }
 #define UNUSED_PINS
 
 /* COL2ROW, ROW2COL*/
diff --git a/quantum/template/avr/keyboard.c b/quantum/template/avr/keyboard.c
new file mode 100644 (file)
index 0000000..e852a42
--- /dev/null
@@ -0,0 +1,51 @@
+/* Copyright %YEAR% %YOUR_NAME%
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+#include "%KEYBOARD%.h"
+
+// Optional override functions below.
+// You can leave any or all of these undefined.
+// These are only required if you want to perform custom actions.
+
+/*
+
+void matrix_init_kb(void) {
+  // put your keyboard start-up code here
+  // runs once when the firmware starts up
+
+  matrix_init_user();
+}
+
+void matrix_scan_kb(void) {
+  // put your looping keyboard code here
+  // runs every cycle (a lot)
+
+  matrix_scan_user();
+}
+
+bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
+  // put your per-action keyboard code here
+  // runs for every action, just before processing by the firmware
+
+  return process_record_user(keycode, record);
+}
+
+void led_set_kb(uint8_t usb_led) {
+  // put your keyboard LED indicator (ex: Caps Lock LED) toggling code here
+
+  led_set_user(usb_led);
+}
+
+*/
diff --git a/quantum/template/avr/template.c b/quantum/template/avr/template.c
deleted file mode 100644 (file)
index e852a42..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/* Copyright %YEAR% %YOUR_NAME%
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-#include "%KEYBOARD%.h"
-
-// Optional override functions below.
-// You can leave any or all of these undefined.
-// These are only required if you want to perform custom actions.
-
-/*
-
-void matrix_init_kb(void) {
-  // put your keyboard start-up code here
-  // runs once when the firmware starts up
-
-  matrix_init_user();
-}
-
-void matrix_scan_kb(void) {
-  // put your looping keyboard code here
-  // runs every cycle (a lot)
-
-  matrix_scan_user();
-}
-
-bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
-  // put your per-action keyboard code here
-  // runs for every action, just before processing by the firmware
-
-  return process_record_user(keycode, record);
-}
-
-void led_set_kb(uint8_t usb_led) {
-  // put your keyboard LED indicator (ex: Caps Lock LED) toggling code here
-
-  led_set_user(usb_led);
-}
-
-*/
diff --git a/quantum/template/base/keyboard.h b/quantum/template/base/keyboard.h
new file mode 100644 (file)
index 0000000..2e531b1
--- /dev/null
@@ -0,0 +1,35 @@
+/* Copyright %YEAR% %YOUR_NAME%
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+#pragma once
+
+#include "quantum.h"
+
+/* This a shortcut to help you visually see your layout.
+ *
+ * The first section contains all of the arguments representing the physical
+ * layout of the board and position of the keys.
+ *
+ * The second converts the arguments into a two-dimensional array which
+ * represents the switch matrix.
+ */
+#define LAYOUT( \
+    k00, k01, k02, \
+      k10,  k11   \
+) \
+{ \
+    { k00, k01,   k02 }, \
+    { k10, KC_NO, k11 }, \
+}
index 308cb92a7760df0a8728e169154dea43fe72a0ac..3508055b78668cb728f95131b87c157ee218779b 100644 (file)
 #include QMK_KEYBOARD_H
 
 // Defines the keycodes used by our macros in process_record_user
-enum custom_keycodes { QMKBEST = SAFE_RANGE, QMKURL };
+enum custom_keycodes {
+    QMKBEST = SAFE_RANGE,
+    QMKURL
+};
 
 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
-    [0] = LAYOUT(/* Base */
-                 KC_A, KC_1, KC_H, KC_TAB, KC_SPC),
+    [0] = LAYOUT( /* Base */
+        KC_A, KC_1, KC_H,
+          KC_TAB, KC_SPC
+    ),
 };
 
 bool process_record_user(uint16_t keycode, keyrecord_t *record) {
@@ -45,8 +50,14 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
     return true;
 }
 
-void matrix_init_user(void) {}
+void matrix_init_user(void) {
+
+}
 
-void matrix_scan_user(void) {}
+void matrix_scan_user(void) {
 
-void led_set_user(uint8_t usb_led) {}
+}
+
+void led_set_user(uint8_t usb_led) {
+
+}
index 21aa663d55b8c56f9c15022fa4e7786fdd44d6da..e052ed80f14dc9864ea1e5f8c1cf59dd4eb89259 100644 (file)
@@ -1 +1 @@
-# The default keymap for %KEYBOARD%
\ No newline at end of file
+# The default keymap for %KEYBOARD%
diff --git a/quantum/template/base/template.h b/quantum/template/base/template.h
deleted file mode 100644 (file)
index 595da73..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/* Copyright %YEAR% %YOUR_NAME%
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-#pragma once
-
-#include "quantum.h"
-
-/* This a shortcut to help you visually see your layout.
- *
- * The first section contains all of the arguments representing the physical
- * layout of the board and position of the keys.
- *
- * The second converts the arguments into a two-dimensional array which
- * represents the switch matrix.
- */
-#define LAYOUT(k00, k01, k02, k10, k11) \
-    { {k00, k01, k02}, {k10, KC_NO, k11}, }
index a780a10afc397df83be6b7729c4fed604df71938..f6d7c25e044941f5dce810d0ccf90a25ce2e74ff 100644 (file)
@@ -23,7 +23,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #define PRODUCT_ID 0x422D
 #define DEVICE_VER 0x0001
 #define MANUFACTURER You
-#define PRODUCT % KEYBOARD %
+#define PRODUCT %KEYBOARD%
 #define DESCRIPTION A custom keyboard
 
 #define RGBLED_NUM 16
@@ -31,13 +31,10 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #define MATRIX_ROWS 8
 #define MATRIX_COLS 11
 
-#define MATRIX_ROW_PINS \
-    { B0, B1, B2, B3, B4, B5, B6, B7 }
-#define MATRIX_COL_PINS \
-    { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5 }
+#define MATRIX_ROW_PINS { B0, B1, B2, B3, B4, B5, B6, B7 }
+#define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5 }
 // #define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5, C4, C3, C2, C1, C0, D7 }
-#define UNUSED_PINS \
-    {}
+#define UNUSED_PINS {}
 
 #define DIODE_DIRECTION COL2ROW
 #define DEBOUNCE 5
diff --git a/quantum/template/ps2avrgb/keyboard.c b/quantum/template/ps2avrgb/keyboard.c
new file mode 100644 (file)
index 0000000..efc8517
--- /dev/null
@@ -0,0 +1,90 @@
+/* Copyright %YEAR% %YOUR_NAME%
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "%KEYBOARD%.h"
+
+#ifdef RGBLIGHT_ENABLE
+
+#    include <string.h>
+#    include "i2c_master.h"
+#    include "rgblight.h"
+
+extern rgblight_config_t rgblight_config;
+
+void matrix_init_kb(void) {
+    i2c_init();
+    // call user level keymaps, if any
+    matrix_init_user();
+}
+
+// custom RGB driver
+void rgblight_set(void) {
+    if (!rgblight_config.enable) {
+        memset(led, 0, 3 * RGBLED_NUM);
+    }
+
+    i2c_transmit(0xb0, (uint8_t*)led, 3 * RGBLED_NUM, 100);
+}
+
+bool rgb_init = false;
+
+void matrix_scan_kb(void) {
+    // if LEDs were previously on before poweroff, turn them back on
+    if (rgb_init == false && rgblight_config.enable) {
+        i2c_transmit(0xb0, (uint8_t*)led, 3 * RGBLED_NUM, 100);
+        rgb_init = true;
+    }
+
+    rgblight_task();
+    matrix_scan_user();
+}
+
+#endif
+
+// Optional override functions below.
+// You can leave any or all of these undefined.
+// These are only required if you want to perform custom actions.
+
+/*
+
+void matrix_init_kb(void) {
+  // put your keyboard start-up code here
+  // runs once when the firmware starts up
+
+  matrix_init_user();
+}
+
+void matrix_scan_kb(void) {
+  // put your looping keyboard code here
+  // runs every cycle (a lot)
+
+  matrix_scan_user();
+}
+
+bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
+  // put your per-action keyboard code here
+  // runs for every action, just before processing by the firmware
+
+  return process_record_user(keycode, record);
+}
+
+void led_set_kb(uint8_t usb_led) {
+  // put your keyboard LED indicator (ex: Caps Lock LED) toggling code here
+
+  led_set_user(usb_led);
+}
+
+*/
diff --git a/quantum/template/ps2avrgb/template.c b/quantum/template/ps2avrgb/template.c
deleted file mode 100644 (file)
index efc8517..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-/* Copyright %YEAR% %YOUR_NAME%
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "%KEYBOARD%.h"
-
-#ifdef RGBLIGHT_ENABLE
-
-#    include <string.h>
-#    include "i2c_master.h"
-#    include "rgblight.h"
-
-extern rgblight_config_t rgblight_config;
-
-void matrix_init_kb(void) {
-    i2c_init();
-    // call user level keymaps, if any
-    matrix_init_user();
-}
-
-// custom RGB driver
-void rgblight_set(void) {
-    if (!rgblight_config.enable) {
-        memset(led, 0, 3 * RGBLED_NUM);
-    }
-
-    i2c_transmit(0xb0, (uint8_t*)led, 3 * RGBLED_NUM, 100);
-}
-
-bool rgb_init = false;
-
-void matrix_scan_kb(void) {
-    // if LEDs were previously on before poweroff, turn them back on
-    if (rgb_init == false && rgblight_config.enable) {
-        i2c_transmit(0xb0, (uint8_t*)led, 3 * RGBLED_NUM, 100);
-        rgb_init = true;
-    }
-
-    rgblight_task();
-    matrix_scan_user();
-}
-
-#endif
-
-// Optional override functions below.
-// You can leave any or all of these undefined.
-// These are only required if you want to perform custom actions.
-
-/*
-
-void matrix_init_kb(void) {
-  // put your keyboard start-up code here
-  // runs once when the firmware starts up
-
-  matrix_init_user();
-}
-
-void matrix_scan_kb(void) {
-  // put your looping keyboard code here
-  // runs every cycle (a lot)
-
-  matrix_scan_user();
-}
-
-bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
-  // put your per-action keyboard code here
-  // runs for every action, just before processing by the firmware
-
-  return process_record_user(keycode, record);
-}
-
-void led_set_kb(uint8_t usb_led) {
-  // put your keyboard LED indicator (ex: Caps Lock LED) toggling code here
-
-  led_set_user(usb_led);
-}
-
-*/
index 35d89e4026b04a8eea0c3610f984acba80bc02a4..fe7c1a8299c4679a3c773dd7179f750415555cd7 100755 (executable)
@@ -41,8 +41,8 @@ copy_templates() {
     echo " done"
 
     echo -n "Renaming keyboard files..."
-    mv "${keyboard_dir}/template.c" "${keyboard_dir}/${keyboard_name}.c"
-    mv "${keyboard_dir}/template.h" "${keyboard_dir}/${keyboard_name}.h"
+    mv "${keyboard_dir}/keyboard.c" "${keyboard_dir}/${keyboard_name}.c"
+    mv "${keyboard_dir}/keyboard.h" "${keyboard_dir}/${keyboard_name}.h"
     echo " done"
 }
 
index 4737d693b8d757a3a93fa394e592a7af14c504f4..8ca65f21a05d57d4ef9a0f61b1db09cb8d756913 100755 (executable)
@@ -12,7 +12,7 @@ if [[ "$TRAVIS_BRANCH" == "master" && "$TRAVIS_PULL_REQUEST" == "false" ]] ; the
 # fix formatting
 git checkout master
 git diff --diff-filter=AM --name-only -n 1 -z ${TRAVIS_COMMIT_RANGE} | xargs -0 dos2unix
-git diff --diff-filter=AM --name-only -n 1 -z ${TRAVIS_COMMIT_RANGE} | grep -e '^drivers' -e '^quantum' -e '^tests' -e '^tmk_core' | xargs -0 clang-format
+git diff --diff-filter=AM --name-only -n 1 -z ${TRAVIS_COMMIT_RANGE} | grep -e '^drivers' -e '^quantum' -e '^tests' -e '^tmk_core' | grep -v 'quantum/template' | xargs -0 clang-format
 git diff --diff-filter=AM --name-only -n 1 -z ${TRAVIS_COMMIT_RANGE} | xargs -0 git add
 git commit -m "format code according to conventions [skip ci]" && git push git@github.com:qmk/qmk_firmware.git master