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
22rm -rf out
23rm -rf .gn
24
25mkdir -p out/$VARIANTS
26mkdir -p out/preloader
27mkdir -p out/$VARIANTS/build_configs/parts_info
28cp -rf build/indep_configs/mapping/component_mapping.json out/$VARIANTS/build_configs
29ln -s build/indep_configs/dotfile.gn .gn
30
31export SOURCE_ROOT_DIR="$PWD"
32
33# set python3
34HOST_DIR="linux-x86"
35HOST_OS="linux"
36NODE_PLATFORM="linux-x64"
37
38PYTHON3_DIR=${SOURCE_ROOT_DIR}/prebuilts/python/${HOST_DIR}/current/
39PYTHON3=${PYTHON3_DIR}/bin/python3
40PYTHON=${PYTHON3_DIR}/bin/python
41export PATH=${SOURCE_ROOT_DIR}/prebuilts/build-tools/${HOST_DIR}/bin:${PYTHON3_DIR}/bin:$PATH
42
43${PYTHON3} ${SOURCE_ROOT_DIR}/build/indep_configs/scripts/generate_components.py -hp $1 -sp $2 -v ${VARIANTS} -rp ${SOURCE_ROOT_DIR}
44${PYTHON3} ${SOURCE_ROOT_DIR}/build/indep_configs/scripts/generate_target_build_gn.py -p $2 -rp ${SOURCE_ROOT_DIR} -t ${TEST_FILTER}
45${PYTHON3} ${SOURCE_ROOT_DIR}/build/indep_configs/scripts/variants_info_handler.py -rp ${SOURCE_ROOT_DIR} -v ${VARIANTS}
46${PYTHON3} ${SOURCE_ROOT_DIR}/build/indep_configs/scripts/gn_ninja_cmd.py -rp ${SOURCE_ROOT_DIR} -v ${VARIANTS}
47
48rm -rf .gn
49ln -s build/core/gn/dotfile.gn .gn
50
51exit 0
52