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

Multi-threaded QMK compilation breaks the script #51

Open
precondition opened this issue Sep 18, 2021 · 0 comments
Open

Multi-threaded QMK compilation breaks the script #51

precondition opened this issue Sep 18, 2021 · 0 comments

Comments

@precondition
Copy link
Contributor

precondition commented Sep 18, 2021

I have the following code block at the top of my keymap rules.mk:

# Automatically update the keymap visualization when compiling
.PHONY: %
%:
	keymapviz -k dactyl_manuform5x6 -t fancy -r keyboards/handwired/dactyl_manuform/5x6/keymaps/precondition/keymap.c -c keyboards/handwired/dactyl_manuform/5x6/keymaps/precondition/keymapviz.toml > /dev/null

This lets me automatically update the keymap visualizations any time I run qmk compile or qmk flash which is awesome. However, this only works if I use a single thread for compiling my keymap. If I use the -j/--jobs option of the qmk CLI with any value above 1, keymapviz often throws an error and thus aborts the entire compilation operation. Although in some rare cases, the script works fine and the compilation is not aborted; clear sign of a race condition.

The error that keymapviz throws is the following:

Making handwired/dactyl_manuform/5x6 with keymap precondition

Traceback (most recent call last):
  File "/home/vern/.local/bin/keymapviz", line 8, in <module>
    sys.exit(main())
  File "/home/vern/.local/lib/python3.8/site-packages/keymapviz/keymapviz.py", line 91, in main
    output_keymap_c(arg.keymap_c.name, kmvz.keymap_c())
  File "/home/vern/.local/lib/python3.8/site-packages/keymapviz/keymapviz.py", line 79, in output_keymap_c
    os.rename(output_filename, output_filename + ".bac")
FileNotFoundError: [Errno 2] No such file or directory: 'keyboards/handwired/dactyl_manuform/5x6/keymaps/precondition/keymap.c' -> 'keyboards/handwired/dactyl_manuform/5x6/keymaps/precondition/keymap.c.bac'
Traceback (most recent call last):
  File "/home/vern/.local/bin/keymapviz", line 8, in <module>
    sys.exit(main())
  File "/home/vern/.local/lib/python3.8/site-packages/keymapviz/keymapviz.py", line 91, in main
    output_keymap_c(arg.keymap_c.name, kmvz.keymap_c())
  File "/home/vern/.local/lib/python3.8/site-packages/keymapviz/keymapviz.py", line 79, in output_keymap_c
    os.rename(output_filename, output_filename + ".bac")
FileNotFoundError: [Errno 2] No such file or directory: 'keyboards/handwired/dactyl_manuform/5x6/keymaps/precondition/keymap.c' -> 'keyboards/handwired/dactyl_manuform/5x6/keymaps/precondition/keymap.c.bac'
Traceback (most recent call last):
  File "/home/vern/.local/bin/keymapviz", line 8, in <module>
    sys.exit(main())
  File "/home/vern/.local/lib/python3.8/site-packages/keymapviz/keymapviz.py", line 91, in main
    output_keymap_c(arg.keymap_c.name, kmvz.keymap_c())
  File "/home/vern/.local/lib/python3.8/site-packages/keymapviz/keymapviz.py", line 79, in output_keymap_c
    os.rename(output_filename, output_filename + ".bac")
FileNotFoundError: [Errno 2] No such file or directory: 'keyboards/handwired/dactyl_manuform/5x6/keymaps/precondition/keymap.c' -> 'keyboards/handwired/dactyl_manuform/5x6/keymaps/precondition/keymap.c.bac'
make[1]: *** No rule to make target '.build/obj_handwired_dactyl_manuform_5x6_precondition/quantum/keymap_common.d', needed by '.build/obj_handwired_dactyl_manuform_5x6_precondition/quantum/keymap_common.o'.  Stop.
make[1]: *** Waiting for unfinished jobs....
avr-gcc (GCC) 5.4.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Make finished with errors
make: *** [Makefile:535: handwired/dactyl_manuform/5x6:precondition] Error 1

Honestly, I'm not sure whether the problem has to be solved within keymapviz itself, within my particular .PHONY block or within the QMK CLI.

PS: I use keymapviz 1.7.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant