Skip to content

Commit

Permalink
added target in makefile for building Windows artifacts and updated g…
Browse files Browse the repository at this point in the history
…ithub workflow to run the same

In order to build Windows artifacts, we have added a target for the same in Makefile. We are using a cross-compiler to build Windows artifacts.

Also, we have added this target in the Github action.

To ensure that customers building their own plugins can build Windows binaries for different architectures and using different cross-compilers, these build settings are customizable.
  • Loading branch information
Harsh Rawat authored and PettitWesley committed Jul 19, 2022
1 parent e733c24 commit 5373048
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@ jobs:
go-version: 1.17
id: go

- name: Install cross-compiler for Windows
run: sudo apt-get install -y gcc-multilib gcc-mingw-w64

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: golint
run: go get -u golang.org/x/lint/golint

- name: Build
run: make build test
run: make build windows-release test
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.

# Build settings.
GOARCH ?= amd64
COMPILER ?= x86_64-w64-mingw32-gcc # Cross-compiler for Windows

ROOT := $(shell pwd)

all: build
Expand All @@ -34,6 +38,12 @@ release:
go build -buildmode c-shared -o ./bin/firehose.so ./
@echo "Built Amazon Kinesis Data Firehose Fluent Bit Plugin"

.PHONY: windows-release
windows-release:
mkdir -p ./bin
GOOS=windows GOARCH=$(GOARCH) CGO_ENABLED=1 CC=$(COMPILER) go build -buildmode c-shared -o ./bin/firehose.dll ./
@echo "Built Amazon Kinesis Data Firehose Fluent Bit Plugin for Windows"

.PHONY: generate
generate: $(SOURCES)
PATH=$(SCRIPT_PATH) go generate ./...
Expand Down
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,20 @@ Run `make` to build `./bin/firehose.so`. Then use with Fluent Bit:
./fluent-bit -e ./firehose.so -i cpu \
-o firehose \
-p "region=us-west-2" \
-p "delivery-stream=example-stream"
-p "delivery_stream=example-stream"
```

For building Windows binaries, we need to install `mingw-64w` for cross-compilation. The same can be done using-
```
sudo apt-get install -y gcc-multilib gcc-mingw-w64
```
After this step, run `make windows-release` to build `./bin/firehose.dll`. Then use with Fluent Bit on Windows:
```
./fluent-bit.exe -e ./firehose.dll -i dummy `
-o firehose `
-p "region=us-west-2" `
-p "delivery_stream=example-stream"
```
### Plugin Options

* `region`: The region which your Firehose delivery stream(s) is/are in.
Expand Down

0 comments on commit 5373048

Please sign in to comment.