Refactoring the dotnettool (#231)
[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_INSTRUMENT             0x1000
34
35 typedef std::function<void (std::string)> afterCreate;
36
37 typedef enum {
38         NI_ERROR_NONE = 0,
39         NI_ERROR_INVALID_PARAMETER = -1,
40         NI_ERROR_ALREADY_EXIST = -2,
41         NI_ERROR_NO_SUCH_FILE = -3,
42         NI_ERROR_INVALID_PACKAGE = -4,
43         NI_ERROR_NOT_SUPPORTED = -5,
44         NI_ERROR_CORE_NI_FILE = -6,
45         NI_ERROR_UNKNOWN = -9
46 } ni_error_e;
47
48 /**
49  * @brief : structure which contains base directory info
50  */
51 typedef struct NiCommonOption {
52         std::string runtimeDir; /**< .NETCore Runtime directory */
53         std::string tizenFXDir; /**< TizenFX directory */
54         std::string extraDirs; /**< ":" seperated directories which can be set by plugins */
55 } NiCommonOption;
56
57 /**
58  * @brief initialize NICommon
59  * @param[i] options base directory info
60  * @return ni_error_e 0 on success, otherwise a negative error value
61  */
62 ni_error_e initNICommon(NiCommonOption* option);
63
64 /**
65  * @brief finalize NICommon
66  * @details Before re-initialize NICommon, you have to finalize current NICommon first.
67  */
68 void finalizeNICommon();
69
70 /**
71  * @brief create native images for platform DLLs (.NETCore + TizenFX)
72  * @param[i] flags additional flags for the image generator
73  * @return ni_error_e
74  */
75 ni_error_e createNiPlatform(DWORD flags);
76
77 /**
78  * @brief create a native image for a single DLL
79  * @param[i] dllPath path to input DLL
80  * @param[i] flags additional flags for the image generator
81  * @return ni_error_e
82  */
83 ni_error_e createNiDll(const std::string& dllPath, DWORD flags);
84
85 /**
86  * @brief create native images for TAC DLLs
87  * @param[i] rootPaths paths to TAC directories
88  * @param[i] count length of rootPaths
89  * @param[i] flags additional flags for the image generator
90  */
91 void createNiUnderTAC(const std::string rootPaths[], int count, DWORD flags);
92
93 /**
94  * @brief creates a symbolic link file, the native image of TAC for specific package.
95  * @param[i] pkgId package ID
96  * @param[i] flags additional flags for the image generator
97  * @return ni_error_e
98  */
99 ni_error_e createTACPkgRoot(const std::string& pkgId, DWORD flags);
100
101 /**
102  * @brief create native images for all DLLs under directories
103  * @param[i] rootPaths paths to directories
104  * @param[i] count length of rootPaths
105  * @param[i] flags additional flags for the image generator
106  * @return ni_error_e
107  */
108 ni_error_e createNiUnderDirs(const std::string rootPaths[], int count, DWORD flags);
109
110 /**
111  * @brief create native images for all DLLs in a package
112  * @param[i] pkgId package ID
113  * @param[i] flags additional flags for the image generator
114  * @return ni_error_e
115  */
116 ni_error_e createNiUnderPkgRoot(const std::string& pkgId, DWORD flags);
117
118 /**
119  * @brief create a native image for a single dll in a package
120  * @param[i] pkgId package ID
121  * @param[i] dllPath path to input DLL
122  * @param[i] flags additional flags for the image generator
123  * @return ni_error_e
124  */
125 ni_error_e createNiDllUnderPkgRoot(const std::string& pkgId, const std::string& dllPath, DWORD flags);
126
127 /**
128  * @brief remove platform native images (.NETCore + TizenFX)
129  */
130 void removeNiPlatform();
131
132 /**
133  * @brief remove native images under directories
134  * @param[i] rootPaths paths to directories
135  * @param[i] count length of rootPaths
136  */
137 void removeNiUnderDirs(const std::string rootPaths[], int count);
138
139 /**
140  * @brief remove native images of a package
141  * @param[i] pkgId package ID
142  * @return ni_error_e
143  */
144 ni_error_e removeNiUnderPkgRoot(const std::string& pkgId);
145
146 /**
147  * @brief regenerate native images of all installed applications
148  * @param[i] flags additional flags for the image generator
149  * @return ni_error_e
150  */
151 ni_error_e regenerateAppNI(DWORD flags);
152
153 /**
154  * @brief regenerate native image of TAC for all shared assembly.
155  * @param[i] flags additional flags for the image generator
156  * @return ni_error_e
157  */
158 ni_error_e regenerateTACNI(DWORD flags);
159
160 #endif /* __NI_COMMON_H__ */