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?)
In order to allow us to reference the padding in the FILE_KEY structure,
for reproducible and cross-platform consistent builds, turn the padding
into an `_reserved` (must always be zero) field.
Changes to compiler to utilise this will be in a follow-up commit.
In order to be able to provide a more robust round-trip comparison of
existing .kmx binary fixtures with compiler output, this commit rebuilds
them with the `-no-compiler-version` kmcomp flag, to omit the
`TSS_COMPILEDVERSION` store.
Appending a `+` to a builder option will automatically pass that option to child scripts.
Applying #8371 to master branch and @darcywong00 will then re-apply to #7407
Fixes#8373.
Note that the core functionality requested in #8373 is already in place;
this commit just does some cleanup to make this easier to maintain in
the future:
* Uses `builder_is_debug_build` function to test for debug build
(instead of `builder_has_option --debug`, which would also work but
using the other function avoids typo issues with the option name).
* Renames `$_builder_debug` to `$_builder_debug_internal` to reduce
naming confusion
* Documents `$builder_debug`, `builder_is_debug_build`, and clarifies
usage of `--debug` option.
* Logs command line for dep builds (we could hide this in the future,
but it certainly doesn't hurt for now!)