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

could you help to support bazel? #18

Open
sammi opened this issue Jan 5, 2022 · 7 comments
Open

could you help to support bazel? #18

sammi opened this issue Jan 5, 2022 · 7 comments
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@sammi
Copy link

sammi commented Jan 5, 2022

Could you support bazel , so someone using bazel for their cpp project could import it in his WORKSPACE like:

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "libstst",
urls = ["https://github.com/ccpfw/tst/archive/{sha256_hash_value}.zip"],
)

@igagis igagis self-assigned this Jan 5, 2022
@igagis
Copy link
Member

igagis commented Jan 8, 2022

@sammi I have never used bazel before and my understanding is that it is some kind of another build system. Do I understand right that it provides ability to install packages of libraries from some bazel-repo and dependency management? That means packaging for bazel and deployment to that repo. So, I would need my own bazel repo?

Could you give any insights of what is needed to be done to support bazel?

Note, that tst has a number of dependencies which are also my own libraries, so those dependencies will have to be bazel-packed as well. But if bazel allows automatic dependency management (i.e. installing needed dependencies along with the requested library) then it should not be a big problem.

@sammi
Copy link
Author

sammi commented Jan 8, 2022

@igagis, yes, bazel is a build system, each repo needs a WORKSPACE, your internal lib is a PACKAGE, which just need a bazel BUILD file to define it. Bazel will take care of the dependencies. I guess have a look its website could be helpful as well.

https://bazel.build/

Another sample you could check out is google test lib, which is using bazel as its official build tool.
https://github.com/google/googletest

@igagis
Copy link
Member

igagis commented Jan 8, 2022

The main build system for all my libs is https://github.com/cppfw/prorab and I want to leave it so as it serves pretty well for my needs.

But, I'm thinking of adding "side build systems" support to my libs, because I've also been requested to support for example CMake earlier.
So, I think of creating a separate directory in project tree, say build directory where I'd put all the side build systems related files. This is to isolate all the build system-related files from other files in the project tree. Is it possible to make it so for bazel? Or does it require the WORKSPACE and BUILD files to reside in the source tree?

Also, I don't have time at the moment to implement and support those "side build systems" support, and likely will not ever have time for that, so if you could take the responsibility for bazel part of that you are very welcome. I can assist with advice and do PRs review as best as I can.
So, basically, PRs are welcome for this request.

@igagis igagis added enhancement New feature or request help wanted Extra attention is needed labels Jan 8, 2022
@sammi
Copy link
Author

sammi commented Jan 8, 2022

@igagis, for bazel project, adding WORKSPACE and BUILD in the source tree would be its convention. Although add side folder would work, but it is not the natural way.

I'd like help to support the bazel for you project. I hope I could get a PR ready soon.

Oh wait, it seems that there are quite a few dependent libs are being managed by prorab, I guess choose bazel to build the lib would not be a trivial project, I may not be able to do it soon.

@igagis
Copy link
Member

igagis commented Jan 8, 2022

@sammi yes, as I mentioned, there are a number of dependencies.

Yes, I understand, that having those WORKSPACE and BUILD in source tree is natural for bazel, but the names of those files are too generic, there can easily be name collision with other possible build systems. As I said, my project may support several build systems in the future, this is the main reason the files need to be isolated in separate directories. For bazel it should be build/bazel.

And this is what I asked you before, how does bazel manage dependencies? In your example code snippet there is only URL to sources snapshot urls = ["https://github.com/ccpfw/tst/archive/{sha256_hash_value}.zip"],. So, what if the snapshot also depends on other libs I suppose bazel will not download any dependency source snapshots. I assume there is no any plase in bazel files where dependencies could be listed even. Or am I wrong?
This is quite normal that build system doesn't manage dependencies, as it is not its purpose. Dependencies should normally be managed via packaging, e.g. deb, rpm, homebrew, pacman, conan, nuget etc.

So, generally speaking, "managing" dependencies by just downloading source code snapshots is not practical because of the multiple levels of dependencies.

@sammi
Copy link
Author

sammi commented Jan 8, 2022

@igagis, you just hit the weakness for bazel external dependencies management. It is quite bad to manage transitive deps at this moment, actually, bazel are introducing brand new external management mechanism by "bzlmod".

https://docs.bazel.build/versions/main/bzlmod.html

The idea is to use bazel_dep to manage dependencies, each module only care its own direct deps.

@igagis
Copy link
Member

igagis commented Jan 8, 2022

@sammi looks good! So, when the feature is more stable then the libs can be adapted to bazel :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants