Revamp the ways in which the library can be built #621

Merged
lhchavez merged 1 commits from build-tags-revamp into master 2020-06-21 17:40:53 -05:00
lhchavez commented 2020-06-21 09:11:28 -05:00 (Migrated from github.com)

This change allows to link the system version of libgit2 statically.
Since -tags static is already used for the bundled version of the
library and to avoid breaking old workflows, -tags static,system_libgit2 is now used to select that.

This means that the valid combinations are:

Flag Effect
No flags Dynamically-linked against the system libgit2
-tags static,system_libgit2 Statically-linked against the system libgit2
-tags static Statically-linked against the bundled libgit2

Note that there is no way to express dynamically linking against the
bundled libgit2 because that makes very little sense, since the binaries
wouldn't be able to be distributed. If that's still desired, the
PKG_CONFIG_PATH environment variable can set before building the code.
Makefile has
an example of how it is used in the CI.

This change allows to link the system version of libgit2 statically. Since `-tags static` is already used for the bundled version of the library and to avoid breaking old workflows, `-tags static,system_libgit2` is now used to select that. This means that the valid combinations are: | Flag | Effect | |-------------------------------|-----------------------------------------------| | _No flags_ | Dynamically-linked against the system libgit2 | | `-tags static,system_libgit2` | Statically-linked against the system libgit2 | | `-tags static` | Statically-linked against the bundled libgit2 | Note that there is no way to express dynamically linking against the bundled libgit2 because that makes very little sense, since the binaries wouldn't be able to be distributed. If that's still desired, the `PKG_CONFIG_PATH` environment variable can set before building the code. [`Makefile`](https://github.com/libgit2/git2go/blob/master/Makefile) has an example of how it is used in the CI.
suhaibmujahid commented 2020-06-21 16:01:12 -05:00 (Migrated from github.com)

Thank you for this PR. This will eliminate the workaround that I do to build statically because I'm using the go module mod in my project.

Thank you for this PR. This will eliminate the workaround that I do to build statically because I'm using the go module mod in my project.
lhchavez commented 2020-06-21 17:40:31 -05:00 (Migrated from github.com)

awesome, seems like there is some demand for this. I changed the system tag since it's too vague (and collision-prone) in favor of system_libgit2. Let's land this!

awesome, seems like there is some demand for this. I changed the `system` tag since it's too vague (and collision-prone) in favor of `system_libgit2`. Let's land this!
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: jcarr/git2go#621
No description provided.