Skip to content

Commit

Permalink
added support for building Windows artifacts
Browse files Browse the repository at this point in the history
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 639cd18 commit 955c4b4
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
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
11 changes: 11 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

all: build

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

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


.PHONY: build
build: $(PLUGIN_BINARY) release

Expand Down
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,28 @@ A Fluent Bit output plugin for Amazon Kinesis Data Streams.

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]).

### Usage

Run `make` to build `./bin/kinesis.so`. Then use with Fluent Bit:
```
./fluent-bit -e ./kinesis.so -i cpu \
-o kinesis \
-p "region=us-west-2" \
-p "stream=test-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`. Then use with Fluent Bit on Windows:
```
./fluent-bit.exe -e ./kinesis.dll -i dummy `
-o kinesis `
-p "region=us-west-2" `
-p "stream=test-stream"
```

### Plugin Options

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

0 comments on commit 955c4b4

Please sign in to comment.