Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow overriding the rule for $(KEYMAP_OUTPUT)/src/keymap.c #15480

Closed
wants to merge 1 commit into from

Conversation

pfn
Copy link

@pfn pfn commented Dec 15, 2021

Description

Reorder the keymap.json branch in build_keyboard.mk such that
keymap rules.mk definitions can define their own rule for the
generated keymap.c and config.h files

This is also a step towards #6873; provides a similar solution to what #13197 did, but this time by allowing a keymap to create their own keymap.c generation override.

For example, with the changes included on this branch, I am able to do this:

$(KEYMAP_C): $(KEYMAP_JSON)
	$(QMK_BIN) json2c --quiet --output $(KEYMAP_C) $(KEYMAP_JSON)
	sed -i -e '2 i #include "pfn_keymap.h"' $(KEYMAP_C)

The downside of this approach is that there is an overridden recipe warning, but perhaps that is a good thing.

Types of Changes

  • Core
  • Bugfix
  • New feature
  • Enhancement/optimization
  • Keyboard (addition or update)
  • Keymap/layout/userspace (addition or update)
  • Documentation

Issues Fixed or Closed by This PR

Checklist

  • My code follows the code style of this project: C, Python
  • I have read the PR Checklist document and have made the appropriate changes.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have tested the changes and verified that they work and don't break anything (as well as I can manage).

Reorder the keymap.json branch in build_keyboard.mk such that
keymap rules.mk definitions can define their own rule for the
generated keymap.c and config.h files
@github-actions github-actions bot added the core label Dec 15, 2021
@zvecr zvecr changed the base branch from master to develop December 15, 2021 09:57
@pfn
Copy link
Author

pfn commented Dec 15, 2021

Lots of push back on this change, so I have a workaround that works for this situation as well:

  1. create a stub keymap.c, it can be empty or contain code as desired
  2. download the configurator json into any arbitrarily named file.json, it must not be named keymap.json in the keymap folder
  3. modify rules.mk in the keymap folder as follows
SRC += keymap_configurator.c

.SECONDEXPANSION # required to allow expanding $$(KEYMAP_PATH), $(KEYMAP_PATH) doesn't expand
keymap_configurator.c: $$(KEYMAP_PATH)/pfn.json
	$(QMK_BIN) json2c --quiet --output $@ $<
	sed -i -e '2 i #include "pfn_keymap.h"' $@

@pfn pfn closed this Dec 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant