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

[README] Encourage using the Swift build script #77

Merged
merged 1 commit into from Apr 12, 2016

Conversation

modocache
Copy link
Collaborator

New contributors to swift-corelibs-xctest are having some difficulty knowing where to start:

The problem is that over time this project has begun to take on more dependencies:

  • To build the project, one must use a modern Swift 3 compiler (often one more recent than the latest https://swift.org snapshot).
  • To build the project, one must have swift-corelibs-foundation checked out at a particular path.
  • To run the test suite, one must have the LLVM lit test runner installed at a particular path.

In addition, the build steps differ based on whether the contributor is using an OS X or Linux development environment.

This commit revamps the README and the Linux build_script.py to require fewer steps for new contributors to get started. Specifically, it encourages contributors to use the Swift utils/build-script. There are many reasons to do so:

  • The XCTest CI uses that script, so contributors will need to make sure it passes to get their contributions merged.
  • That script ensures that the correct build of swiftc and swift-corelibs-foundation are used.
  • That script works across all platforms, and is invoked in the same way on each platform.

In addition, more detailed information on the project has been moved to a Documentation directory. This resembles other projects in the Swift family of repositories.


This should probably be merged after apple/swift#1748. That pull request puts the final touches on building XCTest via the Swift build script on OS X.

@shahmishal
Copy link
Member

@swift-ci Please test

@shahmishal
Copy link
Member

@swift-ci Please test

@shahmishal
Copy link
Member

@modocache Looks like we have a new failure, so the changes you made might have helped resolve swiftc issues.

/Users/buildnode/jenkins/workspace/swift-corelibs-xctest-PR-osx/swift-corelibs-foundation/Foundation/NSXMLParser.swift:31:11: error: use of undeclared type '_CFXMLInterface'
extension _CFXMLInterface {
          ^~~~~~~~~~~~~~~
/Users/buildnode/jenkins/workspace/swift-corelibs-xctest-PR-osx/swift-corelibs-foundation/Foundation/NSXMLNode.swift:774:24: error: use of undeclared type '_CFXMLNodePtr'
    internal init(ptr: _CFXMLNodePtr) {

@modocache
Copy link
Collaborator Author

Yeah, I took a look at that this morning but can't tell what's wrong. The same build failure doesn't reproduce for me locally, either...

@parkera, any ideas? I could probably figure this out eventually, but help would be greatly appreciated!

@parkera
Copy link
Member

parkera commented Mar 23, 2016

Hm, I'm not sure. @shahmishal is the Foundation build passing without this change?

@modocache
Copy link
Collaborator Author

@parkera Just to be clear, this pull request doesn't really change anything besides documentation. The XCTest CI job for OS X has been failing since its introduction. 😅 I've been submitting pull requests to apple/swift to attempt to fix it, then running tests on this pull request to check whether it's been fixed.

I believe Foundation is built and tested via its own mechanism--it doesn't use xcodebuild like the XCTest CI job does. Maybe XCTest should do the same...?

@parkera
Copy link
Member

parkera commented Mar 23, 2016

Yah I think we should probably merge this; the failure seems unrelated.

@modocache
Copy link
Collaborator Author

@parkera It's true that the failure is unrelated to this change. But the documentation changes in this pull request are to encourage people to use utils/build-script --preset buildbot_incremental,tools=RA,stdlib=RA,XCTest to build the project locally. I don't want to encourage that unless the CI works with that preset. Since it's currently failing, I don't want to merge this yet.

Instead, I'd like to get to the bottom of the failure first. Once we have a single command all contributors can use to build and test the project, I'll update this pull request to recommend using that.

@modocache
Copy link
Collaborator Author

@briancroom @mike-ferris-apple The changes to the Swift build script have landed, and this can now be merged. I think these README instructions are much simpler for newcomers--what do you think?

build_parser.set_defaults(func=_build)
build_parser.add_argument(
"--swiftc",
help="Path to the 'swiftc' compiler that will be used to build "
"XCTest.so, XCTest.swiftmodule, and XCTest.swiftdoc. This will "
"also be used to build the tests for those built products if the "
"--test option is specified.",
metavar="PATH",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious why you chose to remove the metavar values here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't think they added any value, and I figured I'd just include them in this pull request.

This is the help text diff:

diff --git a/build_script_help_text.txt b/build_script_help_text.txt
index 194df0d..e28cd3b 100755
--- a/build_script_help_text.txt
+++ b/build_script_help_text.txt

$ build_script.py build -h
# ...
optional arguments:
  -h, --help            show this help message and exit
-  --swiftc PATH       Path to the 'swiftc' compiler that will be used to
+  --swiftc SWIFTC     Path to the 'swiftc' compiler that will be used to
                        build XCTest.so, XCTest.swiftmodule, and
                        XCTest.swiftdoc. This will also be used to build the
                        tests for those built products if the --test option is
                        specified.
-  --build-dir PATH
+  --build-dir BUILD_DIR
                        Path to the output build directory. If not specified,
                        a temporary directory is used
-  --foundation-build-dir PATH
+  --foundation-build-dir FOUNDATION_BUILD_DIR
                        Path to swift-corelibs-foundation build products,
                        which the built XCTest.so will be linked against.
-  --swift-build-dir PATH
+  --swift-build-dir SWIFT_BUILD_DIR
                        deprecated, do not use
  --arch ARCH           deprecated, do not use
-  --module-install-path PATH
+  --module-install-path MODULE_PATH
                        Location at which to install XCTest.swiftmodule and
                        XCTest.swiftdoc. This directory will be created if it
                        doesn't already exist.
-  --library-install-path PATH
+  --library-install-path LIB_PATH
                        Location at which to install XCTest.so. This directory
                        will be created if it doesn't already exist.
  --release             builds for release
  --debug               builds for debug (the default)
  --test                Whether to run tests after building. Note that you
                        must have cloned https://github.com/apple/swift-llvm
                        at /Users/bgesiak/GitHub/apple/llvm in order to run
                        this command.

Personally I think it's less code without them, and removing them provides clearer help text. What do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation! Looks great.

I'm pretty sure I'd trust your judgement over mine on things Python 😆 Always looking to learn.

New contributors to swift-corelibs-xctest are having some difficulty
knowing where to start:

- https://bugs.swift.org/browse/SR-981
- https://bugs.swift.org/browse/SR-907
- https://bugs.swift.org/browse/SR-906

The problem is that over time this project has begun to take on more
dependencies:

- To build the project, one must use a modern Swift 3 compiler (often
  one more recent than the latest https://swift.org snapshot).
- To build the project, one must have swift-corelibs-foundation checked
  out at a particular path.
- To run the test suite, one must have the LLVM `lit` test runner
  installed at a particular path.

In addition, the build steps differ based on whether the contributor is
using an OS X or Linux development environment.

This commit revamps the README and the Linux `build_script.py` to
require fewer steps for new contributors to get started. Specifically,
it encourages contributors to use the Swift `utils/build-script`. There
are many reasons to do so:

- The XCTest CI uses that script, so contributors will need to make
  sure it passes to get their contributions merged.
- That script ensures that the correct build of `swiftc` and
  swift-corelibs-foundation are used.
- That script works across all platforms, and is invoked in the same
  way on each platform.

In addition, more detailed information on the project has been moved to
a Documentation directory. This resembles other projects in the Swift
family of repositories.
@briancroom
Copy link
Collaborator

Hey @modocache, overall, I think this is a good direction for the project as we attempt to lower the barrier to entry for contributors. The writeup itself in the README is very well done 💯

The only thing that makes me hesitate is that I've personally had some rather unpleasant experiences with running the build script on my dev machine, ranging from "whelp, better find something to do for the next 2 hours" to "wait why is clang failing to build. Hmm maybe if I symlink these headers here... 😕" etc. Having said that, I realize that these issues are probably mostly tied to some quirk on my particular system, and I know that the script has a fully-supported incremental build mode which, especially in conjunction with the new build preset that you got merged (yay!), should make it reasonable to use for development.

Assuming that other folks are seeing successful builds by following these instructions, I would consider this good to merge!

(I'm hoping to get a chance to wipe my Swift dev environment sometime soon and start afresh which should theoretically straighten out my issues, and also help me understand the experience of new contributors.)

@modocache
Copy link
Collaborator Author

Hmm maybe if I symlink these headers here...

Yeah, that does sound strange... I think one benefit here is that there's a wider body of people running the Swift build script. I consider that important; personally I had a lot of trouble building LLVM from source a few years ago, but kept at it because I knew it couldn't possibly be broken for everyone--"it must be a problem on my end", I thought, and I tried to figure out what was wrong. I also consider the Swift build script much more user-friendly. So all-in-all, I don't think building Swift is an unreasonable prerequisite.

I think if we can get a passing OS X and Linux CI build on this pull request, we should go ahead and merge it. The script works for me locally. @mike-ferris-apple?

@mike-ferris
Copy link

@swift-ci please test

@briancroom
Copy link
Collaborator

Looks like more strange Foundation build issues on the OS X CI box:

=== BUILD TARGET SwiftFoundation OF PROJECT Foundation WITH CONFIGURATION Debug ===

Check dependencies
warning: using 'ALWAYS_SEARCH_USER_PATHS = YES' while building targets which define modules ('DEFINES_MODULE = YES') may fail. Please migrate to using 'ALWAYS_SEARCH_USER_PATHS = NO'.
warning: using 'ALWAYS_SEARCH_USER_PATHS = YES' while building targets which define modules ('DEFINES_MODULE = YES') may fail. Please migrate to using 'ALWAYS_SEARCH_USER_PATHS = NO'.
warning: no umbrella header found for target 'SwiftFoundation', module map will not be generated

2016-04-10 08:42:29.294 xcodebuild[22177:33024]  DVTAssertions: Warning in /Library/Caches/com.apple.xbs/Sources/DVTFrameworks/DVTFrameworks-10174/DVTFoundation/Utilities/DVTFileSystemUtilities.mm:142
Details:  lstat('/Users/buildnode/Library/Developer/Xcode/DerivedData/XCTest-dvkzigzfgybeztatzsyerimgjubd/Build/Products/Debug/SwiftFoundation.framework/Versions/A/Modules') failed with errno 2 (No such file or directory)
Function: DVTRecursiveMkdirResult dvt_recursiveMkdir_returningErrorString(NSString *__strong, NSString *__autoreleasing *)
Thread:   <NSThread: 0x7fbfcb41b820>{number = 5, name = (null)}
Please file a bug at http://bugreport.apple.com with this warning message and any useful information you can provide.
Create product structure
/bin/mkdir -p /Users/buildnode/Library/Developer/Xcode/DerivedData/XCTest-dvkzigzfgybeztatzsyerimgjubd/Build/Products/Debug/SwiftFoundation.framework/Versions/A/Modules
/bin/mkdir -p /Users/buildnode/Library/Developer/Xcode/DerivedData/XCTest-dvkzigzfgybeztatzsyerimgjubd/Build/Products/Debug/SwiftFoundation.framework
error: File is a broken symbolic link: /Users/buildnode/Library/Developer/Xcode/DerivedData/XCTest-dvkzigzfgybeztatzsyerimgjubd/Build/Products/Debug/SwiftFoundation.framework

** BUILD FAILED **


The following build commands failed:

@parkera @phausler have you seen this sort of thing before?

@phausler
Copy link
Member

Looks like the failure is a build config race condition. It is expecting a product directory to exist but it has not been created yet (and the command is not recursive) I have not seen this specific failure before but I have seen similar ones in other projects.

@briancroom
Copy link
Collaborator

Now that apple/swift#2137 is in, could someone fire off CI again on this and apple/swift#2137? I have high hopes of clean builds at last! @mike-ferris-apple @shahmishal

@parkera
Copy link
Member

parkera commented Apr 11, 2016

@swift-ci please test

@briancroom
Copy link
Collaborator

Bingo! I think we've achieved our goal. Thanks for pushing us onwards @modocache.

Despite recent discussion about a minor strategy change and bringing Darwin into the build script after all, this PR is still unquestionably a step forward.

@briancroom briancroom merged commit ab3a2d9 into apple:master Apr 12, 2016
@modocache modocache deleted the readme-getting-started branch April 12, 2016 01:40
@modocache
Copy link
Collaborator Author

I... I can't believe the day has finally come that we have a passing OS X and Linux CI!! Thanks, @briancroom! Couldn't have done it without apple/swift#2137!

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.

None yet

6 participants