diff options
-rw-r--r-- | CMakeLists.txt | 9 | ||||
-rw-r--r-- | app_example/perf-test/CMakeLists.txt | 6 | ||||
-rw-r--r-- | doc/Build_DMM.md | 2 | ||||
-rw-r--r-- | release/configure/module_config.json | 28 | ||||
-rwxr-xr-x | scripts/build.sh | 3 | ||||
-rw-r--r-- | scripts/dmm.spec | 45 | ||||
-rwxr-xr-x | scripts/generate_dmm_rpm.sh | 36 | ||||
-rw-r--r-- | src/CMakeLists.txt | 4 |
8 files changed, 113 insertions, 20 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 7016a70..eed1625 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,6 +26,9 @@ SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_PATH}) SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIB_PATH_SHARED}) SET(DMM_DPDK_INSTALL_DIR "" CACHE STRING "to get the dpdk install path by cmd") +SET(GENERATE_RPM_PATH ${CMAKE_CURRENT_LIST_DIR}/release/rpm) +file(MAKE_DIRECTORY ${GENERATE_RPM_PATH}) + MESSAGE(STATUS "Top dir is: " ${CMAKE_CURRENT_LIST_DIR}) MESSAGE(STATUS "Static library dir: " ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}) MESSAGE(STATUS "Executable binary dir: " ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) @@ -51,7 +54,7 @@ SET(post_compile "${PROJECT_BINARY_DIR}/post_compile.sh") FILE(WRITE ${post_compile} "#!/bin/bash\n") if(WITH_HAL_LIB) else() -FILE(APPEND ${post_compile} +FILE(APPEND ${post_compile} " cp -f ${CMAKE_CURRENT_LIST_DIR}/src/nSocket/include/nstack_dmm_api.h ${CMAKE_CURRENT_LIST_DIR}/release/include/ @@ -74,7 +77,7 @@ endif() SET(clean_compile "${PROJECT_BINARY_DIR}/clean_compile.sh") FILE(WRITE ${clean_compile} "#!/bin/bash\n") -FILE(APPEND ${clean_compile} +FILE(APPEND ${clean_compile} " rm -rf ${CMAKE_CURRENT_LIST_DIR}/release/include/*.h @@ -88,6 +91,8 @@ echo post clean process success. ADD_CUSTOM_TARGET(DPDK ALL COMMAND sh post_compile.sh) ADD_DEPENDENCIES(DPDK dmm_api) +ADD_CUSTOM_TARGET(pkg-rpm COMMAND sh ../scripts/generate_dmm_rpm.sh) + ADD_CUSTOM_TARGET(clean-all COMMAND ${CMAKE_BUILD_TOOL} clean COMMAND sh clean_compile.sh) diff --git a/app_example/perf-test/CMakeLists.txt b/app_example/perf-test/CMakeLists.txt index 4abde0f..d9cc829 100644 --- a/app_example/perf-test/CMakeLists.txt +++ b/app_example/perf-test/CMakeLists.txt @@ -18,15 +18,15 @@ LINK_DIRECTORIES(${LIB_PATH_SHARED} ${LIB_PATH_STATIC}) ADD_EXECUTABLE(vc_common multi_tcp_common_app_Cli.c) ADD_DEPENDENCIES(vc_common nStackAPI) -TARGET_LINK_LIBRARIES(vc_common libnStackAPI.so -Wl,-rpath=. -lpthread -lrt) +TARGET_LINK_LIBRARIES(vc_common libnStackAPI.so -lpthread -lrt) ADD_EXECUTABLE(vs_epoll multi_tcp_epoll_app_Ser.c) ADD_DEPENDENCIES(vs_epoll nStackAPI) -TARGET_LINK_LIBRARIES(vs_epoll libnStackAPI.so -Wl,-rpath=. -lpthread -lrt) +TARGET_LINK_LIBRARIES(vs_epoll libnStackAPI.so -lpthread -lrt) ADD_EXECUTABLE(vs_select multi_tcp_select_app_Ser.c) ADD_DEPENDENCIES(vs_select nStackAPI) -TARGET_LINK_LIBRARIES(vs_select libnStackAPI.so -Wl,-rpath=. -lpthread -lrt) +TARGET_LINK_LIBRARIES(vs_select libnStackAPI.so -lpthread -lrt) ADD_EXECUTABLE(kc_common multi_tcp_common_app_Cli.c) TARGET_LINK_LIBRARIES(kc_common pthread) diff --git a/doc/Build_DMM.md b/doc/Build_DMM.md index bda16b0..3eaf714 100644 --- a/doc/Build_DMM.md +++ b/doc/Build_DMM.md @@ -44,6 +44,8 @@ Note: ``` Then we can get libnStackAPI.so + For centos we can use the command 'make pkg-rpm' to generate the rpm package in release/rpm. + # 4. Env Setting: - Hugepage setting: diff --git a/release/configure/module_config.json b/release/configure/module_config.json index 6b171d8..4532d1a 100644 --- a/release/configure/module_config.json +++ b/release/configure/module_config.json @@ -2,22 +2,23 @@ "default_stack_name": "kernel", /*when rd can't be find maybe choose the defualt one*/ "module_list": [ { - "stack_name": "kernel", /*stack name*/ + "stack_name": "kernel", /*stack name*/ "function_name": "kernel_stack_register", /*function name*/ - "libname": "./", /*library name, if loadtype is static, this maybe - null, else must give a library name*/ - "loadtype": "static", /*library load type: static or dynamic*/ - "deploytype": "1", /*deploy model type:model type1, model type2, - model type3. Indicating single or multi process - deployment. Used during shared memory initialization.*/ - "maxfd": "1024", /*the max fd supported*/ - "minfd": "0", /*the min fd supported*/ - "priorty": "1", /*priorty when executing, reserv*/ - "stackid": "0", /*stack id, this must be ordered and not be repeated*/ + "libname": "./", /*library name, if loadtype is static, this maybe + null, else must give a library name*/ + "loadtype": "static", /*library load type: static or dynamic*/ + "deploytype": "1", /*deploy model type:model type1, model type2, + model type3. Indicating single or multi process + deployment. Used during shared memory initialization.*/ + "maxfd": "1024", /*the max fd supported*/ + "minfd": "0", /*the min fd supported*/ + "priorty": "1", /*priorty when executing, reserv*/ + "stackid": "0", /*stack id, this must be ordered and not be repeated*/ }, + /************************** + *this is not a real stack, just an example for multiple stack configurations* { - "stack_name": "stackx", /*this is not a real stack, just an example for multiple - stack configurations*/ + "stack_name": "stackx", "function_name": "stackx_register", "libname": "libstackx.so", "loadtype": "dynmic", @@ -27,5 +28,6 @@ "priorty": "1", "stackid": "1", }, + ***************************/ ] } diff --git a/scripts/build.sh b/scripts/build.sh index d09df32..989d898 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -159,6 +159,9 @@ cd $BUILD_DIR rm -rf * cmake .. make -j 8 +if [ "$OS_ID" == "centos" ]; then + make pkg-rpm +fi ############### Preapre APP test directory echo -e "\e[41m Preapring APP test directory.....\e[0m" diff --git a/scripts/dmm.spec b/scripts/dmm.spec new file mode 100644 index 0000000..4869140 --- /dev/null +++ b/scripts/dmm.spec @@ -0,0 +1,45 @@ +Name: dmm +Version: 18.04 +Release: 1%{?dist} +Summary: DMM Project + +License: GPL +URL: https://gerrit.fd.io/r/dmm +Source: %{name}-%{version}.tar.gz + +%description +The DMM framework provides posix socket APIs to the application. A protocol +stack could be plugged into the DMM. DMM will choose the most suitable stack +for the application. + +%prep +%setup -q + + +%build +cd build/ +cmake .. +make -j 8 + +%install +cd ../../BUILDROOT +mkdir -p %{name}-%{version}-%{release}.x86_64/usr/bin +mkdir -p %{name}-%{version}-%{release}.x86_64/usr/lib64 + +install -c ../BUILD/%{name}-%{version}/release/bin/kc_common %{name}-%{version}-%{release}.x86_64/usr/bin +install -c ../BUILD/%{name}-%{version}/release/bin/ks_epoll %{name}-%{version}-%{release}.x86_64/usr/bin +install -c ../BUILD/%{name}-%{version}/release/bin/vc_common %{name}-%{version}-%{release}.x86_64/usr/bin +install -c ../BUILD/%{name}-%{version}/release/bin/vs_epoll %{name}-%{version}-%{release}.x86_64/usr/bin +install -c ../BUILD/%{name}-%{version}/release/bin/ks_select %{name}-%{version}-%{release}.x86_64/usr/bin +install -c ../BUILD/%{name}-%{version}/release/bin/vs_select %{name}-%{version}-%{release}.x86_64/usr/bin + +install -c ../BUILD/%{name}-%{version}/release/lib64/libdmm_api.a %{name}-%{version}-%{release}.x86_64/usr/lib64 +install -c ../BUILD/%{name}-%{version}/release/lib64/libnStackAPI.so %{name}-%{version}-%{release}.x86_64/usr/lib64 + +%files +/usr/bin/* +/usr/lib64/* +%doc + + +%changelog diff --git a/scripts/generate_dmm_rpm.sh b/scripts/generate_dmm_rpm.sh new file mode 100755 index 0000000..bce4580 --- /dev/null +++ b/scripts/generate_dmm_rpm.sh @@ -0,0 +1,36 @@ +######################################################################### +# +# Copyright (c) 2018 Huawei Technologies Co.,Ltd. +# 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. +######################################################################### +#!/bin/sh + +cur_directory=${PWD} +name="dmm" +version="18.04" + +mkdir -p ~/rpmbuild/SOURCES + +cd ../ +git archive --format=tar.gz -o ~/rpmbuild/SOURCES/${name}-${version}.tar.gz --prefix=${name}-${version}/ master + +cd ~/rpmbuild/SOURCES +tar xzvf ${name}-${version}.tar.gz + +cp ${name}-${version}/scripts/dmm.spec ~/rpmbuild/SOURCES + +echo "generate the rpm package" +#QA_RPATHS=$[ 0x0002 ] is to shield the warning about rpath when generating the rpm package +QA_RPATHS=$[ 0x0002 ] rpmbuild -ba dmm.spec --define "_sourcedir ${PWD}" --define "%_rpmdir ${cur_directory}/../release/rpm" + +cd ${cur_directory} diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fa4f112..bf2eb01 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -34,14 +34,14 @@ INCLUDE_DIRECTORIES( SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -g -fPIC -m64 -mssse3 -std=gnu89") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -Wshadow -Wfloat-equal -Wformat=2") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector -fstack-protector-all") -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-z,relro,-z,now -Wl,--disable-new-dtags,--rpath,../lib64") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-z,relro,-z,now -Wl,--disable-new-dtags") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-z,noexecstack -mcmodel=medium") SET(COMPLE_CONFIG ${PROJECT_SOURCE_DIR}/src/framework/common/include/compile_config.h) ADD_DEFINITIONS(-include ${COMM_CONFIG}) ADD_DEFINITIONS(-include ${COMPLE_CONFIG}) ADD_DEFINITIONS(-D_GNU_SOURCE -D_FORTIFY_SOURCE=2) -LINK_DIRECTORIES(${LIB_PATH_SHARED} ${LIB_PATH_STATIC}) +#LINK_DIRECTORIES(${LIB_PATH_SHARED} ${LIB_PATH_STATIC}) if(WITH_SECUREC_LIB) LINK_LIBRARIES(pthread dl securec) |