• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
21# copy runtime to target out, and runtime/css-what is solt link, copy it always follow symbolic links in SOURCE
22if [ "${10}" == 'true' ];then
23  cp -R -L $2 $8
24else
25  cp -r -L $2 $8
26fi
27
28# $2 => node $4 => node_modules
29cp -f $4 $8
30
31if [ -d "$prebuilts_path" ]; then
32  echo "copy node_modules..."
33  if [ "${10}" == 'true' ];then
34    cp -R $3 $8
35  else
36    cp -r $3 $8
37  fi
38else
39  echo "download node_modules..."
40  npm install
41  cp -r ./node_modules ../../third_party/jsframework
42fi
43
44cp -f $5 $8
45cp -f $6 $8
46cp -f ${9} $8
47cp -f ${12} $8
48cp -r $7 $8
49if [ -d "$prebuilts_path" ]; then
50  echo "prebuilts exists"
51  # address problme of parallzing compile
52  rm -rf "$8/current"
53  link_path=$(realpath $1)
54  ln -s $link_path "$8/current"
55  cd $8
56  if [ "${10}" == 'true' ];then
57    ./current/bin/node build_strip_native_min.js || exit 1 &
58    # run unit test
59    ./current/bin/node node_modules/.bin/mocha -r ts-node/register test/lib.ts test/ut/**/*.ts test/ut/*.ts || exit 1 &
60    wait
61  else
62    ./current/bin/node build_strip_native_min.js || exit 1 &
63    # run unit test
64    ./current/bin/node node_modules/.bin/mocha -r ts-node/register test/lib.ts test/ut/**/*.ts test/ut/*.ts || exit 1&
65    wait
66  fi
67else
68  npm run build
69  # run unit test
70  npm run test:unit
71fi
72
73# after running, remove dependency file
74rm -rf ./node_modules
75if [ "${10}" == 'true' ];then
76  rm -rf ./current
77else
78  rm -rf ./current
79fi
80rm -rf ./runtime
81rm -rf ./tsconfig.json
82rm -rf build_strip_native_min.js
83rm -rf ./test
84rm -rf ./.eslintrc
85rm -rf ./.babelrc
86rm -rf ./package.json
87