diff --git a/Makefile b/Makefile index 70e47dd..70e392f 100644 --- a/Makefile +++ b/Makefile @@ -29,6 +29,9 @@ ANDROID_OUT_DIR = $(OUT_DIR)/android/$(NDK_ARCH) ANDROID_SYSROOTS_OUT_DIR = $(OUT_DIR)/sysroots/$(NDK_ARCH) HOST_OUT_DIR = $(OUT_DIR)/host +HOST_OS = $(shell uname -o) +HOST_MACHINE = $(shell uname -m) + export PATH:=$(abspath $(HOST_OUT_DIR)/bin):$(PATH) all: diff --git a/projects/buck2/build.mk b/projects/buck2/build.mk index 3301e28..0b2dc21 100644 --- a/projects/buck2/build.mk +++ b/projects/buck2/build.mk @@ -1,17 +1,30 @@ # Copyright (c) Meta Platforms, Inc. and affiliates. BUCK2_VERSION := 2023-09-01 -BUCK2_ARCHIVE := buck2.zst -BUCK2_URL := https://github.com/facebook/buck2/releases/download/$(BUCK2_VERSION)/buck2-x86_64-unknown-linux-gnu.zst + +ifeq ($(HOST_OS),GNU/Linux) +BUCK2_ARCHIVE_SUFFIX := unknown-linux-gnu +else +BUCK2_ARCHIVE_SUFFIX := apple-darwin +endif + +ifeq ($(HOST_MACHINE),arm64) +BUCK2_ARCHIVE_INFIX := aarch64 +else +BUCK2_ARCHIVE_INFIX := $(HOST_MACHINE) +endif + +BUCK2_ARCHIVE := buck2-$(BUCK2_ARCHIVE_INFIX)-$(BUCK2_ARCHIVE_SUFFIX).zst +BUCK2_URL := https://github.com/facebook/buck2/releases/download/$(BUCK2_VERSION)/$(BUCK2_ARCHIVE) $(HOST_OUT_DIR)/bin/buck2: $(DOWNLOADS_DIR)/$(BUCK2_ARCHIVE) | $(HOST_OUT_DIR) # commands to unpack $(BUCK2_ARCHIVE) and set the executable flag - zstd -d $(DOWNLOADS_DIR)/$(BUCK2_ARCHIVE) -o $(HOST_OUT_DIR)/bin/buck2 - chmod +x $(HOST_OUT_DIR)/bin/buck2 + zstd -d $(DOWNLOADS_DIR)/$(BUCK2_ARCHIVE) -o $@ + chmod +x $@ $(DOWNLOADS_DIR)/$(BUCK2_ARCHIVE): | $(DOWNLOADS_DIR) # instructions to download the archive - wget -q -O $(DOWNLOADS_DIR)/$(BUCK2_ARCHIVE) $(BUCK2_URL) + wget -q -O $@ $(BUCK2_URL) # Phony target for host .PHONY: buck2-host