|
| 1 | +project(script) |
| 2 | +cmake_minimum_required(VERSION 2.6) |
| 3 | + |
| 4 | +set(DUMMY ${CMAKE_BUILD_TYPE}) |
| 5 | + |
| 6 | +FUNCTION(PREPEND var prefix) |
| 7 | + SET(listVar "") |
| 8 | + FOREACH(f ${ARGN}) |
| 9 | + LIST(APPEND listVar "${prefix}/${f}") |
| 10 | + ENDFOREACH(f) |
| 11 | + SET(${var} "${listVar}" PARENT_SCOPE) |
| 12 | +ENDFUNCTION(PREPEND) |
| 13 | + |
| 14 | +set(bindings_src ${PROJECT_SOURCE_DIR}/dom/bindings/codegen) |
| 15 | +set(webidls_src ${PROJECT_SOURCE_DIR}/dom/webidls) |
| 16 | + |
| 17 | +# Without Bindings/* stuff, since we install that separately below |
| 18 | +set(globalgen_base_src |
| 19 | + PrototypeList.rs |
| 20 | + RegisterBindings.rs |
| 21 | + InterfaceObjectMap.rs |
| 22 | + InterfaceTypes.rs |
| 23 | + InheritTypes.rs |
| 24 | + UnionTypes.rs |
| 25 | + ) |
| 26 | + |
| 27 | +set(globalgen_src |
| 28 | + ${globalgen_base_src} |
| 29 | + Bindings/mod.rs |
| 30 | + ) |
| 31 | + |
| 32 | +file(GLOB_RECURSE webidls ${webidls_src}/*.webidl) |
| 33 | +string(REGEX REPLACE ";" "\n" webidl_filelist "${webidls}") |
| 34 | +file(WRITE "${PROJECT_BINARY_DIR}/webidls.list" "${webidl_filelist}") |
| 35 | +string(REGEX REPLACE "\\.webidl(;|$)" "\\1" bindings "${webidls}") |
| 36 | +string(REGEX REPLACE "(^|;)${webidls_src}/" "\\1" bindings "${bindings}") |
| 37 | + |
| 38 | +set(globalgen_deps |
| 39 | + ${bindings_src}/GlobalGen.py |
| 40 | + ${bindings_src}/Bindings.conf |
| 41 | + ${bindings_src}/Configuration.py |
| 42 | + ${bindings_src}/CodegenRust.py |
| 43 | + ${bindings_src}/parser/WebIDL.py |
| 44 | + ) |
| 45 | +set(bindinggen_deps |
| 46 | + ${bindings_src}/BindingGen.py |
| 47 | + ${bindings_src}/Bindings.conf |
| 48 | + ${bindings_src}/Configuration.py |
| 49 | + ${bindings_src}/CodegenRust.py |
| 50 | + ${bindings_src}/parser/WebIDL.py |
| 51 | + ) |
| 52 | + |
| 53 | +add_custom_command( |
| 54 | + OUTPUT Bindings |
| 55 | + COMMAND ${CMAKE_COMMAND} -E make_directory Bindings |
| 56 | + ) |
| 57 | +add_custom_command( |
| 58 | + OUTPUT _cache |
| 59 | + COMMAND ${CMAKE_COMMAND} -E make_directory _cache |
| 60 | + ) |
| 61 | + |
| 62 | +add_custom_command( |
| 63 | + OUTPUT ParserResults.pkl ${globalgen_src} |
| 64 | + COMMAND python -B ${bindings_src}/pythonpath.py -I ${bindings_src}/parser -I ${bindings_src}/ply |
| 65 | + ${bindings_src}/GlobalGen.py |
| 66 | + --cachedir=_cache |
| 67 | + --filelist=webidls.list |
| 68 | + ${bindings_src}/Bindings.conf |
| 69 | + . |
| 70 | + ${PROJECT_SOURCE_DIR} |
| 71 | + DEPENDS Bindings _cache ${globalgen_deps} ${webidls} |
| 72 | + VERBATIM |
| 73 | + ) |
| 74 | + |
| 75 | +add_custom_target(generate-bindings ALL DEPENDS ${globalgen_src}) |
| 76 | + |
| 77 | +foreach(binding IN LISTS bindings) |
| 78 | + add_custom_command( |
| 79 | + OUTPUT Bindings/${binding}Binding.rs |
| 80 | + COMMAND python -B ${bindings_src}/pythonpath.py -I ${bindings_src}/parser -I ${bindings_src}/ply |
| 81 | + ${bindings_src}/BindingGen.py |
| 82 | + ${bindings_src}/Bindings.conf |
| 83 | + . |
| 84 | + Bindings/${binding}Binding |
| 85 | + ${webidls_src}/${binding}.webidl |
| 86 | + DEPENDS Bindings ${bindinggen_deps} ${webidls_src}/${binding}.webidl ParserResults.pkl |
| 87 | + VERBATIM |
| 88 | + ) |
| 89 | + add_custom_target(${binding} DEPENDS Bindings/${binding}Binding.rs) |
| 90 | + add_dependencies(generate-bindings ${binding}) |
| 91 | +endforeach() |
| 92 | + |
| 93 | +PREPEND(globalgen_out ${CMAKE_BINARY_DIR}/ ${globalgen_base_src}) |
| 94 | +install(FILES ${globalgen_out} DESTINATION .) |
| 95 | +install(DIRECTORY ${CMAKE_BINARY_DIR}/Bindings/ DESTINATION Bindings) |
0 commit comments