Skip to content

Commit

Permalink
ADD: compile script, compile guide
Browse files Browse the repository at this point in the history
  • Loading branch information
go-compile committed May 11, 2022
1 parent 8012c43 commit af2f9b9
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
cmd/localrelay/*.toml
bin/
22 changes: 22 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
build:
GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -trimpath -o ./bin/localrelay-windows-x64.exe ./cmd/localrelay
GOOS=windows GOARCH=386 go build -ldflags="-s -w" -trimpath -o ./bin/localrelay-windows.exe ./cmd/localrelay
GOOS=windows GOARCH=arm64 go build -ldflags="-s -w" -trimpath -o ./bin/localrelay-windows-arm64.exe ./cmd/localrelay

GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w" -trimpath -o ./bin/localrelay-darwin ./cmd/localrelay
GOOS=darwin GOARCH=arm64 go build -ldflags="-s -w" -trimpath -o ./bin/localrelay-darwin-arm64 ./cmd/localrelay

GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -trimpath -o ./bin/localrelay-linux-64 ./cmd/localrelay
GOOS=linux GOARCH=386 go build -ldflags="-s -w" -trimpath -o ./bin/localrelay-linux ./cmd/localrelay
GOOS=linux GOARCH=arm64 go build -ldflags="-s -w" -trimpath -o ./bin/localrelay-linux-arm64 ./cmd/localrelay

GOOS=freebsd GOARCH=amd64 go build -ldflags="-s -w" -trimpath -o ./bin/localrelay-freebsd-64 ./cmd/localrelay
GOOS=freebsd GOARCH=386 go build -ldflags="-s -w" -trimpath -o ./bin/localrelay-freebsd ./cmd/localrelay
GOOS=freebsd GOARCH=arm64 go build -ldflags="-s -w" -trimpath -o ./bin/localrelay-freebsd-arm64 ./cmd/localrelay

GOOS=openbsd GOARCH=amd64 go build -ldflags="-s -w" -trimpath -o ./bin/localrelay-openbsd-64 ./cmd/localrelay
GOOS=openbsd GOARCH=386 go build -ldflags="-s -w" -trimpath -o ./bin/localrelay-openbsd ./cmd/localrelay
GOOS=openbsd GOARCH=arm64 go build -ldflags="-s -w" -trimpath -o ./bin/localrelay-openbsd-arm64 ./cmd/localrelay

clean:
rm -rf ./bin/
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,31 @@ localrelay run onion.toml bitwarden.toml
# Keep adding the config files to the command
localrelay run onion.toml bitwarden.toml nextcloud.toml piped.toml
```

# Build

This repository contains two code bases. The Localrelay package in the root and the CLI app in `./cmd/localrelay`. To compile the CLI you have two options. Compile for all targets (via the Makefile) or compile directly.

## Compile For All Targets

Open a terminal in the root of the repository and execute:
```
make
```
The binaries will be placed in `./bin/`.

## Compile For One Platform

Open a terminal and cd into `./cmd/localrelay`.

```bash
go build -trimpath -ldflags="-s -w"
```

The binary will be created in the current directory (`./cmd/localrelay`).

### Cross Compile

```bash
GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -trimpath -o ./bin/localrelay-linux-64 ./cmd/localrelay
```

0 comments on commit af2f9b9

Please sign in to comment.