Skip to content

Commit 9fd8f2a

Browse files
committed
Update README
1 parent 8541acc commit 9fd8f2a

File tree

1 file changed

+45
-80
lines changed

1 file changed

+45
-80
lines changed

README.md

Lines changed: 45 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,121 +1,86 @@
11
# LibGit2Sharp.NativeBinaries
22

33
**[Libgit2Sharp][lg2s]** is a managed wrapper around **[libgit2][lg2]**, and as
4-
such requires compilation of libgit2 for your platform.
4+
such requires compilation of libgit2 for your platform.
55

66
LibGit2Sharp makes this easy by distributing, and leveraging as a dependency,
77
the **[LibGit2Sharp.NativeBinaries][lg2s-nb]** NuGet package.
88

99
This package contains the compiled versions of the libgit2 native library for
1010
the following platforms:
1111

12-
- Windows (x86/amd64)
13-
- Mac OS X (x86/amd64)
14-
- Linux (amd64)
15-
16-
**Note:** Due to the large number of distributions, the Linux support is
17-
currently *experimental*. Would you encounter any issue with it, please open an
18-
**[issue][tracker]**.
12+
- Windows (x86, x64)
13+
- macOS (x64)
14+
- Linux (arm, arm64, x64)
1915

2016
[lg2s-nb]: https://www.nuget.org/packages/LibGit2Sharp.NativeBinaries
2117
[lg2]: https://libgit2.github.com/
2218
[lg2s]: http://libgit2sharp.com/
23-
[tracker]: https://github.com/libgit2/libgit2sharp.nativebinaries/issues
2419

25-
## How to build your own native binaries
20+
## Script overview
2621

27-
If you need to build your own native binaries for some reason, you can
28-
do so easily with the scripts in this repository:
22+
The following scripts are used build and update this repo.
2923

30-
1. Clone the `LibGit2Sharp.NativeBinaries` repository. Do so recursively
31-
to ensure that the `libgit2` submodule is initialized automatically:
24+
### build.libgit2.ps1
3225

33-
`git clone --recursive https://github.com/libgit2/libgit2sharp.nativebinaries`
26+
This script builds Windows libgit2 binaries. This requires Visual Studio 2019.
3427

35-
(If you have already cloned this repository (which seems quite
36-
likely since you are reading this file!) then you can simply run
37-
`git submodule init` followed by `git submodule update`.)
28+
To build x86 binaries:
3829

39-
2. Update the included libgit2 sources and configuration files to the
40-
version of libgit2 you want to build. For example, to build
41-
commit `1a2b3c4`:
30+
`build.libgit2.ps1 -x86`
4231

43-
`UpdateLibgit2ToSha.ps1 1a2b3c4`
32+
To build x64 binaries:
4433

45-
Or you can specify references. To build the remote's `master` branch:
34+
`build.libgit2.ps1 -x64`
4635

47-
`UpdateLibgit2ToSha.ps1 master`
36+
If both parameters are specified, both will be built. See the script for additional parameters.
4837

49-
3. Build the libgit2 binaries. For Windows, this requires a Visual Studio
50-
installation, and will compile both x86 and amd64 variants. (See
51-
"Notes on Visual Studio", below). Run the build PowerShell script,
52-
specifying the version number of Visual Studio as the first argument.
53-
For example, to build with Visual Studio 2013 (aka "Visual Studio 12.0"):
38+
### build.libgit2.sh
5439

55-
`build.libgit2.ps1 12`
40+
This script builds Linux and macOS binaries. It can be invoked directly, but for Linux binaries, dockerbuild.sh should be used instead.
5641

57-
For Linux, this will build only the architecture that you're running
58-
(x86 or amd64). For Mac OS X, this will build a fat library that
59-
includes both x86 and amd64. Run the shell script:
42+
### dockerbuild.sh
6043

61-
`build.libgit2.sh`
44+
This script will build one of the Dockerfiles in the repo. It chooses which one to run based on the value of the RID environment variable. Using docker to build the Linux binaries for the various RIDs ensures that a specific environment and distro is used.
6245

