From 74aba7256696e7c6fc34c781da18fff4cfd46e88 Mon Sep 17 00:00:00 2001 From: Robert Akhmerov Date: Mon, 25 May 2020 00:27:23 +0300 Subject: [PATCH] feature-11 Fix headers --- compiler/run.js | 10 ++++++---- compiler/template/rgb_matrix_user.inc | 3 +-- compiler/template/zored_keymap.c | 7 ++----- compiler/template/zored_keymap.h | 12 +++++++++++- example/planck/keymap.c | 6 ++---- example/planck/keymap.h | 12 +++++++++++- example/planck/rgb_matrix_user.inc | 3 +-- 7 files changed, 34 insertions(+), 19 deletions(-) diff --git a/compiler/run.js b/compiler/run.js index 417bce1..bc9885c 100644 --- a/compiler/run.js +++ b/compiler/run.js @@ -26,7 +26,7 @@ function main () { ) const files = new KeymapFiles(keyboard) - const { comboCount } = compileKeymap(layers, keyboard, files, keyFactory, config.dance_enemies, config) + const { comboCount } = compileKeymap(layers, keyboard, files, keyFactory, config.dance_enemies) compileSettings(keyboard, files, { COMBO_COUNT: comboCount }) @@ -542,7 +542,7 @@ function compileKeymap (layers, keyboard, files, keyFactory, danceEnemies) { const Mustache = require('mustache') const { combos, comboCount } = getCombos(keyboard.config.combos, keyFactory) - const result = Mustache.render(fs.readFileSync('compiler/template/zored_keymap.c', 'utf8'), _.merge({ + const config = _.merge({ dance: getDanceTemplateData(layers, danceEnemies, keyFactory), unicode: getUnicodeTemplateData(layers), layers: getLayersTemplateData(layers, keyboard), @@ -550,8 +550,10 @@ function compileKeymap (layers, keyboard, files, keyFactory, danceEnemies) { combos, mappings: getMappings(keyboard.config.mappings, keyFactory), keyGroups: getKeyGroups(layers) - }, keyboard.getTemplateData(layers))) - files.add('keymap.c', result) + }, keyboard.getTemplateData(layers)); + [['zored_keymap.h','keymap.h'],['zored_keymap.c','keymap.c']].forEach(([from, to]) => + files.add(to, Mustache.render(fs.readFileSync(`compiler/template/${from}`, 'utf8'), config)) + ); return { comboCount } } diff --git a/compiler/template/rgb_matrix_user.inc b/compiler/template/rgb_matrix_user.inc index f5f464d..3c925be 100644 --- a/compiler/template/rgb_matrix_user.inc +++ b/compiler/template/rgb_matrix_user.inc @@ -1,9 +1,8 @@ -#include "keymap.h" - #ifndef DISABLE_RGB_MATRIX_ZORED_EFFECT RGB_MATRIX_EFFECT(zored_effect) #ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS +#include "keymap.h" static bool zored_effect(effect_params_t* params) { RGB_MATRIX_USE_LIMITS(led_min, led_max); diff --git a/compiler/template/zored_keymap.c b/compiler/template/zored_keymap.c index ba5c739..293eb2c 100644 --- a/compiler/template/zored_keymap.c +++ b/compiler/template/zored_keymap.c @@ -1,6 +1,6 @@ {{! Keymap template for all of my keymaps. Has a lot of common code. }} -{{! This guy should be before RGB. }} +#include "keymap.h" {{#ergodox}} #include "ergodox_ez.h" @@ -23,10 +23,7 @@ #include "keymap_steno.h" #endif -enum operating_systems { - OS_MACOS = 1, - OS_WINDOWS, -} zored_os = OS_WINDOWS; +operating_systems zored_os = OS_WINDOWS; {{#mappings}} uint8_t mappingIndex = 0; diff --git a/compiler/template/zored_keymap.h b/compiler/template/zored_keymap.h index f78de2f..f08943f 100644 --- a/compiler/template/zored_keymap.h +++ b/compiler/template/zored_keymap.h @@ -1 +1,11 @@ -#include QMK_KEYBOARD_H +#ifndef ZORED_KEYMAP_H +#define ZORED_KEYMAP_H + +typedef enum { + OS_MACOS = 1, + OS_WINDOWS, +} operating_systems; + +extern operating_systems zored_os; + +#endif // ZORED_KEYMAP_H diff --git a/example/planck/keymap.c b/example/planck/keymap.c index 219fa97..615e854 100644 --- a/example/planck/keymap.c +++ b/example/planck/keymap.c @@ -1,4 +1,5 @@ +#include "keymap.h" #include QMK_KEYBOARD_H @@ -13,10 +14,7 @@ #include "keymap_steno.h" #endif -enum operating_systems { - OS_MACOS = 1, - OS_WINDOWS, -} zored_os = OS_WINDOWS; +operating_systems zored_os = OS_WINDOWS; uint8_t map_mod (uint8_t mod) { diff --git a/example/planck/keymap.h b/example/planck/keymap.h index f78de2f..f08943f 100644 --- a/example/planck/keymap.h +++ b/example/planck/keymap.h @@ -1 +1,11 @@ -#include QMK_KEYBOARD_H +#ifndef ZORED_KEYMAP_H +#define ZORED_KEYMAP_H + +typedef enum { + OS_MACOS = 1, + OS_WINDOWS, +} operating_systems; + +extern operating_systems zored_os; + +#endif // ZORED_KEYMAP_H diff --git a/example/planck/rgb_matrix_user.inc b/example/planck/rgb_matrix_user.inc index f5f464d..3c925be 100644 --- a/example/planck/rgb_matrix_user.inc +++ b/example/planck/rgb_matrix_user.inc @@ -1,9 +1,8 @@ -#include "keymap.h" - #ifndef DISABLE_RGB_MATRIX_ZORED_EFFECT RGB_MATRIX_EFFECT(zored_effect) #ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS +#include "keymap.h" static bool zored_effect(effect_params_t* params) { RGB_MATRIX_USE_LIMITS(led_min, led_max);