aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Alexander Kuznetsov <alexkuz@gmail.com> 2022-01-28 06:09:40 +0300
committerGravatar GitHub <noreply@github.com> 2022-01-27 19:09:40 -0800
commitaad33c2611ae08d142a68213ece0eeb072621113 (patch)
tree0371cdd47573bc869667b7741173353a8972c6a5
parentff2335a910d8ab012193c1e5d48e24012408fb4c (diff)
downloadbun-aad33c2611ae08d142a68213ece0eeb072621113.tar.gz
bun-aad33c2611ae08d142a68213ece0eeb072621113.tar.zst
bun-aad33c2611ae08d142a68213ece0eeb072621113.zip
Automate clang version checking / code signing (#113)
-rw-r--r--Makefile16
1 files changed, 14 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 96617ca94..55257675e 100644
--- a/Makefile
+++ b/Makefile
@@ -53,8 +53,17 @@ ZIG ?= $(shell which zig || echo -e "error: Missing zig. Please make sure zig is
# This is easier to happen than you'd expect.
# Using realpath here causes issues because clang uses clang++ as a symlink
# so if that's resolved, it won't build for C++
-CC ?= $(shell which clang-13 || which clang)
-CXX ?= $(shell which clang++-13 || which clang++)
+CC = $(shell which clang-13 || which clang)
+CXX = $(shell which clang++-13 || which clang++)
+
+ifeq ($(OS_NAME),darwin)
+LLVM_PREFIX = $(shell brew --prefix llvm)
+LDFLAGS += " -L$(LLVM_PREFIX)/lib"
+CPPFLAGS += " -I$(LLVM_PREFIX)/include"
+CC = $(LLVM_PREFIX)/bin/clang
+CXX = $(LLVM_PREFIX)/bin/clang++
+CODESIGN_IDENTITY ?= $(shell security find-identity -v -p codesigning | awk '/Apple Development/ { print $$2 }')
+endif
# macOS sed is different
SED = $(shell which gsed || which sed)
@@ -288,6 +297,8 @@ BUN_LLD_FLAGS = $(OBJ_FILES) \
$(DEFAULT_LINKER_FLAGS) \
$(PLATFORM_LINKER_FLAGS)
+CLANG_VERSION = $(shell $(CC) --version | awk '/version/ {for(i=1; i<=NF; i++){if($$i=="version"){split($$(i+1),v,".");print v[1]}}}')
+
bun:
@@ -353,6 +364,7 @@ docker-push-base:
require:
@echo "Checking if the required utilities are available..."
+ @if [ $(CLANG_VERSION) -lt "13" ]; then echo -e "ERROR: clang version >=13 required, found: $(CLANG_VERSION). Install with:\n\n $(POSIX_PKG_MANAGER) install llvm@13"; exit 1; fi
@cmake --version >/dev/null 2>&1 || (echo -e "ERROR: cmake is required."; exit 1)
@esbuild --version >/dev/null 2>&1 || (echo -e "ERROR: esbuild is required."; exit 1)
@npm --version >/dev/null 2>&1 || (echo -e "ERROR: npm is required."; exit 1)