1e484b35bSopenharmony_ci#!/bin/bash
2e484b35bSopenharmony_ci# Copyright (c) 2021 Huawei Device Co., Ltd.
3e484b35bSopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License");
4e484b35bSopenharmony_ci# you may not use this file except in compliance with the License.
5e484b35bSopenharmony_ci# You may obtain a copy of the License at
6e484b35bSopenharmony_ci#
7e484b35bSopenharmony_ci#     http://www.apache.org/licenses/LICENSE-2.0
8e484b35bSopenharmony_ci#
9e484b35bSopenharmony_ci# Unless required by applicable law or agreed to in writing, software
10e484b35bSopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS,
11e484b35bSopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12e484b35bSopenharmony_ci# See the License for the specific language governing permissions and
13e484b35bSopenharmony_ci# limitations under the License.
14e484b35bSopenharmony_ci
15e484b35bSopenharmony_ciset -e
16e484b35bSopenharmony_ciecho "copy source code..."
17e484b35bSopenharmony_ciprebuilts_path=${11}
18e484b35bSopenharmony_ci# copy dependency file to generate dir of gn
19e484b35bSopenharmony_ci# the params come from .gn
20e484b35bSopenharmony_ci
21e484b35bSopenharmony_ci# copy runtime to target out, and runtime/css-what is solt link, copy it always follow symbolic links in SOURCE
22e484b35bSopenharmony_ciif [ "${10}" == 'true' ];then
23e484b35bSopenharmony_ci  cp -R -L $2 $8
24e484b35bSopenharmony_cielse
25e484b35bSopenharmony_ci  cp -r -L $2 $8
26e484b35bSopenharmony_cifi
27e484b35bSopenharmony_ci
28e484b35bSopenharmony_ci# $2 => node $4 => node_modules
29e484b35bSopenharmony_cicp -f $4 $8
30e484b35bSopenharmony_ci
31e484b35bSopenharmony_ciif [ -d "$prebuilts_path" ]; then
32e484b35bSopenharmony_ci  echo "copy node_modules..."
33e484b35bSopenharmony_ci  if [ "${10}" == 'true' ];then
34e484b35bSopenharmony_ci    cp -R $3 $8
35e484b35bSopenharmony_ci  else
36e484b35bSopenharmony_ci    cp -r $3 $8
37e484b35bSopenharmony_ci  fi
38e484b35bSopenharmony_cielse
39e484b35bSopenharmony_ci  echo "download node_modules..."
40e484b35bSopenharmony_ci  npm install
41e484b35bSopenharmony_ci  cp -r ./node_modules ../../third_party/jsframework
42e484b35bSopenharmony_cifi
43e484b35bSopenharmony_ci
44e484b35bSopenharmony_cicp -f $5 $8
45e484b35bSopenharmony_cicp -f $6 $8
46e484b35bSopenharmony_cicp -f ${9} $8
47e484b35bSopenharmony_cicp -f ${12} $8
48e484b35bSopenharmony_cicp -r $7 $8
49e484b35bSopenharmony_ciif [ -d "$prebuilts_path" ]; then
50e484b35bSopenharmony_ci  echo "prebuilts exists"
51e484b35bSopenharmony_ci  # address problme of parallzing compile
52e484b35bSopenharmony_ci  rm -rf "$8/current"
53e484b35bSopenharmony_ci  link_path=$(realpath $1)
54e484b35bSopenharmony_ci  ln -s $link_path "$8/current"
55e484b35bSopenharmony_ci  cd $8
56e484b35bSopenharmony_ci  if [ "${10}" == 'true' ];then
57e484b35bSopenharmony_ci    ./current/bin/node build_strip_native_min.js || exit 1 &
58e484b35bSopenharmony_ci    # run unit test
59e484b35bSopenharmony_ci    ./current/bin/node node_modules/.bin/mocha -r ts-node/register test/lib.ts test/ut/**/*.ts test/ut/*.ts || exit 1 &
60e484b35bSopenharmony_ci    wait
61e484b35bSopenharmony_ci  else
62e484b35bSopenharmony_ci    ./current/bin/node build_strip_native_min.js || exit 1 &
63e484b35bSopenharmony_ci    # run unit test
64e484b35bSopenharmony_ci    ./current/bin/node node_modules/.bin/mocha -r ts-node/register test/lib.ts test/ut/**/*.ts test/ut/*.ts || exit 1&
65e484b35bSopenharmony_ci    wait
66e484b35bSopenharmony_ci  fi
67e484b35bSopenharmony_cielse
68e484b35bSopenharmony_ci  npm run build
69e484b35bSopenharmony_ci  # run unit test
70e484b35bSopenharmony_ci  npm run test:unit
71e484b35bSopenharmony_cifi
72e484b35bSopenharmony_ci
73e484b35bSopenharmony_ci# after running, remove dependency file
74e484b35bSopenharmony_cirm -rf ./node_modules
75e484b35bSopenharmony_ciif [ "${10}" == 'true' ];then
76e484b35bSopenharmony_ci  rm -rf ./current
77e484b35bSopenharmony_cielse
78e484b35bSopenharmony_ci  rm -rf ./current
79e484b35bSopenharmony_cifi
80e484b35bSopenharmony_cirm -rf ./runtime
81e484b35bSopenharmony_cirm -rf ./tsconfig.json
82e484b35bSopenharmony_cirm -rf build_strip_native_min.js
83e484b35bSopenharmony_cirm -rf ./test
84e484b35bSopenharmony_cirm -rf ./.eslintrc
85e484b35bSopenharmony_cirm -rf ./.babelrc
86e484b35bSopenharmony_cirm -rf ./package.json
87