vgg_runtime
vgg_runtime copied to clipboard
The official implementation of VGG Specs with cross-platform rendering and scripting capabilities.
VGG Runtime
VGG Runtime is an implementation of VGG Specs with cross-platform vector graphics rendering and user interaction capabilities. It accepts any file conforming to the VGG Specs as input.
NOTE A
.darumafile is one such type of input that you can convert from other design files using the VGG Command-line tool.
Cross Platform Support
| Platform\Arch | X86 | ARM | RISC-V | WASM |
|---|---|---|---|---|
| Linux | ✅ | ✅ | ✅ | N/A |
| Android | ❌ | ⛏️ | ⭕️ | N/A |
| Harmony | ❌ | ⛏️ | ⭕️ | N/A |
| iOS | N/A | ✅ | N/A | N/A |
| macOS | ✅ | ✅ | N/A | N/A |
| Windows | ✅ | ❌ | N/A | N/A |
| WASM | N/A | N/A | N/A | ✅ |
✅ Supported ⛏️ Working in process ⭕️ Not supported (but planned) ❌ Not supported (no official plan)
Tested embedded devices on Linux
- ARM: Macbook M2, Raspberry Pi 4B
- RISC-V: Lichee Pi 4A
How To Build
This project can be built straightforwardly with CMake using common practices, though the dependencies might be a bit complicated.
1. Build Requirements
- C++ compiler supports C++20 or higher
- CMake >= 3.19
- Ninja and Python3 is required for building Skia and Nodejs
- Netwide Assembler (NASM) for building Nodejs under Windows
NOTE For the Python 3.12, you have to
pip install setuptoolswhen building Nodejs
2. Dependent Libraries
- Use
git submodule update --init --recursiveto fetch VGG submodules. - Libraries that will be automatically downloaded and built
- Nodejs
- Skia
- (windows only) SDL2
- System/user-provided libraries
- (except for windows) SDL >= 2.26
- (optional) Vulkan SDK with SPIR-V tools
Optional: Specify Skia manually
You can also use your own Skia by specifying SKIA_DIR:
cmake .. -DSKIA_DIR=/path/to/your/skia
Skia can be downloaded from the official website. We use our Skia fork vgg/m116 branch for building, which has some modifications and fixes for our scenario. We don't assure other versions could be successfully compiled using our CMake script.
3. Build Examples
Linux/macOS building example
mkdir build
cd build
cmake ..
cmake --build . --parallel
Note: For release build, please add
-DCMAKE_BUILD_TYPE=Releaseto the firstcmakecommand.
Windows building example
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug -G "Visual Studio 17 2022"
cmake --build . --parallel --config Debug -t sdl_runtime
Note: For release build, just replace
DebugwithRelease.
WebAssembly building example
Emscripten SDK is required to build WebAssembly version. You should install and activate at least one version of emsdk before proceeding.
mkdir build.wasm
cd build.wasm
source /path/to/emsdk/emsdk_env.sh
emcmake cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build . --parallel
iOS building example
Build & install vgg_container libraries for vgg_ios.
mkdir build.ios
cd build.ios
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../cmake/vgg.ios.toolchain.cmake -DVGG_VAR_TARGET="iOS"
# cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE=../cmake/vgg.ios.toolchain.cmake -DVGG_VAR_TARGET="iOS-simulator"
cmake --build . --parallel -t vgg_container
cmake --install . --prefix <path/to/vgg_ios/VggRuntime/external>
Android Building example
We currently only support Android NDK = 27 and Android API_LEVEL >= 24.
You need to download Android NDK r27 from here: https://github.com/android/ndk/releases/tag/r27
Build & install vgg_container libraries for vgg_android.
# For x86_64
mkdir build.android.x86_64
cd build.android.x86_64
cmake .. -DCMAKE_TOOLCHAIN_FILE=<android_ndk_path>/build/cmake/android.toolchain.cmake -DVGG_VAR_TARGET="Android-x86_64" -DANDROID_NDK=<android_ndk_path> -DANDROID_PLATFORM=android-24 -DANDROID_ABI=x86_64
cmake --build . --parallel
cmake --install . --prefix <path/to/vgg_android>/VggRuntime/external/x86_64
# For arm64
cd ..
mkdir build.android.arm64
cd build.android.arm64
cmake .. -DCMAKE_TOOLCHAIN_FILE=<android_ndk_path>/build/cmake/android.toolchain.cmake -DVGG_VAR_TARGET="Android-arm64-v8a" -DANDROID_NDK=<android_ndk_path> -DANDROID_PLATFORM=android-24 -DANDROID_ABI=arm64-v8a
cmake --build . --parallel
cmake --install . --prefix <path/to/vgg_android>/VggRuntime/external/arm64-v8a
Qt building example
Build & install vgg_container libraries for vgg_qt.
mkdir build.qt
cd build.qt
cmake .. -DVGG_CONTAINER_FOR_QT=ON -DCMAKE_BUILD_TYPE=Release
cmake --build . --parallel -t vgg_container --config Release
cmake --install . --component container --config Release --prefix <path/to/vgg_qt/VggContainer/external>
Note: For debug build, please replace
ReleasewithDebugto thecmakecommands.
4. Unit test
Linux/macOS unit test
cd build
cmake .. -DENABLE_UNIT_TEST=ON
cmake --build . --parallel -t unit_tests
ctest
How To Run
Make sure you have built the sdl_runtime target. Then in the build directory, run it with
./sdl_runtime /path/to/your/file.daruma
where file.daruma is a file conforming to VGG Specs, which can be generated using VGG Command-line tool. An example could be downloaded here.
Running with custom font configuration
VGG Runtime uses fonts in system directories by default, but you can assign extra font folders in a configuration file as follows
./sdl_runtime /path/to/your/file.daruma -c /path/to/your/config.json
where an example of config.json is provided in asset/etc/config.json.
Star History
LICENSE
VGG Runtime is licensed under VGG License, which includes a royalty fee under certain conditions.
You can find a simplified explanation in VGG FAQ if you don't want to read the tedious license.
And you are welcome to contribute to this project under VGG's Contributor Reward Program.