Commit a89aab8d authored by Robert Schmidt's avatar Robert Schmidt

build_oai: add --build-tool-opt to pass options to build tool

There are command line options that one might pass to ninja/make, but
for which cmake does not provide an interface. For instance, make/ninja
support -k/-kN to "keep going" after errors. Cmake does not provide an
option, but it is still possible to pass this. Make a build_oai option
to allow this, used in the next commit.
parent 03946cd4
...@@ -48,6 +48,7 @@ CMAKE_BUILD_TYPE="RelWithDebInfo" ...@@ -48,6 +48,7 @@ CMAKE_BUILD_TYPE="RelWithDebInfo"
CMAKE_CMD="$CMAKE" CMAKE_CMD="$CMAKE"
OPTIONAL_LIBRARIES="telnetsrv enbscope uescope nrscope ldpc_cuda ldpc_t2 websrv oai_iqplayer imscope" OPTIONAL_LIBRARIES="telnetsrv enbscope uescope nrscope ldpc_cuda ldpc_t2 websrv oai_iqplayer imscope"
TARGET_LIST="" TARGET_LIST=""
BUILD_TOOL_OPT="-j$(nproc)"
function print_help() { function print_help() {
echo_info " echo_info "
...@@ -56,6 +57,8 @@ for a number of distributions (Ubuntu 22-24, Fedora, RHEL9). ...@@ -56,6 +57,8 @@ for a number of distributions (Ubuntu 22-24, Fedora, RHEL9).
Options: Options:
--arch-native --arch-native
Passes -march=native to the compiler. Passes -march=native to the compiler.
--build-tool-opt
Pass options to build tool (ninja/make), e.g. -k (\"keep going\")
-c | --clean -c | --clean
Erase all files to make a rebuild from start Erase all files to make a rebuild from start
-C | --clean-all -C | --clean-all
...@@ -160,6 +163,9 @@ function main() { ...@@ -160,6 +163,9 @@ function main() {
--arch-native) --arch-native)
echo_fatal "Error: specify --arch-native on the command line to cmake directly: ./build_oai --cmake-opt \"-DCMAKE_C_FLAGS=-march=native -DCMAKE_CXX_FLAGS=-march=native\"" echo_fatal "Error: specify --arch-native on the command line to cmake directly: ./build_oai --cmake-opt \"-DCMAKE_C_FLAGS=-march=native -DCMAKE_CXX_FLAGS=-march=native\""
shift;; shift;;
--build-tool-opt)
BUILD_TOOL_OPT+=" $2"
shift 2;;
-c | --clean) -c | --clean)
CLEAN=1 CLEAN=1
shift;; shift;;
...@@ -490,7 +496,7 @@ function main() { ...@@ -490,7 +496,7 @@ function main() {
CMAKE_CMD="$CMAKE_CMD ../../.." CMAKE_CMD="$CMAKE_CMD ../../.."
echo_info "Running \"$CMAKE_CMD\"" echo_info "Running \"$CMAKE_CMD\""
eval $CMAKE_CMD eval $CMAKE_CMD
compilations $BUILD_DIR all.txt $TARGET_LIST compilations $BUILD_DIR all.txt "$TARGET_LIST" "${BUILD_TOOL_OPT}"
################### ###################
# Doxygen Support # # Doxygen Support #
################### ###################
...@@ -513,9 +519,9 @@ function main() { ...@@ -513,9 +519,9 @@ function main() {
cd $DIR/nas_sim_tools/build cd $DIR/nas_sim_tools/build
${CMAKE_CMD% *} .. ${CMAKE_CMD% *} ..
compilations nas_sim_tools usim.txt usim compilations nas_sim_tools usim.txt "usim" "${BUILD_TOOL_OPT}"
compilations nas_sim_tools nvram.txt nvram compilations nas_sim_tools nvram.txt "nvram" "${BUILD_TOOL_OPT}"
compilations nas_sim_tools conf2uedata.txt conf2uedata compilations nas_sim_tools conf2uedata.txt "conf2uedata" "${BUILD_TOOL_OPT}"
# generate USIM data # generate USIM data
if [ -f conf2uedata ]; then if [ -f conf2uedata ]; then
......
...@@ -208,20 +208,20 @@ check_errors() { ...@@ -208,20 +208,20 @@ check_errors() {
} }
compilations() { compilations() {
[[ $# -gt 2 ]] || echo_fatal "compilations needs more than three arguments" [[ $# -eq 4 ]] || echo_fatal "compilations <dir> <logfile> <targets> <build-tool-opt>"
local dir=$1 local dir=$1
shift 1 local logfile=$2
local logfile=$1 local targets=$3
shift 1 local build_tool_opt=$4
local targets=$@
local verbose=$([ "$VERBOSE_COMPILE" == "1" ] && echo "-v" || echo "") local verbose=$([ "$VERBOSE_COMPILE" == "1" ] && echo "-v" || echo "")
echo cd $OPENAIR_DIR/cmake_targets/$dir/build echo cd $OPENAIR_DIR/cmake_targets/$dir/build
cd $OPENAIR_DIR/cmake_targets/$dir/build cd $OPENAIR_DIR/cmake_targets/$dir/build
echo_info "Running \"$CMAKE --build . $verbose --target $targets -- -j$(nproc)\"" $green cmd="$CMAKE --build . ${verbose} --target ${targets} -- ${build_tool_opt}"
echo_info "Running \"${cmd}\"" $green
echo "Log file for compilation is being written to: $dlog/$logfile" echo "Log file for compilation is being written to: $dlog/$logfile"
set +e set +e
{ {
$CMAKE --build . $verbose --target $targets -- -j$(nproc) eval ${cmd}
ret=$? ret=$?
} > $dlog/$logfile 2>&1 } > $dlog/$logfile 2>&1
# Print the errors and warnings for CI purposes # Print the errors and warnings for CI purposes
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment