Snap for 14079904 from 1d24fdd352f7fe678f10136f26a159708b9c63b0 to 25Q4-release

Change-Id: I716a3f21691d5ba8bb38027971c193ac9950ef73
tree: bfa30fe3232e9e32cf41230acd17366779a34af9
  1. .github/
  2. src/
  3. tests/
  4. utils/
  5. .gitignore
  6. Cargo.lock
  7. Cargo.toml
  8. LICENSE
  9. METADATA
  10. MODULE_LICENSE_APACHE2
  11. OWNERS
  12. README.md
README.md

Ninja to Soong CI badge

ninja-to-soong is a project to generate Soong files (Android.bp) for the Android build system.

Legal

ninja-to-soong is licensed under the terms of the Apache 2.0 license

How does it work?

  1. ninja-to-soong generates Ninja files using either:
  2. ninja-to-soong generates Soong files using Ninja files.

Dependencies

Using ninja-to-soong

<ninja-to-soong> $ cargo run --release -- --aosp-path <path> <project1> <project2>

Options

  • --aosp-path <path>: Path to Android tree
  • --ext-proj-path <path>: Path to external project rust file
  • --clean-tmp: Remove the temporary directory before running
  • --copy-to-aosp: Copy generated Soong files into the Android tree
  • --skip-build: Skip build step
  • --skip-gen-ninja: Skip generation of Ninja files
  • -h, --help: Display the help and exit

Environment variables

  • N2S_ANGLE_PATH: Path to angle sources (default: <aosp-path>/external/angle)
  • N2S_NDK: Android NDK (default: android-ndk-r27c)
  • N2S_NDK_PATH: Path to Android NDK (default: temporary directory)
  • N2S_TMP_PATH: Path used by ninja-to-soong to store its temporary directories (default: std::env::temp_dir())

Supported projects

ProjectNinja GeneratorTargets
angle (WIP)GNlibEGL_angle.so, libGLESv2_angle.so, libGLESv1_CM_angle.so
clpeakCMakeclpeak
clspvCMakeclvk dependencies
clvkCMakelibclvk.so
fwupd (WIP)Mesonfwupdmgr & fwupd-binder
llvm-projectCMakeclvk & clspv dependencies
mesamesonlibgallium_dri.so, libglapi.so, libEGL_mesa.so, libGLESv2_mesa.so, libGLESv1_CM_mesa.so, libvulkan_${VENDOR}.so
OpenCL-CTSCMakeEvery binary in test_conformance/opencl_conformance_tests_full.csv
OpenCL-ICD-LoaderCMakelibOpenCL.so
SPIRV-ToolsCMakeclvk dependencies & spirv-val (for OpenCL-CTS)
SPIRV-HeadersCMakeclspv & SPIRV-Tools dependencies

Adding a project

To add a project, create a <project>.rs implementing the Project trait under the project folder.

Then add the project in define_ProjectId! in project.rs.

The following feature can be used to output debug information when writting a new project:

<ninja-to-soong> $ cargo run --release --features debug_project -- --aosp-path <path> <new_project>

External project

ninja-to-soong is able to take a external rust project file, compile it and link with it at runtime.

This is useful for project where the configuration file cannot be shared upstream for example, or when a project prefer to have the configuration file hosted in the project repository.

An example of such a configuration file can be found here

The important points are:

  • Add ninja-to-soong crate: extern crate ninja_to_soong;, and use all modules needed for the project.
  • Expose a get_project function without mangling:
#[no_mangle]
pub fn get_project() -> Box<dyn Project>

Then the project can be run with the following command:

<ninja-to-soong> $ cargo run --release -- --ext-proj-path <path_to_rust_file> 

Tests

ninja-to-soong uses github actions to check that changes do not bring regression. It checks that the generated files match their reference (located in the tests folder).

Each project in the tests folder contains the following files:

  • Android.bp: the reference file to generate
  • checkout.sh: a script to checkout the repository in the CI
  • gen-ninja.sh: a script to generate Ninja files

Modification to checkout.sh & gen-ninja.sh trigger the generation of Ninja files in the CI, otherwise it uses the cached files from a previous CI run.

If you want more information take a look at the github action script