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