adevtool/src/frontend
Dmitry Muhomor 0691a32fa6 generate-all: pass extra commands to lunch/choosecombo in envsetup.sh
Requires the corresponding patch in build/make repo.
2023-08-31 16:03:43 -04:00
..
devices.ts
generate.ts generate-all: pass extra commands to lunch/choosecombo in envsetup.sh 2023-08-31 16:03:43 -04:00
readme.ts update links to adevtool GitHub 2023-08-31 16:03:43 -04:00
source.ts

import { promises as fs } from 'fs'

import { DeviceConfig } from '../config/device'
import { PropResults } from './generate'
import { VendorDirectories } from '../blobs/build'

function createReadme(device: string, friendlyDevice: string) {
  // Hard-coded here for convenient formatting
  return `# ${friendlyDevice} vendor module

This is an automatically-generated vendor module to build AOSP for the ${friendlyDevice} (codename \`${device}\`).

Generated by [adevtool](https://github.com/GrapheneOS/adevtool). [More info](https://github.com/GrapheneOS/adevtool/blob/main/README.md)
`
}

function getFriendlyName(props: PropResults) {
  let product = props.stockProps.get('product')!
  let manufacturer = product.get('ro.product.product.manufacturer')!
  let model = product.get('ro.product.product.model')!
  return `${manufacturer} ${model}`
}

export async function writeReadme(config: DeviceConfig, dirs: VendorDirectories, props: PropResults | null) {
  let friendlyDevice = props === null ? config.device.name : getFriendlyName(props)
  let readme = createReadme(config.device.name, friendlyDevice)
  await fs.writeFile(`${dirs.out}/README.md`, readme)
}