Skip to content

Commit 57af6be

Browse files
committed
README: provide some information to future hackers
1 parent 58e36e0 commit 57af6be

File tree

1 file changed

+104
-0
lines changed

1 file changed

+104
-0
lines changed

README.md

+104
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
Native Binaries NuGet Package for LibGit2Sharp
2+
==============================================
3+
4+
[Libgit2Sharp](https://github.com/libgit2/libgit2sharp) is a managed
5+
wrapper around [libgit2](https://github.com/libgit2/libgit2), and as
6+
such requires compilation of libgit2 for your platform. LibGit2Sharp
7+
makes this easy by distributing NuGet packages that include precompiled
8+
versions of these native binaries.
9+
10+
If you need to build your own native binaries for some reason, you can
11+
do so easily with the scripts in this repository:
12+
13+
1. Clone the `LibGit2Sharp.NativeBinaries` repository. Do so recursively
14+
to ensure that the `libgit2` submodule is initialized automatically:
15+
16+
`git clone --recursive https://github.com/libgit2/libgit2sharp.nativebinaries`
17+
18+
(If you have already cloned this repository (which seems quite
19+
likely since you are reading this file!) then you can simply run
20+
`git submodule init` followed by `git submodule update`.)
21+
22+
2. Update the included libgit2 sources and configuration files to the
23+
version of libgit2 you want to build. For example, to build
24+
commit `1a2b3c4`:
25+
26+
`UpdateLibgit2ToSha.ps1 1a2b3c4`
27+
28+
Or you can specify references. To build the remote's `master` branch:
29+
30+
`UpdateLibgit2ToSha.ps1 master`
31+
32+
3. Build the libgit2 binaries. For Windows, this requires a Visual Studio
33+
installation, and will compile both x86 and amd64 variants. (See
34+
"Notes on Visual Studio", below). Run the build PowerShell script,
35+
specifying the version number of Visual Studio as the first argument.
36+
For example, to build with Visual Studio 2013 (aka "Visual Studio 12.0"):
37+
38+
`build.libgit2.ps1 12`
39+
40+
For Linux, this will build only the architecture that you're running
41+
(x86 or amd64). For Mac OS X, this will build a fat library that
42+
includes both x86 and amd64. Run the shell script:
43+
44+
`build.libgit2.sh`
45+
46+
4. Create the NuGet package from the built binaries. You will need to
47+
specify the version number of the resultant NuGet package that you
48+
want to generate. Note that you may wish to provide a suffix to
49+
disambiguate your custom package from the official, published NuGet
50+
packages. For example, if you are building a product called
51+
`fooproduct` then that may be a helpful suffix.
52+
53+
To build a NuGet package at version `1.2.3-foo`:
54+
55+
`buildpackage.ps1 1.2.3-foo`
56+
57+
And the result will be a NuGet package in the current directory:
58+
59+
`LibGit2Sharp.NativeBinaries.1.2.3-foo.nupkg`
60+
61+
Note that the `-foo` suffix technically makes this a "prerelease"
62+
package, according to NuGet, which may be further help in avoiding
63+
any mixups with the official packages, but may also require you to
64+
opt-in to prerelease packages in your NuGet package manager.
65+
66+
Specifying custom DLL names
67+
---------------------------
68+
If you want to redistribute a LibGit2Sharp that uses a custom libgit2,
69+
you may want to change the name of the libgit2 shared library file to
70+
disambiguate it from other installations. This may be useful if you
71+
are running as a plugin inside a larger process and wish to avoid
72+
conflicting with other plugins who may wish to use LibGit2Sharp and
73+
want to ensure that *your* version of libgit2 is loaded into memory
74+
and available to you.
75+
76+
For example, if your plugin names if `fooplugin`, you may wish to
77+
distribute a DLL named `git2-fooplugin.dll`. You can specify the
78+
custom DLL name as the second argument to the update and build scripts:
79+
80+
UpdateLibgit2ToSha.ps1 1a2b3c4 git2-fooplugin
81+
build.libgit2.sh 14 git2-fooplugin
82+
83+
Then build the NuGet package as described above, making sure to provide
84+
a helpful suffix to ensure that your NuGet package will not be confused
85+
with the official packages.
86+
87+
Notes on Visual Studio
88+
----------------------
89+
Visual Studio is required to build the native binaries, however you
90+
do not need to install a *paid* version of Visual Studio. libgit2
91+
can be compiled using [Visual Studio Community](https://www.visualstudio.com/en-us/products/visual-studio-community-vs),
92+
which is free for building open source applications.
93+
94+
You need to specify the actual version number (not the marketing name)
95+
of Visual Studio. (For example, "Visual Studio 2013" is the name of the
96+
product, but its actual version number is "12.0".) A handy guide:
97+
98+
| Marketing Name | Version Number
99+
|--------------------|---------------
100+
| Visual Studio 2010 | 10
101+
| Visual Studio 2012 | 11
102+
| Visual Studio 2013 | 12
103+
| Visual Studio 2015 | 14
104+

0 commit comments

Comments
 (0)