diff --git a/3_build_tensorflow_cpp_generic_x86_64.sh b/3_build_tensorflow_cpp_generic_x86_64.sh index ac8ca1d..78d86e3 100755 --- a/3_build_tensorflow_cpp_generic_x86_64.sh +++ b/3_build_tensorflow_cpp_generic_x86_64.sh @@ -19,17 +19,31 @@ cd $DIR/tensorflow # Clean up git clean -fdx git reset --hard -git apply < $DIR/tf_base.patch || exit 1 -git apply < $DIR/tf_generic_x86_64.patch || exit 1 + +patch -p1 < $DIR/tf_base.patch +if [ $? != 0 ]; then + echo -e "FATAL: tf_base.patch FAILED!" + exit 1 +fi +patch -p1 < $DIR/tf_generic_x86_64.patch +if [ $? != 0 ]; then + echo -e "FATAL: tf_generic_x86_64.patch FAILED!" + exit 1 +fi # Build the Tensorflow cd tensorflow/contrib/cmake cmake . -Dtensorflow_ENABLE_GRPC_SUPPORT=OFF -Dtensorflow_ENABLE_SSL_SUPPORT=OFF -Dtensorflow_BUILD_PYTHON_BINDINGS=OFF \ - -Dtensorflow_ENABLE_POSITION_INDEPENDENT_CODE=ON -Dtensorflow_BUILD_SHARED_LIB=ON -Dtensorflow_BUILD_CC_EXAMPLE=OFF -DCMAKE_BUILD_TYPE=Release || exit 1 -make -j8 tensorflow || exit 1 -cd ../../.. + -Dtensorflow_ENABLE_POSITION_INDEPENDENT_CODE=ON -Dtensorflow_BUILD_SHARED_LIB=ON -Dtensorflow_BUILD_CC_EXAMPLE=OFF -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX=${DIR}/tensorflow/install || exit 1 +make -j8 tensorflow install || exit 1 + +# Copy headers +cd ${DIR}/tensorflow/install/include || exit 1 +cp -rf * $DIR/packaging/headers/ || exit 1 # Copy/prepare the final binaries +cd $DIR/tensorflow cp tensorflow/contrib/cmake/protobuf/src/protobuf/libprotobuf.a $DIR/packaging/libs/libprotobuf-tf-static.a || exit 1 g++ -shared -o $DIR/packaging/libs/libprotobuf-tf.so -Wl,--whole-archive -l:libprotobuf-tf-static.a -L$DIR/packaging/libs/ -Wl,--no-whole-archive || exit 1 cp tensorflow/contrib/cmake/nsync/src/nsync/libnsync.a $DIR/packaging/libs/libnsync-tf.a || exit 1 diff --git a/3_build_tensorflow_cpp_optimized_x86_64.sh b/3_build_tensorflow_cpp_optimized_x86_64.sh index 081b07a..b575d30 100755 --- a/3_build_tensorflow_cpp_optimized_x86_64.sh +++ b/3_build_tensorflow_cpp_optimized_x86_64.sh @@ -19,17 +19,30 @@ cd $DIR/tensorflow # Clean up git clean -fdx git reset --hard -git apply < $DIR/tf_base.patch || exit 1 -git apply < $DIR/tf_optimized_x86_64.patch || exit 1 +patch -p1 < $DIR/tf_base.patch +if [ $? != 0 ]; then + echo -e "FATAL: tf_base.patch FAILED!" + exit 1 +fi +patch -p1 < $DIR/tf_optimized_x86_64.patch +if [ $? != 0 ]; then + echo -e "FATAL: tf_optimized_x86_64.patch FAILED!" + exit 1 +fi # Build the Tensorflow cd tensorflow/contrib/cmake cmake . -Dtensorflow_ENABLE_GRPC_SUPPORT=OFF -Dtensorflow_ENABLE_SSL_SUPPORT=OFF -Dtensorflow_BUILD_PYTHON_BINDINGS=OFF \ - -Dtensorflow_ENABLE_POSITION_INDEPENDENT_CODE=ON -Dtensorflow_BUILD_SHARED_LIB=ON -Dtensorflow_BUILD_CC_EXAMPLE=OFF -DCMAKE_BUILD_TYPE=Release || exit 1 -make -j8 tensorflow || exit 1 -cd ../../.. + -Dtensorflow_ENABLE_POSITION_INDEPENDENT_CODE=ON -Dtensorflow_BUILD_SHARED_LIB=ON -Dtensorflow_BUILD_CC_EXAMPLE=OFF -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX=${DIR}/tensorflow/install || exit 1 +make -j8 tensorflow install || exit 1 + +# Copy headers +cd ${DIR}/tensorflow/install/include || exit 1 +cp -rf * $DIR/packaging/headers/ || exit 1 # Copy/prepare the final binaries +cd $DIR/tensorflow cp tensorflow/contrib/cmake/protobuf/src/protobuf/libprotobuf.a $DIR/packaging/libs/libprotobuf-tf-static.a || exit 1 g++ -shared -o $DIR/packaging/libs/libprotobuf-tf.so -Wl,--whole-archive -l:libprotobuf-tf-static.a -L$DIR/packaging/libs/ -Wl,--no-whole-archive || exit 1 cp tensorflow/contrib/cmake/nsync/src/nsync/libnsync.a $DIR/packaging/libs/libnsync-tf.a || exit 1