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

hide_prod_dependencies / hide_other_dependencies / etc #42

Open
chrisballinger opened this issue Nov 30, 2020 · 2 comments
Open

hide_prod_dependencies / hide_other_dependencies / etc #42

chrisballinger opened this issue Nov 30, 2020 · 2 comments

Comments

@chrisballinger
Copy link

I think I encountered a scenario where it would be useful to have an additional flag beyond // dev for other dependencies, Possibly prod would be a good start, but maybe it could be more flexible and support like hide_${whatever}_dependencies for anything tagged // whatever. I have been prototyping a Swift Package for OpenCV, which uses a binary xcframework dependency. Normally it will point to a remote URL for a tagged release, but if you want to run swift test against local changes, you'd need to comment out the binaryTarget url/checksum and use a local path version instead.

        // Recompute checksum via `swift package --package-path /path/to/opencv compute-checksum /path/to/opencv2.xcframework.zip`
//        .binaryTarget(
//            name: "opencv2",
//            url: "https://github.com/Rightpoint/opencv/releases/download/4.5.1/opencv2-4.5.1-dynamic.xcframework.zip",
//            checksum: "48273710fe03eb6d6a77ca57f96ef7917db395e6c3bc62e2b495df3dc8f1a0a9"
//        ),
        // If you are compiling OpenCV locally, you can uncomment the below block to use a custom copy
        // e.g. `$ python platforms/apple/build_xcframework.py --dynamic build/dynamic-xcframework`
        .binaryTarget(
            name: "opencv2",
            path: "build/dynamic-xcframework/opencv2.xcframework"
        ),

This seems like the perfect candidate for that scenario.

Does this sound like a feature you'd consider merging? And, if so, could someone point me in the right direction for hacking on this? Thanks!

@f-meloni
Copy link
Member

f-meloni commented Nov 30, 2020

Hi @chrisballinger
This is something I'm happy to take PRs for.
The only think I would like it to keep it retro compatible with the current code.

So I would deprecate the current logic without branch name and would make two new ones https://github.com/shibapm/Rocket/blob/master/Sources/RocketLib/Step.swift#L1-L10 (because they contain dev in the name)

(I would rename hideDependencies and unhideDependencies to hideDevDependencies and unhideDevDependencies, this should not make any breaking change)

Now that you have your two new steps you can have an Executor for them.

https://github.com/shibapm/Rocket/blob/master/Sources/RocketLib/Step.swift#L16-L36

Executors can also have parameters (then you can have one step that has as parameter the string that you have on the comment, and the default value is dev)

https://github.com/shibapm/Rocket/blob/master/Sources/RocketLib/Executors/HideDevDependenciesExecutor.swift#L3 the parameters are defined using the Generic value in the class.

Parameters needs to implement StepParameters protocol, that requires an init with dictionary https://github.com/shibapm/Rocket/blob/master/Sources/RocketLib/Parameters/ModifyDevDependenciesParameters.swift

The current dev dependencies executors (https://github.com/shibapm/Rocket/blob/master/Sources/RocketLib/Executors/HideDevDependenciesExecutor.swift https://github.com/shibapm/Rocket/blob/master/Sources/RocketLib/Executors/UnhideDevDependenciesExecutor.swift) use

https://github.com/shibapm/Rocket/blob/master/Sources/RocketLib/Executors/Utils/DevDependenciesModifier.swift

That has all the logic you need, if you parametrise https://github.com/shibapm/Rocket/blob/master/Sources/RocketLib/Executors/Utils/DevDependenciesModifier.swift#L53 it should work.

Please let me know if you need any more help :)

@chrisballinger
Copy link
Author

Awesome, thanks so much for the walkthrough!

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

No branches or pull requests

2 participants