Quellcode durchsuchen

Add userspace config.h handling to build script (#2640)

* Add userspace 'config.h' file

* Add more robust docs

* Remove config.h code from drashna userspace

* Spelling error

* Include links to Config Options page

* Remove config.h documentation from userspace doc, as it's no longer needed
Drashna Jaelre vor 7 Jahren
Ursprung
Commit
162a67cbc5
4 geänderte Dateien mit 27 neuen und 34 gelöschten Zeilen
  1. 4 0
      build_keyboard.mk
  2. 23 1
      docs/feature_userspace.md
  3. 0 27
      users/drashna/readme.md
  4. 0 6
      users/drashna/rules.mk

+ 4 - 0
build_keyboard.mk

@@ -204,6 +204,10 @@ endif
 # User space stuff
 USER_PATH := users/$(KEYMAP)
 -include $(USER_PATH)/rules.mk
+ifneq ("$(wildcard users/$(KEYMAP)/config.h)","")
+    CONFIG_H += users/$(KEYMAP)/config.h
+endif
+
 
 # Object files directory
 #     To put object files in current directory, use a dot (.), do NOT make

+ 23 - 1
docs/feature_userspace.md

@@ -3,10 +3,11 @@
 If you use more than one keyboard with a similar keymap, you might see the benefit in being able to share code between them. Create your own folder in `users/` named the same as your keymap (ideally your github username, `<name>`) with the following structure:
 
 * `/users/<name>/` (added to the path automatically)
-  * `readme.md`
+  * `readme.md` (optional, recommended)
   * `rules.mk` (included automatically)
   * `<name>.h` (optional)
   * `<name>.c` (optional)
+  * `config.h` (optional)
 
 `<name>.c` will need to be added to the SRC in `rules.mk` like this:
 
@@ -24,10 +25,31 @@ For example,
 
 Will include the `/users/jack/` folder in the path, along with `/users/jack/rules.mk`.
 
+Additionally, `config.h` here will be processed like the same file in your keymap folder.  This is handled separately from the `<name>.h` file.  
+
+The reason for this, is that `<name>.h` won't be added in time to add settings (such as `#define TAPPING_TERM 100`), and including the `<name.h>` file in any `config.h` files will result in compile issues. 
+
+So you should use the `config.h` for QMK settings, and the `<name>.h` file for user or keymap specific settings. 
+ 
 ## Readme
 
 Please include authorship (your name, github username, email), and optionally [a license that's GPL compatible](https://www.gnu.org/licenses/license-list.html#GPLCompatibleLicenses).
 
+## `Config.h`
+
+If you do add a `config,h` file, you want to make sure that it only gets processed once.  So you may want to start off with something like this: 
+
+```c
+#ifndef USERSPACE_CONFIG_H
+#define USERSPACE_CONFIG_H
+
+// Put normal config.h settings here:
+
+#endif // !USERSPACE_CONFIG_H
+```
+
+You can use any option hre that you could use in your keymap's `config.h` file. You can find a list of vales [here](config_options.md). 
+
 ## Example
 
 For a brief example, checkout `/users/_example/` , or for a more detailed examples check out [`template.h`](https://github.com/qmk/qmk_firmware/blob/master/users/drashna/template.h) and [`template.c`](https://github.com/qmk/qmk_firmware/blob/master/users/drashna/template.c) in `/users/drashna/` .

Datei-Diff unterdrückt, da er zu groß ist
+ 0 - 27
users/drashna/readme.md


+ 0 - 6
users/drashna/rules.mk

@@ -2,10 +2,4 @@
 SRC += drashna.c
 EXTRAFLAGS        += -flto
 
-ifneq ("$(wildcard users/$(KEYMAP)/config.h)","")
-    CONFIG_H += users/$(KEYMAP)/config.h
-endif
 
-ifeq ($(strip $(NO_SECRETS)), yes)
-    OPT_DEFS += -DNO_SECRETS
-endif