1# Run the Completion Model Codegenerator on the model present in the 2# ${model} directory. 3# Produces a pair of files called ${filename}.h and ${filename}.cpp in the 4# ${CMAKE_CURRENT_BINARY_DIR}. The generated header 5# will define a C++ class called ${cpp_class} - which may be a 6# namespace-qualified class name. 7set(CLANGD_COMPLETION_MODEL_COMPILER ${CMAKE_CURRENT_LIST_DIR}/CompletionModelCodegen.py) 8function(gen_decision_forest model filename cpp_class) 9 set(model_compiler ${CLANGD_COMPLETION_MODEL_COMPILER}) 10 11 set(output_dir ${CMAKE_CURRENT_BINARY_DIR}) 12 set(header_file ${output_dir}/${filename}.h) 13 set(cpp_file ${output_dir}/${filename}.cpp) 14 15 add_custom_command(OUTPUT ${header_file} ${cpp_file} 16 COMMAND "${Python3_EXECUTABLE}" ${model_compiler} 17 --model ${model} 18 --output_dir ${output_dir} 19 --filename ${filename} 20 --cpp_class ${cpp_class} 21 COMMENT "Generating code completion model runtime..." 22 DEPENDS ${model_compiler} ${model}/forest.json ${model}/features.json 23 VERBATIM ) 24 25 set_source_files_properties(${header_file} PROPERTIES 26 GENERATED 1) 27 set_source_files_properties(${cpp_file} PROPERTIES 28 GENERATED 1) 29 30 # Disable unused label warning for generated files. 31 if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") 32 set_source_files_properties(${cpp_file} PROPERTIES 33 COMPILE_FLAGS /wd4102) 34 else() 35 set_source_files_properties(${cpp_file} PROPERTIES 36 COMPILE_FLAGS -Wno-unused) 37 endif() 38endfunction() 39