Keil Project Compilation
Invoke py_keil_build.py to compile projects via Keil UV4 command-line interface, and return structured build results.
Tool Script
Script Path: py_keil_build.py
Dependencies: Python 3.x standard library + Installed Keil MDK (with UV4.exe)
Usage
# Incremental build (default)
python py_keil_build.py -p <project.uvprojx>
# Full rebuild (clean rebuild)
python py_keil_build.py -p <project.uvprojx> -r
# Specify UV4.exe path
python py_keil_build.py -p <project.uvprojx> -k "D:\keil\UV4\UV4.exe"
Parameter Description
| Parameter | Short | Description | Default |
|---|---|---|---|
--project |
-p |
.uvprojx file path |
Required |
--keil |
-k |
UV4.exe path | D:\application\keil_v5\UV4\UV4.exe |
--rebuild |
-r |
Full rebuild | Incremental build |
Output Structure
Returns JSON format result:
{
"status": "success", // "success" or "failed" or "error"
"log_path": "C:\\project\\Objects\\GD32F303RCT6.build_log.htm", // 编译日志路径
"errors": 0, // 编译错误数
"warnings": 3 // 编译警告数
}
Notes
- Keil default installation path:
D:\application\keil_v5\UV4\UV4.exe, if different please specify with-k - Build output is printed directly to terminal (no log file generated)
- Build success is determined by checking if
*build_log*.htmexists after compilation- First checks:
<project_dir>\Objects\*build_log*.htm - Falls back to searching recursively in project directory
- First checks:
Typical Workflow
- First use
keil-parserto confirm project configuration is correct - Call this tool to build, check if
errors_countis 0 - After successful build, use
jlink-downloadto flash firmware
