Skip to content

Commit

Permalink
Copy more C++ headers into the package
Browse files Browse the repository at this point in the history
  • Loading branch information
kecsap committed Dec 30, 2018
1 parent 10b4715 commit 3068fda
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 10 deletions.
24 changes: 19 additions & 5 deletions 3_build_tensorflow_cpp_generic_x86_64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 18 additions & 5 deletions 3_build_tensorflow_cpp_optimized_x86_64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3068fda

Please sign in to comment.