diff --git a/CMakeLists.txt b/CMakeLists.txt index 1d1d75061..c0d689331 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,7 @@ option(BUILD_APPS "Build the hicn apps" OFF) option(BUILD_CTRL "Build the hicn control tools" ON) option(BUILD_HICNPLUGIN "Build the hicn vpp plugin" OFF) option(BUILD_HICNEXTRAPLUGIN "Build the hicn extra plugin" OFF) +option(BUILD_SYSREPOPLUGIN "Build the sysrepo plugin" OFF) list(APPEND dir_options BUILD_LIBHICN @@ -36,6 +37,10 @@ list(APPEND dir_options BUILD_UTILS BUILD_APPS BUILD_CTRL + BUILD_HICNPLUGIN + BUILD_HICNEXTRAPLUGIN + BUILD_SYSREPOPLUGIN + BUILD_LIBMEMIF ) set(BUILD_LIBHICN_DIR lib) @@ -45,7 +50,9 @@ set(BUILD_UTILS_DIR utils) set(BUILD_APPS_DIR apps) set(BUILD_CTRL_DIR ctrl) set(BUILD_HICNPLUGIN_DIR hicn-plugin) -set(BUILD_HICNEXTRAPLUGIN_DIR utils/extras/) +set(BUILD_SYSREPOPLUGIN_DIR ctrl/sysrepo-plugins) +set(BUILD_HICNEXTRAPLUGIN_DIR extras/hicn-extra-plugin) +set(BUILD_LIBMEMIF_DIR extras/libmemif) ## Add enabled components foreach (opt ${dir_options}) @@ -69,11 +76,20 @@ set(HICN_CTRL hicn-ctrl) set(LIBHICN_CTRL hicn-ctrl) set(HICN_APPS hicn-apps) set(FACE_MGR facemgr) +set(LIBMEMIF memif) if (BUILD_HICNPLUGIN AND "${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") - list(APPEND subdirs - ${BUILD_HICNPLUGIN_DIR} - ) + find_package(Libmemif) + + if (NOT Libmemif_FOUND) + message(STATUS "Libmemif not found in the system. Building it as external project.") + list(INSERT subdirs 0 + ${BUILD_LIBMEMIF_DIR} + ) + + unset(LIBMEMIF_INCLUDE_DIRS) + unset(LIBMEMIF_LIBRARIES) + endif() list(APPEND HICN_BINARY_API_INCLUDE_DIRS ${PROJECT_BINARY_DIR}/hicn-plugin @@ -83,20 +99,16 @@ if (BUILD_HICNPLUGIN AND "${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") set(LIBTRANSPORT ${LIBTRANSPORT}-memif) endif() -if (BUILD_HICNEXTRAPLUGIN AND "${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") - list(APPEND subdirs - ${BUILD_HICNEXTRAPLUGIN_DIR} - ) -endif() - ## Libraries targets set(LIBHICN_SHARED ${LIBHICN}.shared) set(LIBTRANSPORT_SHARED ${LIBTRANSPORT}.shared) set(LIBHICN_CTRL_SHARED ${LIBHICN_CTRL}.shared) +set(LIBMEMIF_SHARED ${LIBMEMIF}.shared) set(LIBHICN_STATIC ${LIBHICN}.static) set(LIBTRANSPORT_STATIC ${LIBTRANSPORT}.static) set(LIBHICN_CTRL_STATIC ${LIBHICN_CTRL}.static) +set(LIBMEMIF_STATIC ${LIBMEMIF}.static) ## HEADER FILES set(HICN_INCLUDE_DIRS "" "" CACHE INTERNAL "" FORCE) diff --git a/apps/higet/CMakeLists.txt b/apps/higet/CMakeLists.txt index d337f2620..83a13bcca 100644 --- a/apps/higet/CMakeLists.txt +++ b/apps/higet/CMakeLists.txt @@ -23,7 +23,7 @@ set(CMAKE_MODULE_PATH ) if (NOT CMAKE_BUILD_TYPE) - message(STATUS "No build type selected, default to Release") + message(STATUS "${PROJECT_NAME}: No build type selected, default to Release") set(CMAKE_BUILD_TYPE "Release") endif () diff --git a/apps/http-proxy/CMakeLists.txt b/apps/http-proxy/CMakeLists.txt index 0b97c0e5c..7e29edcf8 100644 --- a/apps/http-proxy/CMakeLists.txt +++ b/apps/http-proxy/CMakeLists.txt @@ -20,7 +20,7 @@ set(CMAKE_MODULE_PATH ) if (NOT CMAKE_BUILD_TYPE) - message(STATUS "No build type selected, default to Release") + message(STATUS "${PROJECT_NAME}: No build type selected, default to Release") set(CMAKE_BUILD_TYPE "Release") endif () diff --git a/ctrl/facemgr/CMakeLists.txt b/ctrl/facemgr/CMakeLists.txt index fcd221a98..f688dd2ca 100644 --- a/ctrl/facemgr/CMakeLists.txt +++ b/ctrl/facemgr/CMakeLists.txt @@ -21,7 +21,7 @@ endif() project(facemgr) if (NOT CMAKE_BUILD_TYPE) - message(STATUS "No build type selected, default to Release") + message(STATUS "${PROJECT_NAME}: No build type selected, default to Release") set(CMAKE_BUILD_TYPE "Release") endif() diff --git a/ctrl/libhicnctrl/CMakeLists.txt b/ctrl/libhicnctrl/CMakeLists.txt index 3a2358f65..cb1bd722c 100644 --- a/ctrl/libhicnctrl/CMakeLists.txt +++ b/ctrl/libhicnctrl/CMakeLists.txt @@ -16,7 +16,7 @@ cmake_minimum_required(VERSION 3.5 FATAL_ERROR) project(libhicnctrl) if (NOT CMAKE_BUILD_TYPE) - message(STATUS "No build type selected, default to Release") + message(STATUS "${PROJECT_NAME}: No build type selected, default to Release") set(CMAKE_BUILD_TYPE "Release") endif() diff --git a/utils/sysrepo-plugins/CMakeLists.txt b/ctrl/sysrepo-plugins/CMakeLists.txt similarity index 100% rename from utils/sysrepo-plugins/CMakeLists.txt rename to ctrl/sysrepo-plugins/CMakeLists.txt diff --git a/utils/sysrepo-plugins/README.md b/ctrl/sysrepo-plugins/README.md similarity index 100% rename from utils/sysrepo-plugins/README.md rename to ctrl/sysrepo-plugins/README.md diff --git a/utils/sysrepo-plugins/cmake/FindHicnLight.cmake b/ctrl/sysrepo-plugins/cmake/FindHicnLight.cmake similarity index 100% rename from utils/sysrepo-plugins/cmake/FindHicnLight.cmake rename to ctrl/sysrepo-plugins/cmake/FindHicnLight.cmake diff --git a/utils/sysrepo-plugins/cmake/FindHicnPlugin.cmake b/ctrl/sysrepo-plugins/cmake/FindHicnPlugin.cmake similarity index 100% rename from utils/sysrepo-plugins/cmake/FindHicnPlugin.cmake rename to ctrl/sysrepo-plugins/cmake/FindHicnPlugin.cmake diff --git a/utils/sysrepo-plugins/cmake/FindSysrepo.cmake b/ctrl/sysrepo-plugins/cmake/FindSysrepo.cmake similarity index 100% rename from utils/sysrepo-plugins/cmake/FindSysrepo.cmake rename to ctrl/sysrepo-plugins/cmake/FindSysrepo.cmake diff --git a/utils/sysrepo-plugins/cmake/FindVPP.cmake b/ctrl/sysrepo-plugins/cmake/FindVPP.cmake similarity index 100% rename from utils/sysrepo-plugins/cmake/FindVPP.cmake rename to ctrl/sysrepo-plugins/cmake/FindVPP.cmake diff --git a/utils/sysrepo-plugins/cmake/Packager.cmake b/ctrl/sysrepo-plugins/cmake/Packager.cmake similarity index 100% rename from utils/sysrepo-plugins/cmake/Packager.cmake rename to ctrl/sysrepo-plugins/cmake/Packager.cmake diff --git a/utils/sysrepo-plugins/cmake/Packaging.cmake b/ctrl/sysrepo-plugins/cmake/Packaging.cmake similarity index 100% rename from utils/sysrepo-plugins/cmake/Packaging.cmake rename to ctrl/sysrepo-plugins/cmake/Packaging.cmake diff --git a/utils/sysrepo-plugins/hicn-light/CMakeLists.txt b/ctrl/sysrepo-plugins/hicn-light/CMakeLists.txt similarity index 100% rename from utils/sysrepo-plugins/hicn-light/CMakeLists.txt rename to ctrl/sysrepo-plugins/hicn-light/CMakeLists.txt diff --git a/utils/sysrepo-plugins/hicn-light/plugin/CMakeLists.txt b/ctrl/sysrepo-plugins/hicn-light/plugin/CMakeLists.txt similarity index 100% rename from utils/sysrepo-plugins/hicn-light/plugin/CMakeLists.txt rename to ctrl/sysrepo-plugins/hicn-light/plugin/CMakeLists.txt diff --git a/utils/sysrepo-plugins/hicn-light/plugin/hicn_light.c b/ctrl/sysrepo-plugins/hicn-light/plugin/hicn_light.c similarity index 100% rename from utils/sysrepo-plugins/hicn-light/plugin/hicn_light.c rename to ctrl/sysrepo-plugins/hicn-light/plugin/hicn_light.c diff --git a/utils/sysrepo-plugins/hicn-light/plugin/hicn_light.h b/ctrl/sysrepo-plugins/hicn-light/plugin/hicn_light.h similarity index 100% rename from utils/sysrepo-plugins/hicn-light/plugin/hicn_light.h rename to ctrl/sysrepo-plugins/hicn-light/plugin/hicn_light.h diff --git a/utils/sysrepo-plugins/hicn-light/plugin/hicn_light_comm.c b/ctrl/sysrepo-plugins/hicn-light/plugin/hicn_light_comm.c similarity index 100% rename from utils/sysrepo-plugins/hicn-light/plugin/hicn_light_comm.c rename to ctrl/sysrepo-plugins/hicn-light/plugin/hicn_light_comm.c diff --git a/utils/sysrepo-plugins/hicn-light/plugin/hicn_light_comm.h b/ctrl/sysrepo-plugins/hicn-light/plugin/hicn_light_comm.h similarity index 100% rename from utils/sysrepo-plugins/hicn-light/plugin/hicn_light_comm.h rename to ctrl/sysrepo-plugins/hicn-light/plugin/hicn_light_comm.h diff --git a/utils/sysrepo-plugins/hicn-light/plugin/model/hicn_model.c b/ctrl/sysrepo-plugins/hicn-light/plugin/model/hicn_model.c similarity index 100% rename from utils/sysrepo-plugins/hicn-light/plugin/model/hicn_model.c rename to ctrl/sysrepo-plugins/hicn-light/plugin/model/hicn_model.c diff --git a/utils/sysrepo-plugins/hicn-light/plugin/model/hicn_model.h b/ctrl/sysrepo-plugins/hicn-light/plugin/model/hicn_model.h similarity index 100% rename from utils/sysrepo-plugins/hicn-light/plugin/model/hicn_model.h rename to ctrl/sysrepo-plugins/hicn-light/plugin/model/hicn_model.h diff --git a/utils/sysrepo-plugins/hicn-light/plugin/model/tlock.c b/ctrl/sysrepo-plugins/hicn-light/plugin/model/tlock.c similarity index 100% rename from utils/sysrepo-plugins/hicn-light/plugin/model/tlock.c rename to ctrl/sysrepo-plugins/hicn-light/plugin/model/tlock.c diff --git a/utils/sysrepo-plugins/hicn-light/plugin/model/tlock.h b/ctrl/sysrepo-plugins/hicn-light/plugin/model/tlock.h similarity index 100% rename from utils/sysrepo-plugins/hicn-light/plugin/model/tlock.h rename to ctrl/sysrepo-plugins/hicn-light/plugin/model/tlock.h diff --git a/utils/sysrepo-plugins/hicn-plugin/CMakeLists.txt b/ctrl/sysrepo-plugins/hicn-plugin/CMakeLists.txt similarity index 100% rename from utils/sysrepo-plugins/hicn-plugin/CMakeLists.txt rename to ctrl/sysrepo-plugins/hicn-plugin/CMakeLists.txt diff --git a/utils/sysrepo-plugins/hicn-plugin/plugin/hicn_plugin.c b/ctrl/sysrepo-plugins/hicn-plugin/plugin/hicn_plugin.c similarity index 100% rename from utils/sysrepo-plugins/hicn-plugin/plugin/hicn_plugin.c rename to ctrl/sysrepo-plugins/hicn-plugin/plugin/hicn_plugin.c diff --git a/utils/sysrepo-plugins/hicn-plugin/plugin/hicn_plugin.h b/ctrl/sysrepo-plugins/hicn-plugin/plugin/hicn_plugin.h similarity index 100% rename from utils/sysrepo-plugins/hicn-plugin/plugin/hicn_plugin.h rename to ctrl/sysrepo-plugins/hicn-plugin/plugin/hicn_plugin.h diff --git a/utils/sysrepo-plugins/hicn-plugin/plugin/hicn_vpp_comm.c b/ctrl/sysrepo-plugins/hicn-plugin/plugin/hicn_vpp_comm.c similarity index 100% rename from utils/sysrepo-plugins/hicn-plugin/plugin/hicn_vpp_comm.c rename to ctrl/sysrepo-plugins/hicn-plugin/plugin/hicn_vpp_comm.c diff --git a/utils/sysrepo-plugins/hicn-plugin/plugin/hicn_vpp_comm.h b/ctrl/sysrepo-plugins/hicn-plugin/plugin/hicn_vpp_comm.h similarity index 100% rename from utils/sysrepo-plugins/hicn-plugin/plugin/hicn_vpp_comm.h rename to ctrl/sysrepo-plugins/hicn-plugin/plugin/hicn_vpp_comm.h diff --git a/utils/sysrepo-plugins/hicn-plugin/plugin/ietf/ietf_interface.c b/ctrl/sysrepo-plugins/hicn-plugin/plugin/ietf/ietf_interface.c similarity index 100% rename from utils/sysrepo-plugins/hicn-plugin/plugin/ietf/ietf_interface.c rename to ctrl/sysrepo-plugins/hicn-plugin/plugin/ietf/ietf_interface.c diff --git a/utils/sysrepo-plugins/hicn-plugin/plugin/ietf/ietf_interface.h b/ctrl/sysrepo-plugins/hicn-plugin/plugin/ietf/ietf_interface.h similarity index 100% rename from utils/sysrepo-plugins/hicn-plugin/plugin/ietf/ietf_interface.h rename to ctrl/sysrepo-plugins/hicn-plugin/plugin/ietf/ietf_interface.h diff --git a/utils/sysrepo-plugins/hicn-plugin/plugin/model/hicn_model.c b/ctrl/sysrepo-plugins/hicn-plugin/plugin/model/hicn_model.c similarity index 100% rename from utils/sysrepo-plugins/hicn-plugin/plugin/model/hicn_model.c rename to ctrl/sysrepo-plugins/hicn-plugin/plugin/model/hicn_model.c diff --git a/utils/sysrepo-plugins/hicn-plugin/plugin/model/hicn_model.h b/ctrl/sysrepo-plugins/hicn-plugin/plugin/model/hicn_model.h similarity index 100% rename from utils/sysrepo-plugins/hicn-plugin/plugin/model/hicn_model.h rename to ctrl/sysrepo-plugins/hicn-plugin/plugin/model/hicn_model.h diff --git a/utils/sysrepo-plugins/hicn-plugin/plugin/model/tlock.c b/ctrl/sysrepo-plugins/hicn-plugin/plugin/model/tlock.c similarity index 100% rename from utils/sysrepo-plugins/hicn-plugin/plugin/model/tlock.c rename to ctrl/sysrepo-plugins/hicn-plugin/plugin/model/tlock.c diff --git a/utils/sysrepo-plugins/hicn-plugin/plugin/model/tlock.h b/ctrl/sysrepo-plugins/hicn-plugin/plugin/model/tlock.h similarity index 100% rename from utils/sysrepo-plugins/hicn-plugin/plugin/model/tlock.h rename to ctrl/sysrepo-plugins/hicn-plugin/plugin/model/tlock.h diff --git a/utils/sysrepo-plugins/yang/hicn/hicn.yang b/ctrl/sysrepo-plugins/yang/hicn/hicn.yang similarity index 100% rename from utils/sysrepo-plugins/yang/hicn/hicn.yang rename to ctrl/sysrepo-plugins/yang/hicn/hicn.yang diff --git a/utils/sysrepo-plugins/yang/hicn/rpc_call_samples.xml b/ctrl/sysrepo-plugins/yang/hicn/rpc_call_samples.xml similarity index 100% rename from utils/sysrepo-plugins/yang/hicn/rpc_call_samples.xml rename to ctrl/sysrepo-plugins/yang/hicn/rpc_call_samples.xml diff --git a/utils/sysrepo-plugins/yang/hicn/sysrepo_startup.xml b/ctrl/sysrepo-plugins/yang/hicn/sysrepo_startup.xml similarity index 100% rename from utils/sysrepo-plugins/yang/hicn/sysrepo_startup.xml rename to ctrl/sysrepo-plugins/yang/hicn/sysrepo_startup.xml diff --git a/utils/sysrepo-plugins/yang/ietf/iana-if-type@2014-05-08.yang b/ctrl/sysrepo-plugins/yang/ietf/iana-if-type@2014-05-08.yang similarity index 100% rename from utils/sysrepo-plugins/yang/ietf/iana-if-type@2014-05-08.yang rename to ctrl/sysrepo-plugins/yang/ietf/iana-if-type@2014-05-08.yang diff --git a/utils/sysrepo-plugins/yang/ietf/ietf-interfaces.yang b/ctrl/sysrepo-plugins/yang/ietf/ietf-interfaces.yang similarity index 100% rename from utils/sysrepo-plugins/yang/ietf/ietf-interfaces.yang rename to ctrl/sysrepo-plugins/yang/ietf/ietf-interfaces.yang diff --git a/utils/sysrepo-plugins/yang/ietf/ietf-ip@2014-06-16.yang b/ctrl/sysrepo-plugins/yang/ietf/ietf-ip@2014-06-16.yang similarity index 100% rename from utils/sysrepo-plugins/yang/ietf/ietf-ip@2014-06-16.yang rename to ctrl/sysrepo-plugins/yang/ietf/ietf-ip@2014-06-16.yang diff --git a/utils/sysrepo-plugins/yang/ietf/ietf-yang-types@2013-07-15.yang b/ctrl/sysrepo-plugins/yang/ietf/ietf-yang-types@2013-07-15.yang similarity index 100% rename from utils/sysrepo-plugins/yang/ietf/ietf-yang-types@2013-07-15.yang rename to ctrl/sysrepo-plugins/yang/ietf/ietf-yang-types@2013-07-15.yang diff --git a/utils/extras/CMakeLists.txt b/extras/hicn-extra-plugin/CMakeLists.txt similarity index 78% rename from utils/extras/CMakeLists.txt rename to extras/hicn-extra-plugin/CMakeLists.txt index d92ac4a68..6147afa1b 100644 --- a/utils/extras/CMakeLists.txt +++ b/extras/hicn-extra-plugin/CMakeLists.txt @@ -24,19 +24,19 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} set (CMAKE_CXX_STANDARD 11) set (CMAKE_C_STANDARD 11) +include (Packaging) + # Check for memfd_create syscall include(CheckSymbolExists) CHECK_SYMBOL_EXISTS ( "__NR_memfd_create" "sys/syscall.h" HAVE_MEMFD_CREATE ) if ( HAVE_MEMFD_CREATE ) - add_definitions ( -DHAVE_MEMFD_CREATE ) + add_definitions ( -DHAVE_MEMFD_CREATE ) endif() if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR) - set(HICN_EXTRA_PLUGIN extra-plugin) + set(HICN_EXTRA_PLUGIN extra-plugin) endif() -include (Packaging) - # Dependencies find_package(Vpp REQUIRED) @@ -60,17 +60,20 @@ set(HICN_EXTRA_PLUGIN_HEADER_FILES ) if (NOT VPP_HOME) - set(VPP_HOME /usr) + set(VPP_HOME /usr) endif() if (NOT CMAKE_BUILD_TYPE) set (CMAKE_BUILD_TYPE "Release") endif (NOT CMAKE_BUILD_TYPE) -SET(EXTRA_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR} CACHE STRING "extra_install_prefix") +SET(EXTRA_INSTALL_PREFIX + ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR} + CACHE STRING "extra_install_prefix" +) if (CMAKE_BUILD_TYPE STREQUAL "Release") - set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Wall -march=native -O3 -g") + set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Wall -march=native -O3 -g") elseif (CMAKE_BUILD_TYPE STREQUAL "Debug") set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall -march=native -O0 -g") add_definitions(-DCLIB_DEBUG -fPIC -fstack-protector-all) @@ -80,25 +83,30 @@ include_directories(SYSTEM) include_directories(${CMAKE_CURRENT_BINARY_DIR}) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DEXTRA_VPP_PLUGIN=1") + add_library(hicn_extra_plugin SHARED - ${HICN_EXTRA_PLUGIN_SOURCE_FILES}) + ${HICN_EXTRA_PLUGIN_SOURCE_FILES} +) include_directories(${CMAKE_CURRENT_BINARY_DIR}/vpp_plugins) set(VPP_INSTALL_PLUGIN ${EXTRA_INSTALL_PREFIX}/vpp_plugins) set_target_properties(hicn_extra_plugin - PROPERTIES - LINKER_LANGUAGE C - INSTALL_RPATH ${VPP_INSTALL_PLUGIN} - PREFIX "" - LIBRARY_OUTPUT_NAME "hicn_router") + PROPERTIES + LINKER_LANGUAGE C + INSTALL_RPATH ${VPP_INSTALL_PLUGIN} + PREFIX "" + LIBRARY_OUTPUT_NAME "hicn_router" +) install(DIRECTORY - DESTINATION ${VPP_INSTALL_PLUGIN} - COMPONENT ${HICN_EXTRA_PLUGIN}) + DESTINATION ${VPP_INSTALL_PLUGIN} + COMPONENT ${HICN_EXTRA_PLUGIN} +) install(TARGETS hicn_extra_plugin - DESTINATION - ${VPP_INSTALL_PLUGIN} - COMPONENT ${HICN_EXTRA_PLUGIN}) + DESTINATION + ${VPP_INSTALL_PLUGIN} + COMPONENT ${HICN_EXTRA_PLUGIN} +) diff --git a/utils/extras/README.md b/extras/hicn-extra-plugin/README.md similarity index 100% rename from utils/extras/README.md rename to extras/hicn-extra-plugin/README.md diff --git a/utils/extras/cmake/Modules/Packaging.cmake b/extras/hicn-extra-plugin/cmake/Modules/Packaging.cmake similarity index 100% rename from utils/extras/cmake/Modules/Packaging.cmake rename to extras/hicn-extra-plugin/cmake/Modules/Packaging.cmake diff --git a/utils/extras/devices/rtnetlink/mapper.c b/extras/hicn-extra-plugin/devices/rtnetlink/mapper.c similarity index 100% rename from utils/extras/devices/rtnetlink/mapper.c rename to extras/hicn-extra-plugin/devices/rtnetlink/mapper.c diff --git a/utils/extras/devices/rtnetlink/mapper.h b/extras/hicn-extra-plugin/devices/rtnetlink/mapper.h similarity index 100% rename from utils/extras/devices/rtnetlink/mapper.h rename to extras/hicn-extra-plugin/devices/rtnetlink/mapper.h diff --git a/utils/extras/devices/rtnetlink/netns.c b/extras/hicn-extra-plugin/devices/rtnetlink/netns.c similarity index 100% rename from utils/extras/devices/rtnetlink/netns.c rename to extras/hicn-extra-plugin/devices/rtnetlink/netns.c diff --git a/utils/extras/devices/rtnetlink/netns.h b/extras/hicn-extra-plugin/devices/rtnetlink/netns.h similarity index 100% rename from utils/extras/devices/rtnetlink/netns.h rename to extras/hicn-extra-plugin/devices/rtnetlink/netns.h diff --git a/utils/extras/devices/rtnetlink/rtnl.c b/extras/hicn-extra-plugin/devices/rtnetlink/rtnl.c similarity index 100% rename from utils/extras/devices/rtnetlink/rtnl.c rename to extras/hicn-extra-plugin/devices/rtnetlink/rtnl.c diff --git a/utils/extras/devices/rtnetlink/rtnl.h b/extras/hicn-extra-plugin/devices/rtnetlink/rtnl.h similarity index 100% rename from utils/extras/devices/rtnetlink/rtnl.h rename to extras/hicn-extra-plugin/devices/rtnetlink/rtnl.h diff --git a/utils/extras/devices/rtnetlink/test.c b/extras/hicn-extra-plugin/devices/rtnetlink/test.c similarity index 100% rename from utils/extras/devices/rtnetlink/test.c rename to extras/hicn-extra-plugin/devices/rtnetlink/test.c diff --git a/utils/extras/rtinject/tap_inject.c b/extras/hicn-extra-plugin/rtinject/tap_inject.c similarity index 100% rename from utils/extras/rtinject/tap_inject.c rename to extras/hicn-extra-plugin/rtinject/tap_inject.c diff --git a/utils/extras/rtinject/tap_inject.h b/extras/hicn-extra-plugin/rtinject/tap_inject.h similarity index 100% rename from utils/extras/rtinject/tap_inject.h rename to extras/hicn-extra-plugin/rtinject/tap_inject.h diff --git a/utils/extras/rtinject/tap_inject_netlink.c b/extras/hicn-extra-plugin/rtinject/tap_inject_netlink.c similarity index 100% rename from utils/extras/rtinject/tap_inject_netlink.c rename to extras/hicn-extra-plugin/rtinject/tap_inject_netlink.c diff --git a/utils/extras/rtinject/tap_inject_node.c b/extras/hicn-extra-plugin/rtinject/tap_inject_node.c similarity index 100% rename from utils/extras/rtinject/tap_inject_node.c rename to extras/hicn-extra-plugin/rtinject/tap_inject_node.c diff --git a/utils/extras/rtinject/tap_inject_tap.c b/extras/hicn-extra-plugin/rtinject/tap_inject_tap.c similarity index 100% rename from utils/extras/rtinject/tap_inject_tap.c rename to extras/hicn-extra-plugin/rtinject/tap_inject_tap.c diff --git a/extras/libmemif/CMakeLists.txt b/extras/libmemif/CMakeLists.txt new file mode 100644 index 000000000..c9cea96f1 --- /dev/null +++ b/extras/libmemif/CMakeLists.txt @@ -0,0 +1,68 @@ +# Copyright (c) 2019 Cisco and/or its affiliates. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set(CMAKE_MODULE_PATH + ${CMAKE_MODULE_PATH} + "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/Modules" + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules" +) + +include(ExternalProject) +include(Packaging) + +if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR) + set(LIBMEMIF memif) +endif() + +execute_process( + COMMAND bash -c "if [ ! -d vpp ]; then + git clone https://github.com/FDio/vpp.git -b stable/1908 vpp; + else + pushd vpp && git pull && popd; + fi" + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} +) + +execute_process( + COMMAND ${CMAKE_COMMAND} -E + remove_directory ${CMAKE_CURRENT_BINARY_DIR}/libmemif + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} +) + +execute_process( + COMMAND ${CMAKE_COMMAND} -E + copy_directory vpp/extras/libmemif ${CMAKE_CURRENT_BINARY_DIR}/libmemif + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} +) + +execute_process( + COMMAND ${CMAKE_COMMAND} -E rename ${CMAKE_CURRENT_BINARY_DIR}/libmemif/src + ${CMAKE_CURRENT_BINARY_DIR}/libmemif/memif + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} +) + +execute_process( + COMMAND + ${CMAKE_COMMAND} -E + copy ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists1.patch libmemif/CMakeLists.txt + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} +) + +execute_process( + COMMAND ${CMAKE_COMMAND} -E + copy ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists2.patch libmemif/memif/CMakeLists.txt + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} +) + +include(Packaging) +add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/libmemif ${CMAKE_CURRENT_BINARY_DIR}/libmemif) \ No newline at end of file diff --git a/extras/libmemif/CMakeLists1.patch b/extras/libmemif/CMakeLists1.patch new file mode 100644 index 000000000..f699a3ce5 --- /dev/null +++ b/extras/libmemif/CMakeLists1.patch @@ -0,0 +1,58 @@ +# Copyright (c) 2017 Cisco and/or its affiliates. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +cmake_minimum_required(VERSION 3.5 FATAL_ERROR) + +project(memif) +set(CMAKE_C_STANDARD 11) + +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake") + +include(CheckCCompilerFlag) +include(CheckFunctionExists) + +execute_process( + COMMAND find ${VPP_SRC} -type d -name "cmake" + OUTPUT_VARIABLE CMAKE_DEPS_FOLDER + OUTPUT_STRIP_TRAILING_WHITESPACE +) +include(BuildMacros) + +if (NOT CMAKE_BUILD_TYPE) + message(STATUS "${PROJECT_NAME}: No build type selected, default to Release") + set(CMAKE_BUILD_TYPE "Release") +endif () + +set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g -DMEMIF_DBG -DICMP_DBG") +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) +set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib) +set(CMAKE_INSTALL_MESSAGE NEVER) + +find_package(Threads REQUIRED) +include_directories(${CMAKE_THREADS_INCLUDE_DIRS}) + +check_function_exists(memfd_create HAVE_MEMFD_CREATE) +if(${HAVE_MEMFD_CREATE}) + add_definitions(-DHAVE_MEMFD_CREATE) +endif() + +include_directories(src) +set(LIBMEMIF memif) + +set(LIBMEMIF_INCLUDE_DIRS + ${CMAKE_CURRENT_SOURCE_DIR} + "" CACHE INTERNAL + "" FORCE +) + +add_subdirectory(memif) \ No newline at end of file diff --git a/extras/libmemif/CMakeLists2.patch b/extras/libmemif/CMakeLists2.patch new file mode 100644 index 000000000..69a7e773b --- /dev/null +++ b/extras/libmemif/CMakeLists2.patch @@ -0,0 +1,42 @@ +# Copyright (c) 2017 Cisco and/or its affiliates. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +cmake_minimum_required(VERSION 3.5 FATAL_ERROR) + +set(HEADERS_DIR ${CMAKE_CURRENT_SOURCE_DIR}) + +list(APPEND MEMIF_HEADERS + libmemif.h + memif.h +) + +list(APPEND MEMIF_PRIVATE_HEADERS + memif_private.h + socket.h +) + +list(APPEND MEMIF_SOURCES + main.c + socket.c +) + +include_directories(${HEADERS_DIR}) + +build_library(${LIBMEMIF} + SHARED + SOURCES ${MEMIF_SOURCES} + INSTALL_HEADERS ${MEMIF_HEADERS} + LINK_LIBRARIES ${CMAKE_THREAD_LIBS_INIT} + INSTALL_ROOT_DIR memif + COMPONENT libmemif +) \ No newline at end of file diff --git a/extras/libmemif/cmake/Modules/Packaging.cmake b/extras/libmemif/cmake/Modules/Packaging.cmake new file mode 100644 index 000000000..d6db75a72 --- /dev/null +++ b/extras/libmemif/cmake/Modules/Packaging.cmake @@ -0,0 +1,29 @@ +# Copyright (c) 2017-2019 Cisco and/or its affiliates. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +###################### +# Packages section +###################### + +set(${LIBMEMIF}_DESCRIPTION + "Libmemif, shared memory interface" + CACHE STRING "Description for deb/rpm package." +) + +set(${LIBMEMIF}_DEB_DEPENDENCIES + "" CACHE STRING "Dependencies for deb/rpm package." +) + +set(${LIBMEMIF}_RPM_DEPENDENCIES + "" CACHE STRING "Dependencies for deb/rpm package." +) diff --git a/hicn-light/CMakeLists.txt b/hicn-light/CMakeLists.txt index 31d189a3b..9edb146e4 100644 --- a/hicn-light/CMakeLists.txt +++ b/hicn-light/CMakeLists.txt @@ -16,7 +16,7 @@ cmake_minimum_required(VERSION 3.5 FATAL_ERROR) project(hicn-light) if (NOT CMAKE_BUILD_TYPE) - message(STATUS "No build type selected, default to Release") + message(STATUS "${PROJECT_NAME}: No build type selected, default to Release") set(CMAKE_BUILD_TYPE "Release") endif() diff --git a/hicn-plugin/CMakeLists.txt b/hicn-plugin/CMakeLists.txt index 15df64952..4a6d5e47d 100644 --- a/hicn-plugin/CMakeLists.txt +++ b/hicn-plugin/CMakeLists.txt @@ -207,12 +207,29 @@ elseif (CMAKE_BUILD_TYPE STREQUAL "Debug") endif() execute_process(COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/hicn) + # These files are missing from vpp binary distribution execute_process( - COMMAND curl https://git.fd.io/vpp/plain/src/vpp-api/vapi/vapi_json_parser.py?h=stable/1908 -o ${CMAKE_BINARY_DIR}/vapi_json_parser.py - COMMAND curl https://git.fd.io/vpp/plain/src/vpp-api/vapi/vapi_c_gen.py?h=stable/1908 -o ${CMAKE_BINARY_DIR}/vapi_c_gen.py - COMMAND curl https://git.fd.io/vpp/plain/src/vpp-api/vapi/vapi_cpp_gen.py?h=stable/1908 -o ${CMAKE_BINARY_DIR}/vapi_cpp_gen.py - ) + COMMAND + bash -c + "if [ ! -e ${CMAKE_BINARY_DIR}/vapi_json_parser.py ]; then + curl https://git.fd.io/vpp/plain/src/vpp-api/vapi/vapi_json_parser.py?h=stable/1908 -o ${CMAKE_BINARY_DIR}/vapi_json_parser.py; + fi;" +) +execute_process( + COMMAND + bash -c + "if [ ! -e ${CMAKE_BINARY_DIR}/vapi_c_gen.py ]; then + curl https://git.fd.io/vpp/plain/src/vpp-api/vapi/vapi_c_gen.py?h=stable/1908 -o ${CMAKE_BINARY_DIR}/vapi_c_gen.py; + fi;" +) +execute_process( + COMMAND + bash -c + "if [ ! -e ${CMAKE_BINARY_DIR}/vapi_cpp_gen.py ]; then + curl https://git.fd.io/vpp/plain/src/vpp-api/vapi/vapi_cpp_gen.py?h=stable/1908 -o ${CMAKE_BINARY_DIR}/vapi_cpp_gen.py; + fi;" +) add_custom_command( COMMAND chmod +x ${CMAKE_BINARY_DIR}/vapi_json_parser.py ${CMAKE_BINARY_DIR}/vapi_c_gen.py ${CMAKE_BINARY_DIR}/vapi_cpp_gen.py diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 4c51f3daf..9d8267f5f 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -22,7 +22,7 @@ set(CMAKE_MODULE_PATH ) if (NOT CMAKE_BUILD_TYPE) - message(STATUS "No build type selected, default to Release") + message(STATUS "${PROJECT_NAME}: No build type selected, default to Release") set(CMAKE_BUILD_TYPE "Release") endif() @@ -36,7 +36,7 @@ include (Packaging) option(CMAKE_BUILD_TEST "Build unit tests" OFF) if (NOT CMAKE_BUILD_TYPE) - message(STATUS "No build type selected, default to Release") + message(STATUS "${PROJECT_NAME}: No build type selected, default to Release") set(CMAKE_BUILD_TYPE "Release") endif() diff --git a/libtransport/CMakeLists.txt b/libtransport/CMakeLists.txt index fb059e390..68e9efe77 100644 --- a/libtransport/CMakeLists.txt +++ b/libtransport/CMakeLists.txt @@ -25,7 +25,7 @@ include(DefaultConfiguration) include(BuildMacros) if (NOT CMAKE_BUILD_TYPE) - message(STATUS "No build type selected, default to Release") + message(STATUS "${PROJECT_NAME}: No build type selected, default to Release") set(CMAKE_BUILD_TYPE "Release") endif () @@ -58,15 +58,9 @@ set(INSTALL_INCLUDE_DIR include/hicn/transport) if ((BUILD_HICNPLUGIN OR BUILD_MEMIF_CONNECTOR) AND "${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") set(__vpp__ 1) find_package(Vpp REQUIRED) - find_package(Libmemif REQUIRED) + list(APPEND LIBTRANSPORT_INTERNAL_INCLUDE_DIRS ${VPP_INCLUDE_DIRS} - ${LIBMEMIF_INCLUDE_DIRS} - ) - - list(APPEND LIBRARIES - # ${VPP_INCLUDE_DIRS} - ${LIBMEMIF_LIBRARIES} ) endif () @@ -76,33 +70,54 @@ find_package_wrapper(Libparc REQUIRED) find_package_wrapper(Asio REQUIRED) if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR) - find_package_wrapper(Libhicn REQUIRED) if (__vpp__) find_package_wrapper(HicnBinaryApi REQUIRED) + find_package(Libmemif REQUIRED) + + list(APPEND LIBRARIES + ${LIBMEMIF_LIBRARIES} + ) endif() + + find_package_wrapper(Libhicn REQUIRED) + set(LIBTRANSPORT hicntransport) set(LIBTRANSPORT_SHARED ${LIBTRANSPORT}.shared) set(LIBTRANSPORT_STATIC ${LIBTRANSPORT}.static) else() - if (ANDROID_API) + if(ANDROID_API) set(HICN_LIBRARIES ${LIBHICN_STATIC}) list(APPEND DEPENDENCIES ${LIBHICN_STATIC} ) - else () + else() set(HICN_LIBRARIES ${LIBHICN_SHARED}) list(APPEND DEPENDENCIES ${LIBHICN_SHARED} ) - endif () - if (__vpp__) - list(APPEND DEPENDENCIES - hicn_plugin - ) + if (__vpp__) + list(APPEND DEPENDENCIES + hicn_plugin + ) + + if (NOT Libmemif_FOUND) + list(APPEND DEPENDENCIES + ${LIBMEMIF_SHARED} + ) + + list(APPEND LIBRARIES + ${LIBMEMIF_SHARED} + ) + endif() + endif() endif() endif() +list(APPEND LIBTRANSPORT_INTERNAL_INCLUDE_DIRS + ${LIBMEMIF_INCLUDE_DIRS} +) + include(Packaging) find_package(Threads REQUIRED) diff --git a/libtransport/cmake/Modules/Packaging.cmake b/libtransport/cmake/Modules/Packaging.cmake index c7ba3d06d..bd6bfc11a 100644 --- a/libtransport/cmake/Modules/Packaging.cmake +++ b/libtransport/cmake/Modules/Packaging.cmake @@ -32,22 +32,22 @@ set(lib${LIBTRANSPORT}-devel_DESCRIPTION ${lib${LIBTRANSPORT}_DESCRIPTION} if ((BUILD_MEMIF_CONNECTOR OR BUILD_HICNPLUGIN) AND "${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") set(lib${LIBTRANSPORT}_DEB_DEPENDENCIES - "lib${LIBHICN} (>= stable_version), libparc (>= 1.0), vpp (>= stable_version-release), vpp (<< next_version-release)" + "lib${LIBHICN} (>= stable_version), libparc (>= 1.0), libmemif (>= stable_version), vpp (>= stable_version-release), vpp (<< next_version-release)" CACHE STRING "Dependencies for deb/rpm package." ) set(lib${LIBTRANSPORT}_RPM_DEPENDENCIES - "lib${LIBHICN} >= stable_version, libparc >= 1.0, vpp >= stable_version-release, vpp < next_version-release" + "lib${LIBHICN} >= stable_version, libparc >= 1.0, libmemif >= stable_version, vpp >= stable_version-release, vpp < next_version-release" CACHE STRING "Dependencies for deb/rpm package." ) set(lib${LIBTRANSPORT}-dev_DEB_DEPENDENCIES - "lib${LIBTRANSPORT} (>= stable_version), libasio-dev (>= 1.10), libhicn-dev (>= stable_version), libparc-dev (>= 1.0), vpp-dev (>= stable_version-release), vpp-dev (<< next_version-release)" + "lib${LIBTRANSPORT} (>= stable_version), libasio-dev (>= 1.10), libhicn-dev (>= stable_version), libmemif-dev (>= stable_version), libparc-dev (>= 1.0), vpp-dev (>= stable_version-release), vpp-dev (<< next_version-release)" CACHE STRING "Dependencies for deb/rpm package." ) set(lib${LIBTRANSPORT}-dev_RPM_DEPENDENCIES - "lib${LIBTRANSPORT} >= stable_version, asio-devel >= 1.10, lib${LIBHICN}-devel >= stable_version, libparc-devel >= 1.0, vpp-devel >= stable_version-release, vpp-devel < next_version-release" + "lib${LIBTRANSPORT} >= stable_version, asio-devel >= 1.10, lib${LIBHICN}-devel >= stable_version, libmemif-devel >= stable_version, libparc-devel >= 1.0, vpp-devel >= stable_version-release, vpp-devel < next_version-release" CACHE STRING "Dependencies for deb/rpm package." ) diff --git a/scripts/build-packages.sh b/scripts/build-packages.sh index 45e2ddf92..c9856a0a0 100644 --- a/scripts/build-packages.sh +++ b/scripts/build-packages.sh @@ -24,8 +24,8 @@ PACKAGECLOUD_RELEASE_REPO_RPM="https://packagecloud.io/install/repositories/fdio VPP_GIT_REPO="https://git.fd.io/vpp" VPP_BRANCH="stable/1908" -VPP_VERSION_DEB="19.08-release" -VPP_VERSION_RPM="19.08-release.x86_64" +VPP_VERSION_DEB="19.08.1-release" +VPP_VERSION_RPM="19.08.1-release.x86_64" BUILD_TOOLS_UBUNTU="build-essential doxygen" LIBSSL_LIBEVENT_UBUNTU="libevent-dev libssl-dev" @@ -73,19 +73,6 @@ setup_fdio_repo() { fi } -MEMIF_HOME="" -build_libmemif_static() { - git clone ${VPP_GIT_REPO} -b ${VPP_BRANCH} vpp - pushd vpp - sed 's/SHARED/STATIC/g' src/cmake/library.cmake -i - mkdir -p build-root/build-libmemif && pushd build-root/build-libmemif - cmake ../../extras/libmemif/ -DCMAKE_C_FLAGS="-fPIC" -DCMAKE_INSTALL_PREFIX=. - make install - MEMIF_HOME="$(pwd)" - popd - popd -} - setup() { # Figure out what system we are running on if [ -f /etc/os-release ]; then @@ -126,8 +113,6 @@ setup() { export CC=${CC_COMPILER} CXX=${CXX_COMPILER} fi - build_libmemif_static - # do nothing but check compiler version c++ --version } @@ -156,7 +141,6 @@ build_package() { -DBUILD_HICNEXTRAPLUGIN=ON \ -DBUILD_LIBTRANSPORT=ON \ -DBUILD_APPS=ON \ - -DLIBMEMIF_HOME=${MEMIF_HOME} \ ${SCRIPT_PATH}/.. make package diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt index ad81427e7..5fc071734 100644 --- a/utils/CMakeLists.txt +++ b/utils/CMakeLists.txt @@ -23,7 +23,7 @@ set(CMAKE_MODULE_PATH ) if (NOT CMAKE_BUILD_TYPE) - message(STATUS "No build type selected, default to Release") + message(STATUS "${PROJECT_NAME}: No build type selected, default to Release") set(CMAKE_BUILD_TYPE "Release") endif ()