13af6ab5fSopenharmony_ci# Copyright (c) 2021-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_ciif(CMAKE_CROSSCOMPILING)
153af6ab5fSopenharmony_ci    return()
163af6ab5fSopenharmony_ciendif()
173af6ab5fSopenharmony_ci
183af6ab5fSopenharmony_ciadd_custom_target(es2panda_tests_options)
193af6ab5fSopenharmony_ciadd_dependencies(es2panda_tests es2panda_tests_options)
203af6ab5fSopenharmony_ci
213af6ab5fSopenharmony_cifunction(check_option_help_otput target_name INPUT_ARGS OUTPUT_HELP_LINE)
223af6ab5fSopenharmony_ci    separate_arguments(INPUT_ARGS)
233af6ab5fSopenharmony_ci    add_custom_target(es2panda_check_opts_${target_name}
243af6ab5fSopenharmony_ci        COMMENT "es2panda: checking option ${INPUT_ARGS}"
253af6ab5fSopenharmony_ci        COMMAND es2panda ${INPUT_ARGS} 2> ${CMAKE_BINARY_DIR}/es2panda_check_opts_${target_name}.out || true
263af6ab5fSopenharmony_ci        COMMAND grep -q ${OUTPUT_HELP_LINE} ${CMAKE_BINARY_DIR}/es2panda_check_opts_${target_name}.out
273af6ab5fSopenharmony_ci        DEPENDS es2panda
283af6ab5fSopenharmony_ci    )
293af6ab5fSopenharmony_ci
303af6ab5fSopenharmony_ci    add_dependencies(es2panda_tests_options es2panda_check_opts_${target_name})
313af6ab5fSopenharmony_ciendfunction()
323af6ab5fSopenharmony_ci
333af6ab5fSopenharmony_cicheck_option_help_otput(bco_opt "--help" "bco-optimizer:")
343af6ab5fSopenharmony_cicheck_option_help_otput(bco_opt_help "--bco-optimizer --help" "bytecode-opt-peepholes:")
353af6ab5fSopenharmony_cicheck_option_help_otput(comp_opt "--help" "bco-compiler:")
363af6ab5fSopenharmony_cicheck_option_help_otput(comp_opt_help "--bco-compiler --help" "compiler-disasm-dump:")
373af6ab5fSopenharmony_cicheck_option_help_otput(opt_level "--opt-level 7" "out of range parameter value \\\"7\\\"")
383af6ab5fSopenharmony_cicheck_option_help_otput(version "--version" "Es2panda Version")
393af6ab5fSopenharmony_cicheck_option_help_otput(list_phases "--list-phases" "Available phases:")
40