speakup: Generate speakupmap.h automatically
Samuel Thibault
maintainerPATCH v4 1/1 speakup: Generate speakupmap.h automatically
speakupmap.h was not actually intended to be source code, speakupmap.map is.
This resurrects the makemapdata.c and genmap.c tools to generate speakupmap.h automatically from the input and speakup headers, and the speakupmap.map keyboard mapping source file.
---
difference with v3:
- Fix out-of-tree builds
difference with v2:
- Stuff utils.c into utils.h
- Add .gitignore
difference with v1:
- Add missing dependency between main.c and speakupmap.h
drivers/accessibility/speakup/.gitignore | 4 drivers/accessibility/speakup/Makefile | 28 ++++ drivers/accessibility/speakup/genmap.c | 162 ++++++++++++++++++++++++++++ drivers/accessibility/speakup/makemapdata.c | 125 +++++++++++++++++++++ drivers/accessibility/speakup/speakupmap.h | 66 ----------- drivers/accessibility/speakup/utils.h | 102 +++++++++++++++++ 6 files changed, 421 insertions(+), 66 deletions(-)
drivers/accessibility/speakup/Makefile +28 -0
@@ -30,3 +30,31 @@ speakup-y := \ thread.o \ varhandlers.o speakup-$(CONFIG_SPEAKUP_SERIALIO) += serialio.o + + +clean-files := mapdata.h speakupmap.h + + +# Generate mapdata.h from headers +hostprogs += makemapdata +makemapdata-objs := makemapdata.o + +quiet_cmd_mkmap = MKMAP $@ + cmd_mkmap = TOPDIR=$(srctree) $(obj)/makemapdata > $@ + +$(obj)/mapdata.h: $(obj)/makemapdata + $(call cmd,mkmap) + + +# Generate speakupmap.h from mapdata.h +hostprogs += genmap +genmap-objs := genmap.o +$(obj)/genmap.o: $(obj)/mapdata.h + +quiet_cmd_genmap = GENMAP $@ + cmd_genmap = $(obj)/genmap $< > $@ + +$(obj)/speakupmap.h: $(src)/speakupmap.map $(obj)/genmap + $(call cmd,genmap) + +$(obj)/main.o: $(obj)/speakupmap.h
drivers/accessibility/speakup/genmap.c new file +162 -0
162 lines not on this page · raw message
drivers/accessibility/speakup/makemapdata.c new file +125 -0
125 lines not on this page · raw message
drivers/accessibility/speakup/speakupmap.h deleted +0 -66
66 lines not on this page · raw message
drivers/accessibility/speakup/utils.h new file +102 -0
102 lines not on this page · raw message
drivers/accessibility/speakup/.gitignore new file +4 -0
@@ -0,0 +1,4 @@ +/makemapdata +/mapdata.h +/genmap +/speakupmap.h
Hi,
I was building 6.0-rc1 and this patch seem to cause some compiling issues. The u_char was not defined in my host build environment (I suspect because of the musl based host) which leads to the makemapdata failing to compile. Changing the file to use "unsigned char" seems to solve the issue.
After that I also had some weird issues of the build system trying to write speakupmap.h into the source dir and not the output dir (the source is read only due to the tooling I use) but this seems to have been resolved by cleanly rebuilding the speakup dir.
A patch changing the type follows.
Nikita
-- >8 --
From bc239d8740f9e31240e8727f76227daa1aec3c4f Mon Sep 17 00:00:00 2001
From: Nikita Travkin <[email protected]>
Date: Tue, 16 Aug 2022 11:39:52 +0500
Subject: [PATCH] speakup: Fix compilation in some build environments
A compilation error may occur if the host CC doesn't have u_char defined:
HOSTCC drivers/accessibility/speakup/makemapdata.o
In file included from ../drivers/accessibility/speakup/makemapdata.c:15:../drivers/accessibility/speakup/utils.h: In function 'hash_name':../drivers/accessibility/speakup/utils.h:57:9: error: unknown type name 'u_char'; did you mean 'char'?
57 | u_char *pn = (u_char *)name;
| ^~~~~~
| charFix this by using "unsigned char" instead.
--- drivers/accessibility/speakup/utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/accessibility/speakup/utils.h +1 -1
@@ -54,7 +54,7 @@ static inline int oops(const char *msg, const char *info)static inline struct st_key *hash_name (char *name) { -u_char *pn = (u_char *)name; +unsigned char *pn = (unsigned char *)name;int hash =0 ;while (*pn) {
Signature · 1 line
2.35.3
Re: [PATCH] speakup: Fix compilation in some build environments
Hello,
Nikita Travkin, le mar. 16 août 2022 12:28:43 +0500, a ecrit:
Quoted 12 lines
-- >8 --
Frombc239d8740f9e31240e8727f76227daa1aec3c4fMon Sep 17 00:00:00 2001
From: Nikita Travkin <[email protected]>
Date: Tue, 16 Aug 2022 11:39:52 +0500A compilation error may occur if the host CC doesn't have
u_chardefined:HOSTCC
drivers/accessibility/speakup/makemapdata.o
In file included from../drivers/accessibility/speakup/makemapdata.c:15:../drivers/accessibility/speakup/utils.h: In function 'hash_name':../drivers/accessibility/speakup/utils.h:57:9: error: unknown type name 'u_char'; did you mean 'char'?
Quoted 8 lines
57 | u_char *pn = (u_char *)name; | ^~~~~~ | charFix this by using "unsigned char" instead.
Fixes 6a5c94d92699 ("speakup: Generate speakupmap.h automatically")Signed-off-by Nikita Travkin <[email protected]>
Thanks!
Quoted 20 lines
--- drivers/accessibility/speakup/utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/accessibility/speakup/utils.h +1
-1@@ -54,7 +54,7 @@ static inline int oops(const char *msg, const char *info)static inline struct st_key *hash_name (char *name) { -u_char *pn = (u_char *)name; +unsigned char *pn = (unsigned char *)name;int hash =0 ;while (*pn) {Signature · 1 line
2.35.3
Samuel Thibault
maintainerHello,
Nikita Travkin, le mar. 16 août 2022 12:28:43 +0500, a ecrit:
Quoted 4 lines
After that I also had some weird issues of the build system trying to write
speakupmap.hinto the source dir and not the output dir (the source is read only due to the tooling I use) but this seems to have been resolved by cleanly rebuilding the speakup dir.
Mmm, how did you get/update your source dir? The latest version of the patchset does generate it in the build tree.
Samuel
Hi,
Samuel Thibault писал(а) 16.08.2022 23:33:
Quoted 11 lines
Hello,
Nikita Travkin, le mar. 16 août 2022 12:28:43 +0500, a ecrit:
Quoted 4 lines
After that I also had some weird issues of the build system trying to write
speakupmap.hinto the source dir and not the output dir (the source is read only due to the tooling I use) but this seems to have been resolved by cleanly rebuilding the speakup dir.Mmm, how did you get/update your source dir? The latest version of the patchset does generate it in the build tree.
It's just a git tree for Linux in which I've checked-out the v6.0-rc1 tag and applied few unrelated patches on top.
The thing confused me a bit as all other artifacts were properly placed in the output dir with an exception of the speakupmap.h.
My guess would be that I had some cache left over in the build dir from before this patch, when the file was hardcoded so it tried to recreate it as it was. This seems reproducible:
(Please note that the build tooling I use handles the output dir in the output below)
$ sudo rm -rf .output/drivers/accessibility/speakup/ $ git checkout v5.19 $ make -j12 allnoconfig $ make -j12 menuconfig # Enable speakup $ make -j12 (... Builds correctly)
$ git checkout v6.0-rc1 $ git cherry-pick bc239d8740f9 [отделённый HEAD c32cda0a1b44] speakup: Fix compilation in some build environments Date: Tue Aug 16 11:39:52 2022 +0500 1 file changed, 1 insertion(+), 1 deletion(-)
$ make -j12 allnoconfig $ make -j12 menuconfig # Enable speakup the same way $ make -j12 *** pmbootstrap envkernel.sh active for /home/travler/devel/pmos/linux! *** make: Entering directory '/mnt/linux' make[1]: Entering directory '/mnt/linux/.output' SYNC include/config/auto.conf.cmd
(...)
CC drivers/accessibility/speakup/buffers.o CC drivers/accessibility/speakup/devsynth.o CC drivers/accessibility/speakup/i18n.o AR kernel/built-in.a CC drivers/accessibility/speakup/fakekey.o HOSTCC drivers/accessibility/speakup/makemapdata.o CC drivers/accessibility/speakup/keyhelp.o CC drivers/accessibility/speakup/kobjects.o CC drivers/accessibility/speakup/selection.o CC drivers/accessibility/speakup/spk_ttyio.o CC drivers/accessibility/speakup/synth.o CC drivers/accessibility/speakup/thread.o CC drivers/accessibility/speakup/varhandlers.o CC drivers/of/device.o HOSTLD drivers/accessibility/speakup/makemapdata MKMAP drivers/accessibility/speakup/mapdata.h HOSTCC drivers/accessibility/speakup/genmap.o HOSTLD drivers/accessibility/speakup/genmap GENMAP ../drivers/accessibility/speakup/speakupmap.h /bin/sh: can't create ../drivers/accessibility/speakup/speakupmap.h: Permission denied make[4]: *** [../drivers/accessibility/speakup/Makefile:58: ../drivers/accessibility/speakup/speakupmap.h] Error 1 make[4]: *** Waiting for unfinished jobs.... CC drivers/of/platform.o CC drivers/of/property.o CC drivers/of/kobj.o CC drivers/of/fdt.o CC drivers/of/fdt_address.o CC drivers/of/address.o CC drivers/of/irq.o CC drivers/of/of_reserved_mem.o
make[3]: *** [../scripts/Makefile.build:465: drivers/accessibility/speakup] Error 2 make[2]: *** [../scripts/Makefile.build:465: drivers/accessibility] Error 2 make[2]: *** Waiting for unfinished jobs....
AR drivers/of/built-in.a
make[1]: *** [/mnt/linux/Makefile:1855: drivers] Error 2
make[1]: Leaving directory '/mnt/linux/.output'
make: *** [Makefile:222: __sub-make] Error 2
make: Leaving directory '/mnt/linux'
Run 'pmbootstrap log' for details.
$ sudo rm -rf .output/drivers/accessibility/speakup/ $ make -j12 (...) HOSTLD drivers/accessibility/speakup/makemapdata MKMAP drivers/accessibility/speakup/mapdata.h HOSTCC drivers/accessibility/speakup/genmap.o HOSTLD drivers/accessibility/speakup/genmap GENMAP drivers/accessibility/speakup/speakupmap.h CC drivers/accessibility/speakup/main.o AR drivers/accessibility/speakup/built-in.a (... Builds correctly again)
Nikita
Quoted 1 line
Samuel
Hi,
(For some reason my mail client decided to put me as To: and drop Samuel... so this is a resend. Sorry for the spam)
Samuel Thibault писал(а) 16.08.2022 23:33:
Quoted 11 lines
Hello,
Nikita Travkin, le mar. 16 août 2022 12:28:43 +0500, a ecrit:
Quoted 4 lines
After that I also had some weird issues of the build system trying to write
speakupmap.hinto the source dir and not the output dir (the source is read only due to the tooling I use) but this seems to have been resolved by cleanly rebuilding the speakup dir.Mmm, how did you get/update your source dir? The latest version of the patchset does generate it in the build tree.
It's just a git tree for Linux in which I've checked-out the v6.0-rc1 tag and applied few unrelated patches on top.
The thing confused me a bit as all other artifacts were properly placed in the output dir with an exception of the speakupmap.h.
My guess would be that I had some cache left over in the build dir from before this patch, when the file was hardcoded so it tried to recreate it as it was. This seems reproducible:
(Please note that the build tooling I use handles the output dir in the output below)
$ sudo rm -rf .output/drivers/accessibility/speakup/ $ git checkout v5.19 $ make -j12 allnoconfig $ make -j12 menuconfig # Enable speakup $ make -j12 (... Builds correctly)
$ git checkout v6.0-rc1 $ git cherry-pick bc239d8740f9 [отделённый HEAD c32cda0a1b44] speakup: Fix compilation in some build environments Date: Tue Aug 16 11:39:52 2022 +0500 1 file changed, 1 insertion(+), 1 deletion(-)
$ make -j12 allnoconfig $ make -j12 menuconfig # Enable speakup the same way $ make -j12 *** pmbootstrap envkernel.sh active for /home/travler/devel/pmos/linux! *** make: Entering directory '/mnt/linux' make[1]: Entering directory '/mnt/linux/.output' SYNC include/config/auto.conf.cmd
(...)
CC drivers/accessibility/speakup/buffers.o CC drivers/accessibility/speakup/devsynth.o CC drivers/accessibility/speakup/i18n.o AR kernel/built-in.a CC drivers/accessibility/speakup/fakekey.o HOSTCC drivers/accessibility/speakup/makemapdata.o CC drivers/accessibility/speakup/keyhelp.o CC drivers/accessibility/speakup/kobjects.o CC drivers/accessibility/speakup/selection.o CC drivers/accessibility/speakup/spk_ttyio.o CC drivers/accessibility/speakup/synth.o CC drivers/accessibility/speakup/thread.o CC drivers/accessibility/speakup/varhandlers.o CC drivers/of/device.o HOSTLD drivers/accessibility/speakup/makemapdata MKMAP drivers/accessibility/speakup/mapdata.h HOSTCC drivers/accessibility/speakup/genmap.o HOSTLD drivers/accessibility/speakup/genmap GENMAP ../drivers/accessibility/speakup/speakupmap.h /bin/sh: can't create ../drivers/accessibility/speakup/speakupmap.h: Permission denied make[4]: *** [../drivers/accessibility/speakup/Makefile:58: ../drivers/accessibility/speakup/speakupmap.h] Error 1 make[4]: *** Waiting for unfinished jobs.... CC drivers/of/platform.o CC drivers/of/property.o CC drivers/of/kobj.o CC drivers/of/fdt.o CC drivers/of/fdt_address.o CC drivers/of/address.o CC drivers/of/irq.o CC drivers/of/of_reserved_mem.o
make[3]: *** [../scripts/Makefile.build:465: drivers/accessibility/speakup] Error 2 make[2]: *** [../scripts/Makefile.build:465: drivers/accessibility] Error 2 make[2]: *** Waiting for unfinished jobs....
AR drivers/of/built-in.a
make[1]: *** [/mnt/linux/Makefile:1855: drivers] Error 2
make[1]: Leaving directory '/mnt/linux/.output'
make: *** [Makefile:222: __sub-make] Error 2
make: Leaving directory '/mnt/linux'
Run 'pmbootstrap log' for details.
$ sudo rm -rf .output/drivers/accessibility/speakup/ $ make -j12 (...) HOSTLD drivers/accessibility/speakup/makemapdata MKMAP drivers/accessibility/speakup/mapdata.h HOSTCC drivers/accessibility/speakup/genmap.o HOSTLD drivers/accessibility/speakup/genmap GENMAP drivers/accessibility/speakup/speakupmap.h CC drivers/accessibility/speakup/main.o AR drivers/accessibility/speakup/built-in.a (... Builds correctly again)
Nikita
Quoted 1 line
Samuel
Samuel Thibault
maintainerHello,
Nikita Travkin, le mer. 17 août 2022 09:10:11 +0500, a ecrit:
Quoted 13 lines
Samuel Thibault писал(а) 16.08.2022 23:33:
Quoted 8 lines
Nikita Travkin, le mar. 16 août 2022 12:28:43 +0500, a ecrit:
Quoted 4 lines
After that I also had some weird issues of the build system trying to write
speakupmap.hinto the source dir and not the output dir (the source is read only due to the tooling I use) but this seems to have been resolved by cleanly rebuilding the speakup dir.Mmm, how did you get/update your source dir? The latest version of the patchset does generate it in the build tree.
It's just a git tree for Linux in which I've checked-out the v6.0-rc1 tag and applied few unrelated patches on top.
Quoted 6 lines
The thing confused me a bit as all other artifacts were properly placed in the output dir with an exception of the
speakupmap.h.My guess would be that I had some cache left over in the build dir from before this patch, when the file was hardcoded so it tried to recreate it as it was.
That was my guess as well.
Quoted 1 line
This seems reproducible:
Ok. I guess the confusion is coming from the firstly-generated .main.o.cmd file that would still refer to the in-source origin. I don't think we can do much about this case, unfortunately.
Thanks for checking,
Samuel