From db48e2ee3bc744babf93b6b5ef708dbda2523f49 Mon Sep 17 00:00:00 2001 From: Mehrdad Hessar Date: Tue, 7 Sep 2021 23:01:28 +0200 Subject: [PATCH] add platform to build directory (#8945) --- .../reference-vm/arduino/provision_setup.sh | 5 ++- apps/microtvm/reference-vm/rebuild-tvm.sh | 13 +++++- .../reference-vm/zephyr/provision_setup.sh | 5 ++- .../reference-vm/zephyr/rebuild-tvm.sh | 43 ------------------- tutorials/micro/micro_reference_vm.py | 4 +- 5 files changed, 20 insertions(+), 50 deletions(-) delete mode 100755 apps/microtvm/reference-vm/zephyr/rebuild-tvm.sh diff --git a/apps/microtvm/reference-vm/arduino/provision_setup.sh b/apps/microtvm/reference-vm/arduino/provision_setup.sh index aeb46a8f7649..1a24cbad9419 100644 --- a/apps/microtvm/reference-vm/arduino/provision_setup.sh +++ b/apps/microtvm/reference-vm/arduino/provision_setup.sh @@ -22,7 +22,8 @@ set -ex # NOTE: TVM is presumed to be mounted already by Vagrantfile. cd "${TVM_HOME}" -apps/microtvm/reference-vm/rebuild-tvm.sh +platform="arduino" +apps/microtvm/reference-vm/rebuild-tvm.sh ${platform} # Build poetry cd apps/microtvm/reference-vm/arduino @@ -43,6 +44,6 @@ echo "------------------------------[ TVM Message ]----------------------------- poetry lock -vvv poetry install -echo "export TVM_LIBRARY_PATH=\"$TVM_HOME\"/build-microtvm" >>~/.profile +echo "export TVM_LIBRARY_PATH=\"$TVM_HOME\"/build-microtvm-${platform}" >>~/.profile echo "VENV_PATH=\$((cd \"$TVM_HOME\"/apps/microtvm/reference-vm/arduino && poetry env list --full-path) | sed -E 's/^(.*)[[:space:]]\(Activated\)\$/\1/g')" >>~/.profile echo "source \$VENV_PATH/bin/activate" >>~/.profile diff --git a/apps/microtvm/reference-vm/rebuild-tvm.sh b/apps/microtvm/reference-vm/rebuild-tvm.sh index 1cebcf7166af..aca138d877b3 100755 --- a/apps/microtvm/reference-vm/rebuild-tvm.sh +++ b/apps/microtvm/reference-vm/rebuild-tvm.sh @@ -15,9 +15,20 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. +# +# "Usage ./apps/microtvm/reference-vm/rebuild-tvm.sh " +# set -e +if [ "$#" -lt 1 -o "$1" == "--help" ]; then + echo "Usage ./apps/microtvm/reference-vm/rebuild-tvm.sh " + exit -1 +fi + +platform=$1 +shift 1 + # Get number of cores for build if [ -n "${TVM_CI_NUM_CORES}" ]; then num_cores=${TVM_CI_NUM_CORES} @@ -28,7 +39,7 @@ fi cd "$(dirname $0)" cd "$(git rev-parse --show-toplevel)" -BUILD_DIR=build-microtvm +BUILD_DIR="build-microtvm-${platform}" if [ ! -e "${BUILD_DIR}" ]; then mkdir "${BUILD_DIR}" diff --git a/apps/microtvm/reference-vm/zephyr/provision_setup.sh b/apps/microtvm/reference-vm/zephyr/provision_setup.sh index 2ee2350b377a..e1f3bef75508 100644 --- a/apps/microtvm/reference-vm/zephyr/provision_setup.sh +++ b/apps/microtvm/reference-vm/zephyr/provision_setup.sh @@ -22,7 +22,8 @@ set -ex # NOTE: TVM is presumed to be mounted already by Vagrantfile. cd "${TVM_HOME}" -apps/microtvm/reference-vm/rebuild-tvm.sh +platform="zephyr" +apps/microtvm/reference-vm/rebuild-tvm.sh ${platform} # Build poetry cd apps/microtvm/reference-vm/zephyr @@ -44,7 +45,7 @@ poetry lock -vvv poetry install poetry run pip3 install -r ${ZEPHYR_BASE}/scripts/requirements.txt -echo "export TVM_LIBRARY_PATH=\"$TVM_HOME\"/build-microtvm" >>~/.profile +echo "export TVM_LIBRARY_PATH=\"$TVM_HOME\"/build-microtvm-${platform}" >>~/.profile echo "VENV_PATH=\$((cd \"$TVM_HOME\"/apps/microtvm/reference-vm/zephyr && poetry env list --full-path) | sed -E 's/^(.*)[[:space:]]\(Activated\)\$/\1/g')" >>~/.profile echo "source \$VENV_PATH/bin/activate" >>~/.profile echo "export PATH=\"\${PATH}:\${HOME}/zephyr-sdk/sysroots/x86_64-pokysdk-linux/usr/bin\"" >>~/.profile diff --git a/apps/microtvm/reference-vm/zephyr/rebuild-tvm.sh b/apps/microtvm/reference-vm/zephyr/rebuild-tvm.sh deleted file mode 100755 index a4c659438d4d..000000000000 --- a/apps/microtvm/reference-vm/zephyr/rebuild-tvm.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash -e -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -set -e - -# Get number of cores for build -if [ -n "${TVM_CI_NUM_CORES}" ]; then - num_cores=${TVM_CI_NUM_CORES} -else - # default setup for Vagrantfile - num_cores=2 -fi - -cd "$(dirname $0)" -cd "$(git rev-parse --show-toplevel)" -BUILD_DIR=build-microtvm - -if [ ! -e "${BUILD_DIR}" ]; then - mkdir "${BUILD_DIR}" -fi -cp cmake/config.cmake "${BUILD_DIR}" -cd "${BUILD_DIR}" -sed -i 's/USE_MICRO OFF/USE_MICRO ON/' config.cmake -sed -i 's/USE_PROFILER OFF/USE_PROFILER ON/' config.cmake -sed -i 's/USE_LLVM OFF/USE_LLVM ON/' config.cmake -cmake .. -rm -rf standalone_crt host_standalone_crt # remove stale generated files -make -j${num_cores} diff --git a/tutorials/micro/micro_reference_vm.py b/tutorials/micro/micro_reference_vm.py index bb262893eb6b..e2b75ea42a1f 100644 --- a/tutorials/micro/micro_reference_vm.py +++ b/tutorials/micro/micro_reference_vm.py @@ -111,13 +111,13 @@ Rebuilding TVM inside the Reference VM -------------------------------------- -After the first boot, you'll need to ensure you keep the build, in ``$TVM_HOME/build-microtvm``, +After the first boot, you'll need to ensure you keep the build, in ``$TVM_HOME/build-microtvm-zephyr``, up-to-date when you modify the C++ runtime or checkout a different revision. You can either re-provision the machine (``vagrant provision`` in the same directory you ran ``vagrant up`` before) or manually rebuild TVM yourself. Remember: the TVM ``.so`` built inside the VM is different from the one you may use on your host -machine. This is why it's built inside the special directory ``build-microtvm``. +machine. This is why it's built inside the special directory ``build-microtvm-zephyr``. Logging in to the VM --------------------