79709635388d50432f54f86c6f1dc6d9241f3ece
[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
22 #ifndef DWORD
23 #define DWORD uint32_t
24 #endif
25
26 /**
27  * Common flags passed to crossgen()
28 */
29 #define NI_FLAGS_ENABLER2R              0x0001
30 #define NI_FLAGS_APPNI                  0x0002
31 #define NI_FLAGS_COMPATIBILITY          0x0004
32 #define NI_FLAGS_VERBOSE                0x0008
33 #define NI_FLAGS_APP_UNDER_RO_AREA      0x0010
34 #define NI_FLAGS_INSTRUMENT             0x1000
35
36 typedef std::function<void (std::string)> afterCreate;
37
38 typedef enum {
39         NI_ERROR_NONE = 0,
40         NI_ERROR_INVALID_PARAMETER = -1,
41         NI_ERROR_ALREADY_EXIST = -2,
42         NI_ERROR_NO_SUCH_FILE = -3,
43         NI_ERROR_INVALID_PACKAGE = -4,
44         NI_ERROR_NOT_SUPPORTED = -5,
45         NI_ERROR_CORE_NI_FILE = -6,
46         NI_ERROR_UNKNOWN = -9
47 } ni_error_e;
48
49 /**
50  * @brief initialize NICommon
51  * @return ni_error_e 0 on success, otherwise a negative error value
52  */
53 ni_error_e initNICommon();
54
55 /**
56  * @brief finalize NICommon
57  * @details Before re-initialize NICommon, you have to finalize current NICommon first.
58  */
59 void finalizeNICommon();
60
61 /**
62  * @brief create native images for platform DLLs (.NETCore + TizenFX)
63  * @param[in] flags additional flags for the image generator
64  * @return ni_error_e
65  */
66 ni_error_e createNIPlatform(DWORD flags);
67
68 /**
69  * @brief create a native image for a single DLL
70  * @param[in] dllPath path to input DLL
71  * @param[in] flags additional flags for the image generator
72  * @return ni_error_e
73  */
74 ni_error_e createNIDll(const std::string& dllPath, DWORD flags);
75
76
77 /**
78  * @brief create native images for all DLLs under directories
79  * @param[in] rootPaths paths to directories
80  * @param[in] flags additional flags for the image generator
81  * @return ni_error_e
82  */
83 ni_error_e createNIUnderDirs(const std::string& rootPaths, DWORD flags);
84
85 /**
86  * @brief create native images for all DLLs in a package
87  * @param[in] pkgId package ID
88  * @param[in] flags additional flags for the image generator
89  * @return ni_error_e
90  */
91 ni_error_e createNIUnderPkgRoot(const std::string& pkgId, DWORD flags);
92
93 /**
94  * @brief remove platform native images (.NETCore + TizenFX)
95  */
96 void removeNIPlatform();
97
98 /**
99  * @brief remove native images under directories
100  * @param[in] rootPaths paths to directories
101  */
102 void removeNIUnderDirs(const std::string& rootPaths);
103
104 /**
105  * @brief remove native images of a package
106  * @param[in] pkgId package ID
107  * @return ni_error_e
108  */
109 ni_error_e removeNIUnderPkgRoot(const std::string& pkgId);
110
111 /**
112  * @brief regenerate native images of all installed applications
113  * @param[in] flags additional flags for the image generator
114  * @return ni_error_e
115  */
116 ni_error_e regenerateAppNI(DWORD flags);
117
118 /**
119  * @brief regenerate native image of TAC for all shared assembly.
120  * @param[in] flags additional flags for the image generator
121  * @return ni_error_e
122  */
123 ni_error_e regenerateTACNI(DWORD flags);
124
125 #endif /* __NI_COMMON_H__ */