Update unit test build/run scripts to use build_rive.sh (#10320) 4bd8c63b93 * Update unit test scripts to use build_rive.sh The unit test test.bat and test.sh were doing their own ad-hoc building instead of using build_rive. This updates test.sh to call build_rive.sh for the build. This script could probably be pared down further but I did not want to break any of the existing command line arguments that people are probably using. Additionally, test.bat did not have up-to-date build flags in it, so now it does a similar Windows development environment setup to build_rive.bat and then calls directly into test.sh, so it won't get out of sync with the main script anymore. * Additional test.sh changes - There was a block of code that I could have removed but didn't (made redundant by the call to build_rive) - Add build_rive's parent directory to the path before calling it (will fix the test failing on Linux) - Removed the `sh` before build_rive.sh as it does not need to be shell invoked. * The pr_unit_tests.yaml execution for Mac needed to do a clean furing the asan build because it had already done a build without asan before, the change to build_rive means that we now catch the premake parameter change (adding asan), and so clean needs to happen for that build to be correct. * For now, move the build_rive.sh call into the two branches that previously had the build calls (linux, for instance, does not build, which seems incorrect given the github workflow is trying to run it. * Adding a note to test.sh to describe why the build_rive script is called in the way it is (vs. the obvious way) * Additional unit test script fixes (unifying windows build further, and some warnings) - Add the ability to specify a toolset on the command line (i.e. "--toolset=msc") that will get passed along to build_rive (thus making the 'clang' toolset in the windows build only a default) - Update the unit_test_windows and unit_test_windows_msvc entries in the github unit test workflows to call test.bat now (which required combining the build/run steps, but this matches all the other configurations) - Also added some additional parameter validation, mainly warnings on ignored/unsupported parameters Co-authored-by: JoshJRive <joshua@rive.app>

Rive C++ is a runtime library for Rive, a real-time interactive design and animation tool.
The C++ runtime for Rive provides these runtime features:
We use premake5. The Rive dev team primarily works on MacOS. There is some work done by the community to also support Windows and Linux. PRs welcomed for specific platforms you wish to support! We encourage you to use premake as it's highly extensible and configurable for a variety of platforms.
In the rive-cpp directory, run build.sh to debug build and build.sh release for a release build.
If you've put the premake5 executable in the rive-cpp/build folder, you can run it with PATH=.:$PATH ./build.sh
Rive makes use of clang vector builtins, which are, as of 2022, still a work in progress. Please use clang and ensure you have the latest version.
Uses the Catch2 testing framework.
cd tests/unit_tests ./test.sh
In the tests/unit_tests directory, run test.sh to compile and execute the tests.
(if you've installed premake5 in rive-runtime/build, you can run it with PATH=../../build:$PATH ./test.sh)
The tests live in rive/test. To add new tests, create a new xxx_test.cpp file here. The test harness will automatically pick up the new file.
There's a VSCode command provided to run tests from the Tasks: Run Task command palette.
rive-cpp uses clang-format, you can install it with brew on MacOS: brew install clang-format.
Note that if you‘re on MacOS you’ll want to install valgrind, which is somewhat complicated these days. This is the easiest solution (please PR a better one when it becomes available).
brew tap LouisBrunner/valgrind brew install --HEAD LouisBrunner/valgrind/valgrind
You can now run the all the tests through valgrind by running test.sh memory.
If you want to examine the generated assembly code per cpp file, install Disassembly Explorer in VSCode.
A disassemble task is provided to compile and preview the generated assembly. You can reach it via the Tasks: Run Task command palette or you can bind it to a shortcut by editing your VSCode keybindings.json:
[
{
"key": "cmd+d",
"command": "workbench.action.tasks.runTask",
"args": "disassemble"
}
]