OSDN Git Service

Merge "add a simple vehicle hal invocation in vts test"
[android-x86/hardware-interfaces.git] / update-makefiles.sh
1 #!/bin/bash
2
3 if [ ! -d hardware/interfaces ] ; then
4   echo "Where is hardware/interfaces?";
5   exit 1;
6 fi
7
8 if [ ! -d system/libhidl/transport ] ; then
9   echo "Where is system/libhidl/transport?";
10   exit 1;
11 fi
12
13 packages=$(pushd hardware/interfaces > /dev/null; \
14            find . -type f -name \*.hal -exec dirname {} \; | sort -u | \
15            cut -c3- | \
16            awk -F'/' \
17                 '{printf("android.hardware"); for(i=1;i<NF;i++){printf(".%s", $i);}; printf("@%s\n", $NF);}'; \
18            popd > /dev/null)
19
20 for p in $packages; do
21   echo "Updating $p";
22   hidl-gen -Lmakefile -r android.hardware:hardware/interfaces -r android.hidl:system/libhidl/transport $p;
23   hidl-gen -Landroidbp -r android.hardware:hardware/interfaces -r android.hidl:system/libhidl/transport $p;
24 done
25
26 # subdirectories of hardware/interfaces which contain an Android.bp file
27 android_dirs=$(find hardware/interfaces/*/     \
28               -name "Android.bp"               \
29               -printf "%h\n"                   \
30               | cut -d "/" -f1-3               \
31               | sort | uniq)
32
33 echo "Updating Android.bp files."
34
35 for bp_dir in $android_dirs; do
36   bp="$bp_dir/Android.bp"
37   # locations of Android.bp files in specific subdirectory of hardware/interfaces
38   android_bps=$(find $bp_dir                   \
39                 -name "Android.bp"             \
40                 ! -path $bp_dir/Android.bp     \
41                 -printf "%h\n"                 \
42                 | sort)
43
44   echo "// This is an autogenerated file, do not edit." > "$bp";
45   echo "subdirs = [" >> "$bp";
46   for a in $android_bps; do
47     echo "    \"${a#$bp_dir/}\"," >> "$bp";
48   done
49   echo "]" >> "$bp";
50 done