Skip to content
Snippets Groups Projects
Verified Commit a8addbd1 authored by Andrei Gherzan's avatar Andrei Gherzan :penguin:
Browse files

ohos-sanity.bbclass: Add OpenHarmony sanity checks bbclass


This bbclass is meant to handle various build configuration checks. As
per the current implementation, it handles collections deprecation.

Deprecated collections can be either completely removed or replaced by
another layer. The format of OHOS_DEPRECATED_COLLECTIONS is a list of
<DEPRECATED_COLLECTION>:<REPLACEMENT_COLLECTION>. When
<REPLACEMENT_COLLECTION> is not provided, the layer was removed without
a replacement.

Signed-off-by: Andrei Gherzan's avatarAndrei Gherzan <andrei.gherzan@huawei.com>
parent d2b321b2
No related branches found
No related tags found
No related merge requests found
# SPDX-FileCopyrightText: Huawei Inc.
#
# SPDX-License-Identifier: Apache-2.0
# Deprecated collections can be either completely removed or replaced by
# another layer. The format of OHOS_DEPRECATED_COLLECTIONS is a list of
# <DEPRECATED_COLLECTION>:<REPLACEMENT_COLLECTION>. When
# <REPLACEMENT_COLLECTION> is not provided, the layer was removed without a
# replacement.
OHOS_DEPRECATED_COLLECTIONS = " \
"
def unpack_deprecation(elem) -> 'Tuple[str, str]':
elem_split = elem.split(sep=':', maxsplit=1)
return (elem_split[0], elem_split[1] if len(elem_split) == 2 else '')
def ohos_is_valid_config() -> bool:
"""Handles OpenHarmony build configuration sanity checks."""
# By default assume no fatal errors
success = True
#
# Layers deprecation
#
for deprecation in d.getVar('OHOS_DEPRECATED_COLLECTIONS').split():
(deprecated, new) = unpack_deprecation(deprecation)
if deprecated in d.getVar('BBFILE_COLLECTIONS').split():
if new:
if new in d.getVar('BBFILE_COLLECTIONS').split():
bb.warn("bblayers.conf contains both deprecated ({0}) "
"and replaced ({1}) layers. Remove the "
"deprecated layer." \
.format(deprecated, new))
# Having both deprecated and replacement layers is
# unwanted.
success = False
msg = "{0} is a deprecated layer. Adapt your bblayers.conf " \
"to use the {1} replacement.".format(deprecated, new)
else:
msg = "{0} is a deprecated layer. Adapt your bblayers.conf " \
"accordingly.".format(deprecated)
bb.warn(msg)
return success
python ohos_sanity_handler() {
if d.getVar('OHOS_SANITY_SKIP', True) == "1":
bb.warn('OpenHarmony-specific sanity checks were skipped.')
return
if not ohos_is_valid_config():
bb.fatal("OpenHarmony sanity checks included fatal errors. See above.")
}
addhandler ohos_sanity_handler
ohos_sanity_handler[eventmask] = "bb.event.BuildStarted"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment