Skip to content

Commit

Permalink
*: add fips build support (pingcap#201)
Browse files Browse the repository at this point in the history
close pingcap#200

Signed-off-by: Neil Shen <[email protected]>
  • Loading branch information
mornyx authored and overvenus committed Dec 11, 2023
1 parent 44845a2 commit 3df2144
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
28 changes: 21 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,33 @@ PACKAGES_TESTS ?= $$($(PACKAGE_LIST_TESTS))
PACKAGE_DIRECTORIES := $(PACKAGE_LIST) | sed 's|github.com/pingcap/ng-monitoring/||'
FILES := $$(find $$($(PACKAGE_DIRECTORIES)) -name "*.go")
FAIL_ON_STDOUT := awk '{ print } END { if (NR > 0) { exit 1 } }'

LDFLAGS += -X "github.com/pingcap/ng-monitoring/utils/printer.NGMBuildTS=$(shell date -u '+%Y-%m-%d %H:%M:%S')"
LDFLAGS += -X "github.com/pingcap/ng-monitoring/utils/printer.NGMGitHash=$(shell git rev-parse HEAD)"
LDFLAGS += -X "github.com/pingcap/ng-monitoring/utils/printer.NGMGitBranch=$(shell git rev-parse --abbrev-ref HEAD)"

GO := GO111MODULE=on go
BUILD_TS := $(shell date -u '+%Y-%m-%d %H:%M:%S')
GIT_HASH := $(shell git rev-parse HEAD)
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)

BUILD_GOEXPERIMENT ?=
BUILD_CGO_ENABLED ?=
BUILD_TAGS ?=
ifeq ("${ENABLE_FIPS}", "1")
GIT_HASH := $(GIT_HASH) (with fips)
GIT_BRANCH := $(GIT_BRANCH) (with fips)
BUILD_TAGS += boringcrypto
BUILD_GOEXPERIMENT = GOEXPERIMENT=boringcrypto
BUILD_CGO_ENABLED = CGO_ENABLED=1
endif

LDFLAGS += -X "github.com/pingcap/ng-monitoring/utils/printer.NGMBuildTS=$(BUILD_TS)"
LDFLAGS += -X "github.com/pingcap/ng-monitoring/utils/printer.NGMGitHash=$(GIT_HASH)"
LDFLAGS += -X "github.com/pingcap/ng-monitoring/utils/printer.NGMGitBranch=$(GIT_BRANCH)"

GO := $(BUILD_GOEXPERIMENT) $(BUILD_CGO_ENABLED) GO111MODULE=on go
GOBUILD := $(GO) build
GOTEST := $(GO) test -p 8



default:
$(GOBUILD) -ldflags '$(LDFLAGS)' -o bin/ng-monitoring-server ./main.go
$(GOBUILD) -ldflags '$(LDFLAGS)' -tags '${BUILD_TAGS}' -o bin/ng-monitoring-server ./main.go
@echo Build successfully!

fmt:
Expand Down
3 changes: 3 additions & 0 deletions component/conprof/http/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ func TestAPI(t *testing.T) {
ts.setup(t)
defer ts.close(t)

// wait for http server ready
time.Sleep(time.Second)

topoSubScribe := make(topology.Subscriber)
err := conprof.Init(ts.db, topoSubScribe)
require.NoError(t, err)
Expand Down
6 changes: 6 additions & 0 deletions utils/printer/fips.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//go:build boringcrypto
// +build boringcrypto

package printer

import _ "crypto/tls/fipsonly"

0 comments on commit 3df2144

Please sign in to comment.