Skip to content

Commit

Permalink
format to 80 character line limit
Browse files Browse the repository at this point in the history
`prettier --prose-wrap always --print-width 80 --write docs/src/cookbook/vcpkg.md` mostly worked, but removed indenting for some code blocks which I manually restored.
  • Loading branch information
eflanagan0 committed Aug 28, 2019
1 parent 68ff33c commit 668946d
Showing 1 changed file with 61 additions and 49 deletions.
110 changes: 61 additions & 49 deletions docs/src/cookbook/vcpkg.md
Original file line number Diff line number Diff line change
@@ -1,83 +1,97 @@
# build tectonic with vcpkg on macOS


This tutorial will walk you through how to build a *mostly* staticly linked `tectonic` binary on macOS. Why does this matter? Static binaries are more portable and so free you from having to support complex user environments. Thanks to [mcgoo's work](https://github.com/tectonic-typesetting/tectonic/pull/420) we can use `vcpkg`. [vcpkg](https://vcpkg.readthedocs.io/en/latest/) is a C/C++ package manager from Microsoft.

This tutorial will walk you through how to build a _mostly_ staticly linked
`tectonic` binary on macOS. Why does this matter? Static binaries are more
portable and so free you from having to support complex user environments.
Thanks to
[mcgoo's work](https://github.com/tectonic-typesetting/tectonic/pull/420) we can
use `vcpkg`. [vcpkg](https://vcpkg.readthedocs.io/en/latest/) is a C/C++ package
manager from Microsoft.

## prerequisites

This guide assumes you have [git](https://git-scm.com/) installed and are comfortable using the command-line. You'll also need to install [homebrew](https://brew.sh/) to install for `vcpkg`'s gcc dependency. Package management is *fun*.
This guide assumes you have [git](https://git-scm.com/) installed and are
comfortable using the command-line. You'll also need to install
[homebrew](https://brew.sh/) to install for `vcpkg`'s gcc dependency. Package
management is _fun_.

1. install `gcc`:

```sh
brew install gcc
brew install gcc
```

## setting up your environment

1. Install vcpkg
1. Clone the vcpkg repository:
```sh
git clone https://github.com/Microsoft/vcpkg
```
2. Install it for your system:
```sh
./bootstrap-vcpkg.sh
```

2. Install `tectonic` dependencies using vcpkg.
* Run the following command in your checkout of the `vcpkg` repository
1. Install vcpkg

1. Clone the vcpkg repository:
```sh
git clone https://github.com/Microsoft/vcpkg
```
2. Install it for your system:
```sh
./bootstrap-vcpkg.sh
```

2. Install `tectonic` dependencies using vcpkg. \* Run the following command in
your checkout of the `vcpkg` repository
`sh ./vcpkg install freetype harfbuzz\[icu,graphite2\]` It should print
something like the following:

```sh
./vcpkg install freetype harfbuzz\[icu,graphite2\]
$ ./vcpkg install freetype harfbuzz\[icu,graphite2\]
The following packages will be built and installed:
* bzip2[core]:x64-osx
freetype[core]:x64-osx
* gettext[core]:x64-osx
* graphite2[core]:x64-osx
harfbuzz[core,graphite2,icu,ucdn]:x64-osx
* icu[core]:x64-osx
* libiconv[core]:x64-osx
* libpng[core]:x64-osx
* ragel[core]:x64-osx
* zlib[core]:x64-osx
Additional packages (*) will be modified to complete this operation.
Starting package 1/10: graphite2:x64-osx
Building package graphite2[core]:x64-osx...
```
It should print something like the following:
```sh
$ ./vcpkg install freetype harfbuzz\[icu,graphite2\]
The following packages will be built and installed:
* bzip2[core]:x64-osx
freetype[core]:x64-osx
* gettext[core]:x64-osx
* graphite2[core]:x64-osx
harfbuzz[core,graphite2,icu,ucdn]:x64-osx
* icu[core]:x64-osx
* libiconv[core]:x64-osx
* libpng[core]:x64-osx
* ragel[core]:x64-osx
* zlib[core]:x64-osx
Additional packages (*) will be modified to complete this operation.
Starting package 1/10: graphite2:x64-osx
Building package graphite2[core]:x64-osx...
```

## build tectonic

Now we only need to configure tectonic so it knows we are using `vcpkg` to build the binary.
Now we only need to configure tectonic so it knows we are using `vcpkg` to build
the binary.

1. Run `cargo build` with the appropriate environment variables:
```sh
TECTONIC_DEP_BACKEND="vcpkg" VCPKG_ROOT=/Users/me/vcpkg/ cargo build --release
```
```sh
TECTONIC_DEP_BACKEND="vcpkg" VCPKG_ROOT=/Users/me/vcpkg/ cargo build --release
```

You'll need to set `VCPKG_ROOT` to the full path of your vcpkg checkout.
`TECTONIC_DEP_BACKEND="vcpkg"` tells `tectonic` to use `vcpkg` instead of trying to resolve the libraries using `pkgconfig`. `VCPKG_ROOT=/Users/me/vcpkg/` is the root of the `vcpkg` tree where we just installed the required libraries.
`TECTONIC_DEP_BACKEND="vcpkg"` tells `tectonic` to use `vcpkg` instead of trying
to resolve the libraries using `pkgconfig`. `VCPKG_ROOT=/Users/me/vcpkg/` is the
root of the `vcpkg` tree where we just installed the required libraries.
This will take a couple minutes but should eventually print something like:
This will take a couple minutes but should eventuall print something like:
```sh
Finished release [optimized] target(s) in 3m 39s
```
Congratulations! You should now have a mostly staticly linked binary in `target/release` suitable for sharing with users or whatever your needs are.

Congratulations! You should now have a mostly staticly linked binary in
`target/release` suitable for sharing with users or whatever your needs are.
## caveats
I say *mostly* staticly linked because the binary itself presumes system libraries.
You can observe those links by executing `otool` on a given binary:
I say _mostly_ staticly linked because the binary itself presumes system
libraries. You can observe those links by executing `otool` on a given binary:
```sh
otool -L target/release/tectonic

```
In my case it printed the following:
```sh
target/release/tectonic:
/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1454.98.0)
Expand All @@ -91,5 +105,3 @@ target/release/tectonic:
/usr/lib/libresolv.9.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
```


0 comments on commit 668946d

Please sign in to comment.