Commit graph

134 commits

Author SHA1 Message Date
Marc Durdin
a8d0d8454c feat(developer): add api documentation to build
Relates to #10207.

Adds the `api` action to build.sh for each affected module. The `api`
action for each module will generate the api metadata files, and then
the markdown files are generated by /developer/build.sh api.

Note that developer-utils, kmc, and kmcmplib have no api documentation
at this time (and kmcmplib is not Typescript so would need separate
tooling anyway).
2024-02-26 11:45:36 +07:00
Marc Durdin
457275e46f fix(developer): ensure fatal errors report message or made non-fatal
Fixes #10678.

Some messages have been reduced to ERROR instead of FATAL, as they are
not internal compiler errors.

Where fatal messages are raised, the message will now be reported
through correctly to Sentry.
2024-02-20 11:10:39 +07:00
Marc Durdin
e983818bda feat(developer): warn on usage of virtual keys in rule output
Fixes #10059.

Use of the unsupported and undocumented virtual key output, that doesn't
work in recent Keyman versions, at all, now results in a build warning.

Only a warning, because it did kinda work in old versions of Keyman.
2023-11-23 15:13:56 +10:00
Marc Durdin
fa30924b54 chore(developer): common/include dep for kmcmplib
Fixes #9929.
2023-11-03 13:31:45 +07:00
Marc Durdin
d9e759a8d2 chore(developer): address review comments 2023-11-02 11:05:23 +07:00
Marc Durdin
8c1f3c4783 fix(developer): raise error if virtual key in context string
Fixes #7880.

Virtual keys have never been allowed in context. This should be an error
in a keyboard. Note: virtual keys in output are officially unsupported
but still kinda sorta a little bit work in Windows -- but I doubt they
will ever be officially supported.

Also includes small side journey to tidy up names and constants for two
other tests (error_duplicate_group and error_duplicate_store).
2023-10-31 14:04:26 +07:00
Marc Durdin
f61e65ceb9
Merge pull request #9736 from keymanapp/chore/merge-master-into-package-metadata
chore: merge master into package-metadata
2023-10-11 11:28:07 +11:00
Marc Durdin
ba5f18defd chore: rename km_kbp_ to km_core_ 2023-10-09 14:53:13 +07:00
Marc Durdin
693aee5c99
Merge branch 'epic/package-metadata' into chore/merge-master-into-package-metadata 2023-10-04 19:34:16 +11:00
Marc Durdin
7adc9b5d95 feat(developer): support store(&version) '17.0'
Fixes #9541.

Also adds version 16.0 support to the kmcmplib compiler constants, and
unit tests for both versions. Does not add any support for automatic
version feature detection, because that forces an inverted dependency on
the touch layout compilation phase (done in kmc-kmw), which would be a
significant refactor. This may be something we need to support in the
future.
2023-10-02 15:30:07 +07:00
Marc Durdin
454448bc63 chore: use kmc instead of kmcomp to build test keyboards 2023-09-16 15:24:46 +07:00
Marc Durdin
3a2540b077 feat(developer): remove kmcomp
Removes kmcomp.dpr, related source, compilekeymanweb.pas, and related
unit tests.

Cleans up a couple of bits and pieces around kmc in order to help tests
to pass, and updates some tests that had legacy code in them
(particularly missing &TARGETS stores).
2023-09-09 17:47:15 +02:00
Marc Durdin
4c07b6c49c feat(developer): remove kmcmpdll 2023-09-02 12:25:29 +04:00
Marc Durdin
cdf026c2ba chore: Merge branch 'feature-kmc-kmw' into chore/merge-master-into-feature-kmc-kmw-a17s18 2023-08-04 12:54:10 +07:00
Steven R. Loomis
e1d5513952
Update developer/src/kmcmplib/src/meson.build
Co-authored-by: Marc Durdin <marc@durdin.net>
2023-07-31 22:09:34 -05:00
Steven R. Loomis
8c2cd8916a fix(developer): fix breakage from emscripten 3.1.44
- use wasmExports.malloc if available otherwise asm.malloc
2023-07-31 11:16:49 -05:00
Marc Durdin
b0652c2afc chore(developer): wasm debug symbols and upload to sentry 2023-07-13 13:42:47 +07:00
Marc Durdin
b435471b24 feat(developer): add sentry reporting for kmc
Fixes #9113.

