13af6ab5fSopenharmony_ci# Copyright (c) 2023-2024 Huawei Device Co., Ltd.
23af6ab5fSopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License");
33af6ab5fSopenharmony_ci# you may not use this file except in compliance with the License.
43af6ab5fSopenharmony_ci# You may obtain a copy of the License at
53af6ab5fSopenharmony_ci#
63af6ab5fSopenharmony_ci# http://www.apache.org/licenses/LICENSE-2.0
73af6ab5fSopenharmony_ci#
83af6ab5fSopenharmony_ci# Unless required by applicable law or agreed to in writing, software
93af6ab5fSopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS,
103af6ab5fSopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
113af6ab5fSopenharmony_ci# See the License for the specific language governing permissions and
123af6ab5fSopenharmony_ci# limitations under the License.
133af6ab5fSopenharmony_ci
143af6ab5fSopenharmony_cioption(ENABLE_ES2PANDA_COVERAGE "Enable coverage calculation for es2panda" false)
153af6ab5fSopenharmony_ci
163af6ab5fSopenharmony_ciinclude(${PANDA_ROOT}/cmake/toolchain/coverage/unit_tests_lcov.cmake)
173af6ab5fSopenharmony_ci
183af6ab5fSopenharmony_ciadd_custom_target(es2panda_coverage DEPENDS etsstdlib es2panda verifier ark)
193af6ab5fSopenharmony_ci
203af6ab5fSopenharmony_ciif (NOT DEFINED ES2PANDA_PATH)
213af6ab5fSopenharmony_ci    set(ES2PANDA_PATH ${PANDA_ROOT}/tools/es2panda)
223af6ab5fSopenharmony_ciendif()
233af6ab5fSopenharmony_ci
243af6ab5fSopenharmony_ciadd_custom_command(TARGET es2panda_coverage POST_BUILD
253af6ab5fSopenharmony_ci    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
263af6ab5fSopenharmony_ci    COMMAND bash ${ES2PANDA_PATH}/scripts/es2panda_coverage.sh --binary-dir=${PANDA_BINARY_ROOT} --root-dir=${PANDA_ROOT}
273af6ab5fSopenharmony_ci)
283af6ab5fSopenharmony_ci
293af6ab5fSopenharmony_ciif(ENABLE_ES2PANDA_COVERAGE)
303af6ab5fSopenharmony_ci    collect_coverage_for_target(
313af6ab5fSopenharmony_ci        TARGET_NAME es2panda_coverage
323af6ab5fSopenharmony_ci        INCLUDE_DIR_PATTERN '*/es2panda/*'
333af6ab5fSopenharmony_ci    )
343af6ab5fSopenharmony_cielse()
353af6ab5fSopenharmony_ci    message(STATUS "Coverage will not be calculated (may be enabled by -DENABLE_ES2PANDA_COVERAGE=true ).")
363af6ab5fSopenharmony_ciendif(ENABLE_ES2PANDA_COVERAGE)
37