Skip to content

Commit

Permalink
Merge pull request #42 from join-com/more-fixes
Browse files Browse the repository at this point in the history
feat: add support for other platforms
  • Loading branch information
castarco authored Jun 25, 2021
2 parents db83ffb + b16b17b commit 64bcf88
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
25 changes: 23 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,30 @@
#!/bin/sh

# Building binary
go build -o ./dist/protoc-gen-tsx
env GOOS=darwin GOARCH=amd64 go build -o ./dist/protoc-gen-tsx.darwin.amd64
env GOOS=darwin GOARCH=arm64 go build -o ./dist/protoc-gen-tsx.darwin.arm64
env GOOS=linux GOARCH=amd64 go build -o ./dist/protoc-gen-tsx.linux.amd64
env GOOS=linux GOARCH=arm64 go build -o ./dist/protoc-gen-tsx.linux.arm64

rm -f ./dist/protoc-gen-tsx;

if test "$(uname)" = "Darwin" ; then
if test "$(uname -m)" = "x86_64"; then
cp ./dist/protoc-gen-tsx.darwin.amd64 ./dist/protoc-gen-tsx
else
cp ./dist/protoc-gen-tsx.darwin.arm64 ./dist/protoc-gen-tsx ## Best effort guess
fi
elif test "$(uname)" = "Linux" ; then
if test "$(uname -m)" = "x86_64"; then
cp ./dist/protoc-gen-tsx.linux.amd64 ./dist/protoc-gen-tsx
else
cp ./dist/protoc-gen-tsx.linux.arm64 ./dist/protoc-gen-tsx ## Best effort guess
fi
fi

chmod a+x ./dist/*

if [ "${CI}" != "true" ]; then
# Stripping symbols to make the binary more lightweight
strip -u -r -S ./dist/protoc-gen-tsx
strip -u -r -S ./dist/protoc-gen-tsx.darwin.amd64
fi
5 changes: 4 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Generates `ts` files from `proto` file definitions.
To install the "new" generator (bear in mind that it could be installed in `${HOME}/.local/bin` too):
```
curl -Lo protoc-gen-tsx \
https://github.com/join-com/protoc-gen-ts/releases/download/[VERSION]/protoc-gen-tsx.darwin.x86_64 \
https://github.com/join-com/protoc-gen-ts/releases/download/[VERSION]/protoc-gen-tsx.darwin.amd64 \
&& chmod +x protoc-gen-tsx \
&& sudo mv protoc-gen-tsx /usr/local/bin
```
Expand All @@ -20,6 +20,9 @@ curl -Lo protoc-gen-ts \
&& sudo mv protoc-gen-ts /usr/local/bin
```

- If you need a binary for Linux, you can change the word "darwin" in the url by "linux".
- If you need support for the M1 processor, or any other ARM processor, change "amd64" by "arm64".

## Usage

will generate TS implementations into `proto-ts` folder for all your proto files inside `proto`:
Expand Down

0 comments on commit 64bcf88

Please sign in to comment.