Mercurial > hg > orthanc-stone
view Resources/CMake/ProtobufCodeGeneration.cmake @ 508:7105a0bad250 bgo-commands-codegen
- Added HandleSerializedMessage to IStoneApplication (empty impl)
- Split UpdateWebApplication with "WithString" and "WithSerializedMessage" variants
- Due to the modules in TS, globals are now unallowed and the callbacks from C++ to JS are stored in the "window" instance
- Split UpdateStoneApplicationStatusFromCpp with "WithString" and "WithSerializedMessage" variants
- Split NotifyStatusUpdateFromCppToWeb with "WithString" and "WithSerializedMessage" variants
- SendMessageToStoneApplication (C++ global) has been split into SendSerializedMessageToStoneApplication and SendCommandToStoneApplication
- In WasmPlatformApplicationAdapter: HandleMessageFromWeb becomes HandleCommandFromWeb
- In WasmPlatformApplicationAdapter: added HandleSerializedMessageFromWeb
- stonegentool now handles the "json" primitive type (used, a.o., in the VSOL "EditInstance" message)
- Fixed indentation and added json serialization overloads in the stonegentool templates
- Added test of the json primitive type to testWasmIntegrated (in Resources/CodeGeneration)
- Adapted testWasmIntegrated (in Resources/CodeGeneration) to the changes above
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Wed, 06 Mar 2019 10:14:59 +0100 |
parents | 5055031f4a06 |
children |
line wrap: on
line source
# HOW TO USE: # the GenerateCodeFromProtobufSchema will generate files in ${CMAKE_BINARY_DIR} and will # populate PROTOBUF_AUTOGENERATED_SOURCES with the list of generated files # AS OF 2019-01-30, it requires protoc (version 3.6.1.x) to be available in the path set(PROTOBUF_AUTOGENERATED_SOURCES) # TODO: use find_program (<VAR> name1 [path1 path2 ...]) to located the protobuf compiler # TODO: automated the TS plugin installation macro(GenerateCodeFromProtobufSchema schemaFilePath outputBaseDirectory) # extract file name GetFilePathWithoutLastExtension(schemaFilePathWithoutExt ${schemaFilePath}) # remove extension GetFilenameFromPath(schemaFileNameWithoutExt ${schemaFilePathWithoutExt}) set(generatedFilePathWithoutExtension "${CMAKE_BINARY_DIR}/AUTOGENERATED/${schemaFileNameWithoutExt}") set(generatedCppSourceFilePath "${generatedFilePathWithoutExtension}.pb.cc") set(generatedCppHeaderFilePath "${generatedFilePathWithoutExtension}.pb.h") set(generatedJsFilePath "${generatedFilePathWithoutExtension}_pb.js") set(generatedTsFilePath "${generatedFilePathWithoutExtension}_pb.d.ts") # set(generatedJsFileName "${generatedFilePathWithoutExtension}.js") # set(AUTOGENERATED_DIR "${CMAKE_CURRENT_BINARY_DIR}/AUTOGENERATED") # set(AUTOGENERATED_SOURCES) set(PROTOC_EXECUTABLE "PROTOC") find_program(PROTOC_EXECUTABLE_SEARCH ${FLATC_EXECUTABLE}) if(NOT PROTOC_EXECUTABLE_SEARCH) message(FATAL_ERROR "The Protocol Buffers compiler (protoc[.exe]) cannot be found!") endif() # TODO CUSTOMIZE FOR TYPESCRIPT set(SCRIPT_CPP_OPTIONS) list(APPEND SCRIPT_CPP_OPTIONS "----cpp_out=${CMAKE_BINARY_DIR}/AUTOGENERATED") # list(APPEND SCRIPT_CPP_OPTIONS "gnagna") set(SCRIPT_TS_OPTIONS) list(APPEND SCRIPT_TS_OPTIONS "--ts") list(APPEND SCRIPT_TS_OPTIONS "gnagna") add_custom_command( OUTPUT ${generatedCppSourceFilePath} ${generatedCppHeaderFilePath} COMMAND ${PROTOC_EXECUTABLE} ${SCRIPT_CPP_OPTIONS} ${schemaFilePath} DEPENDS ${schemaFilePath} ) add_custom_command( OUTPUT ${generatedTsFileName} ${generatedJsFilePath} COMMAND ${PROTOC_EXECUTABLE} ${SCRIPT_TS_OPTIONS} ${schemaFilePath} DEPENDS ${schemaFilePath} ) # add_custom_command( # OUTPUT # ${generatedJsFileName} # COMMAND # ${FLATC_EXECUTABLE} ${SCRIPT_JS_OPTIONS} ${schemaFilePath} # DEPENDS # ${schemaFilePath} # ) list(APPEND FLATC_AUTOGENERATED_SOURCES "${generatedCppFileName}") # list(APPEND FLATC_AUTOGENERATED_SOURCES "${generatedJsFileName}") list(APPEND FLATC_AUTOGENERATED_SOURCES "${generatedTsFileName}") endmacro()