Home | History | Annotate | Download | only in makefile
      1 #! /bin/sh
      2 
      3 #!/usr/bin/env bash
      4 # Copyright 2015 The TensorFlow Authors. All Rights Reserved.
      5 #
      6 # Licensed under the Apache License, Version 2.0 (the "License");
      7 # you may not use this file except in compliance with the License.
      8 # You may obtain a copy of the License at
      9 #
     10 #     http://www.apache.org/licenses/LICENSE-2.0
     11 #
     12 # Unless required by applicable law or agreed to in writing, software
     13 # distributed under the License is distributed on an "AS IS" BASIS,
     14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     15 # See the License for the specific language governing permissions and
     16 # limitations under the License.
     17 # ==============================================================================
     18 
     19 # Must be run after: build_all_ios.sh
     20 # Creates an iOS framework which is placed under:
     21 #    gen/ios_frameworks/tensorflow_experimental.framework.zip
     22 
     23 set -e
     24 pushd .
     25 
     26 echo "Starting"
     27 SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
     28 
     29 TMP_DIR=$(mktemp -d)
     30 echo "Package dir: " $TMP_DIR
     31 FW_DIR=$TMP_DIR/tensorflow_ios_frameworks
     32 FW_DIR_TFCORE=$FW_DIR/tensorflow_experimental.framework
     33 FW_DIR_TFCORE_HDRS=$FW_DIR_TFCORE/Headers
     34 
     35 echo "Creating target Headers directories"
     36 mkdir -p $FW_DIR_TFCORE_HDRS
     37 
     38 echo "Generate master LICENSE file and copy to target"
     39 bazel build //tensorflow/tools/lib_package:clicenses_generate
     40 cp $SCRIPT_DIR/../../../bazel-genfiles/tensorflow/tools/lib_package/include/tensorflow/c/LICENSE \
     41    $FW_DIR_TFCORE
     42 
     43 echo "Copying static libraries"
     44 cp $SCRIPT_DIR/gen/lib/libtensorflow-core.a \
     45    $FW_DIR_TFCORE/tensorflow_experimental
     46 cp $SCRIPT_DIR/gen/protobuf_ios/lib/libprotobuf.a \
     47    $FW_DIR_TFCORE/libprotobuf_experimental.a
     48 
     49 echo "Headers, populating: tensorflow (core)"
     50 cd $SCRIPT_DIR/../../..
     51 find tensorflow -name "*.h" | tar -cf $FW_DIR_TFCORE_HDRS/tmp.tar -T -
     52 cd $FW_DIR_TFCORE_HDRS
     53 tar xf tmp.tar
     54 rm -f tmp.tar
     55 
     56 echo "Headers, populating: third_party"
     57 cd $SCRIPT_DIR/../../..
     58 tar cf $FW_DIR_TFCORE_HDRS/tmp.tar third_party
     59 cd $FW_DIR_TFCORE_HDRS
     60 tar xf tmp.tar
     61 rm -f tmp.tar
     62 
     63 echo "Headers, populating: unsupported"
     64 cd $SCRIPT_DIR/downloads/eigen
     65 tar cf $FW_DIR_TFCORE_HDRS/third_party/eigen3/tmp.tar unsupported
     66 cd $FW_DIR_TFCORE_HDRS/third_party/eigen3
     67 tar xf tmp.tar
     68 rm -f tmp.tar
     69 
     70 echo "Headers, populating: Eigen"
     71 cd $SCRIPT_DIR/downloads/eigen
     72 tar cf $FW_DIR_TFCORE_HDRS/third_party/eigen3/tmp.tar Eigen
     73 cd $FW_DIR_TFCORE_HDRS/third_party/eigen3
     74 tar xf tmp.tar
     75 rm -f tmp.tar
     76 
     77 echo "Headers, populating: tensorflow (protos)"
     78 cd $SCRIPT_DIR/gen/proto
     79 tar cf $FW_DIR_TFCORE_HDRS/tmp.tar tensorflow
     80 cd $FW_DIR_TFCORE_HDRS
     81 tar xf tmp.tar
     82 # Don't include the auto downloaded/generated to build this library
     83 rm -rf tensorflow/contrib/makefile
     84 rm -f tmp.tar
     85 
     86 echo "Headers, populating: google (proto src)"
     87 cd $SCRIPT_DIR/downloads/protobuf/src
     88 tar cf $FW_DIR_TFCORE_HDRS/tmp.tar google
     89 cd $FW_DIR_TFCORE_HDRS
     90 tar xf tmp.tar
     91 rm -f tmp.tar
     92 
     93 # This is required, otherwise they interfere with the documentation of the
     94 # pod at cocoapods.org
     95 echo "Remove all README files"
     96 cd $FW_DIR_TFCORE_HDRS
     97 find . -type f -name README\* -exec rm -f {} \;
     98 find . -type f -name readme\* -exec rm -f {} \;
     99 
    100 TARGET_GEN_LOCATION="$SCRIPT_DIR/gen/ios_frameworks"
    101 echo "Moving results to target: " $TARGET_GEN_LOCATION
    102 cd $FW_DIR
    103 zip -q -r tensorflow_experimental.framework.zip tensorflow_experimental.framework -x .DS_Store
    104 rm -rf $TARGET_GEN_LOCATION
    105 mkdir -p $TARGET_GEN_LOCATION
    106 cp -r tensorflow_experimental.framework.zip $TARGET_GEN_LOCATION
    107 
    108 echo "Cleaning up"
    109 popd
    110 rm -rf $TMP_DIR
    111 
    112 echo "Finished"
    113