Skip to content

Commit

Permalink
build universal binary on macos
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-obx committed Jul 18, 2024
1 parent 53e9f1b commit 0d439c1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ all: depend build
# Link statically (except for Darwin)
ifneq ($(shell uname -s),Darwin)
BUILD_GO_LDFLAGS=-ldflags '-linkmode external -w -extldflags "-static"'
endif

build: ## Build all targets
CGO_ENABLED=1 go build ${BUILD_GO_LDFLAGS} ./cmd/objectbox-generator/
else
build: ## Build universal binary (arm64, amd64)
CGO_ENABLED=1 GO_ARCH=arm64 go build -o objectbox-generator-arm64 ./cmd/objectbox-generator/
CGO_ENABLED=1 GO_ARCH=amd64 go build -o objectbox-generator-amd64 ./cmd/objectbox-generator/
lipo -create -output objectbox-generator objectbox-generator-arm64 objectbox-generator-amd64
endif

reinstall: build ## Update installed objectbox-generator
mv objectbox-generator "$(shell which objectbox-generator)"
Expand Down
2 changes: 2 additions & 0 deletions third_party/flatbuffers-c-bridge/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ if [[ "$(uname)" == MINGW* ]] || [[ "$(uname)" == CYGWIN* ]]; then
# buildOutputDir=/${buildType}
# buildArgs=
# buildArgs="-- /m" fails with "error MSB1008: Only one project can be specified."
elif [[ "$(uname)" == Darwin ]]; then # build universal binary
configArgs+=' -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64"'
fi

function build() {
Expand Down

0 comments on commit 0d439c1

Please sign in to comment.