Skip to content

Conversation

@congt
Copy link
Contributor

@congt congt commented Oct 25, 2022

…ot lower than those of its deps

Swiftc has already enforced it at compile time, while objective-c doesn't. Adding this validation to ensure it apply to objective-c frameworks, too.

@congt congt force-pushed the cshi/validate-deps-min-os-version branch from ee35669 to 8e93a47 Compare October 26, 2022 00:07
Copy link
Collaborator

@justinseanmartin justinseanmartin left a comment

Choose a reason for hiding this comment

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

Is there a reasonable way to unit test this functionality?

Also, would it be worth perf testing this, or is it not substantial compared to the amount of time compiling? You might be able to leverage the work Dimitris did on Uber Poet to have a substantially sized demo repo.

current_apple_platform = transition_support.current_apple_platform(apple_fragment = ctx.fragments.apple, xcode_config = ctx.attr._xcode_config)

# Validates that the minimum_os_version is not lower than those of the deps.
_validate_deps_minimum_os_version(ctx.attr.framework_name, current_apple_platform.target_os_version, deps + transitive_deps)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it should be able to operate only on its direct dependencies, shouldn't it? If something transitive is lower, I'd think it would get flagged by the thing that depends on it directly. I'm just thinking that this might save some traversal time, but I don't know if it is substantial enough to have a notable impact.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed; since this will check at each level, there's no need to traverse further than one level down at each step.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually an apple_framework_packaging target doesn't directly depends on other apple_framework_packaging targets if one uses the macro apple_framework see https://github.com/bazel-ios/rules_ios/blob/master/rules/framework.bzl#L74-L117:

def apple_framework(name, apple_library = apple_library, **kwargs):
    ...
    framework_deps = []
    ...
    framework_deps.append(force_load_name)

    framework_deps += library.lib_names
    
    apple_framework_packaging(
        name = name,
        ...
        deps = framework_deps,
        ...
    )

Copy link
Contributor

Choose a reason for hiding this comment

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

oh, gross, but since the transitive deps are already being used in a bunch of places, I wouldn't think this would add additional impact then.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah. If you look at the implementation, transitive_deps is NOT all transitive deps of the apple_framework_packaging target. It actually only includes all intermediate libraries and the corresponding apple_framework's deps.

@gyfelton
Copy link
Contributor

should we include other reviewers to make sure they are aware of the change? This one can potentially break other ppl's build

current_apple_platform = transition_support.current_apple_platform(apple_fragment = ctx.fragments.apple, xcode_config = ctx.attr._xcode_config)

# Validates that the minimum_os_version is not lower than those of the deps.
_validate_deps_minimum_os_version(ctx.attr.framework_name, current_apple_platform.target_os_version, deps + transitive_deps)
Copy link
Contributor

Choose a reason for hiding this comment

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

oh, gross, but since the transitive deps are already being used in a bunch of places, I wouldn't think this would add additional impact then.

@congt
Copy link
Contributor Author

congt commented Oct 26, 2022

Is there a reasonable way to unit test this functionality?

Also, would it be worth perf testing this, or is it not substantial compared to the amount of time compiling? You might be able to leverage the work Dimitris did on Uber Poet to have a substantially sized demo repo.

We've already had positive test cases, but I'm not sure how to add negative test cases. Others also ask about this in this issue: bazelbuild/bazel#2751

Performance should not be an issue at all. Everything is in memory. We also iterate deps and transitive_deps multiple times in apple_framework_packaging. Also note that apple_framework_packaging's transitive_deps is its transitive deps. It only includes the various intermediate libraries and the corresponding apple_framework's deps.

Copy link
Contributor

@jerrymarino jerrymarino left a comment

Choose a reason for hiding this comment

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

This looks good overall, my only suggestion is to add an opt-out if people request it. Theoretically we can do that as a followup if anyone complains as this seems reasonable to uphold

@congt congt force-pushed the cshi/validate-deps-min-os-version branch from 8e93a47 to 6cf4b86 Compare January 24, 2023 22:06
…ot lower than those of its deps

Swiftc has already enforced it at compile time, while objective-c doesn't. Adding this validation to ensure it apply to objective-c frameworks, too.
@congt congt force-pushed the cshi/validate-deps-min-os-version branch from 6cf4b86 to c5b4c2b Compare January 24, 2023 22:08
@congt congt merged commit bd0de81 into master Jan 24, 2023
@congt congt deleted the cshi/validate-deps-min-os-version branch January 24, 2023 23:28
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.

7 participants