725ae7ccebc765337438edc3f282591a15c4f5cf
[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
24 #ifndef DWORD
25 #define DWORD uint32_t
26 #endif
27
28 /**
29  * Common flags passed to crossgen()
30 */
31 #define NI_FLAGS_APPNI                  0x0001
32 #define NI_FLAGS_VERBOSE                0x0002
33 #define NI_FLAGS_APP_UNDER_RO_AREA      0x0004
34 #define NI_FLAGS_INPUT_BUBBLE           0x0010
35 #define NI_FLAGS_INPUT_BUBBLE_REF       0x0020
36 #define NI_FLAGS_EXTRA_REF              0x0040
37 #define NI_FLAGS_NO_PIPELINE            0x0080
38 #define NI_FLAGS_MIBC                   0x0100
39 #define NI_FLAGS_PRINT_CMD              0x0200
40 #define NI_FLAGS_SKIP_RO_APP            0x0400
41
42 typedef std::function<void (std::string)> afterCreate;
43
44 typedef enum {
45         NI_ERROR_NONE = 0,
46         NI_ERROR_INVALID_PARAMETER = -1,
47         NI_ERROR_ALREADY_EXIST = -2,
48         NI_ERROR_NO_SUCH_FILE = -3,
49         NI_ERROR_INVALID_PACKAGE = -4,
50         NI_ERROR_NOT_SUPPORTED = -5,
51         NI_ERROR_CORE_NI_FILE = -6,
52         NI_ERROR_ABNORMAL_PROCESS_TERMINATION = -7,
53         NI_ERROR_UNKNOWN = -9
54 } ni_error_e;
55
56 typedef struct NIOption{
57         DWORD flags;
58         std::vector<std::string> refFiles;
59         std::vector<std::string> extraRefPath;
60         std::vector<std::string> inputBubbleRefFiles;
61         std::vector<std::string> mibcPath;
62 } NIOption;
63
64 /**
65  * @brief get NIOption structure for setting
66  * @return NIOption*
67  */
68 NIOption* getNIOption();
69
70 /**
71  * @brief initialize NICommon
72  * @return ni_error_e 0 on success, otherwise a negative error value
73  */
74 ni_error_e initNICommon();
75
76 /**
77  * @brief finalize NICommon
78  * @details Before re-initialize NICommon, you have to finalize current NICommon first.
79  */
80 void finalizeNICommon();
81
82 /**
83  * @brief create native images for platform DLLs (.NETCore + TizenFX)
84  * @param[in] paths paths to directories which contains extra platform dlls
85  * @param[in] flags additional flags for the image generator
86  * @return ni_error_e
87  */
88 ni_error_e createNIPlatform(std::string& extraInputs, NIOption* opt);
89
90 /**
91  * @brief create a native image for a single DLL
92  * @param[in] dllPath path to input DLL
93  * @param[in] flags additional flags for the image generator
94  * @return ni_error_e
95  */
96 ni_error_e createNIDll(const std::string& dllPath, NIOption* opt);
97
98
99 /**
100  * @brief create native images for all DLLs under directories
101  * @param[in] rootPaths paths to directories
102  * @param[in] flags additional flags for the image generator
103  * @return ni_error_e
104  */
105 ni_error_e createNIUnderDirs(const std::string& rootPaths, NIOption* opt);
106
107 /**
108  * @brief create native images for all DLLs in a package
109  * @param[in] pkgId package ID
110  * @param[in] flags additional flags for the image generator
111  * @return ni_error_e
112  */
113 ni_error_e createNIUnderPkgRoot(const std::string& pkgId, NIOption* opt);
114
115 /**
116  * @brief remove platform native images (.NETCore + TizenFX)
117  */
118 void removeNIPlatform();
119
120 /**
121  * @brief remove native images under directories
122  * @param[in] rootPaths paths to directories
123  */
124 void removeNIUnderDirs(const std::string& rootPaths);
125
126 /**
127  * @brief remove native images of a package
128  * @param[in] pkgId package ID
129  * @return ni_error_e
130  */
131 ni_error_e removeNIUnderPkgRoot(const std::string& pkgId);
132
133 /**
134  * @brief regenerate native images of all installed applications
135  * @param[in] flags additional flags for the image generator
136  * @return ni_error_e
137  */
138 ni_error_e regenerateAppNI(NIOption* opt);
139
140 /**
141  * @brief regenerate native image of TAC for all shared assembly.
142  * @param[in] flags additional flags for the image generator
143  * @return ni_error_e
144  */
145 ni_error_e regenerateTACNI(NIOption* opt);
146
147 #endif /* __NI_COMMON_H__ */