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 19, 2024
1 parent 78c1de6 commit b219ec7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ scripts/tmp*
# Command built using `make build`
/objectbox-generator
/objectbox-generator.exe
build/

# CMake/C++ Examples:
examples/*/_deps
Expand Down
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 GOARCH=arm64 go build -o build/objectbox-generator-arm64 ./cmd/objectbox-generator/
CGO_ENABLED=1 GOARCH=amd64 go build -o build/objectbox-generator-amd64 ./cmd/objectbox-generator/
lipo -create -output objectbox-generator build/objectbox-generator-arm64 build/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 b219ec7

Please sign in to comment.