• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2# Copyright (c) 2024 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
15# Install typescript from third_party/typescript
16# Must run this script in arkguard root directory.
17
18set -e
19
20if [ ! -d "../compiler" ]; then
21    echo "Error: must run this script in ace_ets2bundle/compier root directory"
22    exit 1
23fi
24
25TYPESCRIPT_ROOT_DIR="../../../third_party/typescript"
26ARKGUARD_ROOT_DIR="../../../arkcompiler/ets_frontend/arkguard"
27old_work_dir=$(pwd)
28
29# Step 1: build arkguard
30echo "-----------------------------start building arkguard-----------------------------"
31cd $ARKGUARD_ROOT_DIR
32npm install
33./scripts/install_tsc.sh
34npm run build
35package_name=$(npm pack | grep "arkguard-1")
36echo $package_name
37tar -xvf $package_name
38current_dir=$(pwd)
39package_path="$current_dir/package"
40echo "-----------------------------end building arkguard-----------------------------"
41
42cd $old_work_dir
43target_dir=./node_modules/arkguard
44
45echo "move $package_path to override $target_dir"
46if [ -d "$target_dir" ]; then
47    rm -r $target_dir
48fi
49
50mv $package_path $target_dir
51
52# Step 2: build typescript
53echo "-----------------------------start building typescript-----------------------------"
54cd $TYPESCRIPT_ROOT_DIR
55npm install
56npm run build
57package_name=$(npm pack | grep "ohos-typescript")
58echo $package_name
59tar -xvf $package_name
60current_dir=$(pwd)
61tsc_package_path="$current_dir/package"
62echo "-----------------------------end building typescript-----------------------------"
63
64cd $old_work_dir
65target_dir=./node_modules/typescript
66
67echo "move $tsc_package_path to override $target_dir"
68if [ -d "$target_dir" ]; then
69    rm -r $target_dir
70fi
71
72mv $tsc_package_path $target_dir
73