Adds sentry reporting, plus helper functions, for kmc. Includes the
now-standard `-sentry-client-test-exception` command line parameter,
with `kmcmplib` and `event` sub-options available.

Uploads kmc* sourcemaps to sentry on a release build.

On Windows, honours the registry setting for error reporting. Also
includes a command line option `--[no-]error-reporting` (must be used
prior to initial command, e.g. `kmc --no-error-reporting build ...`).
2023-07-11 15:45:41 +07:00
Marc Durdin
5c0f0e87a8 chore: Merge branch 'feature-kmc-kmw' into chore/merge-master-into-feature-kmc-kmw-A17S16 2023-07-07 09:53:34 +07:00
Marc Durdin
d2acfdec5c fix(developer): improve kmcmplib/kmw compiler performance
Fixes #9154.

Improves performance in both kmcmplib and in kmc-kmn/kmw-compiler. After
these changes are applied, vietnamese_telex keyboard builds in around 6
seconds on my machine (down from over 2 minutes). This is certainly only
the surface of performance improvements we could make.

Addresses excessive memory reallocations in kmcmplib, by reallocating
store and key arrays in large chunks of 100 items rather than
reallocating on each new item added. This resulted in a 250x speed-up on
functions such as `AddStore` in WASM build.

Some careful modulus arithmetic was needed for resizing the key array,
which can be grown in larger increments.

Resolved excessive zeroing out of destination buffer in u16ncpy, which
was being called with an 8kb destination buffer on every line of the
file.

In the kmw side, vast majority of the performance cost was in copying of
buffers while loading a .kmx into memory, rather than creating views
into the memory. Essentially replaced this pattern:

```
return this.rString.fromBuffer(source.slice(offset));
```

with:

