Add packaging GitHub repo example

This commit is contained in:
Simon Brand 2018-11-16 11:24:19 +00:00
parent 56c94a8102
commit 077b7f1378
4 changed files with 62 additions and 2 deletions

View File

@ -50,7 +50,7 @@ and restart Powershell.
## Examples ## Examples
See the [documentation](docs/index.md) for specific walkthroughs, including [installing and using a package](docs/examples/installing-and-using-packages.md) and [adding a new package](docs/examples/packaging-zipfiles.md). See the [documentation](docs/index.md) for specific walkthroughs, including [installing and using a package](docs/examples/installing-and-using-packages.md), [adding a new package from a zipfile](docs/examples/packaging-zipfiles.md), and [adding a new package from a GitHub repo](docl/examples/packaging-github-repos.md).
Our docs are now also available online at ReadTheDocs: <https://vcpkg.readthedocs.io/>! Our docs are now also available online at ReadTheDocs: <https://vcpkg.readthedocs.io/>!

View File

@ -10,7 +10,7 @@ Yes! See [the `export` command](../users/integration.md#export).
The `vcpkg update` command lists all packages which are out-of-sync with your current portfiles. To update a package, follow the instructions in the command. The `vcpkg update` command lists all packages which are out-of-sync with your current portfiles. To update a package, follow the instructions in the command.
## How do I get more libraries? ## How do I get more libraries?
The list of libraries is enumerated from the [`ports\`](https://github.com/Microsoft/vcpkg/blob/master/ports) directory. By design, you can add and remove libraries from this directory as you see fit for yourself or your company -- see our [packaging example](../examples/packaging-zipfiles.md). The list of libraries is enumerated from the [`ports\`](https://github.com/Microsoft/vcpkg/blob/master/ports) directory. By design, you can add and remove libraries from this directory as you see fit for yourself or your company -- see our examples on packaging [zipfiles](../examples/packaging-zipfiles.md) and [GitHub repos](../examples/packaging-github-repos.md).
We recommend cloning directly from [GitHub](https://github.com/microsoft/vcpkg) and using `git pull` to update the list of portfiles. Once you've updated your portfiles, `vcpkg update` will indicate any installed libraries that are now out of date. We recommend cloning directly from [GitHub](https://github.com/microsoft/vcpkg) and using `git pull` to update the list of portfiles. Once you've updated your portfiles, `vcpkg update` will indicate any installed libraries that are now out of date.

View File

@ -0,0 +1,59 @@
## Packaging Github Repos Example: libogg
### Create the CONTROL file
The `CONTROL` file is a simple set of fields describing the package's metadata.
*For libogg, we'll create the file `ports\libogg\CONTROL` with the following contents:*
```no-highlight
Source: libogg
Version: 1.3.3
Description: Ogg is a multimedia container format, and the native file and stream format for the Xiph.org multimedia codecs.
```
### Create the portfile
`portfile.cmake` describes how to build and install the package. First we include `vcpkg_common_functions` to give us utilities for carrying this out:
```no-highlight
include(vcpkg_common_functions)
```
Now we download the project from Github with [`vcpkg_from_github`](../maintainers/vcpkg_from_github.md):
```no-highlight
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO xiph/ogg
REF v1.3.3
SHA512 0bd6095d647530d4cb1f509eb5e99965a25cc3dd9b8125b93abd6b248255c890cf20710154bdec40568478eb5c4cde724abfb2eff1f3a04e63acef0fbbc9799b
HEAD_REF master
)
```
The important parts to update are `REPO` for the GitHub repository path, `REF` for a stable tag/commit to use, and `SHA512` with the checksum of the downloaded zipfile (you can get this easily by setting it to `1`, trying to install the package, and copying the checksum).
Finally, we configure the project with CMake, install the package, and copy over the license file:
```no-highlight
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
)
vcpkg_install_cmake()
file(INSTALL ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/libogg RENAME copyright)
```
Check the documentation for [`vcpkg_configure_cmake`](../maintainers/vcpkg_configure_cmake.md) and [`vcpkg_install_cmake`](../maintainers/vcpkg_install_cmake.md) if your package needs additional options.
Now you can run `vcpkg install libogg` to build and install the package.
### Suggested example portfiles
In the `ports\` directory are many libraries that can be used as examples, including many that are not based on CMake.
- Header only libraries
- rapidjson
- range-v3
- MSBuild-based
- cppunit
- mpg123
- Non-CMake, custom buildsystem
- openssl
- ffmpeg

View File

@ -8,6 +8,7 @@ Vcpkg helps you manage C and C++ libraries on Windows, Linux and MacOS. This too
- [Installing and Using Packages Example: sqlite](examples/installing-and-using-packages.md) - [Installing and Using Packages Example: sqlite](examples/installing-and-using-packages.md)
- [Packaging Zipfiles Example: zlib](examples/packaging-zipfiles.md) - [Packaging Zipfiles Example: zlib](examples/packaging-zipfiles.md)
- [Packaging GitHub Repositories Example: libogg](examples/packaging-github-repos.md)
- [Patching Example: Patching libpng to work for x86-uwp](examples/patching.md) - [Patching Example: Patching libpng to work for x86-uwp](examples/patching.md)
### User Help ### User Help