• 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=${12}
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 [ "${11}" == 'true' ];then
23  cp -R -L $3 $9
24  cp -R ${15} $9
25else
26  cp -r -L $3 $9
27  cp -r ${15} $9
28fi
29
30# $2 => node $4 => node_modules
31cp -f $5 $9
32
33if [ -d "$prebuilts_path" ]; then
34  echo "copy node_modules..."
35  if [ "${11}" == 'true' ];then
36    cp -R $4 $9
37  else
38    cp -r $4 $9
39  fi
40else
41  echo "download node_modules..."
42  npm install
43  cp -r ./node_modules ../../third_party/jsframework
44fi
45
46cp -f $6 $9
47cp -f $7 $9
48cp -f ${10} $9
49cp -f $1 $9
50cp -f ${13} $9
51cp -r $8 $9
52if [ -d "$prebuilts_path" ]; then
53  echo "prebuilts exists"
54  # address problme of parallzing compile
55  rm -rf "$9/node-v12.18.4-linux-x64"
56  rm -rf "$9/node-v12.18.4-darwin-x64"
57  cp -r $2 $9
58  cd $9
59  if [ "${11}" == 'true' ];then
60    ./node-v12.18.4-darwin-x64/bin/node ./mock-generate/build.js
61    ./node-v12.18.4-darwin-x64/bin/node build_jsmock_system_plugin.js || exit 1 &
62    ./node-v12.18.4-darwin-x64/bin/node build_strip_native_min.js || exit 1 &
63    # run unit test
64    ./node-v12.18.4-darwin-x64/bin/node node_modules/.bin/mocha -r ts-node/register test/lib.ts test/ut/**/*.ts test/ut/*.ts || exit 1 &
65    wait
66  else
67    ./node-v12.18.4-linux-x64/bin/node ./mock-generate/build.js
68    ./node-v12.18.4-linux-x64/bin/node build_jsmock_system_plugin.js || exit 1 &
69    ./node-v12.18.4-linux-x64/bin/node build_strip_native_min.js || exit 1 &
70    # run unit test
71    ./node-v12.18.4-linux-x64/bin/node node_modules/.bin/mocha -r ts-node/register test/lib.ts test/ut/**/*.ts test/ut/*.ts || exit 1&
72    wait
73  fi
74else
75  npm run build
76  # run unit test
77  npm run test:unit
78fi
79
80# after running, remove dependency file
81rm -rf ./node_modules
82if [ "${11}" == 'true' ];then
83  rm -rf ./node-v12.18.4-darwin-x64
84else
85  rm -rf ./node-v12.18.4-linux-x64
86fi
87rm -rf ./runtime
88rm -rf ./tsconfig.json
89rm -rf build_jsmock_system_plugin.js
90rm -rf build_strip_native_min.js
91rm -rf ./test
92rm -rf ./.eslintrc
93rm -rf ./.babelrc
94rm -rf ./package.json
95rm -rf ./mock-generate
96