Skip to content

Commit

Permalink
Support buck2 downloads on macbooks and arm64 cpus
Browse files Browse the repository at this point in the history
  • Loading branch information
michalgr committed Oct 11, 2023
1 parent 29a711d commit bf5092d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
23 changes: 18 additions & 5 deletions projects/buck2/build.mk
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit bf5092d

Please sign in to comment.