Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix fallback to iphonesimulator in script/cibuild #552

Merged
merged 1 commit into from
Feb 17, 2016

Conversation

tombooth
Copy link
Contributor

In #484 more flags were
added into the variable sdkflag, which then caused the following
execution of run_xctool to always fail. This means that iOS tests have
not been running as part of the TravisCI run, they have only been built.
You can see this if you look at the final run for the PR:
https://travis-ci.org/libgit2/objective-git/builds/78334551#L192

Bash does some great things when trying to interpret variables in
commands. Initially the $sdkflag didn't have any quotes around it as
can be seen in commit 15f906c. When the
second flag was added this would have caused the command to fail because
of the way Bash would interpret the whitespace. Without the surrounding
quotes the command would have been executed as follows:

xctool -workspace ObjectiveGitFramework.xcworkspace RUN_CLANG_STATIC_ANALYZER=NO -sdk iphonesimulator -destination '"platform=iOS' Simulator,name=iPhone '5"' -scheme "ObjectiveGit iOS" test ONLY_ACTIVE_ARCH=NO CODE_SIGN_IDENTITY= CODE_SIGNING_REQUIRED=NO

You can see in the above that the white space was split in the middle of
the -destination parameter and it causes xctool to spout out an
error. When the surrounding quotes were added it caused xctool to run
but $sdkflag would be interpretted as a single argument, as it is
executed as follows:

xctool -workspace ObjectiveGitFramework.xcworkspace RUN_CLANG_STATIC_ANALYZER=NO '-sdk iphonesimulator -destination "platform=iOS Simulator,name=iPhone 5"' -scheme "ObjectiveGit iOS" test ONLY_ACTIVE_ARCH=NO CODE_SIGN_IDENTITY= CODE_SIGNING_REQUIRED=NO

Notice in the above that the entire argument is still surrounded by
single quotes.

This can be solved by switching $sdkflag for an array of strings, this
can then be correctly expanded in the command getting around the issues
highlighted above.

You can read more about these issues with Bash in the following links:

In libgit2#484 more flags were
added into the variable `sdkflag`, which then caused the following
execution of run_xctool to always fail. This means that iOS tests have
not been running as part of the TravisCI run, they have only been built.
You can see this if you look at the final run for the PR:
https://travis-ci.org/libgit2/objective-git/builds/78334551#L192

Bash does some great things when trying to interpret variables in
commands. Initially the `$sdkflag` didn't have any quotes around it as
can be seen in commit 15f906c. When the
second flag was added this would have caused the command to fail because
of the way Bash would interpret the whitespace. Without the surrounding
quotes the command would have been executed as follows:

```
xctool -workspace ObjectiveGitFramework.xcworkspace RUN_CLANG_STATIC_ANALYZER=NO
-sdk iphonesimulator -destination '"platform=iOS' Simulator,name=iPhone
'5"' -scheme "ObjectiveGit iOS" test ONLY_ACTIVE_ARCH=NO CODE_SIGN_IDENTITY=
CODE_SIGNING_REQUIRED=NO
```

You can see in the above that the white space was split in the middle of
the `-destination` parameter and it causes `xctool` to spout out an
error. When the surrounding quotes were added it caused xctool to run
but `$sdkflag` would be interpretted as a single argument, as it is
executed as follows:

```
xctool -workspace ObjectiveGitFramework.xcworkspace RUN_CLANG_STATIC_ANALYZER=NO
'-sdk iphonesimulator -destination "platform=iOS Simulator,name=iPhone 5"'
-scheme "ObjectiveGit iOS" test ONLY_ACTIVE_ARCH=NO CODE_SIGN_IDENTITY=
CODE_SIGNING_REQUIRED=NO
```

Notice in the above that the entire argument is still surrounded by
single quotes.

This can be solved by switching `$sdkflag` for an array of strings, this
can then be correctly expanded in the command getting around the issues
highlighted above.

You can read more about these issues with Bash in the following links:

  - http://mywiki.wooledge.org/BashFAQ/050
  - http://mywiki.wooledge.org/BashFAQ/073
@tombooth
Copy link
Contributor Author

Unsure why it isn't building, but you can see the results of a run here: https://travis-ci.org/tombooth/objective-git/builds/109612507

