facebookarchive / xcbuild

Xcode-compatible build tool.
Other
2k stars 190 forks source link

sdkroot does not follow symlinks, so the build fails, but reports as succeeded #80

Open JonHodgson opened 8 years ago

JonHodgson commented 8 years ago

Because every time you install a new version of XCode these days it wipes all older SDKs, I keep them stored elsewhere on my machine and have a script to setup links inside /Applications/XCode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs

This works fine for XCodeBuild, but when I tried building the same project with XCBuild, I got a stream of

"error: unable to find sdk root"

for each target.

So it doesn't build anything

But at the end, in bright green letters, its says

\ BUILD SUCCEEDED **

So it would seem I'm looking at two bugs, one which results in the build failing, the other which results in that not being reported properly

grp commented 8 years ago

Could you run xcbuild with xcbuild -showsdks and paste the output? The code has no specific checks against symlinks, so should be able to discover those SDKs.

JonHodgson commented 8 years ago

Ok, well it looks like my guess about the symlinks was wrong, if I'm reading this right..

jons-imac:build-OSX jon$ ~/xcbuild/build/xcbuild -showsdks
OS X SDKs:
    Mac OS X 10.1                   -sdk macosx10.1
    OS X 10.10                      -sdk macosx10.10
    OS X 10.11                      -sdk macosx10.11
    Mac OS X 10.2                   -sdk macosx10.2
    Mac OS X 10.3                   -sdk macosx10.3
    Mac OS X 10.3.9                 -sdk macosx10.3.9
    Mac OS X 10.4                   -sdk macosx10.4
    Mac OS X 10.5                   -sdk macosx10.5
    Mac OS X 10.6                   -sdk macosx10.6
    Mac OS X 10.7                   -sdk macosx10.7
    OS X 10.8                       -sdk macosx10.8
    OS X 10.9                       -sdk macosx10.9

iOS SDKs:
    iOS 9.2                         -sdk iphoneos9.2
    iOS 9.2                         -sdk iphoneos9.2

iOS Simulator SDKs:
    Simulator - iOS 9.2             -sdk iphonesimulator9.2
    Simulator - iOS 9.2             -sdk iphonesimulator9.2

tvOS SDKs:
    tvOS 9.1                        -sdk appletvos9.1
    tvOS 9.1                        -sdk appletvos9.1

tvOS Simulator SDKs:
    Simulator - tvOS 9.1            -sdk appletvsimulator9.1
    Simulator - tvOS 9.1            -sdk appletvsimulator9.1

watchOS SDKs:
    watchOS 2.1                     -sdk watchos2.1
    watchOS 2.1                     -sdk watchos2.1

watchOS Simulator SDKs:
    Simulator - watchOS 2.1         -sdk watchsimulator2.1
    Simulator - watchOS 2.1         -sdk watchsimulator2.1

jons-imac:build-OSX jon$ 

However, the output when I try to build the project with xcbuild (the only option I set is -configuration Debug) is

jons-imac:build-OSX jon$ ~/xcbuild/build/xcbuild -configuration Debug
error: registering Compiler specification 'com.apple.xcode.tools.swift.compiler' in domain watchsimulator twice
warning: unhandled Project key buildSettings
warning: unhandled Project key buildStyles
warning: unhandled FileReference key refType
warning: unhandled FileReference key refType
warning: unhandled FileReference key refType
warning: unhandled FileReference key refType
warning: unhandled FileReference key refType
warning: unhandled FileReference key refType
warning: unhandled FileReference key refType
warning: unhandled FileReference key refType
warning: unhandled FileReference key refType
warning: unhandled FileReference key refType
warning: unhandled FileReference key refType
warning: unhandled FileReference key refType
warning: unhandled FileReference key refType
warning: unhandled FileReference key refType
warning: unhandled FileReference key refType
warning: unhandled FileReference key refType
warning: unhandled FileReference key refType
warning: unhandled FileReference key refType
warning: unhandled FileReference key refType
warning: unhandled FileReference key refType
warning: unhandled FileReference key refType
warning: unhandled FileReference key refType
warning: unhandled FileReference key refType
=== BUILD TARGET squirrel OF PROJECT Source WITH CONFIGURATION Debug ===

error: unable to find sdkroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk
error: couldn't create target environment for squirrel

<<Snip - lots of subprojects, all showing the same thing>>

=== BUILD TARGET wpf_unittest OF PROJECT Source WITH CONFIGURATION Debug ===

error: unable to find sdkroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk
error: couldn't create target environment for wpf_unittest
=== BUILD TARGET ALL_BUILD OF PROJECT Source WITH CONFIGURATION Debug ===

error: unable to find sdkroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk
error: couldn't create target environment for ALL_BUILD
** BUILD SUCCEEDED **

replacing XCBuild in the command line with XCodebuild gives a successful build

grp commented 8 years ago

I think the issue here is that with symbolic links, the path stored in the SDK is resolved, but in this case your project appears to specify an SDKROOT with an absolute path pointing to the symlink.

I'm not sure I've seen projects use absolute path SDKROOTs before — is your project generated by CMake? That might also explain the warnings about the (ancient) buildStyles and refType keys.

Regardless, it should be possible to make this work by resolving SDKROOT as a path if it doesn't match as an SDK name.

JonHodgson commented 8 years ago

Yes, tne project is generated by CMake.

I'm afraid you'll have to clarify that last line for me a little.

grp commented 8 years ago

That was mostly a note to myself of how this might be fixed — resolving any symlinks in the SDKROOT before looking up the SDK.

grp commented 8 years ago

For now, you can set SDKROOT manually to get past this:

xcbuild -project <project> -sdk macosx