blob: 86582eb054988a89e5858cb1e91b5dda4b63ce75 [file] [log] [blame]
Gina Dimino391dde62017-11-15 13:48:52 -08001#!/bin/bash
2#
3# Build the CDD HTML and PDF from the source files.
4# From the root directory run:
5# ./cdd_gen.sh --version xx --branch xx
6#
7# where version is the version number and branch is the name of the AOSP branch.
8#
Glenn Kasten06c07212019-08-26 16:51:02 -07009# To run this script, you must install these packages as shown:
10# sudo apt-get install wkhtmltopdf
11# pip install Jinja2
12# pip install markdown
13# pip install pytidylib
Gina Dimino391dde62017-11-15 13:48:52 -080014#
15
Gina Dimino30de4fa2019-01-23 10:46:16 -080016positional=()
Gina Dimino391dde62017-11-15 13:48:52 -080017while [[ $# -gt 0 ]]
18do
19key="$1"
20
21case $key in
22 -v|--version)
Gina Dimino30de4fa2019-01-23 10:46:16 -080023 version="$2"
Gina Dimino391dde62017-11-15 13:48:52 -080024 shift # past argument
25 shift # past value
26 ;;
27 -b|--branch)
Gina Dimino30de4fa2019-01-23 10:46:16 -080028 branch="$2"
Gina Dimino391dde62017-11-15 13:48:52 -080029 shift # past argument
30 shift # past value
31 ;;
32 --default)
Gina Dimino30de4fa2019-01-23 10:46:16 -080033 default=YES
Gina Dimino391dde62017-11-15 13:48:52 -080034 shift # past argument
35 ;;
36 *) # unknown option
Gina Dimino30de4fa2019-01-23 10:46:16 -080037 positional+=("$1") # save it in an array for later
Gina Dimino391dde62017-11-15 13:48:52 -080038 shift # past argument
39 ;;
40esac
41done
Gina Dimino30de4fa2019-01-23 10:46:16 -080042set -- "${positional[@]}" # restore positional parameters
Gina Dimino391dde62017-11-15 13:48:52 -080043
Gina Dimino30de4fa2019-01-23 10:46:16 -080044if [ -z "${version}" ];
Gina Dimino391dde62017-11-15 13:48:52 -080045then
Gina Dimino30de4fa2019-01-23 10:46:16 -080046 read -p "Version number: " version
Gina Dimino391dde62017-11-15 13:48:52 -080047fi
48
Gina Dimino30de4fa2019-01-23 10:46:16 -080049if [ -z "${branch+x}" ];
50then
51 read -p "AOSP branch name for revision history: " branch
52fi
53
54echo "version = ${version}"
55echo "branch = ${branch}"
56
57current_date=$(date "+%m-%d")
58echo "Current Date : $current_date"
59
60filename="android-${version}-cdd-${current_date}"
61echo "$filename"
62
63
64python make_cdd.py --version $version --branch $branch --output $filename;
65
66mkdir -p /tmp/$filename
67
68wkhtmltopdf -B 1in -T 1in -L .75in -R .75in page $filename.html --footer-html source/android-cdd-footer.html /tmp/$filename/$filename-body.pdf
69wkhtmltopdf -s letter -B 0in -T 0in -L 0in -R 0in cover source/android-cdd-cover.html /tmp/$filename/$filename-cover.pdf
70
71
72mv $filename.html /tmp/$filename
73mv $filename-devsite.html /tmp/$filename
74
75echo ""
76echo "The generated files have been placed in the /tmp/$filename directory."
77echo "Please copy them to your Google Drive or another more permanent location."
78echo ""