• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 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
14function(gen_intrinsics_yaml)
15    set(prefix ARG)
16    set(noValues)
17    set(singleValues OUTPUTFILE TARGET)
18    set(multiValues DATAFILES DEPENDS)
19    cmake_parse_arguments(${prefix}
20            "${noValues}"
21            "${singleValues}"
22            "${multiValues}"
23            ${ARGN})
24    set(GENERATOR ${CMAKE_CURRENT_SOURCE_DIR}/templates/gen_intrinsics_data.rb ${CMAKE_CURRENT_SOURCE_DIR}/templates/runtime.rb)
25    set(TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/templates/intrinsics.yaml.erb)
26    set(DEPENDS_LIST ${GENERATOR} ${TEMPLATE} ${ARG_DEPENDS})
27    string(REPLACE ";" "," DATAFILES_STR "${ARG_DATAFILES}")
28    foreach(d ${ARG_DATAFILES})
29        list(APPEND DEPENDS_LIST ${d})
30    endforeach()
31    add_custom_command(OUTPUT ${ARG_OUTPUTFILE}
32            COMMENT "Generate intrinsics.yaml"
33            COMMAND ${GENERATOR} -d ${DATAFILES_STR} -t ${TEMPLATE} -o ${ARG_OUTPUTFILE}
34            DEPENDS ${DEPENDS_LIST})
35    add_custom_target(${ARG_TARGET} ALL DEPENDS ${ARG_OUTPUTFILE})
36endfunction()
37
38set(ECMASCRIPT_RUNTIME_YAML "")
39if (PANDA_WITH_ECMASCRIPT)
40    set(ECMASCRIPT_RUNTIME_YAML ${PANDA_ECMASCRIPT_PLUGIN_SOURCE}/runtime/ecma_runtime.yaml)
41endif()
42
43set(JAVA_RUNTIME_YAML "")
44if (PANDA_WITH_JAVA)
45    set(JAVA_RUNTIME_YAML ${PANDA_JAVA_PLUGIN_SOURCE}/runtime/libcore_runtime.yaml)
46    if(NOT PANDA_TARGET_MOBILE_WITH_MANAGED_LIBS)
47        list(APPEND JAVA_RUNTIME_YAML ${PANDA_JAVA_PLUGIN_SOURCE}/runtime/java_libbase_runtime.yaml)
48    endif()
49endif()
50
51set(ACCORD_RUNTIME_YAML "")
52if (PANDA_WITH_ACCORD)
53    set(ACCORD_RUNTIME_YAML ${PANDA_ACCORD_PLUGIN_SOURCE}/runtime/accord_runtime.yaml)
54endif()
55
56set(INTRINSICS_YAML ${CMAKE_CURRENT_BINARY_DIR}/intrinsics.yaml)
57set(INTRINSICS_TARGET arkruntime_gen_intrinsics_yaml)
58set(DATAFILES_TARGET ${CMAKE_CURRENT_SOURCE_DIR}/runtime.yaml ${JAVA_RUNTIME_YAML} ${ECMASCRIPT_RUNTIME_YAML} ${ACCORD_RUNTIME_YAML} ${IRTOC_INTRINSICS_YAML})
59
60gen_intrinsics_yaml(
61    TARGET ${INTRINSICS_TARGET}
62    DATAFILES ${DATAFILES_TARGET}
63    OUTPUTFILE ${INTRINSICS_YAML}
64)
65
66set(RUNTIME_TEMPLATES
67    intrinsics_gen.h.erb
68    intrinsics.h.erb
69    intrinsics_enum.h.erb
70    unimplemented_intrinsics-inl.cpp.erb
71    )
72
73panda_gen(
74    DATA ${INTRINSICS_YAML}
75    TARGET_NAME intrinsics_gen_arkruntime
76    TEMPLATES ${RUNTIME_TEMPLATES}
77    REQUIRES ${CMAKE_CURRENT_SOURCE_DIR}/templates/intrinsics.rb
78    SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/templates
79    DESTINATION ${GEN_INCLUDE_DIR}
80    EXTRA_DEPENDENCIES ${INTRINSICS_TARGET}
81)
82