1# Copyright (c) 2021-2022 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 14set(LOGGER_FILE "${CMAKE_BINARY_DIR}/libpandabase/logger.yaml") 15set(LOGGER_CORE_FILE "${PROJECT_SOURCE_DIR}/libpandabase/templates/logger.yaml") 16set(LOGGER_GENERATOR "${PROJECT_SOURCE_DIR}/libpandabase/templates/logger_gen.rb") 17 18add_custom_command(OUTPUT ${LOGGER_FILE} 19 COMMENT "Generate logger.yaml" 20 COMMAND ${LOGGER_GENERATOR} -d "${LOGGER_CORE_FILE}" -p "${GEN_PLUGIN_OPTIONS_YAML}" -o ${LOGGER_FILE} 21 DEPENDS ${LOGGER_GENERATOR} ${LOGGER_CORE_FILE} plugin_options_merge 22) 23add_custom_target(logger_yaml_gen DEPENDS ${LOGGER_FILE}) 24 25set(LOGGER_TEMPLATES 26 logger_enum_gen.h.erb 27 logger_impl_gen.inc.erb 28) 29 30add_custom_target(logger_gen) 31 32foreach(TEMPLATE ${LOGGER_TEMPLATES}) 33 get_filename_component(OUTPUT_FILENAME ${TEMPLATE} NAME_WLE) 34 set(OUTPUT ${CMAKE_BINARY_DIR}/libpandabase/generated/${OUTPUT_FILENAME}) 35 36 panda_gen_file( 37 DATAFILE ${LOGGER_FILE} 38 TEMPLATE ${PROJECT_SOURCE_DIR}/libpandabase/templates/${TEMPLATE} 39 OUTPUTFILE ${OUTPUT} 40 REQUIRES ${PROJECT_SOURCE_DIR}/libpandabase/templates/logger.rb 41 EXTRA_DEPENDENCIES logger_yaml_gen 42 ) 43 add_custom_target(logger_gen_${OUTPUT_FILENAME} DEPENDS ${OUTPUT}) 44 add_dependencies(logger_gen logger_gen_${OUTPUT_FILENAME}) 45endforeach() 46 47add_dependencies(arkassembler assembler_extensions) 48 49if(PANDA_ENABLE_LTO AND PANDA_ARKBASE_LTO) 50 set(ARKBASE_TARGETS arkbase arkbase_lto) 51else() 52 set(ARKBASE_TARGETS arkbase) 53endif() 54 55foreach(TARGET ${ARKBASE_TARGETS}) 56 add_dependencies(${TARGET} logger_gen) 57endforeach() 58