misc: experimental configure script

Type: make
Change-Id: Iaeb9d22eec9a7a763b63899814a44e78c8050f1f
Signed-off-by: Damjan Marion <damarion@cisco.com>
This commit is contained in:
Damjan Marion
2021-04-29 18:47:25 +02:00
committed by Andrew Yourtchenko
parent 10796899cf
commit 88b2e3682b
13 changed files with 215 additions and 28 deletions

1
.gitignore vendored
View File

@ -39,7 +39,6 @@ config.log
config.guess
config.sub
config.status
configure
configure.scan
coverage_report
depcomp

View File

@ -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

View File

@ -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) \;

96
configure vendored Executable file
View File

@ -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__

View File

@ -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()
##############################################################################
@ -206,6 +206,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
##############################################################################

View File

@ -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})

View File

@ -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
)

View File

@ -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 \

View File

@ -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":

View File

@ -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
)

View File

@ -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()

View File

@ -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 }
#}

View File

@ -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
)