Skip to content

Commit

Permalink
feat: build host as well
Browse files Browse the repository at this point in the history
  • Loading branch information
polvalente committed Jul 16, 2024
1 parent 94bf014 commit 7ef3c61
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/embedded_devices.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
if: steps.cache-iree-dir.outputs.cache-hit != 'true'
run: make clone_iree
- name: Compile
run: ./scripts/build_and_package.sh ${{ matrix.build_target }}
run: ./scripts/build_and_package.sh ${{ matrix.build_target }} --build-host
- name: Release Artifacts
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
Expand Down
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ else ifeq ($(IREE_BUILD_TARGET), ios)
-DCMAKE_OSX_ARCHITECTURES=arm64\
-DCMAKE_SYSTEM_PROCESSOR=arm64\
-DCMAKE_IOS_INSTALL_COMBINED=YES\
-DCMAKE_OSX_SYSROOT=$(shell xcodebuild -version -sdk iphoneos Path)
-DCMAKE_OSX_SYSROOT=$(shell xcodebuild -version -sdk iphoneos Path)\
-DIREE_HOST_BIN_DIR=$(IREE_HOST_INSTALL_DIR)
else ifeq ($(IREE_BUILD_TARGET), ios_simulator)
BUILD_TARGET_FLAGS += \
-DCMAKE_SYSTEM_NAME=iOS\
Expand Down Expand Up @@ -88,7 +89,11 @@ 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

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

Expand Down
47 changes: 42 additions & 5 deletions scripts/build_and_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,54 @@ get_nproc() {
fi
}

# Initialize variable
build_host_flag=false

# Parse options
while [[ $# -gt 0 ]]; do
case $1 in
--build-host)
build_host_flag=true
shift # Shift past the argument
;;
*)
echo "Unknown option: $1"
exit 1
;;
esac
done

NUM_JOBS=-j$(get_nproc)

mkdir -p iree-runtime/artifacts

IREE_CMAKE_BUILD_DIR=iree-runtime/${IREE_BUILD_TARGET}/iree-build
IREE_RUNTIME_BUILD_DIR=iree-runtime/${IREE_BUILD_TARGET}/build
IREE_INSTALL_DIR=iree-runtime/${IREE_BUILD_TARGET}/install
HOST_ARCH=$(uname -s)-$(uname -m)

echo "Building for target: ${IREE_BUILD_TARGET}"
make ${NUM_JOBS} compile 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=${IREE_BUILD_TARGET}
build() {
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

if $2; then
export IREE_HOST_INSTALL_DIR=iree-runtime/host/install
fi

echo "Building for target: $1"
echo "IREE_HOST_INSTALL_DIR: ${IREE_HOST_INSTALL_DIR}"
make ${NUM_JOBS} compile \
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
}

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

build $IREE_BUILD_TARGET false

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

Expand Down

0 comments on commit 7ef3c61

Please sign in to comment.