• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2025 Huawei Device Co., Ltd.
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6# http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14add_custom_target(es2panda_relative_path_to_file)
15
16function(copy_to_workdir filename)
17    get_filename_component(filename_without_ext ${filename} NAME_WLE)
18    add_custom_target("copy_test_${filename_without_ext}"
19    COMMAND ${CMAKE_COMMAND} -E copy
20            ${CMAKE_CURRENT_SOURCE_DIR}/${filename}
21            ${CMAKE_CURRENT_BINARY_DIR}/${filename_without_ext}/${filename})
22endfunction()
23
24function(launch_with_reletaive_path_single_file filename)
25    copy_to_workdir(${filename})
26    get_filename_component(filename_without_ext ${filename} NAME_WLE)
27    set(filename_abc "${filename_without_ext}.abc")
28    add_custom_command(
29        OUTPUT "${filename_abc}"
30        DEPENDS es2panda copy_test_${filename_without_ext}
31        WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${filename_without_ext}
32        COMMAND ${CMAKE_COMMAND} -E env
33            LD_LIBRARY_PATH=${CMAKE_LIBRARY_OUTPUT_DIRECTORY} ${PANDA_RUN_PREFIX}
34            $<TARGET_FILE:es2panda> --extension=ets --ets-unnamed --output=${filename_abc}
35            ${filename}
36    )
37    add_custom_target(es2panda_relative_path_to_file_${filename_without_ext} DEPENDS ${filename_abc})
38    add_dependencies(es2panda_relative_path_to_file es2panda_relative_path_to_file_${filename_without_ext})
39endfunction()
40
41add_dependencies(es2panda_tests es2panda_relative_path_to_file)
42
43launch_with_reletaive_path_single_file(package_a_file_1.ets)
44