1#!/bin/bash 2# Copyright (c) 2021 Huawei Device Co., Ltd. 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 15set -e 16echo "copy source code..." 17prebuilts_path=${11} 18# copy dependency file to generate dir of gn 19# the params come from .gn 20 21if [ "${14}" == 'true' ];then 22 rm -rf $2/src 23fi 24 25# copy runtime to target out, and runtime/css-what is solt link, copy it always follow symbolic links in SOURCE 26if [ "${10}" == 'true' ];then 27 cp -R -L $2 $8 28else 29 cp -r -L $2 $8 30fi 31 32if [ "${14}" == 'true' ];then 33 cp -r -L ${13} obj/third_party/jsframework/runtime 34fi 35 36# $2 => node $4 => node_modules 37cp -f $4 $8 38 39if [ -d "$prebuilts_path" ]; then 40 echo "copy node_modules..." 41 if [ "${10}" == 'true' ];then 42 cp -R $3 $8 43 else 44 cp -r $3 $8 45 fi 46else 47 echo "download node_modules..." 48 npm install 49 cp -r ./node_modules ../../third_party/jsframework 50fi 51 52cp -f $5 $8 53cp -f $6 $8 54cp -f ${9} $8 55cp -f ${12} $8 56cp -r $7 $8 57if [ -d "$prebuilts_path" ]; then 58 echo "prebuilts exists" 59 # address problme of parallzing compile 60 rm -rf "$8/current" 61 link_path=$(realpath $1) 62 ln -s $link_path "$8/current" 63 cd $8 64 if [ "${10}" == 'true' ];then 65 ./current/bin/node build_strip_native_min.js || exit 1 & 66 # run unit test 67 ./current/bin/node node_modules/.bin/mocha -r ts-node/register test/lib.ts test/ut/**/*.ts test/ut/*.ts || exit 1 & 68 wait 69 else 70 ./current/bin/node build_strip_native_min.js || exit 1 & 71 # run unit test 72 ./current/bin/node node_modules/.bin/mocha -r ts-node/register test/lib.ts test/ut/**/*.ts test/ut/*.ts || exit 1& 73 wait 74 fi 75else 76 npm run build 77 # run unit test 78 npm run test:unit 79fi 80 81# after running, remove dependency file 82rm -rf ./node_modules 83if [ "${10}" == 'true' ];then 84 rm -rf ./current 85else 86 rm -rf ./current 87fi 88rm -rf ./runtime 89rm -rf ./tsconfig.json 90rm -rf build_strip_native_min.js 91rm -rf ./test 92rm -rf ./.eslintrc 93rm -rf ./.babelrc 94rm -rf ./package.json 95