• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2021 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
14project(isa)
15
16set(ISA_FILE "${CMAKE_BINARY_DIR}/isa/isa.yaml")
17set(ISA_CORE_FILE "${PROJECT_SOURCE_DIR}/isa.yaml")
18set(ISA_ASSERTS "${PROJECT_SOURCE_DIR}/asserts.rb")
19set(ISA_COMBINE "${PROJECT_SOURCE_DIR}/combine.rb")
20set(ISAPI "${PROJECT_SOURCE_DIR}/isapi.rb")
21set(ISA_PLUGIN_FILES "")
22
23string(REPLACE ";" "," ISA_PLUGIN_FILES_STR "${ISA_PLUGIN_FILES}")
24
25# ISA combine
26add_custom_command(OUTPUT ${ISA_FILE}
27    COMMENT "Combine ISA files"
28    COMMAND ${ISA_COMBINE} -d "${ISA_CORE_FILE},${ISA_PLUGIN_FILES_STR}" -o ${ISA_FILE}
29    DEPENDS ${ISA_COMBINE} ${ISA_CORE_FILE} ${ISA_PLUGIN_FILES}
30)
31add_custom_target(isa_combine DEPENDS ${ISA_FILE})
32
33# Check ISA_FILE content
34
35set(ASSERT_MARKER "${PROJECT_BINARY_DIR}/assert.ok")
36set(ISA_GEN_RB "${PROJECT_SOURCE_DIR}/gen.rb")
37add_custom_command(OUTPUT ${ASSERT_MARKER}
38    COMMENT "Check ISA content"
39    COMMAND ${ISA_GEN_RB} -d ${ISA_FILE} -r ${ISAPI} -a ${ISA_ASSERTS}
40    COMMAND ${CMAKE_COMMAND} -E touch ${ASSERT_MARKER}
41    DEPENDS ${ISA_FILE} ${ISA_GEN_RB} ${ISA_ASSERTS} ${ISAPI}
42)
43add_custom_target(isa_assert DEPENDS ${ASSERT_MARKER})
44add_dependencies(isa_assert isa_combine)
45
46# Template generation
47set(TEMPLATES
48    instructions.txt.erb
49    isa.md.erb
50)
51panda_isa_gen(TEMPLATES ${TEMPLATES})
52