tombooth added a commit to tombooth/SwiftGit2 that referenced this pull request Feb 16, 2016
These scripts were borrowed from the objective-git project and utilized
in the branch that I am taking inspiration from
(SwiftGit2#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:

libgit2/objective-git#552

commit 24b2a886c0b61cf1dca0d55cac900b26616e50b9
Author: Ben Chatelain <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
Date:   Mon Aug 24 15:25:38 2015 -0600

    Quote sdkflag

commit 2712c2a2beb294cd81ae44f733fdc9f17eb1a259
Author: Ben Chatelain <[email protected]>
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 <[email protected]>
Date:   Mon Aug 24 12:31:31 2015 -0600

    /user -> /usr

commit b8efb3224393d12d720cbbbd348c2cb4ec066d6d
Author: Ben Chatelain <[email protected]>
Date:   Mon Aug 24 09:51:51 2015 -0600

    Abort script if Homebrew is not installed

commit e7b8e1aa4bf6aa20de09ff4b112ec688570914d1
Author: Ben Chatelain <[email protected]>
Date:   Mon Aug 24 09:42:17 2015 -0600

    Move check_deps to after update_submodules

commit 27473a0e8e92a47266664271ed4513806937efda
Author: Ben Chatelain <[email protected]>
Date:   Mon Aug 24 09:34:21 2015 -0600

    Wrap long git submodule command chain for readability

commit 7724e36e7ca1666f535c8967c7534e04664d457e
Author: Ben Chatelain <[email protected]>
Date:   Sun Aug 9 09:12:56 2015 -0600

    Update script comments

commit 768f033f0bf95c01793a941311cdbf45a7fb975c
Author: Ben Chatelain <[email protected]>
Date:   Sat Aug 8 22:51:14 2015 -0600

    Fix iPhone SDK version detection in Xcode 7

commit cb0c5c12f9865e1aa270ed523ce0aeaf72c2be21
Author: Ben Chatelain <[email protected]>
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 <[email protected]>
Date:   Wed Jul 22 17:10:45 2015 +0200

    Prebuild OpenSSL in order to workaround Travis timouts

commit 6c66e65c539e3b53db6c5531743dcfecdb116c55
Author: Ben Chatelain <[email protected]>
Date:   Mon Jul 20 21:45:01 2015 -0600

    Stop letting cmake determine which clang to use

commit 2ea1bd02d33ed7fcd0604404dc98693ad89f3815
Author: joshaber <[email protected]>
Date:   Fri Jul 10 12:39:52 2015 -0400

    Include pkg-config in our dependencies.

commit c906271f580d6901a1200fc4795df250aca47cfc
Author: Ben Chatelain <[email protected]>
Date:   Mon Jul 6 20:09:34 2015 -0600

    Disable CURL in libgit2 iOS build

commit 549717d138fd4cd1828c7e67fb810523794f1ecb
Author: Ben Chatelain <[email protected]>
Date:   Mon Jul 6 20:09:16 2015 -0600

    Remove obsolete OPENSSL_ defines from libgit2 iOS build

commit aed2cc39c831697102ac6aff317990729b55dd2c
Author: Ben Chatelain <[email protected]>
Date:   Thu Jun 25 21:16:56 2015 -0600

    Fix LIBSSH2_INCLUDE_DIRS define

commit 5ba578ac115974f0981d49b7c79072e867ef804b
Author: Ben Chatelain <[email protected]>
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 <[email protected]>
Date:   Mon Feb 16 16:25:15 2015 -0700

    Revert "Fix libgit2 (Mac) build"

    This reverts commit fd67e2bc2fc40171b06df88b627a636bdcf102cb.

commit fd67e2bc2fc40171b06df88b627a636bdcf102cb
Author: Ben Chatelain <[email protected]>
Date:   Tue Feb 10 07:39:25 2015 -0700

    Fix libgit2 (Mac) build

commit b817e13e4c29bea355044e316d9214fbc955ac8f
Author: Ben Chatelain <[email protected]>
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 <[email protected]>
Date:   Thu Nov 6 15:10:33 2014 -0800

    Update objc-build-scripts to stop cleaning automatically

commit f8ff8a60bd0ca6dbfa7b170658c0be8f5f589cd6
Author: Alan Rogers <[email protected]>
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 <[email protected]>
Date:   Tue Oct 28 15:51:15 2014 +1100

    Remove set -e because lol.

commit c32fe343651aacf91cbe3cf7d513c612f62b235e
Author: Alan Rogers <[email protected]>
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 <[email protected]>
Date:   Wed Oct 22 11:51:32 2014 -0700

    Update to jspahrsummers/objc-build-scripts@a54782c

commit 2c337c688a2779b51e6d4178cbace23750f3fde7
Author: Justin Spahr-Summers <[email protected]>
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 <[email protected]>
Date:   Mon Nov 11 11:47:33 2013 -0800

    Add cmake as a required tool

commit 5b6cc97a958caedcc4dcbda18d1a193ed58a2ad6
Author: Justin Spahr-Summers <[email protected]>
Date:   Mon Nov 11 11:37:54 2013 -0800

    Update objc-build-scripts
@pietbrauer pietbrauer closed this Feb 17, 2016
@pietbrauer pietbrauer reopened this Feb 17, 2016
@pietbrauer
Copy link
Member

Hah, tricked Travis 💪

@pietbrauer pietbrauer self-assigned this Feb 17, 2016
@pietbrauer
Copy link
Member

Nice catch, looks good to me. All iOS and Mac Tests run through. It will take a bit longer now (40 vs. 24 minutes), but will lead to better coverage of course.

pietbrauer added a commit that referenced this pull request Feb 17, 2016
Fix fallback to iphonesimulator in script/cibuild
@pietbrauer pietbrauer merged commit 6a18a81 into libgit2:master Feb 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants