Skip to content

Change TargetGroup enum param to packageAccess bool in target declaration #6463

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

Merged
merged 2 commits into from
Apr 22, 2023

Conversation

elsh
Copy link
Contributor

@elsh elsh commented Apr 21, 2023

Change TargetGroup enum param to packageAccess bool in target declaration
Resolves rdar://108361064

@elsh
Copy link
Contributor Author

elsh commented Apr 21, 2023

@swift-ci smoke test

@elsh elsh requested a review from rjmccall April 21, 2023 09:35
Copy link
Contributor

@MaxDesiatov MaxDesiatov left a comment

Choose a reason for hiding this comment

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

LGTM

@elsh
Copy link
Contributor Author

elsh commented Apr 21, 2023

@swift-ci smoke test

@elsh
Copy link
Contributor Author

elsh commented Apr 21, 2023

@swift-ci smoke test windows

@elsh elsh merged commit 38a7d0e into main Apr 22, 2023
@elsh elsh deleted the es-bool branch April 22, 2023 08:29
@@ -253,6 +242,7 @@ public final class Target {
resources: [Resource]? = nil,
publicHeadersPath: String?,
type: TargetType,
packageAccess: Bool = false,
Copy link
Contributor

Choose a reason for hiding this comment

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

defaulting to false is surprising. most other arguments do not have a default value that impact's behavior so imo this should either not have a default

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The resources param above for example has a default value. This removes the need to set the value to false explicitly in Target initialization from static funcs in the earlier versions that do not have this param.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would prefer this does not have a default as it is driving behavior - just like TargetGroup did not have a default before

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that's reasonable; will make the change

dependencies: [Dependency] = [],
path: String? = nil,
exclude: [String] = [],
sources: [String]? = nil,
resources: [Resource]? = nil,
publicHeadersPath: String? = nil,
packageAccess: Bool = true,
Copy link
Contributor

Choose a reason for hiding this comment

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

what does "true" means in this case? that it exposes it symbols to other modules? or that it "can see" other module symbols?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's both. If another target also has this param set to true, this target exposes its package symbols to that target and also can see package symbols from that target, depending on which target imports which.

Copy link
Contributor

Choose a reason for hiding this comment

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

so do both modules (definition and consumer) need to be set to "true" for this feature to work?

Copy link
Contributor Author

@elsh elsh Apr 24, 2023

Choose a reason for hiding this comment

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

Yes. In the example below, A cannot access package symbols from B, but B can access package symbols from C. If A imports C, A still cannot access package symbols from C. If C had packageAccess = false, neither A nor B can access package symbols from C.

target A w/ packageAccess = false:
import B

target B w/ packageAccess = true:
import C

target C w/ packageAccess = true:

Copy link
Contributor

Choose a reason for hiding this comment

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

Most target types have a default of true, right? So I would think of it the other way around, you set this to false in order to opt-out.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is set to true by default in the public static func that introduces this param. The Target initializer itself here has the param set to false because it's called by earlier versions of static funcs that should not have access to package symbols.

@elsh
Copy link
Contributor Author

elsh commented Apr 24, 2023

#6473 removes default param value

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.

4 participants