Add --set-priority option in dotnettool
[platform/core/dotnet/launcher.git] / NativeLauncher / inc / ni_common.h
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef __NI_COMMON_H__
18 #define __NI_COMMON_H__
19
20 #include <functional>
21 #include <vector>
22 #include <string>
23 #include <cstdint>
24
25 #ifndef DWORD
26 #define DWORD uint32_t
27 #endif
28
29 /**
30  * Common flags passed to crossgen()
31 */
32 #define NI_FLAGS_APPNI                  0x0001
33 #define NI_FLAGS_VERBOSE                0x0002
34 #define NI_FLAGS_APP_UNDER_RO_AREA      0x0004
35 #define NI_FLAGS_INPUT_BUBBLE           0x0010
36 #define NI_FLAGS_INPUT_BUBBLE_REF       0x0020
37 #define NI_FLAGS_EXTRA_REF              0x0040
38 #define NI_FLAGS_NO_PIPELINE            0x0080
39 #define NI_FLAGS_MIBC                   0x0100
40 #define NI_FLAGS_PRINT_CMD              0x0200
41 #define NI_FLAGS_SKIP_RO_APP            0x0400
42 #define NI_FLAGS_RM_ORIGIN_AFTER_NI     0x0800
43 #define NI_FLAGS_SET_PRIORITY           0x1000
44
45 typedef std::function<void (std::string)> afterCreate;
46
47 typedef enum {
48         NI_ERROR_NONE = 0,
49         NI_ERROR_INVALID_PARAMETER = -1,
50         NI_ERROR_ALREADY_EXIST = -2,
51         NI_ERROR_NO_SUCH_FILE = -3,
52         NI_ERROR_INVALID_PACKAGE = -4,
53         NI_ERROR_NOT_SUPPORTED = -5,
54         NI_ERROR_CORE_NI_FILE = -6,
55         NI_ERROR_ABNORMAL_PROCESS_TERMINATION = -7,
56         NI_ERROR_UNKNOWN = -9
57 } ni_error_e;
58
59 typedef struct NIOption{
60         DWORD flags;
61         std::vector<std::string> refFiles;
62         std::vector<std::string> extraRefPath;
63         std::vector<std::string> inputBubbleRefFiles;
64         std::vector<std::string> mibcPath;
65         int priority;
66 } NIOption;
67
68 /**
69  * @brief get NIOption structure for setting
70  * @return NIOption*
71  */
72 NIOption* getNIOption();
73
74 /**
75  * @brief initialize NICommon
76  * @return ni_error_e 0 on success, otherwise a negative error value
77  */
78 ni_error_e initNICommon();
79
80 /**
81  * @brief finalize NICommon
82  * @details Before re-initialize NICommon, you have to finalize current NICommon first.
83  */
84 void finalizeNICommon();
85
86 /**
87  * @brief create native images for platform DLLs (.NETCore + TizenFX)
88  * @param[in] paths paths to directories which contains extra platform dlls
89  * @param[in] flags additional flags for the image generator
90  * @return ni_error_e
91  */
92 ni_error_e createNIPlatform(std::string& extraInputs, NIOption* opt);
93
94 /**
95  * @brief create a native image for a single DLL
96  * @param[in] dllPath path to input DLL
97  * @param[in] flags additional flags for the image generator
98  * @return ni_error_e
99  */
100 ni_error_e createNIDll(const std::string& dllPath, NIOption* opt);
101
102
103 /**
104  * @brief create native images for all DLLs under directories
105  * @param[in] rootPaths paths to directories
106  * @param[in] flags additional flags for the image generator
107  * @return ni_error_e
108  */
109 ni_error_e createNIUnderDirs(const std::string& rootPaths, NIOption* opt);
110
111 /**
112  * @brief create native images for all DLLs in a package
113  * @param[in] pkgId package ID
114  * @param[in] flags additional flags for the image generator
115  * @return ni_error_e
116  */
117 ni_error_e createNIUnderPkgRoot(const std::string& pkgId, NIOption* opt);
118
119 /**
120  * @brief remove platform native images (.NETCore + TizenFX)
121  */
122 void removeNIPlatform();
123
124 /**
125  * @brief remove native images under directories
126  * @param[in] rootPaths paths to directories
127  */
128 void removeNIUnderDirs(const std::string& rootPaths);
129
130 /**
131  * @brief remove native images of a package
132  * @param[in] pkgId package ID
133  * @return ni_error_e
134  */
135 ni_error_e removeNIUnderPkgRoot(const std::string& pkgId);
136
137 /**
138  * @brief regenerate native images of all installed applications
139  * @param[in] flags additional flags for the image generator
140  * @return ni_error_e
141  */
142 ni_error_e regenerateAppNI(NIOption* opt);
143
144 /**
145  * @brief regenerate native image of TAC for all shared assembly.
146  * @param[in] flags additional flags for the image generator
147  * @return ni_error_e
148  */
149 ni_error_e regenerateTACNI(NIOption* opt);
150
151 /**
152  * @brief Sets the priority of the process to the specified values from -20 to 19.(default : 0)
153  */
154 void setPriority(NIOption* opt);
155
156 #endif /* __NI_COMMON_H__ */