• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 
16 #ifndef OHOS_ARKCOMPILER_AOTCOMPILER_CONSTANTS_H
17 #define OHOS_ARKCOMPILER_AOTCOMPILER_CONSTANTS_H
18 
19 #include <string>
20 #include <sys/types.h>
21 #include <unordered_map>
22 
23 #include "aot_compiler_error_utils.h"
24 
25 namespace OHOS::ArkCompiler {
26 namespace ArgsIdx {
27 const std::string BUNDLE_UID = "BundleUid";
28 const std::string BUNDLE_GID = "BundleGid";
29 const std::string AN_FILE_NAME = "anFileName";
30 const std::string APP_SIGNATURE = "appIdentifier";
31 const std::string ABC_PATH = "ABC-Path";
32 const std::string TARGET_COMPILER_MODE = "target-compiler-mode";
33 const std::string COMPILER_PKG_INFO = "compiler-pkg-info";
34 const std::string COMPILER_ENABLE_AOT_CODE_COMMENT = "compiler-enable-aot-code-comment";
35 const std::string COMPILER_LOG_OPT = "compiler-log";
36 const std::string COMPILER_AN_FILE_MAX_SIZE = "compiler-an-file-max-size";
37 const std::string AOT_FILE = "aot-file";
38 const std::string IS_SYSTEM_COMPONENT = "isSysComp";
39 
40 
41 const std::string ARKTS_MODE = "moduleArkTSMode";
42 } // namespace ArgsIdx
43 
44 // UID and GID of system users
45 constexpr uid_t OID_SYSTEM = 1000;
46 
47 constexpr const char* BOOLEAN_FALSE = "0";
48 
49 namespace Symbols {
50 constexpr const char* PREFIX = "--";
51 constexpr const char* EQ = "=";
52 } // namespace Symbols
53 
54 /**
55  * @param RetStatusOfCompiler return code of ark_aot_compiler
56  * @attention it must sync with ErrCode of "ets_runtime/ecmascript/aot_compiler.cpp"
57  */
58 enum class RetStatusOfCompiler {
59     ERR_OK = (0),   // IMPORTANT: Only if aot compiler SUCCESS and save an/ai SUCCESS, return ERR_OK.
60     ERR_FAIL = (-1),
61     ERR_HELP = (1),
62     ERR_NO_AP = (2),
63     ERR_MERGE_AP = (3),
64     ERR_CHECK_VERSION = (4),
65     ERR_AN_EMPTY = (5),
66     ERR_AN_FAIL = (6),
67     ERR_AI_FAIL = (7),
68 };
69 
70 struct InfoOfCompiler {
71     int32_t retCode { -1 };
72     std::string mesg;
73 };
74 
75 const std::unordered_map<int, InfoOfCompiler> RetInfoOfCompiler {
76     {static_cast<int>(RetStatusOfCompiler::ERR_OK), {ERR_OK, "AOT compiler success"}},
77     {static_cast<int>(RetStatusOfCompiler::ERR_NO_AP), {ERR_OK_NO_AOT_FILE, "AOT compiler not run: no ap file"}},
78     {static_cast<int>(RetStatusOfCompiler::ERR_CHECK_VERSION),
79         {ERR_OK_NO_AOT_FILE, "AOT compiler not run: check version"}},
80     {static_cast<int>(RetStatusOfCompiler::ERR_MERGE_AP),
81         {ERR_AOT_COMPILER_CALL_FAILED, "AOT compiler fail: merge ap error"}},
82     {static_cast<int>(RetStatusOfCompiler::ERR_AN_EMPTY),
83         {ERR_AOT_COMPILER_CALL_FAILED, "AOT compiler fail: empty an file"}},
84     {static_cast<int>(RetStatusOfCompiler::ERR_AN_FAIL),
85         {ERR_AOT_COMPILER_CALL_FAILED, "AOT compiler fail: save an error"}},
86     {static_cast<int>(RetStatusOfCompiler::ERR_AI_FAIL),
87         {ERR_AOT_COMPILER_CALL_FAILED, "AOT compiler fail: save ai error"}},
88 };
89 
90 const InfoOfCompiler OtherInfoOfCompiler = {ERR_AOT_COMPILER_CALL_FAILED, "AOT compiler fail: other error"};
91 } // namespace OHOS::ArkCompiler
92 #endif
93