Skip to content

Commit

Permalink
Adding a genrule to build a C++ binary snapshot.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 201738733
GitOrigin-RevId: 0a8ebc6357e27a68a2934db12ba75109ff18b573
  • Loading branch information
przydatek authored and Tink Team committed Jun 27, 2018
1 parent 29eeebe commit 6539ec8
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 1 deletion.
33 changes: 33 additions & 0 deletions cc/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,39 @@ genrule(
" `cd external/com_google_protobuf/src/; find google/ -name \"*.h\"`",
)

# Tink binary snapshot.
genrule(
name = "tink_bin_snapshot",
srcs = [
":tink_deps_headers",
":tink_headers",
":libtink.so",
],
outs = [
"tink_bin_snapshot.tar.gz",
],
# The command below packages the header files and the binary library
# into a single compressed tar-archive.
cmd = select({
":linux_x86_64":
"tar -cv -f $(GENDIR)/tink_bin_snapshot.tar --dereference" +
" --transform \"s/^cc/tink_bin_snapshot/\"" +
" -C $(GENDIR) cc/tink_headers.tar cc/tink_deps_headers.tar;" +
"tar -rv -f $(GENDIR)/tink_bin_snapshot.tar --dereference" +
" --transform \"s/^cc/tink_bin_snapshot/\"" +
" -C $(BINDIR) cc/libtink.so;" +
"gzip -c $(GENDIR)/tink_bin_snapshot.tar > $@",
":mac_x86_64":
"tar -cv -f $(GENDIR)/tink_bin_snapshot.tar --dereference" +
" -s \"/^cc/tink_bin_snapshot/p\"" +
" -C $(GENDIR) cc/tink_headers.tar cc/tink_deps_headers.tar;" +
"tar -rv -f $(GENDIR)/tink_bin_snapshot.tar --dereference" +
" -s \"/^cc/tink_bin_snapshot/p\"" +
" -C $(BINDIR) cc/libtink.so;" +
"gzip -c $(GENDIR)/tink_bin_snapshot.tar > $@",
}),
)

# tests

cc_test(
Expand Down
37 changes: 36 additions & 1 deletion docs/CPP-HOWTO.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,42 @@ libraries (cf. versions in the corresponding entries in
depend directly on these libraries at all (i.e. have only the indirect
dependence via Tink).

### Installing pre-build binaries (TODO)
### Installing pre-build binaries

1. Download and unpack a tar-archive with pre-built binary and relevant headers.

```sh
cd /tmp
curl https://some.repository/tar_bin_snapshot.tar.gz -O (TODO)
tar xfvz tar_bin_snapshot.tar.gz
```

2. Install the binary and the headers in appropriate
directories of the target project (`TARGET_DIR`):

```sh
TARGET_DIR="/usr/local"
mkdir -p $TARGET_DIR/lib $TARGET_DIR/include
sudo cp tink_bin_snapshot/libtink.so $TARGET_DIR/lib/
sudo tar xfv tink_bin_snapshot/tink_headers.tar -C $TARGET_DIR/include/
sudo tar xfv tink_bin_snapshot/tink_deps_headers.tar -C $TARGET_DIR/include/
```

3. If in Step 2 you specified a system directory (for example, `/usr/local`)
as the `TARGET_DIR`, then run ldconfig to configure the linker. For example:

```sh
sudo ldconfig
```

If you assigned a `TARGET_DIR` other than a system directory (for example,
`~/mydir`), then you must append the extraction directory (for example,
`~/mydir/lib`) to two environment variables:

```sh
export LIBRARY_PATH=$LIBRARY_PATH:$TARGET_DIR/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$TARGET_DIR/lib
```


### Installing from the source
Expand Down

0 comments on commit 6539ec8

Please sign in to comment.