Skip to content

Commit 79e9976

Browse files
authored
Merge pull request #123 from libgit2/update-readme
Update README
2 parents 8541acc + 961331d commit 79e9976

File tree

4 files changed

+68
-96
lines changed

4 files changed

+68
-96
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ name: CI
22
on:
33
push:
44
branches: [master, release-*]
5-
tags: ["*.*.*"]
5+
tags:
6+
- '[0-9]+.[0-9]+.[0-9]+'
7+
- '[0-9]+.[0-9]+.[0-9]+-*'
68
pull_request:
79
workflow_dispatch:
810
jobs:
@@ -69,7 +71,7 @@ jobs:
6971
run: dotnet tool install --global minver-cli
7072
- name: Run MinVer
7173
id: minver
72-
run: echo "::set-output name=version::$(minver)"
74+
run: echo '::set-output name=version::$(minver)'
7375
- name: Download artifacts
7476
uses: actions/[email protected]
7577
with:

README.md

Lines changed: 57 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,121 +1,98 @@
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 to build libgit2 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. It requires Visual Studio 2019 to run.
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+
```
31+
build.libgit2.ps1 -x86
32+
```
4233

43-
`UpdateLibgit2ToSha.ps1 1a2b3c4`
34+
To build x64 binaries:
4435

45-
Or you can specify references. To build the remote's `master` branch:
36+
```
37+
build.libgit2.ps1 -x64
38+
```
4639

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

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"):
42+
### build.libgit2.sh
5443

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

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:
46+
### dockerbuild.sh
6047

61-
`build.libgit2.sh`
48+
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.
6249

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.
50+
### UpdateLibgit2ToSha.ps1
6951

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

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

74-
And the result will be a NuGet package in the current directory:
56+
```
57+
UpdateLibgit2ToSha.ps1 1a2b3c4
58+
```
7559

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

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.
62+
```
63+
UpdateLibgit2ToSha.ps1 master
64+
```
8265

83-
## Specifying custom DLL names
66+
## Building the package locally
8467

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.
68+
After running the appropriate build script(s) to create binaries, the NuGet package needs to be created.
9269

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:
70+
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:
9671

97-
UpdateLibgit2ToSha.ps1 1a2b3c4 git2-fooplugin
98-
build.libgit2.sh 14 git2-fooplugin
72+
```
73+
dotnet tool install --global minver-cli
74+
```
9975

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.
76+
Once that is installed, running the `minver` command will output a version:
10377

104-
### Notes on Visual Studio
78+
```
79+
MinVer: Using { Commit: 2453a6d, Tag: '2.0.312', Version: 2.0.312, Height: 3 }.
80+
MinVer: Calculated version 2.0.313-alpha.0.3.
81+
2.0.313-alpha.0.3
82+
```
10583

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.
84+
To create the package, use the the following command:
85+
86+
```
87+
nuget.exe Pack nuget.package/NativeBinaries.nuspec -Version <version> -NoPackageAnalysis
88+
```
89+
90+
Where `<version>` is the version from the MinVer tool or manually chosen version.
11091

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
92+
93+
## Notes on Visual Studio
94+
95+
Visual Studio 2019 is required to build the Windows native binaries, however you
96+
do not need to install a *paid* version of Visual Studio. libgit2
97+
can be compiled using [Visual Studio Community](https://visualstudio.microsoft.com/vs/community/),
98+
which is free for building open source applications.

UpdateLibgit2ToSha.ps1

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
#>
77

88
Param(
9-
[string]$sha = 'HEAD',
10-
[string]$libgit2Name = ''
9+
[string]$sha = 'HEAD'
1110
)
1211

1312
Set-StrictMode -Version Latest
@@ -82,11 +81,7 @@ Push-Location $libgit2Directory
8281

8382
Pop-Location
8483

85-
if (![string]::IsNullOrEmpty($libgit2Name)) {
86-
$binaryFilename = $libgit2Name
87-
} else {
88-
$binaryFilename = "git2-" + $sha.Substring(0,7)
89-
}
84+
$binaryFilename = "git2-" + $sha.Substring(0,7)
9085

9186
Set-Content -Encoding ASCII (Join-Path $projectDirectory "nuget.package\libgit2\libgit2_hash.txt") $sha
9287

build.libgit2.ps1

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@
55
If set, run the libgit2 tests on the desired version.
66
.PARAMETER debug
77
If set, build the "Debug" configuration of libgit2, rather than "Release" (default).
8+
.PARAMETER x86
9+
If set, the 32-bit version will be built.
10+
.PARAMETER x64
11+
If set, the 64-bit version will be built.
812
#>
913

1014
Param(
11-
[string]$libgit2Name = '',
1215
[switch]$test,
1316
[switch]$debug,
1417
[switch]$x86,
@@ -23,12 +26,7 @@ $x86Directory = Join-Path $projectDirectory "nuget.package\runtimes\win-x86\nati
2326
$x64Directory = Join-Path $projectDirectory "nuget.package\runtimes\win-x64\native"
2427
$hashFile = Join-Path $projectDirectory "nuget.package\libgit2\libgit2_hash.txt"
2528
$sha = Get-Content $hashFile
26-
27-
if (![string]::IsNullOrEmpty($libgit2Name)) {
28-
$binaryFilename = $libgit2Name
29-
} else {
30-
$binaryFilename = "git2-" + $sha.Substring(0,7)
31-
}
29+
$binaryFilename = "git2-" + $sha.Substring(0,7)
3230

3331
$build_clar = 'OFF'
3432
if ($test.IsPresent) { $build_clar = 'ON' }

0 commit comments

Comments
 (0)