Improves build script performance by:
* using built-ins wherever possible (e.g. string splitting)
* eliminating redundant code
* using absolute (to $KEYMAN_ROOT) rather than relative paths to avoid realpath
* removing unnecessary `npm run` calls
BEFORE | AFTER
-------------------------------|----------------------
time ./core/build.sh --help |
real 0m2.116s | real 0m0.874s
user 0m0.578s | user 0m0.198s
sys 0m0.984s | sys 0m0.289s
-------------------------------|----------------------
time ./web/build.sh --help |
real 0m3.523s | real 0m0.757s
user 0m1.166s | user 0m0.320s
sys 0m2.273s | sys 0m0.455s
-------------------------------|----------------------
time ./web/build.sh -d |
real 1m34.750s | real 0m59.974s
user 0m9.721s | user 0m6.284s
sys 0m19.652s | sys 0m13.202s
@keymanapp-test-bot skip
Note: unit tests require manual build of keyboards in keyboards repo
using kmcmpdll.dll under Windows, and copying into the tests/fixtures
folder, prior to run, under non-Windows platforms.
(Later: will make it possible to build the reference keyboards using
kmcomp.exe on Windows.)
* fixes CheckFilenameConsistency to use Windows functions on Windows,
to check case differences, and only test for file existence on other
platforms which are already case sensitive.
* fixes memory leaks in usage of `wstrtostr2`, and eliminated the
function altogether.
* avoided use of u16sprintf for error messages, as it seems not to be
working correctly (long term, eliminate altogether, use C++ string
formatting).
* fix memory leak and overwrite of token in compiler error message.
* remove debug logging and namespace from filesystem.cpp
Unrelated to kmcmplib:
* improved logs in kmcomp tests (these tests are running on kmcmplib),
so it is easier to diagnose failing tests.
Moves filesystem functionality into filesystem.cpp (it was partially
in kmx_u16.h previously), and adds cross-platform switches. This brings
us most of the way towards being able to run kmcompx under WASM and in
theory other platforms (yet to be tested).
This fixes two issues:
1. `COMP_KEY` structure had padding that was not always zeroed out.
Made this explicit.
2. Rule sorting could be inconsistent when re-sorting rules that
use `+ any() > ...`, which are expanded at compile time into multiple
rules, and which ended up with identical sort keys due to lack of
precision. This relates to #8381 but only adds differentiation for
the otherwise ambiguous rule sort keys, and does not fix that issue,
which requires further investigation.
This is not enough for building to WASM, but wanted to split out the
bigger changes into their own PRs. This is mostly busy-work.
One serious bug fixed:
* u16string_from_string was not converting from UTF-16 correctly
Apart from that, just tidies up a few bits and pieces in kmcmplib:
* type coercion for json-validator.cpp (probably already fixed upstream)
* cleanup of build scripts for new builder variable names
* various compatibility macros for MSVC vs clang
* safer math expressions
* file name casing in headers
* replacement of various ms-only std funcs
* removed some unused variables and consts
* tightened up search for keyboards to get only keyboards in /source/
folders (may be possible to improve further in the future?)
This removes the remaining references to windows.h and windows types and
macros from kmcmplib.
A few TODO items have been added, mostly relating to shared code or
fixed buffer sizes.
Compiler version is now sourced from keymanversion.h.