Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

optimize: add compile universal binary

mingcheng0cf53506c42b
diff --git a/.gitignore b/.gitignore
index 239e76e6..5f313528 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,4 +21,5 @@ Thumbs*.db
tmp
vendor/
.husky
-answer-data/
+/answer-data/
+/answer
diff --git a/Makefile b/Makefile
index 9feb089d..ff29cadc 100644
--- a/Makefile
+++ b/Makefile
@@ -13,6 +13,13 @@ GO=$(GO_ENV) $(shell which go)
build:
@$(GO_ENV) $(GO) build $(GO_FLAGS) -o $(BIN) $(DIR_SRC)
+# https://dev.to/thewraven/universal-macos-binaries-with-go-1-16-3mm3
+universal:
+ @GOOS=darwin GOARCH=amd64 $(GO_ENV) $(GO) build $(GO_FLAGS) -o ${BIN}_amd64 $(DIR_SRC)
+ @GOOS=darwin GOARCH=arm64 $(GO_ENV) $(GO) build $(GO_FLAGS) -o ${BIN}_arm64 $(DIR_SRC)
+ @lipo -create -output ${BIN} ${BIN}_amd64 ${BIN}_arm64
+ @rm -f ${BIN}_amd64 ${BIN}_arm64
+
generate:
go get github.com/google/wire/cmd/wire@latest
go generate ./...
@@ -23,6 +30,7 @@ test:
# clean all build result
clean:
+
@$(GO) clean ./...
@rm -f $(BIN)