LICENSE_EXPRESSION=
LICENSE_NAMES=

MODULE_LICENSES_RESTRICTIONS=
MODULE_LICENSES_RESTRICTION_EXCEPTIONS=
MODULE_LICENSES_RESTRICTION_TYPES=
MODULEWISE_LICENSES_RESTRICTIONS=
MODULEWISE_LICENSES_RESTRICTION_TYPES=
DEFAULT_MODULE_LICENSE=Service-Default-License
EXPLICIT_LICENSE_PREFIXES=
EXPLICIT_LICENSE_EXCEPTIONS=

LICENSES=
LICENSES+=build/conf/licenses.json

macro _DONT_REQUIRE_LICENSE() {
    SET(EXPLICIT_LICENSE_PREFIXES "")
}

### @usage: LICENSE(licenses...)
###
### Specify the licenses of the module, separated by spaces. Specifying multiple licenses interpreted as permission to use this
### library satisfying all conditions of any of the listed licenses.
###
### A license must be prescribed for contribs
macro LICENSE(Flags...) {
    SET(LICENSE_EXPRESSION $Flags)
    SET(LICENSE_NAMES $Flags)
    # TODO(YMAKE-1136) avoid abusing LICENSE
    _CONTRIB_MODULE_HOOKS()
}

### @usage LICENSE_RESTRICTION(ALLOW_ONLY|DENY LicenseProperty...)
###
### Restrict licenses of direct and indirect module dependencies.
###
### ALLOW_ONLY restriction type requires dependent module to have at least one license without properties not listed in restrictions list.
###
### DENY restriction type forbids dependency on module with no license without any listed property from the list.
###
### Note: Can be used multiple times on the same module all specified constraints will be checked.
### All macro invocation for the same module must use same constraints type (DENY or ALLOW_ONLY)
macro LICENSE_RESTRICTION(TYPE, RESTRICTIONS...) {
    SET_APPEND(MODULE_LICENSES_RESTRICTION_TYPES $TYPE)
    SET_APPEND(MODULE_LICENSES_RESTRICTIONS $RESTRICTIONS)
}

### @usage MODULEWISE_LICENSE_RESTRICTION(ALLOW_ONLY|DENY LicenseProperty...)
###
### Restrict licenses per module only, without it peers.
###
### ALLOW_ONLY restriction type requires module to have at least one license without properties not listed in restrictions list.
###
### DENY restriction type forbids module with no license without any listed property from the list.
###
### Note: Can be used multiple times on the same module all specified constraints will be checked.
### All macro invocation for the same module must use same constraints type (DENY or ALLOW_ONLY)
macro MODULEWISE_LICENSE_RESTRICTION(TYPE, RESTRICTIONS...) {
    SET_APPEND(MODULEWISE_LICENSES_RESTRICTION_TYPES $TYPE)
    SET_APPEND(MODULEWISE_LICENSES_RESTRICTIONS $RESTRICTIONS)
}

### @usage LICENSE_RESTRICTION_EXCEPTIONS(Module...)
###
### List of modules for exception from LICENSE_RESTRICTION and MODULEWISE_LICENSE_RESTRICTION logic.
macro LICENSE_RESTRICTION_EXCEPTIONS(EXCEPT...) {
    SET_APPEND(MODULE_LICENSES_RESTRICTION_EXCEPTIONS $EXCEPT)
}