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

Add and update git_repository and http_archive rules #182

Open
jayconrod opened this issue Apr 16, 2018 · 6 comments
Open

Add and update git_repository and http_archive rules #182

jayconrod opened this issue Apr 16, 2018 · 6 comments

Comments

@jayconrod
Copy link
Contributor

Gazelle should be able to add and update git_repository and http_archive rules (the overlay rules provided by Gazelle, not the native rules of the same name) in WORKSPACE using a command like the one below:

gazelle update-repos -kind=git_repository example.com/repo

This will generate build files and write them to third_party/com_example_repo. The build files can be hand-edited and checked in.

The build files can be fixed and updated by running the same command again (perhaps without needing the -kind flag).

@negz
Copy link

negz commented May 31, 2018

This would have helped me today. I set out to add https://github.com/golang/dep to my workspace via a go_repository rule. Unfortunately one of dep's testdata/ directories contains a recursive symlink cycle (golang/dep#1412). Normally I'd use a # gazelle:exclude comment to work around this, but no such option exists for go_repository (bazel-contrib/rules_go#882).

Having failed to use a go_repository I attempted to use an http_archive with an overlay, but descended into Lovecraftian madness while attempting to use a mix of gazelle and hand-hacking to generate all the BUILD files required by dep. In the end I gave up and simply checked all of dep into //third_party and let Gazelle generate BUILD files for me.

@jayconrod
Copy link
Contributor Author

Sorry for the bad experience. I'm currently working on a major refactoring right now which will allow Gazelle to support multiple languages. I hope to get back to feature requests like this soon after.

@negz
Copy link

negz commented May 31, 2018

@jayconrod No need to apologise. :)

I think I'd misunderstood how straightforward what I wanted to do would be anyhow. I was under the impression I'd be able to happily bazel run //third_party/go/github.com/golang/dep/cmd/dep on the contents of my bazel-managed repo similar to how bazel run //:gazelle works (kind of like bazelbuild/buildtools#316). I see now that gazelle has a lot of magic in its wrapper shell script to make that work.

@Fleker
Copy link

Fleker commented Sep 2, 2020

I am currently facing the same issue as noted in #178, where I want to be able to easily export LICENSE files in various repositories but I run into the error

no such target '@com_github_spf13_cobra//:LICENSE.txt': target 'LICENSE.txt' not declared in package ''; however, a source file of this name exists.  (Perhaps add 'exports_files(["LICENSE.txt"])' to /BUILD?) defined by /usr/local/google/home/fleker/.cache/bazel/_bazel_fleker/be884af2cdb0395c1e568ec4bb82fdd6/external/com_github_spf13_cobra/BUILD.bazel and referenced by '//cmd/notices:licenses_go'

As the repository, https://github.com/spf13/cobra, is using standard Golang tools and not Bazel, I am using Gazelle to import it. I don't see a mechanism to actually add an exports_files line to the virtually created BUILD file for the dependency.

If there was a setting to do this automatically, it would go a long way. As for now, I'm somewhat stymied by this barrier and not sure how to implement the license notices short of copying files around.

@pjjw
Copy link

pjjw commented Jun 5, 2023

@Fleker did you ever figure a workaround for this issue?

@Fleker
Copy link

Fleker commented Jun 8, 2023

It looks like I just copied every open-source license into a YAML file and print that out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants