Skip to content

Commit 955c4b4

Browse files
Harsh RawatPettitWesley
authored andcommitted
added support for building Windows artifacts
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.
1 parent 639cd18 commit 955c4b4

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,14 @@ jobs:
1919
go-version: 1.17
2020
id: go
2121

22+
- name: Install cross-compiler for Windows
23+
run: sudo apt-get install -y gcc-multilib gcc-mingw-w64
24+
2225
- name: Check out code into the Go module directory
2326
uses: actions/checkout@v2
2427

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

2831
- name: Build
29-
run: make build test
32+
run: make build windows-release test

Makefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
# ANY KIND, either express or implied. See the License for the specific
1212
# language governing permissions and limitations under the License.
1313

14+
# Build settings.
15+
GOARCH ?= amd64
16+
COMPILER ?= x86_64-w64-mingw32-gcc # Cross-compiler for Windows
17+
1418
all: build
1519

1620
SOURCES := $(shell find . -name '*.go')
@@ -23,6 +27,13 @@ release:
2327
go build -buildmode c-shared -o ./bin/kinesis.so ./
2428
@echo "Built Amazon Kinesis Data Streams Fluent Bit Plugin v$(PLUGIN_VERSION)"
2529

30+
.PHONY: windows-release
31+
windows-release:
32+
mkdir -p ./bin
33+
GOOS=windows GOARCH=$(GOARCH) CGO_ENABLED=1 CC=$(COMPILER) go build -buildmode c-shared -o ./bin/kinesis.dll ./
34+
@echo "Built Amazon Kinesis Data Streams Fluent Bit Plugin v$(PLUGIN_VERSION) for Windows"
35+
36+
2637
.PHONY: build
2738
build: $(PLUGIN_BINARY) release
2839

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,28 @@ A Fluent Bit output plugin for Amazon Kinesis Data Streams.
77

88
If you think you’ve found a potential security issue, please do not post it in the Issues. Instead, please follow the instructions [here](https://aws.amazon.com/security/vulnerability-reporting/) or email AWS security directly at [[email protected]](mailto:[email protected]).
99

10+
### Usage
11+
12+
Run `make` to build `./bin/kinesis.so`. Then use with Fluent Bit:
13+
```
14+
./fluent-bit -e ./kinesis.so -i cpu \
15+
-o kinesis \
16+
-p "region=us-west-2" \
17+
-p "stream=test-stream"
18+
```
19+
20+
For building Windows binaries, we need to install `mingw-64w` for cross-compilation. The same can be done using-
21+
```
22+
sudo apt-get install -y gcc-multilib gcc-mingw-w64
23+
```
24+
After this step, run `make windows-release`. Then use with Fluent Bit on Windows:
25+
```
26+
./fluent-bit.exe -e ./kinesis.dll -i dummy `
27+
-o kinesis `
28+
-p "region=us-west-2" `
29+
-p "stream=test-stream"
30+
```
31+
1032
### Plugin Options
1133

1234
* `region`: The region which your Kinesis Data Stream is in.

0 commit comments

Comments
 (0)