summaryrefslogtreecommitdiffstats
blob: d0cb91c38b393f3d251ea724730aca891d73703e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash

if [ ! -d hardware/interfaces ] ; then
  echo "Where is hardware/interfaces?";
  exit 1;
fi

if [ ! -d system/libhidl/transport ] ; then
  echo "Where is system/libhidl/transport?";
  exit 1;
fi

packages=$(pushd hardware/interfaces > /dev/null; \
           find . -type f -name \*.hal -exec dirname {} \; | sort -u | \
           cut -c3- | \
           awk -F'/' \
                '{printf("android.hardware"); for(i=1;i<NF;i++){printf(".%s", $i);}; printf("@%s\n", $NF);}'; \
           popd > /dev/null)

for p in $packages; do
  echo "Updating $p";
  hidl-gen -Lmakefile -r android.hardware:hardware/interfaces -r android.hidl:system/libhidl/transport $p;
  rc=$?; if [[ $rc != 0 ]]; then exit $rc; fi
  hidl-gen -Landroidbp -r android.hardware:hardware/interfaces -r android.hidl:system/libhidl/transport $p;
  rc=$?; if [[ $rc != 0 ]]; then exit $rc; fi
done

# subdirectories of hardware/interfaces which contain an Android.bp file
android_dirs=$(find hardware/interfaces/*/     \
              -name "Android.bp"               \
              -printf "%h\n"                   \
              | cut -d "/" -f1-3               \
              | sort | uniq)

echo "Updating Android.bp files."

for bp_dir in $android_dirs; do
  bp="$bp_dir/Android.bp"
  # locations of Android.bp files in specific subdirectory of hardware/interfaces
  android_bps=$(find $bp_dir                   \
                -name "Android.bp"             \
                ! -path $bp_dir/Android.bp     \
                -printf "%h\n"                 \
                | sort)

  echo "// This is an autogenerated file, do not edit." > "$bp";
  echo "subdirs = [" >> "$bp";
  for a in $android_bps; do
    echo "    \"${a#$bp_dir/}\"," >> "$bp";
  done
  echo "]" >> "$bp";
done