aboutsummaryrefslogtreecommitdiffstats
path: root/extras/scripts/cross_compile_macos.sh
diff options
context:
space:
mode:
authorNathan Skrzypczak <nathan.skrzypczak@gmail.com>2019-07-31 17:57:58 +0200
committerDave Wallace <dwallacelf@gmail.com>2019-10-09 13:18:47 +0000
commit66f2a8891f4c0fd49433280be06e5e007491e044 (patch)
tree2e3364ae1c874f76a659f4d0b0cf6f4638613234 /extras/scripts/cross_compile_macos.sh
parent7b2e9fb1a8f389fa7b88fcbaf3356cbdae254250 (diff)
docs: Add macos build documentation
Type: docs Change-Id: Iee03aacab2cfcb4e87190302dc641e8273b7f096 Signed-off-by: Nathan Skrzypczak <nathan.skrzypczak@gmail.com>
Diffstat (limited to 'extras/scripts/cross_compile_macos.sh')
-rwxr-xr-xextras/scripts/cross_compile_macos.sh74
1 files changed, 74 insertions, 0 deletions
diff --git a/extras/scripts/cross_compile_macos.sh b/extras/scripts/cross_compile_macos.sh
new file mode 100755
index 00000000000..998d914cf88
--- /dev/null
+++ b/extras/scripts/cross_compile_macos.sh
@@ -0,0 +1,74 @@
+#!/bin/bash
+
+VPP_DIR=$(dirname ${BASH_SOURCE[0]})/../..
+VPP_TOOLCHAIN_FILE=$VPP_DIR/extras/scripts/.config/macos.toolchain
+BUILD_PATCH=$VPP_DIR/extras/scripts/patches/macos_build_externals.patch
+VPP_EXPORT_CC=""
+
+function help() {
+cat << __EOF__
+Usage: $0 [COMMAND]
+conf <dir> create the configuration file
+ with the give cross-toolchain directory
+build run Macos <make build>
+build-release run Macos <make build-release>
+compile_commands Generate compile_commands.json
+__EOF__
+}
+
+function create_toolchain_file () {
+ if [ x$1 = x ]; then
+ echo "Please specify the cross toolchain directory"
+ exit 1
+ fi
+ XCHAIN=$1
+ if [ ! -e ]; then
+ mkdir -p $VPP_DIR/extras/scripts/.config
+ echo "
+SET(CMAKE_SYSTEM_NAME Linux)
+SET(CMAKE_SYSTEM_VERSION 1)
+
+# specify the cross compiler
+SET(CMAKE_C_COMPILER $XCHAIN/x86_64-ubuntu16.04-linux-gnu/bin/x86_64-ubuntu16.04-linux-gnu-gcc)
+SET(CMAKE_CXX_COMPILER $XCHAIN/x86_64-ubuntu16.04-linux-gnu/bin/x86_64-ubuntu16.04-linux-gnu-g++)
+
+# where is the target environment
+SET(CMAKE_FIND_ROOT_PATH $XCHAIN/x86_64-ubuntu16.04-linux-gnu $XCHAIN/x86_64-ubuntu16.04-linux-gnu/x86_64-ubuntu16.04-linux-gnu/sysroot/)
+
+SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
+SET(CMAKE_SYSTEM_PROCESSOR x86_64)
+# This is needed to build vpp-papi
+SET(PYTHON_EXECUTABLE /usr/local/bin/python)" | tee $VPP_TOOLCHAIN_FILE > /dev/null
+ echo "Configration file created"
+ echo "please edit $VPP_TOOLCHAIN_FILE"
+ else
+ echo "configuration file already exists"
+ echo "please edit $VPP_TOOLCHAIN_FILE"
+ fi
+}
+
+function vpp_make () {
+ cd $VPP_DIR ; git apply $BUILD_PATCH
+ trap "cd $VPP_DIR ; git apply -R $BUILD_PATCH" EXIT
+ export VPP_EXTRA_CMAKE_ARGS="-DCMAKE_TOOLCHAIN_FILE=${VPP_TOOLCHAIN_FILE} -DCMAKE_EXPORT_COMPILE_COMMANDS=${VPP_EXPORT_CC}" ; make -C $VPP_DIR $1
+}
+
+case $1 in
+ conf)
+ create_toolchain_file $2
+ ;;
+ build)
+ vpp_make build
+ ;;
+ build-release)
+ vpp_make build-release
+ ;;
+ compile_commands)
+ VPP_EXPORT_CC=ON vpp_make build
+ echo "compile_commands.json should be generated"
+ echo "check $VPP_DIR/build-root/build-vpp_debug-native/vpp/compile_commands.json"
+ ;;
+ *)
+ help
+ ;;
+esac \ No newline at end of file