diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 36 | ||||
-rw-r--r-- | src/cmake/api.cmake | 12 | ||||
-rw-r--r-- | src/pkg/CMakeLists.txt | 10 | ||||
-rwxr-xr-x | src/pkg/debian/rules.in | 2 | ||||
-rwxr-xr-x | src/scripts/compdb_cleanup.py | 33 | ||||
-rw-r--r-- | src/vlib/CMakeLists.txt | 4 | ||||
-rw-r--r-- | src/vpp/CMakeLists.txt | 20 | ||||
-rw-r--r-- | src/vpp/conf/startup.conf.in | 47 | ||||
-rw-r--r-- | src/vppinfra/CMakeLists.txt | 4 |
9 files changed, 144 insertions, 24 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7dfd76a960d..96d373a7066 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -64,6 +64,7 @@ set(VPP_LIBRARY_DIR "lib" CACHE STRING "Relative library directory path") set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${VPP_RUNTIME_DIR}) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${VPP_LIBRARY_DIR}) +set(VPP_BINARY_DIR ${CMAKE_BINARY_DIR}/CMakeFiles) if (CMAKE_BUILD_TYPE) set(CMAKE_C_FLAGS "-g -fPIC -Werror -Wall ${CMAKE_C_FLAGS}") @@ -151,8 +152,7 @@ set(CMAKE_INSTALL_MESSAGE NEVER) include_directories ( ${CMAKE_SOURCE_DIR} - ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}/include + ${VPP_BINARY_DIR} ) set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "vpp") @@ -185,7 +185,7 @@ else() endif() foreach(DIR ${SUBDIRS}) - add_subdirectory(${DIR}) + add_subdirectory(${DIR} ${VPP_BINARY_DIR}/${DIR}) endforeach() ############################################################################## @@ -207,6 +207,36 @@ if (VPP_GIT_TOPLEVEL_DIR) endif() ############################################################################## +# custom targets +############################################################################## + +add_custom_target(run + COMMAND ./${VPP_RUNTIME_DIR}/vpp -c startup.conf + COMMENT "Starting VPP..." + USES_TERMINAL +) + +add_custom_target(debug + COMMAND gdb --args ./${VPP_RUNTIME_DIR}/vpp -c startup.conf + COMMENT "Starting VPP in the debugger..." + USES_TERMINAL +) + +add_custom_target(menu + COMMAND ccmake ${CMAKE_BINARY_DIR} + COMMENT "Starting Configuration TUI..." + USES_TERMINAL +) + +add_custom_target(compdb + COMMAND ninja -C ${CMAKE_BINARY_DIR} -t compdb | + ${CMAKE_SOURCE_DIR}/scripts/compdb_cleanup.py > + ${CMAKE_BINARY_DIR}/compile_commands.json + COMMENT "Generating compile_commands.json" + USES_TERMINAL +) + +############################################################################## # print configuration ############################################################################## message(STATUS "Configuration:") diff --git a/src/cmake/api.cmake b/src/cmake/api.cmake index 67472857fee..007a9060023 100644 --- a/src/cmake/api.cmake +++ b/src/cmake/api.cmake @@ -80,7 +80,7 @@ endfunction() ############################################################################## function(vpp_generate_vapi_c_header f) get_filename_component(output ${f}.vapi.h NAME) - set (output_name ${CMAKE_BINARY_DIR}/vpp-api/vapi/${output}) + set (output_name ${VPP_BINARY_DIR}/vpp-api/vapi/${output}) if(NOT VPP_VAPI_C_GEN) set(VPP_VAPI_C_GEN ${CMAKE_SOURCE_DIR}/vpp-api/vapi/vapi_c_gen.py) set(VPP_VAPI_C_GEN_DEPENDS @@ -93,7 +93,7 @@ function(vpp_generate_vapi_c_header f) set(input ${CMAKE_CURRENT_BINARY_DIR}/${f}.json) add_custom_command( OUTPUT ${output_name} - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/vpp-api/vapi + WORKING_DIRECTORY ${VPP_BINARY_DIR}/vpp-api/vapi COMMAND ${VPP_VAPI_C_GEN} ARGS --remove-path ${input} DEPENDS ${input} ${VPP_VAPI_C_GEN_DEPENDS} @@ -108,7 +108,7 @@ endfunction () function (vpp_generate_vapi_cpp_header f) get_filename_component(output ${f}.vapi.hpp NAME) - set (output_name ${CMAKE_BINARY_DIR}/vpp-api/vapi/${output}) + set (output_name ${VPP_BINARY_DIR}/vpp-api/vapi/${output}) if(NOT VPP_VAPI_CPP_GEN) set(VPP_VAPI_CPP_GEN ${CMAKE_SOURCE_DIR}/vpp-api/vapi/vapi_cpp_gen.py) set(VPP_VAPI_CPP_GEN_DEPENDS @@ -120,7 +120,7 @@ function (vpp_generate_vapi_cpp_header f) set(input ${CMAKE_CURRENT_BINARY_DIR}/${f}.json) add_custom_command( OUTPUT ${output_name} - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/vpp-api/vapi + WORKING_DIRECTORY ${VPP_BINARY_DIR}/vpp-api/vapi COMMAND ${VPP_VAPI_CPP_GEN} ARGS --gen-h-prefix=vapi --remove-path ${input} DEPENDS ${input} ${VPP_VAPI_CPP_GEN_DEPENDS} @@ -164,8 +164,8 @@ function(vpp_add_api_files name dir component) ${file}_enum.h ${file}_types.h ${file}.json - ${CMAKE_BINARY_DIR}/vpp-api/vapi/${name}.vapi.h - ${CMAKE_BINARY_DIR}/vpp-api/vapi/${name}.vapi.hpp + ${VPP_BINARY_DIR}/vpp-api/vapi/${name}.vapi.h + ${VPP_BINARY_DIR}/vpp-api/vapi/${name}.vapi.hpp ) endforeach() add_custom_target(${target} DEPENDS ${header_files}) diff --git a/src/pkg/CMakeLists.txt b/src/pkg/CMakeLists.txt index e466fe8d345..d447774a1fd 100644 --- a/src/pkg/CMakeLists.txt +++ b/src/pkg/CMakeLists.txt @@ -41,7 +41,7 @@ set(VPP_DEB_WITH_PYTHON2 "no") foreach(f rules changelog control) configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/debian/${f}.in - ${CMAKE_BINARY_DIR}/debian/${f} + ${VPP_BINARY_DIR}/debian/${f} @ONLY ) endforeach() @@ -49,15 +49,15 @@ endforeach() foreach(f copyright vpp.preinst vpp.postrm vpp.postinst vpp.service) file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/debian/${f} - DESTINATION ${CMAKE_BINARY_DIR}/debian + DESTINATION ${VPP_BINARY_DIR}/debian ) endforeach() -file(WRITE ${CMAKE_BINARY_DIR}/debian/compat "10\n") +file(WRITE ${VPP_BINARY_DIR}/debian/compat "10\n") -add_custom_target(package-deb +add_custom_target(pkg-deb COMMENT "Building .deb packages..." - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + WORKING_DIRECTORY ${VPP_BINARY_DIR} COMMAND "dpkg-buildpackage" "-us" "-uc" "-b" USES_TERMINAL ) diff --git a/src/pkg/debian/rules.in b/src/pkg/debian/rules.in index 3249220b4f5..15f8eb6f810 100755 --- a/src/pkg/debian/rules.in +++ b/src/pkg/debian/rules.in @@ -30,7 +30,7 @@ override_dh_install: @CMAKE_COMMAND@ \ -D CMAKE_INSTALL_CONFIG_NAME=@CMAKE_BUILD_TYPE@ \ -D CMAKE_INSTALL_COMPONENT=$$c \ - -D CMAKE_INSTALL_PREFIX=@CMAKE_BINARY_DIR@/debian/$$c \ + -D CMAKE_INSTALL_PREFIX=@VPP_BINARY_DIR@/debian/$$c \ -P @CMAKE_BINARY_DIR@/cmake_install.cmake 2>&1 \ | grep -v 'Set runtime path of' ; \ if [ -d debian/$$c/lib ] ; then \ diff --git a/src/scripts/compdb_cleanup.py b/src/scripts/compdb_cleanup.py new file mode 100755 index 00000000000..0302fc2f87c --- /dev/null +++ b/src/scripts/compdb_cleanup.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 + +import sys +import json + +objects = json.load(sys.stdin) + +for i in range(len(objects) - 1, -1, -1): + obj = objects[i] + + # Remove everything except .c files + if not obj["file"].endswith(".c"): + objects.remove(obj) + continue + + # remove duplicates introduced my multiarch + if "CLIB_MARCH_VARIANT" in obj["command"]: + objects.remove(obj) + continue + + # remove if there is no command + if obj["command"] == "": + objects.remove(obj) + continue + + # remove ccache prefix + s = str.split(obj["command"]) + if s[0] == "ccache": + s.remove(s[0]) + s[0] = s[0].split("/")[-1] + obj["command"] = " ".join(s) + +json.dump(objects, sys.stdout, indent=2) diff --git a/src/vlib/CMakeLists.txt b/src/vlib/CMakeLists.txt index dbd74f10095..78fe936da9d 100644 --- a/src/vlib/CMakeLists.txt +++ b/src/vlib/CMakeLists.txt @@ -37,10 +37,10 @@ set(VLIB_PROCESS_LOG2_STACK_SIZE configure_file( ${CMAKE_SOURCE_DIR}/vlib/config.h.in - ${CMAKE_BINARY_DIR}/vlib/config.h + ${CMAKE_CURRENT_BINARY_DIR}/config.h ) install( - FILES ${CMAKE_BINARY_DIR}/vlib/config.h + FILES ${CMAKE_CURRENT_BINARY_DIR}/config.h DESTINATION include/vlib COMPONENT vpp-dev ) diff --git a/src/vpp/CMakeLists.txt b/src/vpp/CMakeLists.txt index df8383709b8..07983502096 100644 --- a/src/vpp/CMakeLists.txt +++ b/src/vpp/CMakeLists.txt @@ -15,17 +15,17 @@ # Generate vpp/app/version.h ############################################################################## add_custom_command( - OUTPUT ${CMAKE_BINARY_DIR}/include/vpp/app/version.h + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/app/version.h WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMAND mkdir - ARGS -p ${CMAKE_BINARY_DIR}/include/vpp/app + ARGS -p ${CMAKE_CURRENT_BINARY_DIR}/app COMMAND scripts/generate_version_h - ARGS ${CMAKE_BINARY_DIR}/include/vpp/app/version.h + ARGS ${CMAKE_CURRENT_BINARY_DIR}/app/version.h COMMENT "Generating VPP version.h" ) add_custom_target(vpp_version_h - DEPENDS ${CMAKE_BINARY_DIR}/include/vpp/app/version.h + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/app/version.h ) ############################################################################## @@ -35,7 +35,7 @@ option(VPP_API_TEST_BUILTIN "Use builtin VPP API test." ON) configure_file( ${CMAKE_SOURCE_DIR}/vpp/vnet/config.h.in - ${CMAKE_BINARY_DIR}/vpp/vnet/config.h + ${CMAKE_CURRENT_BINARY_DIR}/vnet/config.h ) set(VPP_API_FILES @@ -141,3 +141,13 @@ install(FILES conf/80-vpp.conf DESTINATION etc/sysctl.d COMPONENT vpp) add_vpp_test_library(vpp ${VPP_API_FILES} ) + +############################################################################## +# minimal interactive startup.conf - only if not present +############################################################################## +if(NOT EXISTS ${CMAKE_BINARY_DIR}/startup.conf) + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/conf/startup.conf.in + ${CMAKE_BINARY_DIR}/startup.conf + ) +endif() diff --git a/src/vpp/conf/startup.conf.in b/src/vpp/conf/startup.conf.in new file mode 100644 index 00000000000..dd3c37120e2 --- /dev/null +++ b/src/vpp/conf/startup.conf.in @@ -0,0 +1,47 @@ + +unix { + interactive + # log @CMAKE_BINARY_DIR@/vpp.log + # full-coredump + # cli-listen @CMAKE_BINARY_DIR@/cli.sock + # exec @CMAKE_BINARY_DIR@/startup.vpp +} + +api-trace { + on +} + +memory { + main-heap-size 1G + # main-heap-page-size 1G +} + +cpu { + # main-core 1 + # corelist-workers 2-3,18-19 +} + +# buffers { + # buffers-per-numa 128000 + # page-size default-hugepage +# } + +plugins { + plugin dpdk_plugin.so { disable } + plugin unittest_plugin.so { enable } +} + +# dpdk { +# no-pci +#} + +statseg { + size 32m + # page-size 4k + # socket-name @CMAKE_BINARY_DIR@/stats.sock +} + +#logging { + # default-syslog-log-level debug + # class dpdk/cryptodev { rate-limit 100 level debug syslog-level error } +#} diff --git a/src/vppinfra/CMakeLists.txt b/src/vppinfra/CMakeLists.txt index 11193a37482..dd3690bdbf3 100644 --- a/src/vppinfra/CMakeLists.txt +++ b/src/vppinfra/CMakeLists.txt @@ -27,11 +27,11 @@ endif(VPP_VECTOR_GROW_BY_ONE) configure_file( ${CMAKE_SOURCE_DIR}/vppinfra/config.h.in - ${CMAKE_BINARY_DIR}/vppinfra/config.h + ${CMAKE_CURRENT_BINARY_DIR}/config.h ) install( - FILES ${CMAKE_BINARY_DIR}/vppinfra/config.h + FILES ${CMAKE_CURRENT_BINARY_DIR}/config.h DESTINATION include/vppinfra COMPONENT vpp-dev ) |