Modified to support crossgen2 (#330)
[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_USE_CROSSGEN2          0x0100
35 #define NI_FLAGS_INPUT_BUBBLE           0x0200
36 #define NI_FLAGS_INPUT_BUBBLE_REF       0x0400
37 #define NI_FLAGS_NO_PIPELINE            0x0800
38 #define NI_FLAGS_INSTRUMENT             0x1000
39
40 typedef std::function<void (std::string)> afterCreate;
41
42 typedef enum {
43         NI_ERROR_NONE = 0,
44         NI_ERROR_INVALID_PARAMETER = -1,
45         NI_ERROR_ALREADY_EXIST = -2,
46         NI_ERROR_NO_SUCH_FILE = -3,
47         NI_ERROR_INVALID_PACKAGE = -4,
48         NI_ERROR_NOT_SUPPORTED = -5,
49         NI_ERROR_CORE_NI_FILE = -6,
50         NI_ERROR_UNKNOWN = -9
51 } ni_error_e;
52
53 /**
54  * @brief initialize NICommon
55  * @return ni_error_e 0 on success, otherwise a negative error value
56  */
57 ni_error_e initNICommon();
58
59 /**
60  * @brief finalize NICommon
61  * @details Before re-initialize NICommon, you have to finalize current NICommon first.
62  */
63 void finalizeNICommon();
64
65 /**
66  * @brief create native images for platform DLLs (.NETCore + TizenFX)
67  * @param[in] flags additional flags for the image generator
68  * @return ni_error_e
69  */
70 ni_error_e createNIPlatform(DWORD flags);
71
72 /**
73  * @brief create a native image for a single DLL
74  * @param[in] dllPath path to input DLL
75  * @param[in] flags additional flags for the image generator
76  * @return ni_error_e
77  */
78 ni_error_e createNIDll(const std::string& dllPath, DWORD flags);
79
80
81 /**
82  * @brief create native images for all DLLs under directories
83  * @param[in] rootPaths paths to directories
84  * @param[in] flags additional flags for the image generator
85  * @return ni_error_e
86  */
87 ni_error_e createNIUnderDirs(const std::string& rootPaths, DWORD flags);
88
89 /**
90  * @brief create native images for all DLLs in a package
91  * @param[in] pkgId package ID
92  * @param[in] flags additional flags for the image generator
93  * @return ni_error_e
94  */
95 ni_error_e createNIUnderPkgRoot(const std::string& pkgId, DWORD flags);
96
97 /**
98  * @brief remove platform native images (.NETCore + TizenFX)
99  */
100 void removeNIPlatform();
101
102 /**
103  * @brief remove native images under directories
104  * @param[in] rootPaths paths to directories
105  */
106 void removeNIUnderDirs(const std::string& rootPaths);
107
108 /**
109  * @brief remove native images of a package
110  * @param[in] pkgId package ID
111  * @return ni_error_e
112  */
113 ni_error_e removeNIUnderPkgRoot(const std::string& pkgId);
114
115 /**
116  * @brief regenerate native images of all installed applications
117  * @param[in] flags additional flags for the image generator
118  * @return ni_error_e
119  */
120 ni_error_e regenerateAppNI(DWORD flags);
121
122 /**
123  * @brief regenerate native image of TAC for all shared assembly.
124  * @param[in] flags additional flags for the image generator
125  * @return ni_error_e
126  */
127 ni_error_e regenerateTACNI(DWORD flags);
128
129 /**
130  * @brief remove app profile data of a package
131  * @param[in] pkgId package ID
132  * @return ni_error_e
133  */
134 ni_error_e removeAppProfileData(const std::string& pkgId);
135
136 /**
137  * @brief remove all app profile data
138  */
139 void removeAllAppProfileData();
140
141 #endif /* __NI_COMMON_H__ */