1*61046927SAndroid Build Coastguard Worker# meson_to_hermetic: automated build system generation 2*61046927SAndroid Build Coastguard Worker 3*61046927SAndroid Build Coastguard WorkerGoal: ease the integration of Mesa as a component inside larger projects like 4*61046927SAndroid Build Coastguard WorkerAndroid (AOSP). 5*61046927SAndroid Build Coastguard Worker 6*61046927SAndroid Build Coastguard WorkerHow: parse the meson build tree into a python build script, which can be used 7*61046927SAndroid Build Coastguard Workertogether with configuration and options to generate other kinds of build scripts. 8*61046927SAndroid Build Coastguard Worker 9*61046927SAndroid Build Coastguard WorkerStatus: useful, but rough. Supports Android (Soong) and Fuchsia (Bazel). 10*61046927SAndroid Build Coastguard Worker 11*61046927SAndroid Build Coastguard Worker## Python Dependencies 12*61046927SAndroid Build Coastguard Worker- Python 3.11+ 13*61046927SAndroid Build Coastguard Worker - See `requirements.txt` 14*61046927SAndroid Build Coastguard Worker - [](https://github.com/astral-sh/ruff) 15*61046927SAndroid Build Coastguard Worker 16*61046927SAndroid Build Coastguard Worker## Environment Setup 17*61046927SAndroid Build Coastguard Worker 18*61046927SAndroid Build Coastguard Worker1. Open a terminal within `mesa3d/meson_to_hermetic` 19*61046927SAndroid Build Coastguard Worker2. Run the `setup-venv.sh` file to automatically create a python3 venv and install dependencies. 20*61046927SAndroid Build Coastguard Worker 21*61046927SAndroid Build Coastguard Worker## Linting the code 22*61046927SAndroid Build Coastguard Worker1. Before pushing code for review; run `lint.sh` to automatically lint all of the python scripts. 23*61046927SAndroid Build Coastguard Worker - IMPORTANT: Run the lint.sh from the `meson_to_hermetic` directory. 24*61046927SAndroid Build Coastguard Worker 25*61046927SAndroid Build Coastguard Worker## 1 - Generate python from meson 26*61046927SAndroid Build Coastguard Worker 27*61046927SAndroid Build Coastguard Workergenerate_python_build.py: reads meson.build files (following subdir() commands) 28*61046927SAndroid Build Coastguard Workerand uses meson2python to transform the meson into python. 29*61046927SAndroid Build Coastguard Worker 30*61046927SAndroid Build Coastguard Workermeson2python.py: passes meson.build input and the meson grammar to 31*61046927SAndroid Build Coastguard Worker[python lark](https://github.com/lark-parser/lark) to perform lexing and parsing; then 32*61046927SAndroid Build Coastguard Workertransforms the parse tree into valid python. The result is one large python script. 33*61046927SAndroid Build Coastguard Worker 34*61046927SAndroid Build Coastguard Worker## 2 - Generate Android.bp from python 35*61046927SAndroid Build Coastguard Worker 36*61046927SAndroid Build Coastguard Workermeson_android.py defines the meson API entry points and emits Android.bp build 37*61046927SAndroid Build Coastguard Workerconstructs. A config file is read to determine some build parameters such as 38*61046927SAndroid Build Coastguard Worker`cpu_family` (similar to meson's cross file). 39*61046927SAndroid Build Coastguard Worker 40*61046927SAndroid Build Coastguard Worker## Limitations 41*61046927SAndroid Build Coastguard Worker 42*61046927SAndroid Build Coastguard WorkerMeson build options must be set by modifying the defaults in meson_options.txt. 43