diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | build-data/packages/vpp.mk | 4 | ||||
-rwxr-xr-x | configure | 96 | ||||
-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 (renamed from extras/scripts/compdb_cleanup.py) | 5 | ||||
-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 |
13 files changed, 215 insertions, 28 deletions
diff --git a/.gitignore b/.gitignore index 455316c1eb3..d91975e72a0 100644 --- a/.gitignore +++ b/.gitignore @@ -39,7 +39,6 @@ config.log config.guess config.sub config.status -configure configure.scan coverage_report depcomp @@ -628,7 +628,7 @@ cscope: cscope.files compdb: @ninja -C build-root/build-vpp_debug-native/vpp build.ninja @ninja -C build-root/build-vpp_debug-native/vpp -t compdb | \ - extras/scripts/compdb_cleanup.py > compile_commands.json + src/scripts/compdb_cleanup.py > compile_commands.json .PHONY: checkstyle checkstyle: checkfeaturelist diff --git a/build-data/packages/vpp.mk b/build-data/packages/vpp.mk index bbff1ba564f..7db450e0554 100644 --- a/build-data/packages/vpp.mk +++ b/build-data/packages/vpp.mk @@ -54,8 +54,8 @@ vpp_build = $(CMAKE) --build $(PACKAGE_BUILD_DIR) -- $(MAKE_PARALLEL_FLAGS) vpp_install = $(CMAKE) --build $(PACKAGE_BUILD_DIR) -- install | grep -v 'Set runtime path' vpp-package-deb: vpp-install - @$(CMAKE) --build $(PACKAGE_BUILD_DIR)/vpp -- package-deb + @$(CMAKE) --build $(PACKAGE_BUILD_DIR)/vpp -- pkg-deb @find $(PACKAGE_BUILD_DIR) \ - -maxdepth 1 \ + -maxdepth 2 \ \( -name '*.changes' -o -name '*.deb' -o -name '*.buildinfo' \) \ -exec mv {} $(CURDIR) \; diff --git a/configure b/configure new file mode 100755 index 00000000000..165429a2e63 --- /dev/null +++ b/configure @@ -0,0 +1,96 @@ +#!/usr/bin/env bash + +# Experimental script, please consult with dmarion@me.com before +# submitting any changes + +# defaults +build_dir=. +install_dir=/usr/local +build_type=release +prefix_path=/opt/vpp/external/$(uname -m)/ + +help() +{ + cat << __EOF__ +VPP Build Configuration Script + +USAGE: ${0} [options] + +OPTIONS: + --help, -h This help + --build-dir, -b Build directory + --install-dir, -i Install directory + --type, -t Build type (release, debug, ... ) + --wipe, -w Wipe whole repo (except startup.* files) +__EOF__ +} + +while (( "$#" )); do + case "$1" in + -h|--help) + help + exit 1 + ;; + -b|--build-dir) + if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then + build_dir=$2 + shift 2 + else + echo "Error: Argument for $1 is missing" >&2 + exit 1 + fi + ;; + -i|--install-dir) + if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then + install_dir=$2 + shift 2 + else + echo "Error: Argument for $1 is missing" >&2 + exit 1 + fi + ;; + -t|--build-type) + if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then + build_type=$2 + shift 2 + else + echo "Error: Argument for $1 is missing" >&2 + exit 1 + fi + ;; + -w|--wipe) + git clean -fdx --exclude=startup.\* + exit 1 + ;; + -*|--*=) # unsupported flags + echo "Error: Unsupported flag $1" >&2 + exit 1 + ;; + *) # preserve positional arguments + PARAMS="$PARAMS $1" + shift + ;; + esac +done + +cmake \ + -G Ninja \ + -S src \ + -B ${build_dir} \ + -DCMAKE_PREFIX_PATH=${prefix_path} \ + -DCMAKE_INSTALL_PREFIX=${install_dir} \ + -DCMAKE_BUILD_TYPE:STRING=${build_type} + + cat << __EOF__ + + Useful build commands: + + ninja Build VPP + ninja menu Start build configuration TUI + ninja compdb Generate compile_commands.json + ninja run Runs VPP using startup.conf in the build directory + ninja debug Runs VPP inside GDB using startup.conf in the build directory + ninja pkg-deb Create .deb packages + ninja install Install VPP to $install_dir + +__EOF__ 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/extras/scripts/compdb_cleanup.py b/src/scripts/compdb_cleanup.py index 0139b6bb6c5..0302fc2f87c 100755 --- a/extras/scripts/compdb_cleanup.py +++ b/src/scripts/compdb_cleanup.py @@ -18,6 +18,11 @@ for i in range(len(objects) - 1, -1, -1): 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": 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 ) |