Skip to content

Commit

Permalink
feat: add iree build target flag
Browse files Browse the repository at this point in the history
  • Loading branch information
polvalente committed Jun 7, 2024
1 parent 2ff8f31 commit 007a870
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 4 deletions.
13 changes: 12 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,22 @@ jobs:
./scripts/clone_iree.sh ${{ env.BUILD_CACHE }} ${{ env.iree_version }} ${{ env.IREE_DIR }}
build_artifacts:
name: "Build artifacts ({{matrix.build_target}} / Elixir {{ matrix.ELIXIR_VERSION }} / OTP {{ matrix.OTP_VERSION }})"
runs-on: macos-14
strategy:
matrix:
OTP_VERSION: ["27.0"]
ELIXIR_VERSION: ["1.15.4"]
build_target:
- "cpu"
- "ios"
- "ios_simulator"
- "visionos"
- "visionos_simulator"
- "watchos"
- "watchos_simulator"
- "tvos"
- "tvos_simulator"
needs: download_iree
steps:
- name: Checkout
Expand Down Expand Up @@ -122,5 +133,5 @@ jobs:
- name: Build IREE
run: |
make compile IREE_DIR=${{ env.IREE_DIR }}
make compile IREE_DIR=${{ env.IREE_DIR }} IREE_BUILD_TARGET=${{ matrix.build_target }}
ls ${{ env.IREE_DIR }}/install
60 changes: 57 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Environment variables passed via elixir_make
# IREE_GIT_REV
# IREE_DIR
# IREE_BUILD_TARGET

# System vars
TEMP ?= $(HOME)/.cache
Expand All @@ -21,10 +22,62 @@ $(IREE_DIR):
IREE_CMAKE_BUILD_DIR ?= $(abspath iree-runtime/iree-build)
IREE_RUNTIME_INCLUDE_PATH := $(abspath $(IREE_DIR)/runtime/src/iree)
IREE_RUNTIME_BUILD_DIR ?= $(abspath iree-runtime/build)
IREE_RUNTIME_INSTALL_DIR ?= $(abspath iree-runtime/install)

IREE_CMAKE_CONFIG ?= Release

IREE_BUILD_TARGET ?= cpu

BUILD_TARGET_FLAGS = ""

ifeq ($(IREE_BUILD_TARGET), cpu)
else ifeq ($(IREE_BUILD_TARGET), ios)
BUILD_TARGET_FLAGS = \
-DCMAKE_SYSTEM_NAME=iOS\
-DCMAKE_OSX_DEPLOYMENT_TARGET=17.5\
-DCMAKE_OSX_ARCHITECTURES=arm64\
-DCMAKE_SYSTEM_PROCESSOR=arm64\
-DCMAKE_IOS_INSTALL_COMBINED=YES\
-DCMAKE_OSX_SYSROOT=$(shell xcodebuild -version -sdk iphone Path)
else ifeq ($(IREE_BUILD_TARGET), ios_simulator)
BUILD_TARGET_FLAGS = \
-DCMAKE_SYSTEM_NAME=iOS\
-DCMAKE_OSX_DEPLOYMENT_TARGET=17.5\
-DCMAKE_OSX_ARCHITECTURES=arm64\
-DCMAKE_SYSTEM_PROCESSOR=arm64\
-DCMAKE_IOS_INSTALL_COMBINED=YES\
-DCMAKE_OSX_SYSROOT=$(shell xcodebuild -version -sdk iphonesimulator Path)
else ifeq ($(IREE_BUILD_TARGET), visionos)
BUILD_TARGET_FLAGS = \
-DCMAKE_SYSTEM_NAME=visionOS\
-DCMAKE_OSX_DEPLOYMENT_TARGET=1.2\
-DCMAKE_OSX_ARCHITECTURES=arm64\
-DCMAKE_SYSTEM_PROCESSOR=arm64\
-DCMAKE_OSX_SYSROOT=$(shell xcodebuild -version -sdk xros Path)
else ifeq ($(IREE_BUILD_TARGET), visionos_simulator)
BUILD_TARGET_FLAGS = \
-DCMAKE_SYSTEM_NAME=visionOS\
-DCMAKE_OSX_DEPLOYMENT_TARGET=1.2\
-DCMAKE_OSX_ARCHITECTURES=arm64\
-DCMAKE_SYSTEM_PROCESSOR=arm64\
-DCMAKE_OSX_SYSROOT=$(shell xcodebuild -version -sdk xrsimulator Path)
else ifeq ($(IREE_BUILD_TARGET), watchos)
BUILD_TARGET_FLAGS = \
-DCMAKE_SYSTEM_NAME=watchOS\
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.5\
-DCMAKE_OSX_ARCHITECTURES=arm64\
-DCMAKE_SYSTEM_PROCESSOR=arm64\
-DCMAKE_OSX_SYSROOT=$(shell xcodebuild -version -sdk watchos Path)
else ifeq ($(IREE_BUILD_TARGET), watchos_simulator)
BUILD_TARGET_FLAGS = \
-DCMAKE_SYSTEM_NAME=watchOS\
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.5\
-DCMAKE_OSX_ARCHITECTURES=arm64\
-DCMAKE_SYSTEM_PROCESSOR=arm64\
-DCMAKE_OSX_SYSROOT=$(shell xcodebuild -version -sdk watchsimulator Path)
else
BUILD_TARGET_FLAGS = ""
endif

$(IREE_RUNTIME_BUILD_DIR): $(IREE_DIR)
cmake -G Ninja -S $(IREE_DIR) -B $(IREE_RUNTIME_BUILD_DIR) \
-DCMAKE_INSTALL_PREFIX=$(IREE_RUNTIME_BUILD_DIR)/install \
Expand All @@ -44,9 +97,10 @@ $(IREE_INSTALL_DIR): $(IREE_DIR) $(IREE_RUNTIME_BUILD_DIR)
-DIREE_BUILD_COMPILER=OFF\
-DIREE_RUNTIME_BUILD_DIR=$(IREE_RUNTIME_BUILD_DIR)\
-DIREE_RUNTIME_INCLUDE_PATH=$(IREE_RUNTIME_INCLUDE_PATH)\
-DIREE_DIR=$(IREE_DIR)
-DIREE_DIR=$(IREE_DIR) \
$(BUILD_TARGET_FLAGS)
cmake --build $(IREE_CMAKE_BUILD_DIR) --config $(IREE_CMAKE_CONFIG)
cmake --install $(IREE_CMAKE_BUILD_DIR) --config $(IREE_CMAKE_CONFIG) --prefix $(IREE_RUNTIME_INSTALL_DIR)
cmake --install $(IREE_CMAKE_BUILD_DIR) --config $(IREE_CMAKE_CONFIG) --prefix $(IREE_INSTALL_DIR)

# Print IREE Dir
PTD:
Expand Down

0 comments on commit 007a870

Please sign in to comment.