halcc: Add support for hal-api dependency checking 71/304171/12 accepted/tizen_unified_riscv accepted/tizen/unified/20240116.155507 accepted/tizen/unified/riscv/20240117.041616
authorYoungjae Cho <y0.cho@samsung.com>
Thu, 11 Jan 2024 08:50:58 +0000 (17:50 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Mon, 15 Jan 2024 09:11:58 +0000 (18:11 +0900)
commitabd4a834b528bc459849b16a4db492a0b3c0f5cf
tree8fe1cc80b9c38c49985ab64e455a70b299d72232
parente6d63990aef11e24eb6e54d499b28bce73c85d80
halcc: Add support for hal-api dependency checking

Optionally, hal-api can specify dependency, name and version of another
hal-api, that it must work with.

  | <!--hal-api-xxx.xml-->
  |
  | <manifest version="1.0" type="platform" level="2">
  |     <hal>
  |         <name>AAA</name>
  |         <version>1.0</version>
  |         <dependency>
  |             <hal>
  |                 <name>BBB</name>
  |                 <version>1.0</version>
  |             </hal>
  |             ...
  |         </dependency>
  |     </hal>
  |     <hal>
  |         <name>BBB</name>
  |         <version>1.5</version>
  |     </hal>
  |     ...
  | </manifest>

The halcc-object.c now provides
 - halcc_manifest_validate_hal_dependency()

This validates dependencies between hals within manifest. It try to
find compatible hal that specified by hal-api dependency. If it
couldn't find compatible one for the dependency, the resolution fails
and the hal is regarded as not supported.

Let's say a manifest contains below specification about 4 hals
 - AAA@1.5  : success
 - BBB@2.3  : success
 - CCC@3.3  : success
 - DDD@1.0  : success
If there are no dependencies between each other, no problem.

Case1] If AAA@1.5 depends on YYY@1.0.
 - AAA@1.5 -> YYY@1.0  : fail, YYY@1.0 is not specified
 - BBB@2.3  : success
 - CCC@3.3  : success
 - DDD@1.0  : success

Case2] If AAA@1.5 depends on BBB@1.0.
 - AAA@1.5 -> BBB@1.0  : fail, BBB@1.0 isn't compatible with
                         the specified BBB@2.3
 - BBB@2.3  : success
 - CCC@3.3  : success
 - DDD@1.0  : success

Caser3] If AAA@1.5 depends on BBB@2.0, CCC@4.0
 - AAA@1.5 -> BBB@2.0, CCC@4.0 : fail, BBB@2.0 is backward compatible
                         with the specified BBB@2.3, but CCC@4.0 isn't
                         compatible with the specified CCC@3.3.
 - BBB@2.3  : success
 - CCC@3.3  : success
 - DDD@1.0  : success
 If multiple dependencies are specified on a hal, it success only when
 all the dependencies are satisfied.

Case4] If AAA@1.5 depends on BBB@2.0
          and BBB@2.3 depends on CCC@3.0
          and CCC@3.3 depends on DDD@1.5
 - AAA@1.5 -> BBB@2.0  : fail, BBB@2.0 is backward compatible with the
                         specified BBB@2.3, but BBB@2.3 has failed to
                         validate dependency
 - BBB@2.3 -> CCC@3.0  : fail, CCC@3.0 is backward compatible with the
                         specified CCC@3.3, but CCC@3.3 has failed to
                         validate dependency
 - CCC@3.3 -> DDD@1.5  : fail, DDD@1.5 isn't compatible with the
                         specified DDD@1.0
 - DDD@1.0  : success
 The failure is propagated to all hals that have dependency on that
 failed hal.

Case5] If AAA@1.5 depends on BBB@2.1
          and BBB@2.3 depends on CCC@3.0
          and CCC@3.3 depends on AAA@1.0
 - AAA@1.5 -> BBB@2.1  : fail, cyclic dependency
 - BBB@2.3 -> CCC@3.0  : fail, cyclic dependency
 - CCC@3.3 -> AAA@1.0  : fail, cyclic dependency
 - DDD@1.0  : success
 All hals that make dependency cycle are failure.

Case6] If AAA@1.5 depends on BBB@2.0
          and BBB@2.3 depends on CCC@3.0
 - AAA@1.5 -> BBB@2.0  : success
 - BBB@2.3 -> CCC@3.0  : success
 - CCC@3.3  : success
 - DDD@1.0  : success

In addition, the tool hal-compatibility-checker has changed to validate
dependency, by default, before it checks compatibility.

Change-Id: I34ce0f78a9ae9c05f65c77b20199353c93072851
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
halcc/src/hal-compatibility-checker.c
halcc/src/halcc-object.c
halcc/src/halcc-object.h