• 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="../../prebuilts"
18# copy dependency file to generate dir of gn
19# the params come from .gn
20
21# $2 => node $4 => node_modules
22cp -r $3 $9
23cp -f $5 $9
24
25if [ -d "$prebuilts_path" ]; then
26  echo "copy node_modules..."
27  if [ "${11}" == 'true' ];then
28    cp -R $4 $9
29  else
30    cp -r $4 $9
31  fi
32else
33  echo "download node_modules..."
34  npm install
35  cp -r ./node_modules ../../third_party/jsframework
36fi
37
38cp -f $6 $9
39cp -f $7 $9
40cp -f ${10} $9
41cp -f $1 $9
42cp -r $8 $9
43
44if [ -d "$prebuilts_path" ]; then
45  echo "prebuilts exists"
46  # address problme of parallzing compile
47  rm -rf "$9/node-v12.18.4-linux-x64"
48  rm -rf "$9/node-v12.18.4-darwin-x64"
49  cp -r $2 $9
50  cd $9
51  if [ "${11}" == 'true' ];then
52    ./node-v12.18.4-darwin-x64/bin/node build.js
53    # run unit test
54    ./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
55  else
56    ./node-v12.18.4-linux-x64/bin/node build.js
57    # run unit test
58    ./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
59  fi
60else
61  npm run build
62  # run unit test
63  npm run test:unit
64fi
65
66# after running, remove dependency file
67rm -rf ./node_modules
68if [ "${11}" == 'true' ];then
69  rm -rf ./node-v12.18.4-darwin-x64
70else
71  rm -rf ./node-v12.18.4-linux-x64
72fi
73rm -rf ./runtime
74rm -rf ./tsconfig.json
75rm -rf ./build.js
76rm -rf ./test
77rm -rf ./.eslintrc
78rm -rf ./.babelrc
79rm -rf ./package.json
80