1# Copyright 2023 The Android Open Source Project 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15#!/bin/bash 16# 17# Setup repo directory. 18REPO=$(dirname "$0")/../../.. 19 20# Get the boolean flag from the user 21while getopts "b" flag; do 22 case $flag in 23 b) npm_build="true";; 24 *) echo "'-b' flag allows npm build to occur"; exit 1;; 25 esac 26done 27 28# Checks if objs directory exists 29if [ ! -d "$REPO/tools/netsim/objs" ]; then 30 echo "Please run bash scripts/cmake_setup.sh && ninja -C objs first" 31 exit 1 32fi 33 34# Refresh objs/netsim-ui directory 35if [ -d "$REPO/tools/netsim/objs/netsim-ui" ]; then 36 rm -r $REPO/tools/netsim/objs/netsim-ui 37fi 38 39# Create directory for netsim-ui 40mkdir $REPO/tools/netsim/objs/netsim-ui 41 42# If npm build flag is set, perform npm build 43if [[ $npm_build == "true" ]]; then 44 cd $REPO/tools/netsim/ui 45 npm run tsproto 46 npm run build 47 cd .. 48fi 49 50# Copy files from ui/dist into objs/netsim-ui 51cp -r $REPO/tools/netsim/ui/dist/* $REPO/tools/netsim/objs/netsim-ui/