Development Tools
ElenixOS uses many scripting tools during development to assist development. Below, we will introduce the usage of these tools in detail.
Environment Preparation
Before using development tools, you need to prepare the Python environment:
Create Virtual Environment
# Create virtual environment
python -m venv venv
# Activate virtual environment
source venv/bin/activate
# Install dependency packages
pip install -r scripts/requirements.txt
Application Packaging Tool
The application packaging tool (eos_pkg_builder.py) is used to package applications into .eapk or .ewpk files, containing all resources required by the application, such as icons, scripts, resource files, etc.
Features
- Package applications as .eapk files
- Package watchfaces as .ewpk files
- Include all resource files of the application
- Verify application configuration files
Usage
python scripts/eos_pkg_builder.py --input <input_path> --output <output_file> --type <type>
Parameter Description
| Parameter | Description | Example |
|---|---|---|
--input | Input directory path | app/ |
--output | Output file path | app.eapk |
--type | Packaging type | app or watchface |
--compress | Compression level (0-9) | 9 |
--verbose | Verbose output | --verbose |
Examples
# Package application
python scripts/eos_pkg_builder.py --input app/ --output app.eapk --type app
# Package watchface
python scripts/eos_pkg_builder.py --input watchface/ --output watchface.ewpk --type watchface
# Package with compression
python scripts/eos_pkg_builder.py --input app/ --output app.eapk --type app --compress 9
Binding Layer Generation Tool
The binding layer generation tool is used to automatically generate binding code between JavaScript and native code, mainly including SNI (Script Native Interface) and LVGL binding layer.
Tool List
extract_lvgl_types.py: Extract LVGL typesgen_lvgl_desc.py: Generate LVGL descriptiongen_sni_lv_types.py: Generate SNI LVGL types
Usage
# Extract LVGL types
python scripts/sni/extract_lvgl_types.py --input include/lvgl.h --output scripts/sni/config/lv_types.json
# Generate LVGL description
python scripts/sni/gen_lvgl_desc.py --input scripts/sni/config/lv_types.json --output scripts/sni/config/lv_desc.json
# Generate SNI LVGL types
python scripts/sni/gen_sni_lv_types.py --input scripts/sni/config/lv_desc.json --output src/script_engine/sni/sni_gen/sni_lv_types.c
Icon Generation Tool
The icon generation tool is used to convert SVG icons to C code for use in ElenixOS.
Tool List
gen_icon_def.py: Generate icon definitionsttf_mgr.py: Font management tool
Usage
# Generate icon definitions
python scripts/icon/gen_icon_def.py --input icons/ --output src/core/lang/eos_icon.c
# Font management
python scripts/icon/ttf_mgr.py --input font.ttf --output font.c --size 24
Build Tools
ElenixOS provides build scripts to simplify the build process:
Tool List
build.sh: Build scriptclean.sh: Clean build
Usage
# Build embedded version
./scripts/build.sh --platform stm32
# Clean build
./scripts/clean.sh
Debugging Tools
Logging Tool
ElenixOS provides logging tools for debugging and troubleshooting:
// Output logs
eos_log_i("Module", "Message: %d", value);
eos_log_e("Module", "Error: %s", error);
eos_log_w("Module", "Warning: %s", warning);
eos_log_d("Module", "Debug: %s", debug);
Development Tools Best Practices
- Environment isolation: Use virtual environments to isolate the development environment and avoid dependency conflicts
- Automation: Use build scripts to automate the build process
- Version control: Include generated code in version control to ensure code consistency
- Testing: Use embedded devices to test applications
- Documentation: Record tool usage and parameters for future reference
Common Issues and Solutions
Dependency Installation Failure
Issue: Dependency installation failed
Solution:
- Check if the network connection is normal
- Check if the Python version meets the requirements
- Try using
pip install --upgrade pipto upgrade pip
Tool Execution Failure
Issue: Tool execution failed
Solution:
- Check if input parameters are correct
- Check if dependencies are fully installed
- Check if file paths exist
Generated Code Error
Issue: Generated code compilation error
Solution:
- Check if input files are correct
- Check if tool versions are compatible
- Check if generation parameters are reasonable
Summary
ElenixOS provides a series of development tools to help developers develop and deploy applications more efficiently. These tools include application packaging tools, binding layer generation tools, icon generation tools, and build tools.
By using these tools, developers can simplify the development process, improve development efficiency, and ensure code quality. At the same time, these tools also provide support for ElenixOS's continuous integration and continuous deployment.
This document introduces the usage and best practices of ElenixOS development tools, hoping to help developers better use these tools and develop high-quality applications.