```
const data = new Uint8Array(source.buffer, source.byteOffset + offset);
return this.rString.fromBuffer(data);
```
2023-07-04 14:36:25 +07:00
Steven R. Loomis
0f0c1e5e61 feat(common): preflighting on uset 🙀
- allow uset to preflight (calculate # of ranges)

For: #7377
2023-07-03 18:48:48 -05:00
Marc Durdin
be0b2ae583 fix(developer): allow kmcmplib memory usage to grow
Fixes #9112.

Note that this does not address any performance concerns which are a
much bigger issue; it just avoids the crash.
2023-07-03 09:27:53 +07:00
Marc Durdin
562ced5213 fix(developer): GetDelimitedString was using wrong strchr
Picked this up while running `-fsanitize=address` for trying to track
down another bug.

This fixes a buffer overrun (normally invisible) in kmcmplib, where
`xstrchr` was being called, which takes a string as its second
parameter, but being passed a single character. This was incorrect
behaviour for two reasons:

1. Passing a single character doesn't have null termination (big bug!)
2. We were not wanting xstring semantics on the token being parsed here

Replaced with `u16chr`, which does do what we want. Note the
casting because `u16chr` only has a `const` version of its input/output
at present.

Removed `xstrchr` because it is not used anywhere else in kmcmplib.
2023-06-30 08:24:11 +07:00
Marc Durdin
3b735cdc80 fix(developer): ensure delete uses array semantics where appropriate
The kmcmplib compiler source used `delete` instead of `delete[]` in a
number of locations where the corresponding allocation was an array.

This doesn't appear to matter on arrays of primitives on most platforms
that we are targeting, but it _is_ undefined behaviour so we should
correct it.

https://stackoverflow.com/a/2425749/1836776
2023-06-30 08:14:38 +07:00
Marc Durdin
69f679693a
Merge pull request #9088 from keymanapp/chore/developer/kmc-kmn-kmw-compiler-cleanup
chore(developer): cleanup for kmw-compiler.ts 🗜
2023-06-26 17:28:15 +10:00
Marc Durdin
313ad95ecd
Merge pull request #9076 from keymanapp/fix/developer/kmc-kmw-readonly-groups
fix(developer): support readonly groups in kmc-kmn/kmw-compiler 🗜
2023-06-26 17:27:51 +10:00
Marc Durdin
c3bb426ff0
Merge pull request #9075 from keymanapp/fix/developer/kmc-kmw-options-stores
fix(developer): support option stores in kmc-kmn/kmw 🗜
2023-06-26 17:27:41 +10:00
Marc Durdin
b5a1e13d50 chore(developer): add store.line metadata and cleanup 2023-06-26 08:59:56 +07:00
Marc Durdin
d6721f68ba chore: Merge branch 'feature-kmc-kmw' into chore/merge-master-into-feature-kmc-kmw 2023-06-23 15:44:06 +07:00
Marc Durdin
da51f545e1 fix(developer): support readonly groups in kmc-kmn/kmw-compiler
Adds support for readonly groups and corresponding unit test. Again
required more metadata from kmcmplib; this metadata is now fairly
straightforward to patch in without side-effects, which is encouraging.
2023-06-23 15:26:21 +07:00
Marc Durdin
dee046e647 chore(developer): tweak comments 2023-06-23 14:29:14 +07:00
Marc Durdin
8432b06547 fix(developer): support option stores in kmc-kmn/kmw
Adds support for option stores to kmc-kmn/kmw-compiler. This required
adding the relevant store metadata into the output from kmcmplib, and
so I also tidied up the corresponding WASM interfaces slightly more in
the process.

Added unit test for the options store.

While testing this, ran into a second bug with the way I ported a
constant from Delphi to Typescript in constants.ts, so fixed that and
added a corresponding unit test. Small steps, but good ones.
2023-06-23 14:21:30 +07:00
Marc Durdin
24910fb25a chore(developer): cleanup data passing from wasm
Reorganizes the data structures passed out of kmcmplib via WASM to make
it easier to work with the extra metadata and reduce the number of
places we have to touch when we add extra metadata fields.

Preparation for supporting the metadata that the kmw compiler requires.
2023-06-21 15:33:09 +07:00
Marc Durdin
0bd2ca4821 refactor(developer): kmc-kmw becomes component of kmc-kmn
Moves kmc-kmw to being a sub-component of kmc-kmn, as it can never be
independently instantiated anyway. Reorganized tests accordingly.

Note that c8 is currently disabled for kmw-compiler, until we add unit
tests for it.
2023-06-20 11:52:23 +07:00
Marc Durdin
cf91dd378b chore(developer): remove extraneous comment 2023-06-19 15:32:34 +07:00
Marc Durdin
6462b5fc63 refactor(developer): kmc-kmn now builds .js when needed
kmc-kmn calls into kmc-kmw to build .js when it is needed, rather than
kmc-kmw depending on kmc-kmn. This means examining the `&targets` system store
to determine which files need to be generated.

This also implements the `&displayMap` rewrite for both .kvks and
.keyman-touch-layout as part of the KMW compiler.

I suspect that the next step is to place kmc-kmw into a subfolder of
kmc-kmn, given they are part of the same process, and there is no
practical way to separate out the .js generation from the .kmx
generation.
2023-06-19 15:25:09 +07:00
Marc Durdin
adfa032e6f feat(developer): add &displayMap system store
The &displayMap system store adds support for a mapping file that remaps
the On Screen Keyboard files -- .kvks and .keyman-touch-layout, at
compile time, to new ranges. This is specifically intended to resolve a
limitation of unattached marks and diacritics which display
inconsistently across platforms; this is described in more detail in
issue #9031.
2023-06-17 16:21:26 +07:00
Marc Durdin
6db014224c chore(developer): enable hint message for non-Unicode source files 2023-06-12 12:00:48 +07:00
Marc Durdin
57af86ea9c chore(developer): support cp1252 'ansi' keyboards
Fixes #8955.

Adds a mapping table for CP1252 to USV so that we can compile very old
"ANSI"-encoded Keyman keyboard files with kmcmplib, to match kmcmpdll
support.
2023-06-12 11:43:29 +07:00
Marc Durdin
52a08ef21a
Merge pull request #8934 from keymanapp/chore/core/emscripten-location-tweaks
chore(core): look for emcc.py, not emcc
2023-06-07 12:17:35 +10:00
Marc Durdin
044a14f1d9 chore(core): look for emcc.py, not emcc
Relates to #8913.
2023-06-06 07:07:07 +07:00
Marc Durdin
18a3ef36bc chore(developer): ensure kmcmplib messages are all UTF-8
Fixes #8887.
2023-06-05 15:46:40 +07:00
Marc Durdin
d7f22b186f chore(developer): verify long lines compile correctly
Fixes #8888.

Verifies that wrapped lines (ending in \) are handled correctly in
kmcmplib.
2023-06-02 12:01:58 +07:00
Marc Durdin
7301281247 chore(developer): loadFile callback error check and optimization
Fixes #8885.

Adds some optimization and error checking to the loadFile callback in
kmc-kmn. Also handles case of zero-byte bitmap file so we won't crash on
it.
2023-06-01 15:31:31 +07:00
Marc Durdin
c3458d040c refactor(developer): move filename consistency check to kmc
kmcmplib no longer has any filesystem access, so it cannot verify if a
referenced filename in a source file has the same case as the actual
filename on disk (a risk when moving projects between platforms). So
I opted to move this to the `loadFile` callback in kmc, which is the
only place where filesystem is actually accessed, and added
corresponding unit test.

Small additional fixes here:

1. Move from `Buffer` to `Uint8Array` in all kmc-* modules, so that we
   remove that barrier to running on web.
2. Use `callbacks.loadFile` instead of `callbacks.fs.readFileSync`, so
   that we can be sure to run the filename consistency check.
3. Fixed kps parser silently swallowing xml errors on load.
4. Added silent mode to NodeCompilerCallbacks so we could cleanly test
   the new filename consistency hint.
5. Noted a location where we still have NodeJS deps in kmc-ldml.
2023-06-01 15:11:38 +07:00
Marc Durdin
c3ecae4e98 refactor(developer): rearrange kmcmplib interface source
Fixes #8889.

No code changes, just moves WASM interfaces into
CompilerInterfacesWasm.cpp, and CompileKeyboardHandle is renamed to
CompileKeyboardBuffer and moved into its own source file.
2023-06-01 05:29:19 +07:00
Marc Durdin
6f4f20acb8 chore(developer): Add TODO issue numbers to PR 2023-06-01 05:02:24 +07:00
Marc Durdin
47c8a95fb0 refactor(developer): complete fs move out of kmcmplib
* Moves filesystem access out of kmcmplib into kmc-kmn
* Adds filesystem access callback to kmcmplib unit tests
* Cleans up callback interface through wasm
* Adds unit tests for various file load scenarios
* Removes nodefs dependency from kmcmplib wasm build, and removes
  corresponding path mappings which were previously required for wasm
  builds; note that these are still present for the unit tests for
  kmcmplib.
2023-06-01 05:02:23 +07:00
Marc Durdin
980b893644 refactor(developer): move fs for kmn load to caller 2023-06-01 05:02:22 +07:00
Marc Durdin
f36a908d94 chore(developer): move keyboard repo fixtures
Relocates the keyboard-repo fixtures so we can add other local fixtures
for unit tests.
2023-05-30 13:08:53 +07:00