Skip to content

Commit

Permalink
Fixed build for Windows / FreeBSD / Darwin
Browse files Browse the repository at this point in the history
  • Loading branch information
noctarius committed Aug 26, 2023
1 parent a76f681 commit fcb8dd2
Show file tree
Hide file tree
Showing 8 changed files with 115 additions and 25 deletions.
14 changes: 11 additions & 3 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ builds:
goos:
- linux
- windows
- darwin
- freebsd
goarch:
- amd64
Expand All @@ -23,8 +22,17 @@ builds:
ignore:
- goos: windows
goarch: riscv64
- goos: darwin
goarch: riscv64
- main: ./cmd/timescaledb-event-streamer
id: timescaledb-event-streamer-builder-darwin
env:
- CGO_ENABLED=1
ldflags:
- -X 'github.com/noctarius/timescaledb-event-streamer/internal/version.Branch={{.Branch}}' -X 'github.com/noctarius/timescaledb-event-streamer/internal/version.CommitHash={{.Commit}}'
goos:
- darwin
goarch:
- amd64
- arm64

archives:
- id: timescaledb-event-streamer-archiver
Expand Down
24 changes: 15 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,26 @@ license-header-check:

.PHONY: build-local
build-local:
@echo Building MacOS amd64...
@echo "Building MacOS amd64..."
GOOS=darwin GOARCH=amd64 go build -v -ldflags "-X 'github.com/noctarius/timescaledb-event-streamer/internal/version.Branch=${GIT_BRANCH}' -X 'github.com/noctarius/timescaledb-event-streamer/internal/version.CommitHash=${GIT_COMMIT}'" -o dist/macos/amd64/timescaledb-event-streamer ./cmd/timescaledb-event-streamer
@echo Building MacOS arm64...
GOOS=darwin GOARCH=arm64 go build -v -ldflags "-X 'github.com/noctarius/timescaledb-event-streamer/internal/version.Branch=${GIT_BRANCH}' -X 'github.com/noctarius/timescaledb-event-streamer/internal/version.CommitHash=${GIT_COMMIT}'" -o dist/macos/arm64/timescaledb-event-streamer ./cmd/timescaledb-event-streamer
@echo Building Linux amd64...
@echo "Building MacOS arm64..."
CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 go build -v -ldflags "-X 'github.com/noctarius/timescaledb-event-streamer/internal/version.Branch=${GIT_BRANCH}' -X 'github.com/noctarius/timescaledb-event-streamer/internal/version.CommitHash=${GIT_COMMIT}'" -o dist/macos/arm64/timescaledb-event-streamer ./cmd/timescaledb-event-streamer
@echo "Building Linux amd64..."
GOOS=linux GOARCH=amd64 go build -v -ldflags "-X 'github.com/noctarius/timescaledb-event-streamer/internal/version.Branch=${GIT_BRANCH}' -X 'github.com/noctarius/timescaledb-event-streamer/internal/version.CommitHash=${GIT_COMMIT}'" -o dist/linux/amd64/timescaledb-event-streamer ./cmd/timescaledb-event-streamer
@echo "Building Linux arm (32 bit)..."
GOOS=linux GOARCH=arm go build -v -ldflags "-X 'github.com/noctarius/timescaledb-event-streamer/internal/version.Branch=${GIT_BRANCH}' -X 'github.com/noctarius/timescaledb-event-streamer/internal/version.CommitHash=${GIT_COMMIT}'" -o dist/linux/arm32/timescaledb-event-streamer ./cmd/timescaledb-event-streamer
@echo Building Linux arm64...
@echo "Building Linux arm64..."
GOOS=linux GOARCH=arm64 go build -v -ldflags "-X 'github.com/noctarius/timescaledb-event-streamer/internal/version.Branch=${GIT_BRANCH}' -X 'github.com/noctarius/timescaledb-event-streamer/internal/version.CommitHash=${GIT_COMMIT}'" -o dist/linux/arm64/timescaledb-event-streamer ./cmd/timescaledb-event-streamer
@echo Building Windows amd64...
@echo "Building Linux Risc V (64bit)..."
GOOS=linux GOARCH=riscv64 go build -v -ldflags "-X 'github.com/noctarius/timescaledb-event-streamer/internal/version.Branch=${GIT_BRANCH}' -X 'github.com/noctarius/timescaledb-event-streamer/internal/version.CommitHash=${GIT_COMMIT}'" -o dist/linux/arm64/timescaledb-event-streamer ./cmd/timescaledb-event-streamer
@echo "Building Windows amd64..."
GOOS=windows GOARCH=amd64 go build -v -ldflags "-X 'github.com/noctarius/timescaledb-event-streamer/internal/version.Branch=${GIT_BRANCH}' -X 'github.com/noctarius/timescaledb-event-streamer/internal/version.CommitHash=${GIT_COMMIT}'" -o dist/windows/amd64/timescaledb-event-streamer ./cmd/timescaledb-event-streamer
@echo Building Windows arm64...
@echo "Building Windows arm64..."
GOOS=windows GOARCH=arm64 go build -v -ldflags "-X 'github.com/noctarius/timescaledb-event-streamer/internal/version.Branch=${GIT_BRANCH}' -X 'github.com/noctarius/timescaledb-event-streamer/internal/version.CommitHash=${GIT_COMMIT}'" -o dist/windows/arm64/timescaledb-event-streamer ./cmd/timescaledb-event-streamer
@echo "Building FreeBSD amd64..."
GOOS=freebsd GOARCH=amd64 go build -v -ldflags "-X 'github.com/noctarius/timescaledb-event-streamer/internal/version.Branch=${GIT_BRANCH}' -X 'github.com/noctarius/timescaledb-event-streamer/internal/version.CommitHash=${GIT_COMMIT}'" -o dist/linux/amd64/timescaledb-event-streamer ./cmd/timescaledb-event-streamer
@echo "Building FreeBSD arm64..."
GOOS=freebsd GOARCH=arm64 go build -v -ldflags "-X 'github.com/noctarius/timescaledb-event-streamer/internal/version.Branch=${GIT_BRANCH}' -X 'github.com/noctarius/timescaledb-event-streamer/internal/version.CommitHash=${GIT_COMMIT}'" -o dist/linux/arm64/timescaledb-event-streamer ./cmd/timescaledb-event-streamer
@echo "Building FreeBSD Risc V (64bit)..."
GOOS=freebsd GOARCH=riscv64 go build -v -ldflags "-X 'github.com/noctarius/timescaledb-event-streamer/internal/version.Branch=${GIT_BRANCH}' -X 'github.com/noctarius/timescaledb-event-streamer/internal/version.CommitHash=${GIT_COMMIT}'" -o dist/linux/arm64/timescaledb-event-streamer ./cmd/timescaledb-event-streamer

