├── .gitignore ├── .gitmodules ├── README.md ├── build-all.sh ├── build-mosh.sh └── create-libmoshios-framework.sh /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "mosh"] 2 | path = mosh 3 | url = git@github.com:blinksh/mosh.git 4 | [submodule "build-protobuf"] 5 | path = build-protobuf 6 | url = https://gist.github.com/9487468ae3375d0db0cc.git 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # build-mosh 2 | Wrapper to compile Mosh for iOS. This is used to compile a library packaging Mosh to be used in [Blink](http://github.com/blinksh/blink). Please do not use it to compile mosh-client or mosh-server versions. Refer to the original [Mosh](https://github.com/mobile-shell/mosh) for that. 3 | 4 | ## Requirements 5 | - XCode 7 6 | - XCode Command Line Tools 7 | - iOS SDK. 8 | 9 | ## Building 10 | ```bash 11 | git clone --recursive https://github.com/blinksh/build-mosh.git && cd build-mosh 12 | ./build-all.sh 13 | ``` 14 | 15 | This script will build both Mosh and libprotobuf for iOS. The resulting Mosh for iOS will be packaged as libmoshios.framework on the root. The resulting libprotobuf.a will be under build-protobuf/protobuf-ver/lib. 16 | 17 | If you want to customize the compilation of any piece, go to the corresopnding build-mosh or build-protobuf scripts. 18 | 19 | Special thanks to @dariaphoebe for helping to simplify the compilation :) 20 | -------------------------------------------------------------------------------- /build-all.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | cd "${BASH_SOURCE%/*}" 4 | curl -OL https://github.com/blinksh/build-protobuf/releases/download/2.6.1/protobuf-2.6.1.tar.gz 5 | 6 | tar -zxf protobuf-2.6.1.tar.gz || { echo "Protobuf download error"; exit 1; } 7 | mv -f protobuf-2.6.1/ protobuf-release 8 | 9 | echo "Building Mosh" 10 | ./build-mosh.sh && ./create-libmoshios-framework.sh 11 | -------------------------------------------------------------------------------- /build-mosh.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | pwd=`pwd` 4 | PROTOBUFDIR="$pwd/protobuf-release" 5 | XCODEPATH=`xcode-select --print-path` 6 | PLATFORMPATH="$XCODEPATH/Platforms" 7 | TOOLSPATH="$XCODEPATH/Toolchains/XcodeDefault.xctoolchain/usr/bin" 8 | 9 | export IPHONEOS_DEPLOYMENT_TARGET="10.0" 10 | 11 | 12 | findLatestSDKVersion() 13 | { 14 | sdks=`ls $PLATFORMPATH/$1.platform/Developer/SDKs` 15 | arr=() 16 | for sdk in $sdks 17 | do 18 | arr[${#arr[@]}]=$sdk 19 | done 20 | 21 | # Last item will be the current SDK, since it is alpha ordered 22 | count=${#arr[@]} 23 | if [ $count -gt 0 ]; then 24 | sdk=${arr[$count-1]:${#1}} 25 | num=`expr ${#sdk}-4` 26 | SDKVERSION=${sdk:0:$num} 27 | else 28 | SDKVERSION="8.0" 29 | fi 30 | } 31 | 32 | buildit() 33 | { 34 | target=$1 35 | hosttarget=$1 36 | platform=$2 37 | 38 | export ac_cv_path_PROTOC="$PROTOBUFDIR/bin/protoc" 39 | export protobuf_LIBS="$PROTOBUFDIR/lib/libprotobuf.a" 40 | export protobuf_CFLAGS="-I$PROTOBUFDIR/include" 41 | export CC="$(xcrun -sdk iphoneos -find clang)" 42 | export CPP="$CC -E" 43 | export CFLAGS="-arch ${target} -isysroot $PLATFORMPATH/$platform.platform/Developer/SDKs/$platform$SDKVERSION.sdk -miphoneos-version-min=$IPHONEOS_DEPLOYMENT_TARGET -I$pwd/headers" 44 | export AR=$(xcrun -sdk iphoneos -find ar) 45 | export RANLIB=$(xcrun -sdk iphoneos -find ranlib) 46 | export CPPFLAGS="-arch ${target} -isysroot $PLATFORMPATH/$platform.platform/Developer/SDKs/$platform$SDKVERSION.sdk -miphoneos-version-min=$IPHONEOS_DEPLOYMENT_TARGET -I$pwd/headers" 47 | export LDFLAGS="-arch ${target} -isysroot $PLATFORMPATH/$platform.platform/Developer/SDKs/$platform$SDKVERSION.sdk" 48 | 49 | mkdir -p $pwd/output/$target 50 | 51 | cd $pwd/mosh 52 | ./autogen.sh 53 | ./configure --prefix="$pwd/output/$target" --disable-server --disable-client --enable-ios-controller --host=$hosttarget-apple-darwin 54 | 55 | make clean 56 | make 57 | 58 | # ar + ranlib were superseded by libtool on OSX, so the makefile LIBADD won't work to create a single library 59 | libtool -static -o "$pwd/output/$target/libmoshios.a" \ 60 | "$pwd/mosh/src/crypto/libmoshcrypto.a" "$pwd/mosh/src/network/libmoshnetwork.a" "$pwd/mosh/src/protobufs/libmoshprotos.a" \ 61 | "$pwd/mosh/src/statesync/libmoshstatesync.a" "$pwd/mosh/src/terminal/libmoshterminal.a" "$pwd/mosh/src/frontend/libmoshiosclient.a" \ 62 | "$pwd/mosh/src/util/libmoshutil.a" 63 | } 64 | 65 | findLatestSDKVersion iPhoneOS 66 | 67 | mkdir headers 68 | cd headers 69 | for i in ncurses.h ncurses_dll.h unctrl.h curses.h term.h ; do 70 | ln -s /usr/include/$i . 71 | done 72 | cd .. 73 | 74 | buildit i386 iPhoneSimulator 75 | buildit armv7 iPhoneOS 76 | buildit x86_64 iPhoneSimulator 77 | buildit arm64 iPhoneOS 78 | 79 | LIPO=$(xcrun -sdk iphoneos -find lipo) 80 | $LIPO -create $pwd/output/i386/libmoshios.a $pwd/output/armv7/libmoshios.a $pwd/output/x86_64/libmoshios.a $pwd/output/arm64/libmoshios.a -output $pwd/output/libmoshios.a 81 | -------------------------------------------------------------------------------- /create-libmoshios-framework.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | FWNAME=libmoshios 4 | 5 | if [ ! -d output ]; then 6 | echo "Please run build-libssh2.sh first!" 7 | exit 1 8 | fi 9 | 10 | if [ -d $FWNAME.framework ]; then 11 | echo "Removing previous $FWNAME.framework copy" 12 | rm -rf $FWNAME.framework 13 | fi 14 | 15 | 16 | echo "Creating $FWNAME.framework" 17 | mkdir -p $FWNAME.framework/Headers 18 | cp output/libmoshios.a $FWNAME.framework/$FWNAME 19 | cp -r mosh/src/frontend/moshiosbridge.h $FWNAME.framework/Headers/ 20 | echo "Created $FWNAME.framework" 21 | --------------------------------------------------------------------------------