Bring script/ directory up to date

These scripts were borrowed from the objective-git project and utilized
in the branch that I am taking inspiration from
(https://github.com/SwiftGit2/SwiftGit2/pull/44). Bringing these up to
date includes some fixes for working with iOS. The changelog is as
follows:

Currently unmerged PR fixing script/cibuild for iphonesimulator:

https://github.com/libgit2/objective-git/pull/552

commit 24b2a886c0b61cf1dca0d55cac900b26616e50b9
Author: Ben Chatelain <ben@octop.ad>
Date:   Mon Nov 9 21:49:13 2015 -0700

    Fix libssh2 inclusion in libgit2 iOS build script

    - Added CMAKE_PREFIX_PATH to arch-specific libssh2 root dir
    - Added PKG_CONFIG_USE_CMAKE_PREFIX_PATH so things actually make
      sense
    - Removed unused LIBSSH2_INCLUDE_DIRS

commit dca46ad12a958095aca6ee431de842ca62857b11
Author: joe DeCapo <joe@polka.cat>
Date:   Wed Sep 23 05:26:43 2015 -0500

    Disable code signing during build

    Attempting solution from:
http://stackoverflow.com/questions/27671854/travis-ci-fails-to-build-with-a-code-signing-error

commit 0dc6c60dc0c13ecb088b2a93a9ad24b9c72a9b99
Merge: 4447e70 c9da387
Author: Josh Abernathy <joshaber@gmail.com>
Date:   Wed Sep 2 09:36:05 2015 -0400

    Merge pull request #484 from phatblat/ben/ios-test-target

    iOS Test target

commit 4447e700413adf920a665b138149a20344bc9c87
Merge: b7b2549 aa6dd45
Author: Josh Abernathy <joshaber@gmail.com>
Date:   Mon Aug 31 11:53:55 2015 -0500

    Merge pull request #497 from phatblat/ben/bootstrap

    Just install any missing tools in bootstrap

commit 15f906ca2efa9d5ba67744d25a825c9bc75ad9e7
Author: Ben Chatelain <ben@octop.ad>
Date:   Mon Aug 24 15:25:38 2015 -0600

    Quote sdkflag

commit 2712c2a2beb294cd81ae44f733fdc9f17eb1a259
Author: Ben Chatelain <ben@octop.ad>
Date:   Mon Aug 24 14:17:33 2015 -0600

    Add specific iOS simulator destination

    Specifying the destionation works around the following issue with
xctool. Can also hard-code the architecture, but this seems more
future-proof.

    ```
    Failed to query the list of test cases in the test bundle:
2015-08-24 10:57:11.740 sim[50821:2746840]
/Applications/Xcode6.4.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/sim:
No simulator devices appear to be running.  Setting data directories to
/var/empty.
    2015-08-24 10:57:11.741 sim[50821:2746840] DYLD_INSERT_LIBRARIES
contains possible bad values.  Caller beware:
/usr/local/Cellar/xctool/0.2.4/libexec/lib/otest-query-lib-ios.dylib
    dlopen(/Volumes/DerivedData/ObjectiveGitFramework-drtqacfhlqybdcdpqayztrrwneun/Build/Products/Debug-iphonesimulator/ObjectiveGit-iOSTests.xctest/ObjectiveGit-iOSTests,
1): Library not loaded: @rpath/ObjectiveGit.framework/ObjectiveGit
      Referenced from:
/Volumes/DerivedData/ObjectiveGitFramework-drtqacfhlqybdcdpqayztrrwneun/Build/Products/Debug-iphonesimulator/ObjectiveGit-iOSTests.xctest/ObjectiveGit-iOSTests
      Reason: no suitable image found.  Did find:
        /Volumes/DerivedData/ObjectiveGitFramework-drtqacfhlqybdcdpqayztrrwneun/Build/Products/Debug-iphonesimulator/ObjectiveGit.framework/ObjectiveGit:
mach-o, but wrong architecture
    ```

    Indeed, the "wrong architecture" message is correct as the framework
was built for a different architecture than the test binary:

    ```
    lipo -info ObjectiveGit.framework/ObjectiveGit
ObjectiveGit-iOSTests.xctest/ObjectiveGit-iOSTests
2015-08-24 11:03
    Non-fat file: ObjectiveGit.framework/ObjectiveGit is architecture:
i386
    Non-fat file: ObjectiveGit-iOSTests.xctest/ObjectiveGit-iOSTests is
architecture: x86_64
    ```

commit aa6dd4531cf3380250045c3bb19839d3a40934f1
Author: Ben Chatelain <ben@octop.ad>
Date:   Mon Aug 24 12:31:31 2015 -0600

    /user -> /usr

commit b8efb3224393d12d720cbbbd348c2cb4ec066d6d
Author: Ben Chatelain <ben@octop.ad>
Date:   Mon Aug 24 09:51:51 2015 -0600

    Abort script if Homebrew is not installed

commit e7b8e1aa4bf6aa20de09ff4b112ec688570914d1
Author: Ben Chatelain <ben@octop.ad>
Date:   Mon Aug 24 09:42:17 2015 -0600

    Move check_deps to after update_submodules

commit 27473a0e8e92a47266664271ed4513806937efda
Author: Ben Chatelain <ben@octop.ad>
Date:   Mon Aug 24 09:34:21 2015 -0600

    Wrap long git submodule command chain for readability

commit 7724e36e7ca1666f535c8967c7534e04664d457e
Author: Ben Chatelain <ben@octop.ad>
Date:   Sun Aug 9 09:12:56 2015 -0600

    Update script comments

commit 768f033f0bf95c01793a941311cdbf45a7fb975c
Author: Ben Chatelain <ben@octop.ad>
Date:   Sat Aug 8 22:51:14 2015 -0600

    Fix iPhone SDK version detection in Xcode 7

commit cb0c5c12f9865e1aa270ed523ce0aeaf72c2be21
Author: Ben Chatelain <benchatelain@gmail.com>
Date:   Tue Jul 28 22:44:01 2015 -0600

    Just install any missing tools in bootstrap

    Now REQUIRED_TOOLS is a mix of commands and libraries

commit 8dda480f788e006277767810b29d8a760028ce8b
Author: Piet Brauer <piet@nerdishbynature.com>
Date:   Wed Jul 22 17:10:45 2015 +0200

    Prebuild OpenSSL in order to workaround Travis timouts

commit 6c66e65c539e3b53db6c5531743dcfecdb116c55
Author: Ben Chatelain <ben@octop.ad>
Date:   Mon Jul 20 21:45:01 2015 -0600

    Stop letting cmake determine which clang to use

commit 2ea1bd02d33ed7fcd0604404dc98693ad89f3815
Author: joshaber <joshaber@gmail.com>
Date:   Fri Jul 10 12:39:52 2015 -0400

    Include pkg-config in our dependencies.

commit c906271f580d6901a1200fc4795df250aca47cfc
Author: Ben Chatelain <ben@octop.ad>
Date:   Mon Jul 6 20:09:34 2015 -0600

    Disable CURL in libgit2 iOS build

commit 549717d138fd4cd1828c7e67fb810523794f1ecb
Author: Ben Chatelain <ben@octop.ad>
Date:   Mon Jul 6 20:09:16 2015 -0600

    Remove obsolete OPENSSL_ defines from libgit2 iOS build

commit aed2cc39c831697102ac6aff317990729b55dd2c
Author: Ben Chatelain <ben@octop.ad>
Date:   Thu Jun 25 21:16:56 2015 -0600

    Fix LIBSSH2_INCLUDE_DIRS define

commit 5ba578ac115974f0981d49b7c79072e867ef804b
Author: Ben Chatelain <benchatelain@gmail.com>
Date:   Tue Feb 17 17:10:32 2015 -0700

    Fix libgit2 Mac build (again)

    LIBSSH2_INCLUDE_DIR = /usr/local/include/

commit b0b011a9da2c784ef25e793a638c28c3b6387fd0
Author: Ben Chatelain <benchatelain@gmail.com>
Date:   Mon Feb 16 16:25:15 2015 -0700

    Revert "Fix libgit2 (Mac) build"

    This reverts commit fd67e2bc2fc40171b06df88b627a636bdcf102cb.

commit fd67e2bc2fc40171b06df88b627a636bdcf102cb
Author: Ben Chatelain <benchatelain@gmail.com>
Date:   Tue Feb 10 07:39:25 2015 -0700

    Fix libgit2 (Mac) build

commit b817e13e4c29bea355044e316d9214fbc955ac8f
Author: Ben Chatelain <benchatelain@gmail.com>
Date:   Mon Feb 9 08:40:20 2015 -0700

    Fix libgit2-ios build

    Set LIBSSH2_INCLUDE_DIR so that libssh2.h can be found

commit da4608b8a5bb87c3c75c7acdcc453fd69c6b8672
Author: Justin Spahr-Summers <Justin.SpahrSummers@gmail.com>
Date:   Thu Nov 6 15:10:33 2014 -0800

    Update objc-build-scripts to stop cleaning automatically

commit f8ff8a60bd0ca6dbfa7b170658c0be8f5f589cd6
Author: Alan Rogers <alanjrogers@me.com>
Date:   Tue Oct 28 15:51:29 2014 +1100

    Don't try and link .a's in the External folder.

commit 1e02f02ddcaf946f153449d604a0d60e2197aab8
Author: Alan Rogers <alanjrogers@me.com>
Date:   Tue Oct 28 15:51:15 2014 +1100

    Remove set -e because lol.

commit c32fe343651aacf91cbe3cf7d513c612f62b235e
Author: Alan Rogers <alanjrogers@me.com>
Date:   Tue Oct 28 14:41:47 2014 +1100

    Skip installing man pages to avoid too many symlink errors.

commit 88ee2eb305d3aeb1ece99c654f12da1fe2eadc40
Author: Justin Spahr-Summers <Justin.SpahrSummers@gmail.com>
Date:   Wed Oct 22 11:51:32 2014 -0700

    Update to jspahrsummers/objc-build-scripts@a54782c

commit 2c337c688a2779b51e6d4178cbace23750f3fde7
Author: Justin Spahr-Summers <jspahrsummers@github.com>
Date:   Tue May 27 09:21:55 2014 -0700

    Enable libgit2 thread safety for iOS

    No idea why this was ever disabled.

    Resolves libgit2/libgit2#2384.

    /cc @carlosmn @SquaredTiki

commit 19392f8a036dc603f115b6ced0d03f580dee0f47
Author: Justin Spahr-Summers <Justin.SpahrSummers@gmail.com>
Date:   Mon Nov 11 11:47:33 2013 -0800

    Add cmake as a required tool

commit 5b6cc97a958caedcc4dcbda18d1a193ed58a2ad6
Author: Justin Spahr-Summers <Justin.SpahrSummers@gmail.com>
Date:   Mon Nov 11 11:37:54 2013 -0800

    Update objc-build-scripts
This commit is contained in:
Tom Booth 2016-02-15 22:07:13 +00:00
parent 2c1fb0e21f
commit cb5daab309
5 changed files with 65 additions and 42 deletions

View File

@ -9,7 +9,8 @@ export SCRIPT_DIR=$(dirname "$0")
config ()
{
# A whitespace-separated list of executables that must be present and locatable.
: ${REQUIRED_TOOLS="xctool cmake"}
# These will each be installed through Homebrew if not found.
: ${REQUIRED_TOOLS="xctool cmake libssh2 libtool autoconf automake pkg-config"}
export REQUIRED_TOOLS
}
@ -22,12 +23,6 @@ main ()
{
config
if [ -n "$REQUIRED_TOOLS" ]
then
echo "*** Checking dependencies..."
check_deps
fi
local submodules=$(git submodule status)
local result=$?
@ -41,28 +36,38 @@ main ()
echo "*** Updating submodules..."
update_submodules
fi
if [ -n "$REQUIRED_TOOLS" ]
then
echo "*** Checking dependencies..."
check_deps
fi
}
check_deps ()
{
for tool in $REQUIRED_TOOLS
do
which -s "$tool"
if [ "$?" -ne "0" ]
then
echo "*** Error: $tool not found. Please install it and bootstrap again."
exit 1
fi
done
# Check if Homebrew is installed
which -s brew
local result=$?
if [ "$result" -ne "0" ]
then
echo
echo "Homebrew is not installed (http://brew.sh). You will need to manually ensure the following tools are installed:"
echo " $REQUIRED_TOOLS"
echo
echo "Additionally, the following libssh2 files must be symlinked under /usr/local:"
echo " lib/libssh2.a include/libssh2.h include/libssh2_sftp.h include/libssh2_publickey.h"
exit $result
fi
# Ensure that we have libgit2's dependencies installed.
installed=`brew list`
libs="libssh2 libtool autoconf automake"
for lib in $libs
for tool in $REQUIRED_TOOLS
do
# Skip packages that are already installed.
echo "$installed" | grep -q "$lib" && code=$? || code=$?
echo "$installed" | grep -q "$tool" && code=$? || code=$?
if [ "$code" -eq "0" ]
then
@ -72,8 +77,8 @@ check_deps ()
exit $code
fi
echo "*** Installing $lib with Homebrew..."
brew install "$lib"
echo "*** Installing $tool with Homebrew..."
brew install "$tool"
done
brew_prefix=`brew --prefix`
@ -114,7 +119,9 @@ bootstrap_submodule ()
update_submodules ()
{
git submodule sync --quiet && git submodule update --init && git submodule foreach --quiet bootstrap_submodule
git submodule sync --quiet && \
git submodule update --init && \
git submodule foreach --quiet bootstrap_submodule
}
export -f bootstrap_submodule

View File

@ -62,6 +62,9 @@ main ()
"$BOOTSTRAP" || exit $?
fi
echo "*** Prebuilding OpenSSL"
$SCRIPT_DIR/update_libssl_ios
echo "*** The following schemes will be built:"
echo "$SCHEMES" | xargs -n 1 echo " "
echo
@ -87,10 +90,16 @@ run_xctool ()
{
if [ -n "$XCWORKSPACE" ]
then
xctool -workspace "$XCWORKSPACE" $XCTOOL_OPTIONS "$@" 2>&1
xctool -workspace "$XCWORKSPACE" $XCTOOL_OPTIONS "$@" \
ONLY_ACTIVE_ARCH=NO \
CODE_SIGN_IDENTITY="" \
CODE_SIGNING_REQUIRED=NO 2>&1
elif [ -n "$XCODEPROJ" ]
then
xctool -project "$XCODEPROJ" $XCTOOL_OPTIONS "$@" 2>&1
xctool -project "$XCODEPROJ" $XCTOOL_OPTIONS "$@" \
ONLY_ACTIVE_ARCH=NO \
CODE_SIGN_IDENTITY="" \
CODE_SIGNING_REQUIRED=NO 2>&1
else
echo "*** No workspace or project file found."
exit 1
@ -109,7 +118,7 @@ build_scheme ()
echo "*** Building and testing $scheme..."
echo
local sdkflag=
local sdkflags=()
local action=test
# Determine whether we can run unit tests for this target.
@ -120,17 +129,17 @@ build_scheme ()
if [ "$awkstatus" -eq "1" ]
then
# SDK not found, try for iphonesimulator.
sdkflag="-sdk iphonesimulator"
sdkflags=(-sdk iphonesimulator -destination "platform=iOS Simulator,name=iPhone 5")
# Determine whether the unit tests will run with iphonesimulator
run_xctool $sdkflag -scheme "$scheme" run-tests | parse_build
run_xctool "${sdkflags[@]}" -scheme "$scheme" run-tests | parse_build
awkstatus=$?
if [ "$awkstatus" -ne "0" ]
then
# Unit tests will not run on iphonesimulator.
sdkflag=""
sdkflags=()
fi
fi
@ -140,7 +149,7 @@ build_scheme ()
action=build
fi
run_xctool $sdkflag -scheme "$scheme" $action
run_xctool "${sdkflags[@]}" -scheme "$scheme" $action
}
export -f build_scheme

View File

@ -22,7 +22,11 @@ fi
mkdir build
cd build
cmake -DBUILD_SHARED_LIBS:BOOL=OFF -DBUILD_CLAR:BOOL=OFF -DTHREADSAFE:BOOL=ON ..
cmake -DBUILD_SHARED_LIBS:BOOL=OFF \
-DLIBSSH2_INCLUDE_DIRS:PATH=/usr/local/include/ \
-DBUILD_CLAR:BOOL=OFF \
-DTHREADSAFE:BOOL=ON \
..
cmake --build .
product="libgit2.a"

View File

@ -42,18 +42,15 @@ function build_libgit2 ()
LOG="${INSTALL_PREFIX}/build-libgit2.log"
echo "$LOG"
cmake -DCMAKE_C_COMPILER=clang \
cmake \
-DCMAKE_C_COMPILER_WORKS:BOOL=ON \
-DBUILD_SHARED_LIBS:BOOL=OFF \
-DOPENSSL_INCLUDE_DIR:PATH=../../External/ios-openssl/include/ \
-DCMAKE_LIBRARY_PATH:PATH=../../External/libssh2-ios/lib/ \
-DCMAKE_INCLUDE_PATH:PATH=../../External/libssh2-ios/include/libssh2/ \
-DOPENSSL_SSL_LIBRARY:FILEPATH=../../External/ios-openssl/lib/libssl.a \
-DCMAKE_LIBRARY_PATH:PATH="${SDKROOT}/usr/lib/" \
-DOPENSSL_CRYPTO_LIBRARY:FILEPATH=../../External/ios-openssl/lib/libcrypto.a \
-DCMAKE_PREFIX_PATH:PATH="${ROOT_PATH}/External/libssh2-ios/bin/${SDKNAME}-${ARCH}.sdk" \
-DPKG_CONFIG_USE_CMAKE_PREFIX_PATH:BOOL=ON \
-DCMAKE_INSTALL_PREFIX:PATH="${INSTALL_PREFIX}/" \
-DBUILD_CLAR:BOOL=OFF \
-DTHREADSAFE:BOOL=ON \
-DCURL:BOOL=OFF \
"${SYS_ROOT}" \
-DCMAKE_OSX_ARCHITECTURES:STRING="${ARCH}" \
.. >> "${LOG}" 2>&1

View File

@ -14,13 +14,19 @@ function xcode_major_version ()
xcode_version | awk -F '.' '{ print $1 }'
}
# Returns the latest iOS SDK version available
# via xcodebuild
# Returns the latest iOS SDK version available via xcodebuild.
function ios_sdk_version ()
{
# This relies on the fact that the latest iPhone SDK
# is the last thing listed before the Xcode version.
/usr/bin/xcodebuild -version -sdk 2> /dev/null | grep SDKVersion | tail -n 1 | awk '{ print $2 }'
# The grep command produces output like the following, singling out the
# SDKVersion of just the iPhone* SDKs:
#
# iPhoneOS9.0.sdk - iOS 9.0 (iphoneos9.0)
# SDKVersion: 9.0
# --
# iPhoneSimulator9.0.sdk - Simulator - iOS 9.0 (iphonesimulator9.0)
# SDKVersion: 9.0
/usr/bin/xcodebuild -version -sdk 2> /dev/null | grep -A 1 '^iPhone' | tail -n 1 | awk '{ print $2 }'
}
# Returns the path to the specified iOS SDK name