xref: /build/indep_configs/build_indep.sh (revision 5f9996aa)
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
15set -e
16echo $1 $2 $3
17TEST_FILTER=$3
18VARIANTS="default"
19if [ -n "$4" ]; then
20  VARIANTS=$4
21fi
22# keep the logs of hpm
23find out/$VARIANTS -type f -not -name '*.log' -delete
24rm -rf out/preloader/$VARIANTS
25rm -rf .gn
26
27mkdir -p out/preloader
28mkdir -p out/$VARIANTS/build_configs/parts_info
29cp -rf build/indep_configs/mapping/component_mapping.json out/$VARIANTS/build_configs
30ln -s build/indep_configs/dotfile.gn .gn
31
32export SOURCE_ROOT_DIR="$PWD"
33
34# set python3
35HOST_DIR="linux-x86"
36HOST_OS="linux"
37NODE_PLATFORM="linux-x64"
38
39PYTHON3_DIR=$(realpath ${SOURCE_ROOT_DIR}/prebuilts/python/${HOST_DIR}/*/ | tail -1)
40PYTHON3=${PYTHON3_DIR}/bin/python3
41PYTHON=${PYTHON3_DIR}/bin/python
42export PATH=${SOURCE_ROOT_DIR}/prebuilts/build-tools/${HOST_DIR}/bin:${PYTHON3_DIR}/bin:$PATH
43
44${PYTHON3} ${SOURCE_ROOT_DIR}/build/indep_configs/scripts/generate_components.py -hp $1 -sp $2 -v ${VARIANTS} -rp ${SOURCE_ROOT_DIR} -t ${TEST_FILTER}
45if [ -d "binarys/third_party/rust" ];then
46    echo "rust directory exists"
47    if [ -d "third_party/rust" ]; then
48        echo "third_party/rust exists"
49        cp -r binarys/third_party/rust/crates third_party/rust
50    else
51        mkdir -p "third_party/rust"
52        cp -r binarys/third_party/rust/crates third_party/rust
53    fi
54else
55    echo "rust directory exists"
56fi
57${PYTHON3} ${SOURCE_ROOT_DIR}/build/indep_configs/scripts/generate_target_build_gn.py -p $2 -rp ${SOURCE_ROOT_DIR} -t ${TEST_FILTER}
58${PYTHON3} ${SOURCE_ROOT_DIR}/build/indep_configs/scripts/variants_info_handler.py -rp ${SOURCE_ROOT_DIR} -v ${VARIANTS}
59# gn and ninja command
60${PYTHON3} ${SOURCE_ROOT_DIR}/build/indep_configs/scripts/gn_ninja_cmd.py -rp ${SOURCE_ROOT_DIR} -v ${VARIANTS}
61
62if [ $? -ne 0 ]; then
63  exit 1
64fi
65
66rm -rf .gn
67ln -s build/core/gn/dotfile.gn .gn
68
69exit 0
70