diff options
-rw-r--r-- | CMakeLists.txt | 66 | ||||
-rw-r--r-- | cmake/Modules/FindLibtransport.cmake | 3 | ||||
-rw-r--r-- | cmake/Modules/Packager.cmake | 4 | ||||
-rw-r--r-- | hicn-light/cmake/Modules/Packaging.cmake | 4 | ||||
-rw-r--r-- | hicn-plugin/cmake/Modules/Packaging.cmake | 4 | ||||
-rw-r--r-- | libtransport/CMakeLists.txt | 2 | ||||
-rw-r--r-- | libtransport/cmake/Modules/Packaging.cmake | 18 | ||||
-rw-r--r-- | libtransport/src/hicn/transport/CMakeLists.txt | 2 | ||||
-rw-r--r-- | libtransport/src/hicn/transport/core/CMakeLists.txt | 2 | ||||
-rw-r--r-- | libtransport/src/hicn/transport/core/memif_connector.cc | 50 | ||||
-rw-r--r-- | libtransport/src/hicn/transport/core/memif_connector.h | 27 | ||||
-rw-r--r-- | libtransport/src/hicn/transport/core/vpp_forwarder_interface.cc | 4 | ||||
-rw-r--r-- | scripts/build-packages.sh | 43 | ||||
-rw-r--r-- | utils/CMakeLists.txt | 7 | ||||
-rw-r--r-- | utils/cmake/Modules/Packaging.cmake | 4 |
15 files changed, 155 insertions, 85 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 29fa1700b..973946c6f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,38 +21,72 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON) set(HICN_INCLUDE_DIRS ${PROJECT_BINARY_DIR}/lib) -## Target names -set(LIBHICN hicn) -set(LIBHICN_SHARED hicn.shared) -set(LIBHICN_LIGHT hicn-light) -set(HICN_LIGHT_CONTROL hicnLightControl) -set(HICN_LIGHT_DAEMON hicnLightDaemon) -set(HICN_PLUGIN hicn-plugin) -set(LIBTRANSPORT hicntransport) -set(LIBTRANSPORT_SHARED hicntransport.shared) -set(HICN_UTILS hicn-utils) +## Enabled components +option(BUILD_LIBHICN "Build the hicn core library" ON) +option(BUILD_HICNLIGHT "Build the hicn light forwarder" ON) +option(BUILD_LIBTRANSPORT "Build the hicn transport library" ON) +option(BUILD_UTILS "Build the hicn utils" ON) +option(BUILD_HICNPLUGIN "Build the hicn vpp plugin" OFF) + +list(APPEND dir_options + BUILD_LIBHICN + BUILD_HICNLIGHT + BUILD_LIBTRANSPORT + BUILD_UTILS +) + +set(BUILD_LIBHICN_DIR lib) +set(BUILD_HICNLIGHT_DIR hicn-light) +set(BUILD_LIBTRANSPORT_DIR libtransport) +set(BUILD_UTILS_DIR utils) +set(BUILD_HICNPLUGIN_DIR hicn-plugin) ## HEADER FILES set(LIBHICN_HEADER_FILES) set(LIBHICN_LIGHT_HEADER_FILES) set(LIBTRANSPORT_HEADER_FILES) -set(SUBDIRS lib hicn-light libtransport utils) +## Add enabled components +foreach (opt ${dir_options}) + if (${opt}) + list(APPEND subdirs + ${${opt}_DIR} + ) + endif() +endforeach() -add_compile_options(-Wall -Werror) +## Static targets +set(LIBHICN hicn) +set(LIBHICN_LIGHT hicn-light) +set(HICN_LIGHT_CONTROL hicnLightControl) +set(HICN_LIGHT_DAEMON hicnLightDaemon) +set(HICN_PLUGIN hicn-plugin) +set(LIBTRANSPORT hicntransport) +set(HICN_UTILS hicn-utils) -if (BUILD_VPP_PLUGIN AND "${CMAKE_SYSTEM_NAME}" STREQUAL "Linux" ) - list(APPEND SUBDIRS - hicn-plugin +if (BUILD_HICNPLUGIN AND "${CMAKE_SYSTEM_NAME}" STREQUAL "Linux" ) + list(APPEND subdirs + ${BUILD_HICNPLUGIN_DIR} ) list(APPEND HICN_BINARY_API_INCLUDE_DIRS ${PROJECT_BINARY_DIR}/hicn-plugin ${PROJECT_BINARY_DIR}/hicn-plugin/vpp_plugins ) + + set(LIBTRANSPORT ${LIBTRANSPORT}-memif) + set(HICN_UTILS ${HICN_UTILS}-memif) endif() -foreach(dir ${SUBDIRS}) +## Shared targets +set(LIBHICN_SHARED ${LIBHICN}.shared) +set(LIBTRANSPORT_SHARED ${LIBTRANSPORT}.shared) + +add_compile_options(-Wall -Werror) + +message(STATUS "Building the following subprojects: ${subdirs}") + +foreach(dir ${subdirs}) add_subdirectory(${dir}) endforeach() diff --git a/cmake/Modules/FindLibtransport.cmake b/cmake/Modules/FindLibtransport.cmake index 5910a64da..8a650b98c 100644 --- a/cmake/Modules/FindLibtransport.cmake +++ b/cmake/Modules/FindLibtransport.cmake @@ -35,7 +35,8 @@ find_path(LIBTRANSPORT_INCLUDE_DIR hicn/transport/config.h DOC "Find the libtransport includes" ) -find_library(LIBTRANSPORT_LIBRARY NAMES transport +find_library(LIBTRANSPORT_LIBRARY + NAMES hicntransport hicntransport-memif HINTS ${LIBTRANSPORT_SEARCH_PATH_LIST} PATH_SUFFIXES lib DOC "Find the libtransport libraries" diff --git a/cmake/Modules/Packager.cmake b/cmake/Modules/Packager.cmake index 15b5951fa..b19145025 100644 --- a/cmake/Modules/Packager.cmake +++ b/cmake/Modules/Packager.cmake @@ -82,7 +82,7 @@ macro(make_packages) set(CPACK_PACKAGE_VERSION "${deb_ver}") foreach(lc ${components}) - if (${lc} MATCHES "Unspecified.*") + if (${lc} MATCHES ".*Unspecified.*") continue() endif() @@ -110,7 +110,7 @@ macro(make_packages) set(CPACK_PACKAGE_VERSION "${rpm_ver}") foreach(lc ${components}) - if (${lc} MATCHES "Unspecified.*") + if (${lc} MATCHES ".*Unspecified.*") continue() endif() diff --git a/hicn-light/cmake/Modules/Packaging.cmake b/hicn-light/cmake/Modules/Packaging.cmake index 7e8399626..599238cb6 100644 --- a/hicn-light/cmake/Modules/Packaging.cmake +++ b/hicn-light/cmake/Modules/Packaging.cmake @@ -21,11 +21,11 @@ set(${LIBHICN_LIGHT}_DESCRIPTION ) set(${LIBHICN_LIGHT}_DEB_DEPENDENCIES - "libhicn (>= stable_version), libparc (>= 1.0)" + "lib${LIBHICN} (>= stable_version), libparc (>= 1.0)" CACHE STRING "Dependencies for deb/rpm package." ) set(${LIBHICN_LIGHT}_RPM_DEPENDENCIES - "libhicn >= stable_version, libparc >= 1.0" + "lib${LIBHICN} >= stable_version, libparc >= 1.0" CACHE STRING "Dependencies for deb/rpm package." )
\ No newline at end of file diff --git a/hicn-plugin/cmake/Modules/Packaging.cmake b/hicn-plugin/cmake/Modules/Packaging.cmake index 89b8d974b..f0eec7ebe 100644 --- a/hicn-plugin/cmake/Modules/Packaging.cmake +++ b/hicn-plugin/cmake/Modules/Packaging.cmake @@ -21,11 +21,11 @@ set(${HICN_PLUGIN}_DESCRIPTION ) set(${HICN_PLUGIN}_DEB_DEPENDENCIES - "libhicn (>= stable_version), vpp (= stable_version-release), vpp-plugins (= stable_version-release)" + "lib${LIBHICN} (>= stable_version), vpp (= stable_version-release), vpp-plugins (= stable_version-release)" CACHE STRING "Dependencies for deb/rpm package." ) set(${HICN_PLUGIN}_RPM_DEPENDENCIES - "libhicn >= stable_version, vpp = stable_version-release, vpp-plugins = stable_version-release" + "lib${LIBHICN} >= stable_version, vpp = stable_version-release, vpp-plugins = stable_version-release" CACHE STRING "Dependencies for deb/rpm package." ) diff --git a/libtransport/CMakeLists.txt b/libtransport/CMakeLists.txt index 4df87b056..d2567ed77 100644 --- a/libtransport/CMakeLists.txt +++ b/libtransport/CMakeLists.txt @@ -44,7 +44,7 @@ set(raaqm_config_path ${CMAKE_INSTALL_PREFIX}/etc/hicn-consumer.conf) # Install includes set(INSTALL_INCLUDE_DIR include/hicn/transport) -if (BUILD_VPP_PLUGIN AND BUILD_MEMIF_CONNECTOR AND "${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") +if ((BUILD_HICNPLUGIN OR BUILD_MEMIF_CONNECTOR) AND "${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") set(__vpp__ 1) find_package(Vpp REQUIRED) find_package(Libmemif REQUIRED) diff --git a/libtransport/cmake/Modules/Packaging.cmake b/libtransport/cmake/Modules/Packaging.cmake index 64d1dd325..4112d3844 100644 --- a/libtransport/cmake/Modules/Packaging.cmake +++ b/libtransport/cmake/Modules/Packaging.cmake @@ -29,47 +29,47 @@ set(lib${LIBTRANSPORT}-dev_DESCRIPTION ${lib${LIBTRANSPORT}_DESCRIPTION} set(lib${LIBTRANSPORT}-devel_DESCRIPTION ${lib${LIBTRANSPORT}_DESCRIPTION} CACHE STRING "Description for deb/rpm package.") -if ((BUILD_MEMIF_CONNECTOR OR BUILD_VPP_PLUGIN) AND "${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") +if ((BUILD_MEMIF_CONNECTOR OR BUILD_HICNPLUGIN) AND "${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") set(lib${LIBTRANSPORT}_DEB_DEPENDENCIES - "libhicn (>= stable_version), libparc (>= 1.0), vpp-lib (== stable_version-release)" + "lib${LIBHICN} (>= stable_version), libparc (>= 1.0), vpp-lib (= stable_version-release)" CACHE STRING "Dependencies for deb/rpm package." ) set(lib${LIBTRANSPORT}_RPM_DEPENDENCIES - "libhicn >= stable_version, libparc >= 1.0, vpp-lib = stable_version-release" + "lib${LIBHICN} >= stable_version, libparc >= 1.0, vpp-lib = stable_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)" + "lib${LIBTRANSPORT} (>= stable_version), libasio-dev (>= 1.10), libhicn-dev (>= stable_version), libparc-dev (>= 1.0), vpp-dev (= stable_version-release)" CACHE STRING "Dependencies for deb/rpm package." ) set(lib${LIBTRANSPORT}-dev_RPM_DEPENDENCIES - "lib${LIBTRANSPORT} >= stable_version, asio-devel >= 1.10, libhicn-devel >= stable_version, libparc-devel >= 1.0, vpp-devel = stable_version-release" + "lib${LIBTRANSPORT} >= stable_version, asio-devel >= 1.10, lib${LIBHICN}-devel >= stable_version, libparc-devel >= 1.0, vpp-devel = stable_version-release" CACHE STRING "Dependencies for deb/rpm package." ) else() set(lib${LIBTRANSPORT}_DEB_DEPENDENCIES - "libhicn (>= stable_version), libparc (>= 1.0)" + "lib${LIBHICN} (>= stable_version), libparc (>= 1.0)" CACHE STRING "Dependencies for deb/rpm package." ) set(lib${LIBTRANSPORT}_RPM_DEPENDENCIES - "libhicn >= stable_version, libparc >= 1.0" + "lib${LIBHICN} >= stable_version, libparc >= 1.0" 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)" + "lib${LIBTRANSPORT} (>= stable_version), libasio-dev (>= 1.10), lib${LIBHICN}-dev (>= stable_version), libparc-dev (>= 1.0)" CACHE STRING "Dependencies for deb/rpm package." ) set(lib${LIBTRANSPORT}-dev_RPM_DEPENDENCIES - "lib${LIBTRANSPORT} >= stable_version, asio-devel >= 1.10, libhicn-devel >= stable_version, libparc-devel >= 1.0" + "lib${LIBTRANSPORT} >= stable_version, asio-devel >= 1.10, lib${LIBHICN}-devel >= stable_version, libparc-devel >= 1.0" CACHE STRING "Dependencies for deb/rpm package." ) diff --git a/libtransport/src/hicn/transport/CMakeLists.txt b/libtransport/src/hicn/transport/CMakeLists.txt index fd5721273..92330c10b 100644 --- a/libtransport/src/hicn/transport/CMakeLists.txt +++ b/libtransport/src/hicn/transport/CMakeLists.txt @@ -17,7 +17,7 @@ configure_file("config.h.in" "config.h" @ONLY) install( FILES ${CMAKE_CURRENT_BINARY_DIR}/config.h DESTINATION include/hicn/transport - COMPONENT lib${LIBTRANSPORT} + COMPONENT lib${LIBTRANSPORT}-dev ) add_subdirectory(core) diff --git a/libtransport/src/hicn/transport/core/CMakeLists.txt b/libtransport/src/hicn/transport/core/CMakeLists.txt index a97e74b2a..dff93adeb 100644 --- a/libtransport/src/hicn/transport/core/CMakeLists.txt +++ b/libtransport/src/hicn/transport/core/CMakeLists.txt @@ -51,7 +51,7 @@ list(APPEND SOURCE_FILES ) if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") - if (BUILD_WITH_VPP OR BUILD_VPP_PLUGIN) + if (BUILD_WITH_VPP OR BUILD_HICNPLUGIN) list(APPEND HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/vpp_forwarder_interface.h ${CMAKE_CURRENT_SOURCE_DIR}/memif_connector.h diff --git a/libtransport/src/hicn/transport/core/memif_connector.cc b/libtransport/src/hicn/transport/core/memif_connector.cc index 6c5f2ff5f..a650c3681 100644 --- a/libtransport/src/hicn/transport/core/memif_connector.cc +++ b/libtransport/src/hicn/transport/core/memif_connector.cc @@ -20,12 +20,36 @@ #include <sys/epoll.h> #include <cstdlib> +extern "C" { +#include <memif/libmemif.h> +}; + #define CANCEL_TIMER 1 namespace transport { namespace core { +struct memif_connection { + uint16_t index; + /* memif conenction handle */ + memif_conn_handle_t conn; + /* transmit queue id */ + uint16_t tx_qid; + /* tx buffers */ + memif_buffer_t *tx_bufs; + /* allocated tx buffers counter */ + /* number of tx buffers pointing to shared memory */ + uint16_t tx_buf_num; + /* rx buffers */ + memif_buffer_t *rx_bufs; + /* allcoated rx buffers counter */ + /* number of rx buffers pointing to shared memory */ + uint16_t rx_buf_num; + /* interface ip address */ + uint8_t ip_addr[4]; +}; + std::once_flag MemifConnector::flag_; utils::EpollEventReactor MemifConnector::main_event_reactor_; @@ -39,7 +63,7 @@ MemifConnector::MemifConnector(PacketReceivedCallback &&receive_callback, send_timer_(std::make_unique<utils::FdDeadlineTimer>(event_reactor_)), io_service_(io_service), packet_counter_(0), - memif_connection_({}), + memif_connection_(std::make_unique<memif_connection_t>()), tx_buf_counter_(0), is_connecting_(true), is_reconnection_(false), @@ -83,7 +107,7 @@ void MemifConnector::connect(uint32_t memif_id, long memif_mode) { /* get interrupt queue id */ int fd = -1; - err = memif_get_queue_efd(memif_connection_.conn, 0, &fd); + err = memif_get_queue_efd(memif_connection_->conn, 0, &fd); if (TRANSPORT_EXPECT_FALSE(err != MEMIF_ERR_SUCCESS)) { TRANSPORT_LOGI("memif_get_queue_efd: %s", memif_strerror(err)); return; @@ -95,7 +119,7 @@ void MemifConnector::connect(uint32_t memif_id, long memif_mode) { // Add fd to epoll of instance event_reactor_.addFileDescriptor( fd, EPOLLIN, [this](const utils::Event &evt) -> int { - return onInterrupt(memif_connection_.conn, this, 0); + return onInterrupt(memif_connection_->conn, this, 0); }); memif_worker_ = std::make_unique<std::thread>( @@ -103,7 +127,7 @@ void MemifConnector::connect(uint32_t memif_id, long memif_mode) { } int MemifConnector::createMemif(uint32_t index, uint8_t mode, char *s) { - memif_connection_t *c = &memif_connection_; + memif_connection_t *c = memif_connection_.get(); /* setting memif connection arguments */ memif_conn_args_t args; @@ -151,7 +175,7 @@ int MemifConnector::createMemif(uint32_t index, uint8_t mode, char *s) { } int MemifConnector::deleteMemif() { - memif_connection_t *c = &memif_connection_; + memif_connection_t *c = memif_connection_.get(); if (c->rx_bufs) { free(c->rx_bufs); @@ -231,7 +255,7 @@ int MemifConnector::controlFdUpdate(int fd, uint8_t events) { } int MemifConnector::bufferAlloc(long n, uint16_t qid) { - memif_connection_t *c = &memif_connection_; + memif_connection_t *c = memif_connection_.get(); int err; uint16_t r; /* set data pointer to shared memory and set buffer_len to shared mmeory @@ -249,7 +273,7 @@ int MemifConnector::bufferAlloc(long n, uint16_t qid) { } int MemifConnector::txBurst(uint16_t qid) { - memif_connection_t *c = &memif_connection_; + memif_connection_t *c = memif_connection_.get(); int err; uint16_t r; /* inform peer memif interface about data in shared memory buffers */ @@ -313,7 +337,7 @@ int MemifConnector::onDisconnect(memif_conn_handle_t conn, void *private_ctx) { MemifConnector *connector = (MemifConnector *)private_ctx; // TRANSPORT_LOGI ("Packet received: %u", connector->packet_counter_); TRANSPORT_LOGI("Packet to process: %u", - connector->memif_connection_.tx_buf_num); + connector->memif_connection_->tx_buf_num); return 0; } @@ -323,7 +347,7 @@ int MemifConnector::onInterrupt(memif_conn_handle_t conn, void *private_ctx, uint16_t qid) { MemifConnector *connector = (MemifConnector *)private_ctx; - memif_connection_t *c = &connector->memif_connection_; + memif_connection_t *c = connector->memif_connection_.get(); int err = MEMIF_ERR_SUCCESS, ret_val; uint16_t rx; @@ -447,7 +471,7 @@ int MemifConnector::doSend() { max = size < MAX_MEMIF_BUFS ? size : MAX_MEMIF_BUFS; if (TRANSPORT_EXPECT_FALSE( - (n = bufferAlloc(max, memif_connection_.tx_qid)) < 0)) { + (n = bufferAlloc(max, memif_connection_->tx_qid)) < 0)) { TRANSPORT_LOGI("Error allocating buffers."); return -1; } @@ -459,21 +483,21 @@ int MemifConnector::doSend() { const utils::MemBuf *current = packet; std::size_t offset = 0; uint8_t *shared_buffer = - reinterpret_cast<uint8_t *>(memif_connection_.tx_bufs[i].data); + reinterpret_cast<uint8_t *>(memif_connection_->tx_bufs[i].data); do { std::memcpy(shared_buffer + offset, current->data(), current->length()); offset += current->length(); current = current->next(); } while (current != packet); - memif_connection_.tx_bufs[i].len = uint32_t(offset); + memif_connection_->tx_bufs[i].len = uint32_t(offset); TRANSPORT_LOGD("Packet size : %zu", offset); output_buffer_.pop_front(); } - txBurst(memif_connection_.tx_qid); + txBurst(memif_connection_->tx_qid); utils::SpinLock::Acquire locked(write_msgs_lock_); size = output_buffer_.size(); diff --git a/libtransport/src/hicn/transport/core/memif_connector.h b/libtransport/src/hicn/transport/core/memif_connector.h index 4667ec0b2..ff838930f 100644 --- a/libtransport/src/hicn/transport/core/memif_connector.h +++ b/libtransport/src/hicn/transport/core/memif_connector.h @@ -32,33 +32,11 @@ #define _Static_assert static_assert -extern "C" { -#include <memif/libmemif.h> -}; - namespace transport { namespace core { -typedef struct { - uint16_t index; - /* memif conenction handle */ - memif_conn_handle_t conn; - /* transmit queue id */ - uint16_t tx_qid; - /* tx buffers */ - memif_buffer_t *tx_bufs; - /* allocated tx buffers counter */ - /* number of tx buffers pointing to shared memory */ - uint16_t tx_buf_num; - /* rx buffers */ - memif_buffer_t *rx_bufs; - /* allcoated rx buffers counter */ - /* number of rx buffers pointing to shared memory */ - uint16_t rx_buf_num; - /* interface ip address */ - uint8_t ip_addr[4]; -} memif_connection_t; +typedef struct memif_connection memif_connection_t; #define APP_NAME "libtransport" #define IF_NAME "vpp_connection" @@ -68,6 +46,7 @@ typedef struct { #define MEMIF_LOG2_RING_SIZE 11 class MemifConnector : public Connector { + typedef void *memif_conn_handle_t; public: MemifConnector(PacketReceivedCallback &&receive_callback, OnReconnect &&on_reconnect_callback, @@ -135,7 +114,7 @@ class MemifConnector : public Connector { asio::io_service &io_service_; std::unique_ptr<asio::io_service::work> work_; uint32_t packet_counter_; - memif_connection_t memif_connection_; + std::unique_ptr<memif_connection_t> memif_connection_; uint16_t tx_buf_counter_; PacketRing input_buffer_; diff --git a/libtransport/src/hicn/transport/core/vpp_forwarder_interface.cc b/libtransport/src/hicn/transport/core/vpp_forwarder_interface.cc index 828e31a0a..69b18c0d9 100644 --- a/libtransport/src/hicn/transport/core/vpp_forwarder_interface.cc +++ b/libtransport/src/hicn/transport/core/vpp_forwarder_interface.cc @@ -22,6 +22,10 @@ #include <hicn/transport/core/prefix.h> #include <hicn/transport/core/vpp_forwarder_interface.h> +extern "C" { +#include <memif/libmemif.h> +}; + typedef enum { MASTER = 0, SLAVE = 1 } memif_role_t; #define MEMIF_DEFAULT_RING_SIZE 2048 diff --git a/scripts/build-packages.sh b/scripts/build-packages.sh index e41eccc8a..95f1fe043 100644 --- a/scripts/build-packages.sh +++ b/scripts/build-packages.sh @@ -21,6 +21,9 @@ apt_get=${APT_PATH:-"/usr/local/bin/apt-get"} PACKAGECLOUD_RELEASE_REPO_DEB="https://packagecloud.io/install/repositories/fdio/release/script.deb.sh" PACKAGECLOUD_RELEASE_REPO_RPM="https://packagecloud.io/install/repositories/fdio/release/script.rpm.sh" +VPP_GIT_REPO="https://git.fd.io/vpp" +VPP_BRANCH="stable/1901" + VPP_VERSION_DEB="19.01-release" VPP_VERSION_RPM="19.01-release.x86_64" @@ -33,8 +36,10 @@ DEPS_CENTOS="vpp-devel-${VPP_VERSION_RPM} vpp-lib-${VPP_VERSION_RPM} libparc-dev LATEST_EPEL_REPO="http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm" install_cmake() { - cat /etc/resolv.conf - echo "nameserver 8.8.8.8" | sudo tee -a /etc/resolv.conf + if ! grep -q "8.8.8.8" /etc/resolv.conf; then + echo "nameserver 8.8.8.8" | sudo tee -a /etc/resolv.conf + fi + cat /etc/resolv.conf CMAKE_INSTALL_SCRIPT_URL="https://cmake.org/files/v3.8/cmake-3.8.0-Linux-x86_64.sh" @@ -66,6 +71,19 @@ 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 @@ -105,6 +123,8 @@ setup() { ${CC_COMPILER} --version export CC=${CC_COMPILER} CXX=${CXX_COMPILER} + + build_libmemif_static fi # do nothing but check compiler version @@ -122,13 +142,24 @@ build_package() { echo "*******************************************************************" # Make the package - mkdir -p ${SCRIPT_PATH}/../build && pushd ${SCRIPT_PATH}/../build + mkdir -p build && pushd build rm -rf * - cmake -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_VPP_PLUGIN=ON .. + cmake -DCMAKE_INSTALL_PREFIX=/usr ${SCRIPT_PATH}/.. + make package + + rm -rf libtransport + + cmake -DCMAKE_INSTALL_PREFIX=/usr \ + -DBUILD_HICNPLUGIN=ON \ + -DBUILD_LIBTRANSPORT=ON \ + -DLIBMEMIF_HOME=${MEMIF_HOME} \ + ${SCRIPT_PATH}/.. + make package - find . -not -name '*.deb' -not -name '*.rpm' -print0 | xargs -0 rm -rf -- || true + # find . -name '.*Unspecified.*' -print0 | xargs -0 rm -rf -- || true + rm *Unspecified* popd @@ -139,8 +170,6 @@ build_package() { exit 0 } -pushd ${SCRIPT_PATH}/.. build_package -popd exit 0 diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt index a377132e1..077789f57 100644 --- a/utils/CMakeLists.txt +++ b/utils/CMakeLists.txt @@ -29,7 +29,7 @@ if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR) find_package(Libtransport REQUIRED) set(HICN_UTILS hicn-utils) else() - set(LIBTRANSPORT_LIBRARIES ${LIBTRANSPORT}) + set(LIBTRANSPORT_LIBRARIES ${LIBTRANSPORT_SHARED}) endif() include(Packaging) @@ -48,10 +48,9 @@ foreach(util ${UTILS_SRC}) build_executable(${util_name} SOURCES ${util} - LINK_LIBRARIES ${LIBTRANSPORT_LIBRARIES} + LINK_LIBRARIES ${LIBTRANSPORT_LIBRARIES} ${WSOCK32_LIBRARY} ${WS2_32_LIBRARY} DEPENDS ${LIBTRANSPORT} - COMPONENT hicn-utils + COMPONENT ${HICN_UTILS} DEFINITIONS ${COMPILER_DEFINITIONS} - LINK_LIBRARIES ${WSOCK32_LIBRARY} ${WS2_32_LIBRARY} ) endforeach()
\ No newline at end of file diff --git a/utils/cmake/Modules/Packaging.cmake b/utils/cmake/Modules/Packaging.cmake index 37c123cf2..783aa432a 100644 --- a/utils/cmake/Modules/Packaging.cmake +++ b/utils/cmake/Modules/Packaging.cmake @@ -18,11 +18,11 @@ useful for testing and debugging within a hicn network." ) set(${HICN_UTILS}_DEB_DEPENDENCIES - "libhicntransport (>= stable_version)" + "lib${LIBTRANSPORT} (>= stable_version)" CACHE STRING "Dependencies for deb/rpm package." ) set(${HICN_UTILS}_RPM_DEPENDENCIES - "libhicntransport >= stable_version" + "lib${LIBTRANSPORT} >= stable_version" CACHE STRING "Dependencies for deb/rpm package." )
\ No newline at end of file |