summaryrefslogtreecommitdiff
path: root/pkg/kbd
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2017-09-17 00:03:34 -0700
committerMichael Forney <mforney@mforney.org>2017-09-25 19:23:06 -0700
commitba94a8513d9a0aadb3f2c834c74b64aa644c61e8 (patch)
tree48ac6c85baa7b9d960b9e1e726a906e61ca60967 /pkg/kbd
parentcb362b531d79708a259bbf070dee5104fd63df08 (diff)
Rewrite ninja generation scripts in Lua
Diffstat (limited to 'pkg/kbd')
-rw-r--r--pkg/kbd/gen.lua76
-rw-r--r--pkg/kbd/gen.rc75
2 files changed, 76 insertions, 75 deletions
diff --git a/pkg/kbd/gen.lua b/pkg/kbd/gen.lua
new file mode 100644
index 00000000..2abe315d
--- /dev/null
+++ b/pkg/kbd/gen.lua
@@ -0,0 +1,76 @@
+cflags{
+ [[-D 'DATADIR="/share/kbd"']],
+ '-I include',
+ '-I $dir',
+ '-I $srcdir',
+ '-I $srcdir/src',
+ '-I $srcdir/src/libkeymap',
+ '-I $srcdir/src/libkeymap/keymap',
+}
+
+lib('libcommon.a', 'src/(getfd.c xmalloc.c kbd_error.c)')
+lib('libfont.a', 'src/(kdfontop.c kdmapop.c loadunimap.c psffontop.c utf8.c)')
+lib('libkeymap.a', [[src/libkeymap/(
+ analyze.c
+ array.c
+ common.c
+ diacr.c
+ dump.c
+ findfile.c
+ func.c
+ kernel.c
+ kmap.c
+ ksyms.c
+ loadkeys.c
+ modifiers.c
+ parser.c
+ summary.c
+)]])
+
+-- old: loadunimap mapscrn
+-- optional: clrunmap getunimap setlogcons setvesablank setpalette screendump
+-- i386/x86_64 only: resizecons
+-- ubase: chvt
+
+local function x(cmd, section, subst, srcs)
+ if not srcs then
+ srcs = 'src/'..cmd..'.c'
+ end
+ exe(cmd, {srcs, 'libcommon.a', 'libfont.a', 'libkeymap.a'})
+ file('bin/'..cmd, '755', '$outdir/'..cmd)
+ if not section then
+ return
+ end
+ local manpage = string.format('docs/man/man%s/%s.%s', section, cmd, section)
+ if subst then
+ local out = string.format('$outdir/%s.%s', cmd, section)
+ build('sed', out, '$srcdir/'..manpage..'.in', {expr='s,@DATADIR@,/share/kbd,g'})
+ manpage = out
+ end
+ man{manpage}
+end
+
+x('deallocvt', '1')
+x('dumpkeys', '1', true)
+x('fgconsole', '1')
+x('getkeycodes', '8')
+x('kbd_mode', '1')
+x('kbdinfo')
+x('loadkeys', '1', true)
+x('openvt', '1')
+x('psfxtable', '1')
+x('setfont', '8', true, {'src/setfont.c', 'src/mapscrn.c'})
+x('setkeycodes', '8')
+x('setvtrgb', '8')
+x('showconsolefont', '8')
+x('showkey', '1')
+
+-- keymap data
+for keymap in iterlines('keymaps.txt') do
+ local out = '$outdir/keymaps/'..keymap..'.gz'
+ build('gzip', out, '$srcdir/data/keymaps/'..keymap)
+ file('share/kbd/keymaps/'..keymap..'.gz', '644', out)
+end
+sym('share/kbd/keymaps/ppc', 'mac')
+
+fetch 'curl'
diff --git a/pkg/kbd/gen.rc b/pkg/kbd/gen.rc
deleted file mode 100644
index a6191952..00000000
--- a/pkg/kbd/gen.rc
+++ /dev/null
@@ -1,75 +0,0 @@
-cflags\
- -D 'DATADIR=''"/share/kbd"''' \
- -I include\
- -I '$dir' \
- -I '$srcdir' \
- -I '$srcdir'/src\
- -I '$srcdir'/src/libkeymap\
- -I '$srcdir'/src/libkeymap/keymap
-
-lib libcommon.a src/^(getfd.c xmalloc.c kbd_error.c)
-lib libfont.a src/^(kdfontop.c kdmapop.c loadunimap.c psffontop.c utf8.c)
-lib libkeymap.a src/libkeymap/^(\
- analyze.c\
- array.c\
- common.c\
- diacr.c\
- dump.c\
- findfile.c\
- func.c\
- kernel.c\
- kmap.c\
- ksyms.c\
- loadkeys.c\
- modifiers.c\
- parser.c\
- summary.c\
-)
-
-# old: loadunimap mapscrn
-# optional: clrunmap getunimap setlogcons setvesablank setpalette screendump
-# i386/x86_64 only: resizecons
-# ubase: chvt
-
-fn x {
- sect=$1
- exe=$2
- shift 2
- exe $exe src/$exe.c $* libcommon.a libfont.a libkeymap.a
- file bin/$exe '$outdir'/$exe 755
- if(~ $sect ?~) {
- sect=`{printf %s $sect | cut -c -1}
- build '$outdir'/$exe.$sect sed '$srcdir'/docs/man/man$sect/$exe.$sect.in ; with\
- expr s,@DATADIR@,/share/kbd,g
- subdir='$outdir'
- }
- if not subdir=docs/man/man$sect
- if(~ $sect [18])
- man -d $subdir $sect $exe.$sect
- status=()
-}
-
-x 1 deallocvt
-x 1~ dumpkeys
-x 1 fgconsole
-x 8 getkeycodes
-x 1 kbd_mode
-x - kbdinfo
-x 1~ loadkeys
-x 1 openvt
-x 1 psfxtable
-x 8~ setfont src/mapscrn.c
-x 8 setkeycodes
-x 8 setvtrgb
-x 8 showconsolefont
-x 1 showkey
-
-# keymap data
-keymaps=`{grep -v '^#' keymaps.txt}
-for(keymap in keymaps/$keymaps) {
- build '$outdir'/$keymap.gz gzip '$srcdir'/data/$keymap
- file share/kbd/$keymap.gz '$outdir'/$keymap.gz 644
-}
-sym share/kbd/keymaps/ppc mac
-
-fetch curl