diff options
author | Thiago de Arruda <tpadilha84@gmail.com> | 2014-04-10 15:51:44 -0300 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2014-04-11 14:07:45 -0300 |
commit | 35ff53c6b0a98f6376cca5f42ab96499e4b476b6 (patch) | |
tree | 6f3a406846587d3c3ff250b36bfe6ff51e0d5c69 /src | |
parent | 6eeb006c4a225d4b1b9bb7d887759bcb491b2c97 (diff) | |
download | rneovim-35ff53c6b0a98f6376cca5f42ab96499e4b476b6.tar.gz rneovim-35ff53c6b0a98f6376cca5f42ab96499e4b476b6.tar.bz2 rneovim-35ff53c6b0a98f6376cca5f42ab96499e4b476b6.zip |
Add `msgpack_rpc_dispatch`/metadata generator
This adds a lua script which parses the contents of 'api.h'. After the api is
parsed into a metadata table. After that, it will generate:
- A msgpack blob for the metadata table. This msgpack object contains everything
scripting engines need to generate their own wrappers for the remote API.
- The `msgpack_rpc_dispatch` function, which takes care of validating msgpack
requests, converting arguments to C types and passing control to the
appropriate 'api.h' function. The result is then serialized back to msgpack
and returned to the client.
This approach was used because:
- It automatically modifies `msgpack_rpc_dispatch` to reflect API changes.
- Scripting engines that generate remote call wrappers using the msgpack
metadata will also adapt automatically to API changes
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 48f656fad4..8e38839e24 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,5 +1,27 @@ include(CheckLibraryExists) +if(DEFINED ENV{LUA_BINARY}) + set(LUA_BIN $ENV{LUA_BINARY}) +else() + set(LUA_BIN ${DEPS_BIN_DIR}/luajit) +endif() + +set(GENERATED_DIR ${PROJECT_BINARY_DIR}/src/auto) +set(DISPATCH_GENERATOR ${PROJECT_SOURCE_DIR}/scripts/msgpack-gen.lua) +set(API_HEADER ${PROJECT_SOURCE_DIR}/src/api.h) +set(MSGPACK_RPC_HEADER ${PROJECT_SOURCE_DIR}/src/msgpack_rpc.h) +set(MSGPACK_DISPATCH ${GENERATED_DIR}/msgpack_dispatch.c) + +file(MAKE_DIRECTORY ${GENERATED_DIR}) + +add_custom_command(OUTPUT ${MSGPACK_DISPATCH} + COMMAND ${LUA_BIN} ${DISPATCH_GENERATOR} ${API_HEADER} ${MSGPACK_DISPATCH} + DEPENDS + ${API_HEADER} + ${MSGPACK_RPC_HEADER} + ${DISPATCH_GENERATOR} + ) + file( GLOB NEOVIM_SOURCES *.c ) foreach(sfile ${NEOVIM_SOURCES}) @@ -11,6 +33,7 @@ endforeach() list(REMOVE_ITEM NEOVIM_SOURCES ${to_remove}) list(APPEND NEOVIM_SOURCES "${PROJECT_BINARY_DIR}/config/auto/pathdef.c") +list(APPEND NEOVIM_SOURCES "${MSGPACK_DISPATCH}") file( GLOB OS_SOURCES os/*.c ) |