-
Notifications
You must be signed in to change notification settings - Fork 318
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
Consider making this package go gettable? #143
Comments
AFAICT there is no way to make decisions with Go directives based on what packages are installed. While I we could build a no-dep version of libgit2, it would not have any network support other than raw TCP, but that would require custom installation to have TLS/SSH transports anyway. The larger problem however is that this would require a lot of work just to get to the same state as we have now. Getting a package which go will build directly requires rebuilding the build system we have on the libgit2 side and it does not let us automatically handle optional dependencies. So we'd likely have to go all-or-nothing, or have different capabilities by default depending on what we know about the OS, which is ugly. The flat structure of .c files is going to be a pain, but it's also quite likely to increase the effort needed to update between versions of libigt2. The one sure way to make it go-gettable is to go back to dynamic linking by default, but that has the issues that you then have to make sure the version of libgit2 matches on your system, which is more work. If you'd like to send a PR I can take a look, but I don't think I have the time to work on this myself. |
Thanks for getting back to me. I see, I didn't expect those complications. I will take them into account and keep thinking about this more. |
It is deceptively complex to build libgit2, since Git is primarily a local system, and we do want to provide that without bringing in unnecessary dependencies for network. And there are all sorts of quirks for some OSs. The go tool does have more tricks than I thought though, and it's easier than I thought to provide a way to link to a built |
I think any improvement to the process to get it closer to 100% go gettable would be a huge improvement.
Sorry, I don't quite understand what you mean. Couldn't you just update the Go package to have a new commit with the new prebuilt |
There is no precompiled version of libgit2, partly for the same reasons as it's complex to build it via 'go build'. It needs to link to libraries which are available in the system and 'go build' does not let us discover that. |
So what were you referring to when you said this:
|
I mean that once |
There is of course the possibility of using 'go generate' to run some go command (e.g. the "script" to check for thread-locking) and we could create one which calls 'make' or CMake directly, but generate won't be run automatically, so we'd just be changing one extra command with a different one that's spelt slightly differently. |
Now that libgit2 v0.22 is released, I've made a
to get a version of git2go which will work against the system libraries and thus the go tool will like. |
@carlosmn so, with merge v22 into master now static linking is eliminated... which is very unfortunately. |
@carlosmn any suggestions to workaround? |
As master follows the releases, there is no need for static linking. If you would like that, you can use the |
Have you considered this and decided it won't be done? |
See this issue and the README for how this package can be built with the standard Go toolchain. |
Right now, this package requires custom manual steps for its installation:
This is inconvenient, it makes it harder to get than other Go packages (which are just
go get
). Worst of all, this means that any other Go package that imports this one, even if the upstream package is completely go gettable, will no longer be 1 command to install.I think it may be possible for you to change that, and thus improve the experience of anyone using this packages, and make it easy for others to import it and no incur the cost of manual dependency installation steps.
The way you can do that would be similar to how we did it with glfw3 package (currently on a branch, to be merged into master once GLFW 3.1 is released), which is a Go binding for a C library. It was discovered by @slimsag and you can see the discussion in the following issue and PR:
go-gl/glfw#82
go-gl/glfw#83
The general idea is that you vendor the C library source in a subfolder (potentially as a git submodule) and use cgo directives to link to it. Basically, everything you're doing now, except without needing the Makefile and scripts.
The main consideration is that you will need to replace the function of CMake with multiple .go files with build tags (which may require some work and maintenance), which is what we've done in glfw3:
But the end result is a go gettable package that is much easier for users. Just imagine:
What do you think? If this is something you're amendable to, I can assist with questions/answers about the approach and potentially try to make a PR.
The text was updated successfully, but these errors were encountered: