##############################################################################
# API
##############################################################################
-function(vpp_generate_api_header file)
+function(vpp_generate_api_c_header file)
set (output_name ${CMAKE_CURRENT_BINARY_DIR}/${file}.h)
get_filename_component(output_dir ${output_name} DIRECTORY)
add_custom_command (OUTPUT ${output_name}
COMMAND ${CMAKE_SOURCE_DIR}/tools/vppapigen/vppapigen
ARGS --includedir ${CMAKE_SOURCE_DIR} --input ${CMAKE_CURRENT_SOURCE_DIR}/${file} --output ${output_name}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${file}
- COMMENT "Generating API header ${file}.h"
+ COMMENT "Generating API header ${output_name}"
+ )
+endfunction()
+
+function(vpp_generate_api_json_header file)
+ set (output_name ${CMAKE_CURRENT_BINARY_DIR}/${file}.json)
+ get_filename_component(output_dir ${output_name} DIRECTORY)
+ add_custom_command (OUTPUT ${output_name}
+ COMMAND mkdir -p ${output_dir}
+ COMMAND ${CMAKE_SOURCE_DIR}/tools/vppapigen/vppapigen
+ ARGS --includedir ${CMAKE_SOURCE_DIR} --input ${CMAKE_CURRENT_SOURCE_DIR}/${file} JSON --output ${output_name}
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${file}
+ COMMENT "Generating API header ${output_name}"
)
endfunction()
+function(vpp_generate_api_header file)
+ vpp_generate_api_c_header (${file})
+ vpp_generate_api_json_header (${file})
+endfunction()
+
function(vpp_add_api_files target)
unset(header_files)
foreach(file ${ARGN})
vpp_generate_api_header (${file})
- list (APPEND header_files ${file}.h)
+ list (APPEND header_files ${file}.h ${file}.json)
endforeach()
add_custom_target(${target} DEPENDS ${header_files})
endfunction()
# See the License for the specific language governing permissions and
# limitations under the License.
-vpp_generate_api_header(memclnt.api)
-add_custom_target(vlibmemory_api_headers DEPENDS memclnt.api.h)
+vpp_add_api_files(vlibmemory_api_headers
+ memclnt.api
+)
add_library (vlibmemory SHARED
memory_api.c
vxlan/vxlan.c
)
-set (VNET_API_FILES
+vpp_add_api_files(vnet_api_headers
vxlan-gpe/vxlan_gpe.api
ip/ip.api
ip/rd_cp.api
bfd/bfd.api
)
-set(VNET_API_HDRS)
-foreach (file ${VNET_API_FILES})
- vpp_generate_api_header(${file})
- list(APPEND VNET_API_HDRS ${file}.h)
-endforeach()
-add_custom_target(vnet_api_headers DEPENDS ${VNET_API_HDRS})
-
add_library(vnet SHARED ${VNET_SRCS})
vpp_library_set_multiarch_sources(vnet