.PHONY: build
build:
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ require (
github.com/nats-io/nats.go v1.28.0
github.com/samber/do v1.6.0
github.com/samber/lo v1.38.1
github.com/segmentio/stats v4.1.0+incompatible
github.com/segmentio/stats/v4 v4.1.0
github.com/stretchr/testify v1.8.4
github.com/testcontainers/testcontainers-go v0.23.0
github.com/testcontainers/testcontainers-go/modules/localstack v0.23.0
Expand Down Expand Up @@ -92,8 +92,6 @@ require (
github.com/rogpeppe/go-internal v1.9.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/segmentio/fasthash v1.0.3 // indirect
github.com/segmentio/objconv v1.0.1 // indirect
github.com/segmentio/taskstats v0.0.0-20190328215536-52f398ff659c // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/stretchr/objx v0.5.0 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
Expand All @@ -109,3 +107,5 @@ require (
google.golang.org/grpc v1.57.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
)

replace github.com/segmentio/stats/v4 v4.1.0 => github.com/noctarius/segmentio_stats/v4 v4.1.5
8 changes: 2 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ github.com/nats-io/nkeys v0.4.4 h1:xvBJ8d69TznjcQl9t6//Q5xXuVhyYiSos6RPtvQNTwA=
github.com/nats-io/nkeys v0.4.4/go.mod h1:XUkxdLPTufzlihbamfzQ7mw/VGx6ObUs+0bN5sNvt64=
github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw=
github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
github.com/noctarius/segmentio_stats/v4 v4.1.5 h1:53g/etL4gz9h+JIClE2r4pds2zpi16CbJxRsh78CHH8=
github.com/noctarius/segmentio_stats/v4 v4.1.5/go.mod h1:NiR7tIEefE1jnNillXDlIE6eyp9A5MNi/4er0M0QLrU=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
Expand Down Expand Up @@ -213,11 +215,6 @@ github.com/samber/lo v1.38.1/go.mod h1:+m/ZKRl6ClXCE2Lgf3MsQlWfh4bn1bz6CXEOxnEXn
github.com/segmentio/fasthash v1.0.3 h1:EI9+KE1EwvMLBWwjpRDc+fEM+prwxDYbslddQGtrmhM=
github.com/segmentio/fasthash v1.0.3/go.mod h1:waKX8l2N8yckOgmSsXJi7x1ZfdKZ4x7KRMzBtS3oedY=
github.com/segmentio/objconv v1.0.1 h1:QjfLzwriJj40JibCV3MGSEiAoXixbp4ybhwfTB8RXOM=
github.com/segmentio/objconv v1.0.1/go.mod h1:auayaH5k3137Cl4SoXTgrzQcuQDmvuVtZgS0fb1Ahys=
github.com/segmentio/stats v4.1.0+incompatible h1:Sz7ypAORgiXoR8x8VNIOKYoVpJUIeHGt/2UDMjjRFuo=
github.com/segmentio/stats v4.1.0+incompatible/go.mod h1:ZkGKMkt6GVRIsV5Biy4HotVqonMWEsr+uMtOD2NBDeU=
github.com/segmentio/taskstats v0.0.0-20190328215536-52f398ff659c h1:w9MWuPLZVmHC+PngHXHGIGHedeNrJ4HuOogw5ZT7IVk=
github.com/segmentio/taskstats v0.0.0-20190328215536-52f398ff659c/go.mod h1:RRsP8O2UBzJhn2Et6+04bTn263Lf71PLEN13YcehPF0=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
Expand Down Expand Up @@ -355,7 +352,6 @@ gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
Expand Down
4 changes: 3 additions & 1 deletion internal/stats/reporter.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build darwin || linux

/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
Expand All @@ -17,7 +19,7 @@

package stats

import "github.com/segmentio/stats"
import "github.com/segmentio/stats/v4"

type Reporter struct {
statsEnabled bool
Expand Down
28 changes: 28 additions & 0 deletions internal/stats/reporter_noop.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//go:build !linux && !darwin

/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package stats

type Reporter struct {
}

func (r *Reporter) Report(
_ any,
) {
}
8 changes: 5 additions & 3 deletions internal/stats/stats.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build darwin || linux

/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
Expand All @@ -21,9 +23,9 @@ import (
"github.com/go-errors/errors"
"github.com/noctarius/timescaledb-event-streamer/spi/config"
"github.com/noctarius/timescaledb-event-streamer/spi/version"
"github.com/segmentio/stats"
"github.com/segmentio/stats/procstats"
"github.com/segmentio/stats/prometheus"
"github.com/segmentio/stats/v4"
"github.com/segmentio/stats/v4/procstats"
"github.com/segmentio/stats/v4/prometheus"
"golang.org/x/net/context"
"io"
"net/http"
Expand Down
48 changes: 48 additions & 0 deletions internal/stats/stats_noop.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//go:build !darwin && !linux

/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package stats

import (
"github.com/noctarius/timescaledb-event-streamer/spi/config"
)

type Service struct {
}

func NewStatsService(
_ *config.Config,
) *Service {

return &Service{}
}

func (s *Service) Start() error {
return nil
}

func (s *Service) Stop() error {
return nil
}

func (s *Service) NewReporter(
_ string,
) *Reporter {
return &Reporter{}
}

0 comments on commit fcb8dd2

Please sign in to comment.