The `SetError` macro emitted `return FALSE;` which was confusing for
reviewing code flow. Replaced with explicit `AddCompileMessage()` and
`return FALSE;`.
FILE_KEYBOARD is a structure used in multiple libraries and languages.
It is passed around between kmcmplib, kmcmpdll, and kmcomp, with three
separate definitions (kmcmplib/compfile.h, kmcmpdll/compfile.h, and
kmcomp/compile.pas). These duplicate definitions must be maintained for
now because of type issues between the legacy kmcmpdll and kmcmplib,
which means that the definitions must be kept in sync.
Because FILE_KEYBOARD_EXTRA has a C++ class in it, it will be
initialized in CompileKeyboardHandle rather than in the caller, so
FILE_KEYBOARD.extra is now a pointer rather than a struct.
When original kmcomp and kmcmpdll are eventually removed, these
duplications will disappear and some of the memory management and
lifecycle will become easier to manage.
This starts the refactor of the .kmn compiler interfaces for WASM,
moving more file writes into typescript and out of the compiler. Adds a
cleaner binding and structures for passing compile metadata back to
typescript for additional build steps (e.g. kvk, js builds).
Will rebase the Typescript-based KMW compiler onto this so it can start
to benefit from the refactoring.
* Fixes a minor issue with loading a .kvks file with an empty flags set.
* Adds a writeFileSync method to the compiler callback interfaces.
* Adds an e2e compiler test to verify that .kmx and .kvk are both
correctly compiled.
Stage one of the kmcmplib filesystem refactoring, as we move to writing
to buffers and allowing caller to write to disk. Moves responsibility
for writing data out of WriteCompiledKeyboard and into
kmcmp_CompileKeyboardFile. This means that there are now no file writes
in Compiler.cpp, except for the temp UTF16fromUTF8 (which I will also
change to a in-memory buffer "real soon now").
Note that responsibility for writing in kmcmp_CompileKeyboardFile is
very much temporary as we'll move it out of the library altogether in
a subsequent commit.
Adds `ERROR_PackageMustContainAPackageOrAKeyboard` and corresponding
unit tests. A couple of unit tests tweaked as their fixtures were no
longer valid!
This is a transfer of the functionality in the legacy package compiler;
we could go much further in verifying file types and excluding certain
files, but that's a big design session. For now, just refreshed to
include the set of Keyman for Windows and Keyman Engine for Windows
files which are most likely to be accidentally included.
Adds WARN_RedistFileShouldNotBeInPackage and WARN_DocFileDangerous and
corresponding unit tests and constant declarations.
Adds checks for bcp47 tag metadata for keyboards and lexical models --
both validity and minimality. Adds `ERROR_LanguageTagIsNotValid` and
`WARN_LanguageTagIsNotMinimal` messages and corresponding unit tests.
This was implemented by extending the existing duplicate id check, so
renamed that function accordingly.
Downgrades `Warn_KeyboardFileHasNoKeyboardVersion` to
`Info_KeyboardFileHasNoKeyboardVersion`, because this is not an error,
or even something wrong necessarily; it's just something it's good to be
aware of. Updates unit test for kmc to cater for the extra message.
Adds `WARN_KeyboardVersionsDoNotMatch` and
`WARN_KeyboardVersionsDoNotMatchPackageVersion`.
Adds unit tests. Several other 'invalid' packages needed corrections
after adding this validation. Note that one unit test was deleted
because it could never be satisfied after adding this validation step.
Refactor the `extractKeyboardVersionFromKmx` function into a new class
and add extra version checking. This caused a bit of a cascade of test
failures due to some of the 'invalid' fixtures actually being invalid
in multiple ways, so the fixtures have been corrected to only be wrong
in a single way -- the way they are supposed to be broken. This means
additional fixture files in the 'invalid' folder.
Now updates keyboard version metadata for all keyboards in the package.
Upgrades `WARN_FollowKeyboardVersionButNoKeyboards` to
`ERROR_FollowKeyboardVersionButNoKeyboards`, as this leads to invalid
package metadata on build.
Renames `ERROR_KeyboardFileNotFound` to
`ERROR_KeyboardContentFileNotFound` to better reflect that no `<File>`
in the package is found to match a given `<Keyboard>` entry.
Adds `ERROR_KeyboardFileNotFound` when a referenced .kmx does not exist.
Adds and updates corresponding unit tests.
developer:
- update wasm machinery in kmc-kmn to be more self contained
- improve exception situation in wasm functions
common:
- compilerErrorFormatCode() for formatting the raw code such as for tests
- compilerExceptionToString() for formatting exceptions in messages
for: #7234
Adds `WARN_PackageNameDoesNotFollowKeyboardConventions` and
`WARN_PackageNameDoesNotFollowLexicalModelConventions`, refactoring as
required to test filenames, and adds unit tests for same.