1b1994897Sopenharmony_ci# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
2b1994897Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License");
3b1994897Sopenharmony_ci# you may not use this file except in compliance with the License.
4b1994897Sopenharmony_ci# You may obtain a copy of the License at
5b1994897Sopenharmony_ci#
6b1994897Sopenharmony_ci# http://www.apache.org/licenses/LICENSE-2.0
7b1994897Sopenharmony_ci#
8b1994897Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software
9b1994897Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS,
10b1994897Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11b1994897Sopenharmony_ci# See the License for the specific language governing permissions and
12b1994897Sopenharmony_ci# limitations under the License.
13b1994897Sopenharmony_ci
14b1994897Sopenharmony_ciproject(isa)
15b1994897Sopenharmony_ci
16b1994897Sopenharmony_ciset(ISA_FILE "${CMAKE_BINARY_DIR}/isa/isa.yaml")
17b1994897Sopenharmony_ciset(ISA_ASSERTS "${PROJECT_SOURCE_DIR}/asserts.rb")
18b1994897Sopenharmony_ciset(ISAPI "${PROJECT_SOURCE_DIR}/isapi.rb")
19b1994897Sopenharmony_ci
20b1994897Sopenharmony_ciadd_custom_target(isa_combine)
21b1994897Sopenharmony_ciset_target_properties(isa_combine PROPERTIES ISA_PLUGIN_FILES "")
22b1994897Sopenharmony_ci
23b1994897Sopenharmony_cifunction(add_isa_plugin YAML_FILE_PATH)
24b1994897Sopenharmony_ci    get_target_property(YAML_FILES isa_combine ISA_PLUGIN_FILES)
25b1994897Sopenharmony_ci    list(APPEND YAML_FILES ${YAML_FILE_PATH})
26b1994897Sopenharmony_ci    set_target_properties(isa_combine PROPERTIES ISA_PLUGIN_FILES "${YAML_FILES}")
27b1994897Sopenharmony_ciendfunction()
28b1994897Sopenharmony_ci
29b1994897Sopenharmony_ci# Check ISA_FILE content
30b1994897Sopenharmony_ci
31b1994897Sopenharmony_ciset(ASSERT_MARKER "${PROJECT_BINARY_DIR}/assert.ok")
32b1994897Sopenharmony_ciset(ISA_GEN_RB "${PROJECT_SOURCE_DIR}/gen.rb")
33b1994897Sopenharmony_ciadd_custom_command(OUTPUT ${ASSERT_MARKER}
34b1994897Sopenharmony_ci    COMMENT "Check ISA content"
35b1994897Sopenharmony_ci    COMMAND ${ISA_GEN_RB} -d ${ISA_FILE} -r ${ISAPI} -a ${ISA_ASSERTS}
36b1994897Sopenharmony_ci    COMMAND ${CMAKE_COMMAND} -E touch ${ASSERT_MARKER}
37b1994897Sopenharmony_ci    DEPENDS ${ISA_FILE} ${ISA_GEN_RB} ${ISA_ASSERTS} ${ISAPI}
38b1994897Sopenharmony_ci)
39b1994897Sopenharmony_ciadd_custom_target(isa_assert DEPENDS ${ASSERT_MARKER})
40b1994897Sopenharmony_ciadd_dependencies(isa_assert isa_combine)
41b1994897Sopenharmony_ci
42b1994897Sopenharmony_ci# Template generation
43b1994897Sopenharmony_ciset(TEMPLATES
44b1994897Sopenharmony_ci    isa.md.erb
45b1994897Sopenharmony_ci)
46b1994897Sopenharmony_cipanda_isa_gen(TEMPLATES ${TEMPLATES})
47