Skip to content

Commit

Permalink
docs: update README and Makefile with a few more build examples
Browse files Browse the repository at this point in the history
  • Loading branch information
someburner committed Apr 20, 2022
1 parent e0a52e2 commit 9fac31f
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 8 deletions.
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ libhydrogen-clean:
make -C libhydrogen clean

################################################################################
.PHONY: fmt run test
.PHONY: fmt run test run_custom_ld rerun
fmt:
$(SHELL) scripts/cmd.sh "fmt"

Expand All @@ -29,6 +29,11 @@ test:
run:
env CGO_ENABLED=1 go run tests/main.go

run_custom_ld:
env CGO_ENABLED=1 CGO_LDFLAGS="-L/path/to/libhydrogen" CGO_CFLAGS="-I/path/to/libhydrogen" go run tests/main.go

rerun:
env CGO_ENABLED=1 go run -a tests/main.go
################################################################################
.PHONY: race
race:
Expand Down
50 changes: 43 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,61 @@ Golang wrapper for [libhydrogen](https://github.com/jedisct1/libhydrogen).
## Usage

If libhydrogen is already installed system-wide, just `go get` the project
and import `libhydrogen-go` like anything else. Otherwise, you may build
`libhydrogen.a` inside the submodule directory.
and import `libhydrogen-go` like anything else. Otherwise, you may build and
install `libhydrogen.a` from the submodule directory.

**Note**: `libhydrogen-go` is only tested to work against the version of
libhydrogen included as a submodule in this repo.

**Specifying libhydrogen location**: See the `make run_custom_ld` target in
Makefile for example.

**Note**: If editing / recompiling `libhydrogen` and then running tests, it may
be necessary to build with the `-a` flag to force a rebuild. See `make rebuild`
target in Makefile for example.

```sh
# add as go mod dependency
go get github.com/someburner/libhydrogen-go
```
<br>

```go
// and use in project
package main

import (
"fmt"
hydro "github.com/someburner/libhydrogen-go"
)

func main() {
fmt.Println(hydro.VersionVerbose())
}
```

## Install libhydrogen

```sh
# to build inside submodule, or run the examples
cd github.com/someburner/libhydrogen-go
make libhydrogen
git clone --recursive https://github.com/someburner/libhydrogen-go.git
cd libhydrogen-go

# go run tests/main.go
make run
# build/install libhydrogen
cd libhydrogen
make
sudo make install
```

<br>

## Examples

See [example](tests/main.go).
See [example](tests/main.go). Or run with `make`.

```sh
make run
```

## Links

Expand Down

0 comments on commit 9fac31f

Please sign in to comment.