misc: experimental configure script
Type: make
Change-Id: Iaeb9d22eec9a7a763b63899814a44e78c8050f1f
Signed-off-by: Damjan Marion <damarion@cisco.com>
diff --git a/.gitignore b/.gitignore
index 455316c..d91975e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -39,7 +39,6 @@
config.guess
config.sub
config.status
-configure
configure.scan
coverage_report
depcomp
diff --git a/Makefile b/Makefile
index e228131..807d1ea 100644
--- a/Makefile
+++ b/Makefile
@@ -628,7 +628,7 @@
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 bbff1ba..7db450e 100644
--- a/build-data/packages/vpp.mk
+++ b/build-data/packages/vpp.mk
@@ -54,8 +54,8 @@
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 0000000..165429a
--- /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 7dfd76a..96d373a 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -64,6 +64,7 @@
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 @@
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 @@
endif()
foreach(DIR ${SUBDIRS})
- add_subdirectory(${DIR})
+ add_subdirectory(${DIR} ${VPP_BINARY_DIR}/${DIR})
endforeach()
##############################################################################
@@ -207,6 +207,36 @@
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 6747285..007a906 100644
--- a/src/cmake/api.cmake
+++ b/src/cmake/api.cmake
@@ -80,7 +80,7 @@
##############################################################################
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 @@
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 @@
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 @@
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 @@
${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 e466fe8..d447774 100644
--- a/src/pkg/CMakeLists.txt
+++ b/src/pkg/CMakeLists.txt
@@ -41,7 +41,7 @@
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 @@
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 3249220..15f8eb6 100755
--- a/src/pkg/debian/rules.in
+++ b/src/pkg/debian/rules.in
@@ -30,7 +30,7 @@
@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
similarity index 84%
rename from extras/scripts/compdb_cleanup.py
rename to src/scripts/compdb_cleanup.py
index 0139b6b..0302fc2 100755
--- a/extras/scripts/compdb_cleanup.py
+++ b/src/scripts/compdb_cleanup.py
@@ -18,6 +18,11 @@
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 dbd74f1..78fe936 100644
--- a/src/vlib/CMakeLists.txt
+++ b/src/vlib/CMakeLists.txt
@@ -37,10 +37,10 @@
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 df83837..0798350 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 @@
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 @@
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 0000000..dd3c371
--- /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 11193a3..dd3690b 100644
--- a/src/vppinfra/CMakeLists.txt
+++ b/src/vppinfra/CMakeLists.txt
@@ -27,11 +27,11 @@
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
)