63-
4. Create the NuGet package from the built binaries. You will need to
64-
specify the version number of the resultant NuGet package that you
65-
want to generate. Note that you may wish to provide a suffix to
66-
disambiguate your custom package from the official, published NuGet
67-
packages. For example, if you are building a product called
68-
`fooproduct` then that may be a helpful suffix.
46+
### UpdateLibgit2ToSha.ps1
6947

70-
To build a NuGet package at version `1.2.3-foo`:
48+
This script is used to update the libgit2 submodule and update the references within the project to the correct libgit2 revision.
7149

72-
`buildpackage.ps1 1.2.3-foo`
50+
You can update to a specific commit:
7351

74-
And the result will be a NuGet package in the current directory:
52+
`UpdateLibgit2ToSha.ps1 1a2b3c4`
7553

76-
`LibGit2Sharp.NativeBinaries.1.2.3-foo.nupkg`
54+
Or you can specify references:
7755

78-
Note that the `-foo` suffix technically makes this a "prerelease"
79-
package, according to NuGet, which may be further help in avoiding
80-
any mixups with the official packages, but may also require you to
81-
opt-in to prerelease packages in your NuGet package manager.
56+
`UpdateLibgit2ToSha.ps1 master`
8257

83-
## Specifying custom DLL names
58+
## Building the package locally
8459

85-
If you want to redistribute a LibGit2Sharp that uses a custom libgit2,
86-
you may want to change the name of the libgit2 shared library file to
87-
disambiguate it from other installations. This may be useful if you
88-
are running as a plugin inside a larger process and wish to avoid
89-
conflicting with other plugins who may wish to use LibGit2Sharp and
90-
want to ensure that *your* version of libgit2 is loaded into memory
91-
and available to you.
60+
After running the appropriate build script(s) to create binaries, the NuGet package needs to be created.
9261

93-
For example, if your plugin names if `fooplugin`, you may wish to
94-
distribute a DLL named `git2-fooplugin.dll`. You can specify the
95-
custom DLL name as the second argument to the update and build scripts:
62+
First, to use the same version locally that will be generated via CI, install the [minver-cli](https://www.nuget.org/packages/minver-cli) dotnet tool:
9663

97-
UpdateLibgit2ToSha.ps1 1a2b3c4 git2-fooplugin
98-
build.libgit2.sh 14 git2-fooplugin
64+
'dotnet tool install --global minver-cli`
9965

100-
Then build the NuGet package as described above, making sure to provide
101-
a helpful suffix to ensure that your NuGet package will not be confused
102-
with the official packages.
66+
Once that is installed, running the `minver` command will output a version:
10367

104-
### Notes on Visual Studio
68+
```
69+
MinVer: Using { Commit: 2453a6d, Tag: '2.0.312', Version: 2.0.312, Height: 3 }.
70+
MinVer: Calculated version 2.0.313-alpha.0.3.
71+
2.0.313-alpha.0.3
72+
```
10573

106-
Visual Studio is required to build the native binaries, however you
107-
do not need to install a *paid* version of Visual Studio. libgit2
108-
can be compiled using [Visual Studio Community](https://www.visualstudio.com/en-us/products/visual-studio-community-vs),
109-
which is free for building open source applications.
74+
To create the package, use the the following command:
75+
76+
`nuget.exe Pack nuget.package/NativeBinaries.nuspec -Version <version> -NoPackageAnalysis`
77+
78+
Where `<version>` is the version from the MinVer tool or manually chosen version.
11079

111-
You need to specify the actual version number (not the marketing name)
112-
of Visual Studio. (For example, "Visual Studio 2013" is the name of the
113-
product, but its actual version number is "12.0".) A handy guide:
114-
115-
| Marketing Name | Version Number
116-
|--------------------|---------------
117-
| Visual Studio 2010 | 10
118-
| Visual Studio 2012 | 11
119-
| Visual Studio 2013 | 12
120-
| Visual Studio 2015 | 14
121-
| Visual Studio 2017 | 15
80+
81+
## Notes on Visual Studio
82+
83+
Visual Studio 2019 is required to build the Windows native binaries, however you
84+
do not need to install a *paid* version of Visual Studio. libgit2
85+
can be compiled using [Visual Studio Community](https://visualstudio.microsoft.com/vs/community/),
86+
which is free for building open source applications.

0 commit comments

Comments
 (0)