Skip to content

Commit

Permalink
fix: use host-build
Browse files Browse the repository at this point in the history
  • Loading branch information
polvalente committed Jul 16, 2024
1 parent fee1738 commit 9d0b4e0
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 16 deletions.
24 changes: 16 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ else
all: install_runtime nx_iree
endif

compile: install_runtime

.PHONY: clone_iree
clone_iree: $(NX_IREE_SOURCE_DIR)

Expand Down Expand Up @@ -47,7 +45,7 @@ else ifeq ($(IREE_BUILD_TARGET), ios)
-DCMAKE_SYSTEM_PROCESSOR=arm64\
-DCMAKE_IOS_INSTALL_COMBINED=YES\
-DCMAKE_OSX_SYSROOT=$(shell xcodebuild -version -sdk iphoneos Path)\
-DIREE_HOST_BIN_DIR=$(IREE_HOST_INSTALL_DIR)
-DIREE_HOST_BIN_DIR=$(IREE_HOST_BIN_DIR)
else ifeq ($(IREE_BUILD_TARGET), ios_simulator)
BUILD_TARGET_FLAGS += \
-DCMAKE_SYSTEM_NAME=iOS\
Expand Down Expand Up @@ -89,11 +87,8 @@ else
endif

.PHONY: install_runtime
ifdef IREE_HOST_INSTALL_DIR
install_runtime: $(IREE_HOST_INSTALL_DIR) $(IREE_INSTALL_DIR)
else
install_runtime: $(IREE_INSTALL_DIR)
endif
install_runtime: iree_host $(IREE_INSTALL_DIR)


CMAKE_SOURCES = cmake/src/runtime.cc cmake/src/runtime.h

Expand All @@ -108,6 +103,19 @@ $(IREE_INSTALL_DIR): $(NX_IREE_SOURCE_DIR) $(CMAKE_SOURCES)
cmake --build $(IREE_CMAKE_BUILD_DIR) --config $(IREE_CMAKE_CONFIG)
cmake --install $(IREE_CMAKE_BUILD_DIR) --config $(IREE_CMAKE_CONFIG) --prefix $(IREE_INSTALL_DIR)

.PHONY: iree_host
ifdef IREE_HOST_BUILD_DIR
iree_host:
@echo "Building IREE runtime host binaries at $(IREE_HOST_BUILD_DIR)."
cmake -G Ninja -B $(IREE_HOST_BUILD_DIR) \
-DCMAKE_INSTALL_PREFIX=$(IREE_HOST_INSTALL_DIR) \
-DCMAKE_BUILD_TYPE=$(IREE_CMAKE_CONFIG) \
-S $(NX_IREE_SOURCE_DIR)
cmake --build $(IREE_HOST_BUILD_DIR) --target install
else
iree_host:
@echo "No host build directory specified. Skipping."
endif

### NxIREE Runtime NIF library

Expand Down
33 changes: 25 additions & 8 deletions scripts/build_and_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,31 +37,48 @@ mkdir -p iree-runtime/artifacts

HOST_ARCH=$(uname -s)-$(uname -m)

install_dir() {
echo "iree-runtime/$1/install"
}
build() {
echo "Building for target: $1"
local IREE_CMAKE_BUILD_DIR=iree-runtime/$1/iree-build
local IREE_RUNTIME_BUILD_DIR=iree-runtime/$1/build
local IREE_INSTALL_DIR=iree-runtime/$1/install
local IREE_INSTALL_DIR=$(install_dir $1)

if $2; then
export IREE_HOST_INSTALL_DIR=iree-runtime/host/install
if [[ $1 -eq "host" ]]; then
local IREE_HOST_BUILD_DIR=iree-runtime/host-build
local IREE_HOST_INSTALL_DIR=${IREE_HOST_BUILD_DIR}/install
local IREE_HOST_BIN_DIR=${IREE_HOST_BUILD_DIR}/install/bin
else
local IREE_HOST_BIN_DIR=iree-runtime/host-build/install/bin
fi

echo "Building for target: $1"
echo "IREE_HOST_INSTALL_DIR: ${IREE_HOST_INSTALL_DIR}"
make ${NUM_JOBS} compile \
echo "IREE_CMAKE_BUILD_DIR: $IREE_CMAKE_BUILD_DIR"
echo "IREE_RUNTIME_BUILD_DIR: $IREE_RUNTIME_BUILD_DIR"
echo "IREE_INSTALL_DIR: $IREE_INSTALL_DIR"
echo "IREE_HOST_BIN_DIR: $IREE_HOST_BIN_DIR"
echo "IREE_HOST_INSTALL_DIR: $IREE_HOST_INSTALL_DIR"
echo "IREE_HOST_BUILD_DIR: $IREE_HOST_BUILD_DIR"

make ${NUM_JOBS} install_runtime \
IREE_GIT_REV=$(mix iree.version) \
IREE_INSTALL_DIR=${IREE_INSTALL_DIR} \
IREE_CMAKE_BUILD_DIR=${IREE_CMAKE_BUILD_DIR} \
IREE_RUNTIME_BUILD_DIR=${IREE_RUNTIME_BUILD_DIR} \
IREE_BUILD_TARGET=$1

echo $IREE_INSTALL_DIR
}

if $build_host_flag; then
echo "Building Host Runtime"
build host true
build host
echo "Done building Host Runtime"
fi

build $IREE_BUILD_TARGET false
build $IREE_BUILD_TARGET
IREE_INSTALL_DIR=$(install_dir $IREE_BUILD_TARGET)

TAR_NAME=iree-runtime/artifacts/nx_iree-${HOST_ARCH}-${IREE_BUILD_TARGET}.tar.gz

Expand Down

0 comments on commit 9d0b4e0

Please sign in to comment.