Move type-related stuff ouside of parsing

3 new passes: resolving inheritance, evaluating constant expressions and
validation.

`resolveInheritance` completes type fields definition which depends on
type base class (so it needs to be looked up before this pass). That
includes interface method serial autofill and enum value autofill.

`evaluate` evaluates constant expressions. This pass depends on the
previous one as enum autofill creates new expressions (+1s).

`validate` proceedes all type-related checks.

`callForReference` is a special way of calling passes for types:
it is used for types that are defined in reference.
Currently that is only array type (size is defined in reference only)
and template type as it could contain an array.
We need such special way to avoid cyclic evaluate call:
struct S { S[42] arr; };

Test: full build, device boot
Test: hidl_test
Test: full build on mac
Test: generated files differ only in constant expression comments

Change-Id: I499e62ae41c52cc86b13d0014eed790454137af6
22 files changed
tree: 42ffd1b245d908404e3be321fc620bc1c91774c2
  1. c2hal/
  2. include_hash/
  3. test/
  4. utils/
  5. .clang-format
  6. Android.bp
  7. Annotation.cpp
  8. Annotation.h
  9. ArrayType.cpp
  10. ArrayType.h
  11. AST.cpp
  12. AST.h
  13. CompoundType.cpp
  14. CompoundType.h
  15. ConstantExpression.cpp
  16. ConstantExpression.h
  17. Coordinator.cpp
  18. Coordinator.h
  19. DeathRecipientType.cpp
  20. DeathRecipientType.h
  21. EnumType.cpp
  22. EnumType.h
  23. FmqType.cpp
  24. FmqType.h
  25. generateCpp.cpp
  26. generateCppImpl.cpp
  27. generateJava.cpp
  28. generateVts.cpp
  29. HandleType.cpp
  30. HandleType.h
  31. Hash.cpp
  32. hidl-gen_l.ll
  33. hidl-gen_y.yy
  34. HidlTypeAssertion.cpp
  35. HidlTypeAssertion.h
  36. Interface.cpp
  37. Interface.h
  38. Location.h
  39. main.cpp
  40. MemoryType.cpp
  41. MemoryType.h
  42. Method.cpp
  43. Method.h
  44. MODULE_LICENSE_APACHE2
  45. NamedType.cpp
  46. NamedType.h
  47. NOTICE
  48. OWNERS
  49. PointerType.cpp
  50. PointerType.h
  51. PREUPLOAD.cfg
  52. README.md
  53. Reference.h
  54. RefType.cpp
  55. RefType.h
  56. ScalarType.cpp
  57. ScalarType.h
  58. Scope.cpp
  59. Scope.h
  60. StringType.cpp
  61. StringType.h
  62. Type.cpp
  63. Type.h
  64. TypeDef.cpp
  65. TypeDef.h
  66. update-all-google-makefiles.sh
  67. update-makefiles-helper.sh
  68. VectorType.cpp
  69. VectorType.h
README.md

hidl-gen user guide

1. Build

croot
make hidl-gen

2. Run

hidl-gen -o output-path -L language (-r interface-root) fqname

output-path: directory to store the output files.
language: output file for given language. e.g.c++, vts..

fqname: fully qualified name of the input files.
For singe file input, follow the format: package@version::fileName
For directory input, follow the format: package@version

interface-root(optional): prefix and root path for fqname.
If not set, use the default prefix: android.hardware and default root path
defined in $TOP.

examples:

croot
hidl-gen -o output -L c++ -r android.hardware:hardware/interfaces -r android.hidl:system/libhidl/transport android.hardware.nfc@1.0::INfc.hal
hidl-gen -o output -L vts -r android.hardware:hardware/interfaces -r android.hidl:system/libhidl/transport android.hardware.nfc@1.0
hidl-gen -o test -L c++ -r android.hardware:hardware/interfaces -r android.hidl:system/libhidl/transport android.hardware.nfc@1.0
hidl-gen -L hash -r android.hardware:hardware/interfaces -r android.hidl:system/libhidl/transport android.hardware.nfc@1.0