Home | History | Annotate | Download | only in darwin-x86
      1 # inputs
      2 # $PROJ - project name (cmake|ninja|swig)
      3 # $VER - project version
      4 # $1 - name of this file
      5 #
      6 # this file does the following:
      7 #
      8 # 1) define the following env vars
      9 # OS - linux|darwin|windows
     10 # USER - username
     11 # CORES - numer of cores (for parallel builds)
     12 # PATH (with appropriate compilers)
     13 # CFLAGS/CXXFLAGS/LDFLAGS
     14 # RD - root directory for source and object files
     15 # INSTALL - install directory/git repo root
     16 # SCRIPT_FILE=absolute path to the parent build script
     17 # SCRIPT_DIR=absolute path to the parent build script's directory
     18 # COMMON_FILE=absolute path to this file
     19 
     20 #
     21 # 2) create an empty tmp directory at /tmp/$PROJ-$USER
     22 # 3) checkout the destination git repo to /tmp/prebuilts/$PROJ/$OS-x86/$VER
     23 # 4) cd $RD
     24 
     25 UNAME="$(uname)"
     26 case "$UNAME" in
     27 Linux)
     28     SCRATCH=/tmp
     29     OS='linux'
     30     INSTALL_VER=$VER
     31     ;;
     32 Darwin)
     33     SCRATCH=/tmp
     34     OS='darwin'
     35     OSX_MIN=10.6
     36     export CFLAGS="$CFLAGS -mmacosx-version-min=$OSX_MIN"
     37     export CXXFLAGS="$CXXFLAGS -mmacosx-version-min=$OSX_MIN"
     38     export LDFLAGS="$LDFLAGS -mmacosx-version-min=$OSX_MIN"
     39     INSTALL_VER=$VER
     40     ;;
     41 *_NT-*)
     42     if [[ "$UNAME" == CYGWIN_NT-* ]]; then
     43         PATH_PREFIX=/cygdrive
     44     else
     45         # MINGW32_NT-*
     46         PATH_PREFIX=
     47     fi
     48     SCRATCH=$PATH_PREFIX/d/src/tmp
     49     USER=$USERNAME
     50     OS='windows'
     51     CORES=$NUMBER_OF_PROCESSORS
     52     # VS2013 x64 Native Tools Command Prompt
     53     case "$MSVS" in
     54     2013)
     55         export PATH="$PATH_PREFIX/c/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/amd64/":"$PATH_PREFIX/c/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/":"$PATH"
     56         export INCLUDE="C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\INCLUDE;C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\ATLMFC\\INCLUDE;C:\\Program Files (x86)\\Windows Kits\\8.1\\include\\shared;C:\\Program Files (x86)\\Windows Kits\\8.1\\include\\um;C:\\Program Files (x86)\\Windows Kits\\8.1\\include\\winrt;"
     57         export LIB="C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\LIB\\amd64;C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\ATLMFC\\LIB\\amd64;C:\\Program Files (x86)\\Windows Kits\\8.1\\lib\\winv6.3\\um\\x64;"
     58         export LIBPATH="C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319;C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\LIB\\amd64;C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\ATLMFC\\LIB\\amd64;C:\\Program Files (x86)\\Windows Kits\\8.1\\References\\CommonConfiguration\\Neutral;C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v8.1\\ExtensionSDKs\\Microsoft.VCLibs\\12.0\\References\\CommonConfiguration\\neutral;"
     59         INSTALL_VER=${VER}_${MSVS}
     60         ;;
     61     *)
     62         # g++/make build
     63         export CC=x86_64-w64-mingw32-gcc
     64         export CXX=x86_64-w64-mingw32-g++
     65         export LD=x86_64-w64-mingw32-ld
     66         ;;
     67     esac
     68     ;;
     69 *)
     70     exit 1
     71     ;;
     72 esac
     73 
     74 # OSX lacks a "realpath" bash command
     75 realpath() {
     76     [[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
     77 }
     78 
     79 SCRIPT_FILE=$(realpath "$0")
     80 SCRIPT_DIR="$(dirname "$SCRIPT_FILE")"
     81 COMMON_FILE="$SCRIPT_DIR/$1"
     82 
     83 RD=$SCRATCH/$PROJ-$USER
     84 INSTALL="$RD/install"
     85 
     86 cd /tmp # windows can't delete if you're in the dir
     87 rm -rf $RD
     88 mkdir -p $INSTALL
     89 mkdir -p $RD
     90 cd $RD
     91 
     92 commit_and_push()
     93 {
     94     # check into a local git clone
     95     rm -rf $SCRATCH/prebuilts/$PROJ/
     96     mkdir -p $SCRATCH/prebuilts/$PROJ/
     97     cd $SCRATCH/prebuilts/$PROJ/
     98     git clone https://android.googlesource.com/platform/prebuilts/$PROJ/$OS-x86
     99     GIT_REPO="$SCRATCH/prebuilts/$PROJ/$OS-x86"
    100     cd $GIT_REPO
    101     git rm -r * || true  # ignore error caused by empty directory
    102     if [ -n "${EXTRA_FILE}" ]; then
    103 	git reset -- $EXTRA_FILE
    104 	git checkout HEAD -- $EXTRA_FILE
    105     fi
    106     mv $INSTALL/* $GIT_REPO
    107     cp $SCRIPT_FILE $GIT_REPO
    108     cp $COMMON_FILE $GIT_REPO
    109 
    110     git add .
    111     git commit -m "Adding binaries for ${INSTALL_VER}${EXTRA_COMMIT_MSG}"
    112 
    113     # execute this command to upload
    114     #git push origin HEAD:refs/for/master
    115 
    116     rm -rf $RD || true  # ignore error
    117 }
    118