From 8a28e9ff5eed069f7536689e3595fa3a14cb816b Mon Sep 17 00:00:00 2001 From: Arch Blackmann Date: Sat, 31 Oct 2009 18:13:26 +0000 Subject: [PATCH] Begin implementing Keyboard Layout Compiler Tool, as requested by KJK::Hyperion. This is a UNIX-style (Win32-compatible) command-line tool that will take a standard keyboard layout file (in text) and generate the source, defininition, header and resource data for it. The second part of the tool will spawn off the compiler to build the keyboard DLL, or perhaps generate an .rbuild file to perform the work. svn path=/trunk/; revision=43880 --- reactos/tools/kbdtool/kbdtool.rbuild | 7 ++ reactos/tools/kbdtool/main.c | 164 +++++++++++++++++++++++++++ reactos/tools/kbdtool/output.c | 21 ++++ reactos/tools/kbdtool/parser.c | 21 ++++ reactos/tools/tools.rbuild | 3 + 5 files changed, 216 insertions(+) create mode 100644 reactos/tools/kbdtool/kbdtool.rbuild create mode 100644 reactos/tools/kbdtool/main.c create mode 100644 reactos/tools/kbdtool/output.c create mode 100644 reactos/tools/kbdtool/parser.c diff --git a/reactos/tools/kbdtool/kbdtool.rbuild b/reactos/tools/kbdtool/kbdtool.rbuild new file mode 100644 index 00000000000..ca23163941c --- /dev/null +++ b/reactos/tools/kbdtool/kbdtool.rbuild @@ -0,0 +1,7 @@ + + + + main.c + output.c + parser.c + \ No newline at end of file diff --git a/reactos/tools/kbdtool/main.c b/reactos/tools/kbdtool/main.c new file mode 100644 index 00000000000..d89a674eb79 --- /dev/null +++ b/reactos/tools/kbdtool/main.c @@ -0,0 +1,164 @@ +/* + * PROJECT: ReactOS Build Tools [Keyboard Layout Compiler] + * LICENSE: BSD - See COPYING.BSD in the top level directory + * FILE: tools/kbdtool/main.c + * PURPOSE: Main Logic Loop + * PROGRAMMERS: ReactOS Foundation + */ + +/* INCLUDES *******************************************************************/ + +#include +#include +#include +#include +#include "getopt.h" +#include + +/* GLOBALS ********************************************************************/ + +ULONG gVersion = 3; +ULONG gSubVersion = 40; +BOOLEAN UnicodeFile, Verbose, NoLogo, FallbackDriver, SanityCheck, SourceOnly; +ULONG BuildType; + +/* FUNCTIONS ******************************************************************/ + +void +usage() +{ + /* This is who we are */ + printf("\nKbdTool v%d.%02d - convert keyboard text file to C file or a keyboard layout DLL\n\n", + gVersion, gSubVersion); + + /* This is what we do */ + printf("Usage: KbdTool [-v] [-n] [-w] [-k] [-n] [-u|a] [-i|x|m|o|s] FILE\n\n"); + printf("\t[-?] display this message\n"); + printf("\t[-n] no logo or normal build information displayed\n\n"); + printf("\t[-a] Uses non-Unicode source files (default)\n"); + printf("\t[-u] Uses Unicode source files\n\n"); + printf("\t[-v] Verbose diagnostics (and warnings, with -w)\n"); + printf("\t[-w] display extended Warnings\n\n"); + printf("\t[-x] Builds for x86 (default)\n"); + printf("\t[-i] Builds for IA64\n"); + printf("\t[-m] Builds for AMD64\n"); + printf("\t[-o] Builds for WOW64\n"); + printf("\t[-s] Generate Source files (no build)\n\n"); + printf("\tFILE The source keyboard file (required)\n\n"); + + /* Extra hints */ + printf("\t-u/-a are mutually exclusive; kbdutool will use the last one if you specify more than one.\n"); + printf("\t-i/-x/-m/-o-s will exhibit the same behavior when than one of them is specified.\n\n"); + + /* Quit */ + _exit(1); + printf("should not be here"); +} + +int +main(int argc, + char** argv) +{ + CHAR Option; + + /* Loop for parameter */ + while (TRUE) + { + /* Get the options */ + Option = getopt(argc, argv, "aAeEiIkKmMnNOosSuUvVwWxX?"); + if (Option != -1) + { + /* Check supported options */ + switch (Option) + { + /* ASCII File */ + case 'A': + case 'a': + UnicodeFile = 0; + continue; + + /* UNICODE File */ + case 'U': + case 'u': + UnicodeFile = 1; + continue; + + /* Verbose */ + case 'V': + case 'v': + Verbose = 1; + continue; + + /* No logo */ + case 'N': + case 'n': + NoLogo = 1; + continue; + + /* Fallback driver */ + case 'K': + case 'k': + FallbackDriver = 1; + continue; + + /* Sanity Check */ + case 'W': + case 'w': + SanityCheck = 1; + continue; + + /* Itanium */ + case 'I': + case 'i': + BuildType = 1; + continue; + + /* X86 */ + case 'X': + case 'x': + BuildType = 0; + continue; + + /* AMD64 */ + case 'M': + case 'm': + BuildType = 2; + continue; + + /* WOW64 */ + case 'O': + case 'o': + BuildType = 3; + continue; + + /* Source only */ + case 'S': + case 's': + SourceOnly = 1; + continue; + default: + break; + } + + /* If you got here, the options are invalid or missing */ + usage(); + } + break; + } + + /* Do we have no options? */ + if (optind == argc) usage(); + + /* Should we announce ourselves? */ + if (!NoLogo) + { + /* This is who we are */ + printf("\nKbdTool v%d.%02d - convert keyboard text file to C file or a keyboard layout DLL\n\n", + gVersion, gSubVersion); + } + + /* Otherwise... do something */ + printf("Zoom zoom...\n"); +} + +/* EOF */ diff --git a/reactos/tools/kbdtool/output.c b/reactos/tools/kbdtool/output.c new file mode 100644 index 00000000000..c3c1fd0d621 --- /dev/null +++ b/reactos/tools/kbdtool/output.c @@ -0,0 +1,21 @@ +/* + * PROJECT: ReactOS Build Tools [Keyboard Layout Compiler] + * LICENSE: BSD - See COPYING.BSD in the top level directory + * FILE: tools/kbdtool/output.c + * PURPOSE: Output Logic (Source Builder) + * PROGRAMMERS: ReactOS Foundation + */ + +/* INCLUDES *******************************************************************/ + +#include +#include +#include +#include +#include + +/* GLOBALS ********************************************************************/ + +/* FUNCTIONS ******************************************************************/ + +/* EOF */ diff --git a/reactos/tools/kbdtool/parser.c b/reactos/tools/kbdtool/parser.c new file mode 100644 index 00000000000..39ea3fb5a42 --- /dev/null +++ b/reactos/tools/kbdtool/parser.c @@ -0,0 +1,21 @@ +/* + * PROJECT: ReactOS Build Tools [Keyboard Layout Compiler] + * LICENSE: BSD - See COPYING.BSD in the top level directory + * FILE: tools/kbdtool/parser.c + * PURPOSE: Parsing Logic + * PROGRAMMERS: ReactOS Foundation + */ + +/* INCLUDES *******************************************************************/ + +#include +#include +#include +#include +#include + +/* GLOBALS ********************************************************************/ + +/* FUNCTIONS ******************************************************************/ + +/* EOF */ diff --git a/reactos/tools/tools.rbuild b/reactos/tools/tools.rbuild index 164f65d2ec3..51025bead27 100644 --- a/reactos/tools/tools.rbuild +++ b/reactos/tools/tools.rbuild @@ -7,6 +7,9 @@ + + +