15f9996aaSopenharmony_ci#!/usr/bin/env python3
25f9996aaSopenharmony_ci# -*- coding: utf-8 -*-
35f9996aaSopenharmony_ci
45f9996aaSopenharmony_ci#
55f9996aaSopenharmony_ci# Copyright (c) 2023 Huawei Device Co., Ltd.
65f9996aaSopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License");
75f9996aaSopenharmony_ci# you may not use this file except in compliance with the License.
85f9996aaSopenharmony_ci# You may obtain a copy of the License at
95f9996aaSopenharmony_ci#
105f9996aaSopenharmony_ci#     http://www.apache.org/licenses/LICENSE-2.0
115f9996aaSopenharmony_ci#
125f9996aaSopenharmony_ci# Unless required by applicable law or agreed to in writing, software
135f9996aaSopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS,
145f9996aaSopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
155f9996aaSopenharmony_ci# See the License for the specific language governing permissions and
165f9996aaSopenharmony_ci# limitations under the License.
175f9996aaSopenharmony_ci
185f9996aaSopenharmony_cifrom abc import abstractmethod
195f9996aaSopenharmony_cifrom services.interface.service_interface import ServiceInterface
205f9996aaSopenharmony_cifrom resources.config import Config
215f9996aaSopenharmony_cifrom util.log_util import LogUtil
225f9996aaSopenharmony_ci
235f9996aaSopenharmony_ci
245f9996aaSopenharmony_ciclass PreloadInterface(ServiceInterface):
255f9996aaSopenharmony_ci
265f9996aaSopenharmony_ci    def __init__(self):
275f9996aaSopenharmony_ci        super().__init__()
285f9996aaSopenharmony_ci        self._config = Config()
295f9996aaSopenharmony_ci
305f9996aaSopenharmony_ci    @abstractmethod
315f9996aaSopenharmony_ci    def __post_init__(self):
325f9996aaSopenharmony_ci        pass
335f9996aaSopenharmony_ci
345f9996aaSopenharmony_ci    @property
355f9996aaSopenharmony_ci    def outputs(self):
365f9996aaSopenharmony_ci        return self._preloader_outputs
375f9996aaSopenharmony_ci
385f9996aaSopenharmony_ci    @property
395f9996aaSopenharmony_ci    def config(self):
405f9996aaSopenharmony_ci        return self._config
415f9996aaSopenharmony_ci
425f9996aaSopenharmony_ci    def regist_arg(self, arg_name: str, arg_value: str):
435f9996aaSopenharmony_ci        if arg_name in self._args_dict.keys() and self._args_dict[arg_name] != arg_value:
445f9996aaSopenharmony_ci            LogUtil.hb_warning('duplicated regist arg {}, the original value "{}" will be replace to "{}"'.format(
455f9996aaSopenharmony_ci                arg_name, self._args_dict[arg_name], arg_value))
465f9996aaSopenharmony_ci
475f9996aaSopenharmony_ci        self._args_dict[arg_name] = arg_value
485f9996aaSopenharmony_ci
495f9996aaSopenharmony_ci    def run(self):
505f9996aaSopenharmony_ci        self.__post_init__()
515f9996aaSopenharmony_ci        self._generate_build_prop()
525f9996aaSopenharmony_ci        self._generate_build_config_json()
535f9996aaSopenharmony_ci        self._generate_parts_json()
545f9996aaSopenharmony_ci        self._generate_parts_config_json()
555f9996aaSopenharmony_ci        self._generate_build_gnargs_prop()
565f9996aaSopenharmony_ci        self._generate_features_json()
575f9996aaSopenharmony_ci        self._generate_syscap_json()
585f9996aaSopenharmony_ci        self._generate_exclusion_modules_json()
595f9996aaSopenharmony_ci        self._generate_platforms_build()
605f9996aaSopenharmony_ci        self._generate_subsystem_config_json()
615f9996aaSopenharmony_ci        self._generate_systemcapability_json()
625f9996aaSopenharmony_ci        self._generate_compile_standard_whitelist_json()
635f9996aaSopenharmony_ci        self._generate_compile_env_allowlist_json()
645f9996aaSopenharmony_ci
655f9996aaSopenharmony_ci    @abstractmethod
665f9996aaSopenharmony_ci    def _generate_build_prop(self):
675f9996aaSopenharmony_ci        pass
685f9996aaSopenharmony_ci
695f9996aaSopenharmony_ci    @abstractmethod
705f9996aaSopenharmony_ci    def _generate_build_config_json(self):
715f9996aaSopenharmony_ci        pass
725f9996aaSopenharmony_ci
735f9996aaSopenharmony_ci    @abstractmethod
745f9996aaSopenharmony_ci    def _generate_parts_json(self):
755f9996aaSopenharmony_ci        pass
765f9996aaSopenharmony_ci
775f9996aaSopenharmony_ci    @abstractmethod
785f9996aaSopenharmony_ci    def _generate_parts_config_json(self):
795f9996aaSopenharmony_ci        pass
805f9996aaSopenharmony_ci
815f9996aaSopenharmony_ci    @abstractmethod
825f9996aaSopenharmony_ci    def _generate_build_gnargs_prop(self):
835f9996aaSopenharmony_ci        pass
845f9996aaSopenharmony_ci
855f9996aaSopenharmony_ci    @abstractmethod
865f9996aaSopenharmony_ci    def _generate_features_json(self):
875f9996aaSopenharmony_ci        pass
885f9996aaSopenharmony_ci
895f9996aaSopenharmony_ci    @abstractmethod
905f9996aaSopenharmony_ci    def _generate_syscap_json(self):
915f9996aaSopenharmony_ci        pass
925f9996aaSopenharmony_ci
935f9996aaSopenharmony_ci    @abstractmethod
945f9996aaSopenharmony_ci    def _generate_exclusion_modules_json(self):
955f9996aaSopenharmony_ci        pass
965f9996aaSopenharmony_ci
975f9996aaSopenharmony_ci    @abstractmethod
985f9996aaSopenharmony_ci    def _generate_platforms_build(self):
995f9996aaSopenharmony_ci        pass
1005f9996aaSopenharmony_ci
1015f9996aaSopenharmony_ci    @abstractmethod
1025f9996aaSopenharmony_ci    def _generate_subsystem_config_json(self):
1035f9996aaSopenharmony_ci        pass
1045f9996aaSopenharmony_ci
1055f9996aaSopenharmony_ci    @abstractmethod
1065f9996aaSopenharmony_ci    def _generate_systemcapability_json(self):
1075f9996aaSopenharmony_ci        pass
1085f9996aaSopenharmony_ci
1095f9996aaSopenharmony_ci    @abstractmethod
1105f9996aaSopenharmony_ci    def _generate_compile_standard_whitelist_json(self):
1115f9996aaSopenharmony_ci        pass
1125f9996aaSopenharmony_ci
1135f9996aaSopenharmony_ci    @abstractmethod
1145f9996aaSopenharmony_ci    def _generate_compile_env_allowlist_json(self):
1155f9996aaSopenharmony_ci        pass
116