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

Reorder swiftc args to allow user override #715

Merged
merged 2 commits into from
Oct 9, 2016
Merged

Reorder swiftc args to allow user override #715

merged 2 commits into from
Oct 9, 2016

Conversation

keith
Copy link
Member

@keith keith commented Sep 30, 2016

Currently the build target arguments are hard coded in the swiftpm
source. Until they are broken out into some configuration method, it
would be useful for users to be able to override these arguments for
their use case. This change reorders the passed arguments to pass along
the users arguments after the default arguments.

See this thread for more info: https://lists.swift.org/pipermail/swift-build-dev//Week-of-Mon-20160919/000637.html

@ddunbar
Copy link
Contributor

ddunbar commented Sep 30, 2016

LGTM, can we get a functional test that this solves the problem (on macOS only, probably)?

@abertelrud
Copy link
Contributor

Looks good as a short term workaround. Thanks!

@aciidgh
Copy link
Contributor

aciidgh commented Oct 1, 2016

should this be done for C targets too?

@keith
Copy link
Member Author

keith commented Oct 2, 2016

Probably. I can add that to this PR if you'd like.

@aciidgh
Copy link
Contributor

aciidgh commented Oct 2, 2016

Thanks!

@abertelrud
Copy link
Contributor

Did you want to add the C target diff to this PR too, or is there any use in merging it separately? If so, we should have a JIRA covering the C case.

@keith
Copy link
Member Author

keith commented Oct 8, 2016

I've added the C target change here. But haven't dove in to how to add tests for this yet. I'll try and tackle that shortly.

@aciidgh
Copy link
Contributor

aciidgh commented Oct 8, 2016

Great! what you can do for tests is, create a fixture that would only build if this patch is present and drop it in Fixtures/ directory, then add a functional test somewhere in Tests/FunctionalTests/ (probably MiscellaneousTests.swift).
Then there are helpers to load the fixture and execute swift build

  1. XCTAssertBuilds(prefix)
  2. executeSwiftBuild(prefix, configuration: .Debug, printIfError: true, Xcc: [], Xld: [], Xswiftc: [], env: [:]) <-- this should fit here
  3. SwiftPMProduct.SwiftBuild.execute([""], chdir: prefix) <-- most raw form

Let me know if you need any help figuring stuff out!

@keith
Copy link
Member Author

keith commented Oct 8, 2016

I added a small test (which feels pretty brittle). Feedback appreciated!

@aciidgh
Copy link
Contributor

aciidgh commented Oct 8, 2016

LGTM, I don't know if there is a better to way to test this (right now)

Currently the build target arguments are hard coded in the swiftpm
source. Until they are broken out into some configuration method, it
would be useful for users to be able to override these arguments for
their use case. This change reorders the passed arguments to pass along
the users arguments after the default arguments.
This tests our ability to pass a custom minimum deployment target as a
swiftc argument in order to deploy to a higher version than what is
currently checked in as the minimum in the swiftpm source.
@keith
Copy link
Member Author

keith commented Oct 8, 2016

Updated the test to use a custom function with a higher deployment target instead of something from foundation. I think this should be less brittle.

@ddunbar
Copy link
Contributor

ddunbar commented Oct 8, 2016

Thanks for the test, new version looks very reasonable to me.

LGTM!

@ddunbar
Copy link
Contributor

ddunbar commented Oct 8, 2016

@swift-ci please test

/// This file exists to test the ability to override deployment targets via args passed to swiftc
/// For this test to work, this file must have an API call which was introduced in a version
/// higher than the default macOS deployment target that is checked in.
@available(macOS 10.20, *)
Copy link
Contributor

Choose a reason for hiding this comment

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

Cool, I was wondering if available API could be used

@aciidgh
Copy link
Contributor

aciidgh commented Oct 8, 2016

@swift-ci please test

@ddunbar ddunbar merged commit c36d675 into swiftlang:master Oct 9, 2016
@keith keith deleted the ks/argument-order branch October 9, 2016 21:48
@keith
Copy link
Member Author

keith commented Oct 9, 2016

Thanks!

@keith
Copy link
Member Author

keith commented Oct 9, 2016

This fixes https://bugs.swift.org/browse/SR-2535

@abertelrud
Copy link
Contributor

Looks good to me as well. Thanks!

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

4 participants