spiegel-keyman/developer/src/kmc/src/commands/buildClasses/BuildLdmlKeyboard.ts
Marc Durdin f4918d36e2 feat(developer): refactor common compiler steps into BuildActivity.runCompiler
Relates to #9473.

Now that each compiler has a common interface, we can consolidate the
common code into BuildActivity. This makes it very easy to see where the
compiler calls have special cases, such as the model_info and
keyboard_info compilers (these are primarily for internal use, so the
special case work should not be a problem).
2023-12-11 10:10:31 +07:00

19 lines
1.2 KiB
TypeScript

import * as kmcLdml from '@keymanapp/kmc-ldml';
import { CompilerCallbacks, LDMLKeyboardXMLSourceFileReader, CompilerOptions, KeymanFileTypes } from '@keymanapp/common-types';
import { BuildActivity } from './BuildActivity.js';
import { fileURLToPath } from 'url';
export class BuildLdmlKeyboard extends BuildActivity {
public get name(): string { return 'LDML keyboard'; }
public get sourceExtension(): KeymanFileTypes.Source { return KeymanFileTypes.Source.LdmlKeyboard; }
public get compiledExtension(): KeymanFileTypes.Binary { return KeymanFileTypes.Binary.Keyboard; }
public get description(): string { return 'Build a LDML keyboard'; }
public async build(infile: string, outfile: string, callbacks: CompilerCallbacks, options: CompilerOptions): Promise<boolean> {
// TODO-LDML: consider hardware vs touch -- touch-only layout will not have a .kvk
const ldmlCompilerOptions: kmcLdml.LdmlCompilerOptions = {...options, readerOptions: {
importsPath: fileURLToPath(new URL(...LDMLKeyboardXMLSourceFileReader.defaultImportsURL))
}};
const compiler = new kmcLdml.LdmlKeyboardCompiler();
return await super.runCompiler(compiler, infile, outfile, callbacks, ldmlCompilerOptions);
}
}