Review and rebase changes
[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 typedef std::function<void (std::string)> afterCreate;
23
24 typedef enum {
25         NI_ERROR_NONE = 0,
26         NI_ERROR_INVALID_PARAMETER = -1,
27         NI_ERROR_ALREADY_EXIST = -2,
28         NI_ERROR_NO_SUCH_FILE = -3,
29         NI_ERROR_INVALID_PACKAGE = -4,
30         NI_ERROR_NOT_SUPPORTED = -5,
31         NI_ERROR_UNKNOWN = -9
32 } ni_error_e;
33
34 /**
35  * @brief : structure which contains directory info
36  */
37 typedef struct NiCommonOption {
38         std::string runtimeDir; /**< .NETCore Runtime directory */
39         std::string tizenFXDir; /**< TizenFX directory */
40         std::string extraDirs; /**< ":" seperated directories which can be set by plugins */
41 } NiCommonOption;
42
43 /**
44  * @brief initialize NICommon
45  * @param[in] options to initialize path
46  * @return ni_error_e 0 on success, otherwise a negative error value
47  */
48 ni_error_e initNICommon(NiCommonOption* option);
49
50 /**
51  * @brief finalize NICommon
52  * @details Before re-initialize NICommon, you have to finalize current NICommon first.
53  */
54 void finalizeNICommon();
55
56 /**
57  * @brief create native images (NI file) for Platform DLLs (.NETCore + TizenFX)
58  */
59 void createNiPlatform(bool enableR2R, bool doGenUniqueBaseSystem);
60
61 /**
62  * @brief create native image for specific dll with file path.
63  * @param[i] dllPath file path to generate native image
64  * @param[i] enableR2R enable ready-to-run mode
65  * @param[i] doGenUniqueBaseSystem flag whether to generate unique default base address
66  * @return ni_error_e
67  */
68 ni_error_e createNiDll(const std::string& dllPath, bool enableR2R, bool doGenUniqueBaseSystem);
69
70 /**
71  * @brief create native images with files under specific directory.
72  * @param[i] rootPaths directories whicn contains DLLs
73  * @param[i] count number of rootPath
74  * @param[i] enableR2R enable ready-to-run mode
75  * @param[i] doGenUniqueBaseSystem flag whether to generate unique default base address
76  * @param[i] isAppNI if you want to create ni files under nativeImage directory, set it true
77  */
78 void createNiUnderDirs(const std::string rootPaths[], int count, bool enableR2R, bool doGenUniqueBaseSystem, bool isAppNI = false);
79
80 /**
81  * @brief create native images for specific package. (All DLLs)
82  * @param[i] pkgId package ID
83  * @param[i] enableR2R enable ready-to-run mode
84  * @return ni_error_e
85  */
86 ni_error_e createNiUnderPkgRoot(const std::string& pkgId, bool enableR2R);
87
88 /**
89  * @brief create native image for specific dll in the package.
90  * @Details All dlls in the package are added for reference when create native image.
91  * @param[i] pkgId package ID
92  * @param[i] enableR2R enable ready-to-run mode
93  * @return ni_error_e
94  */
95 ni_error_e createNiDllUnderPkgRoot(const std::string& pkgId, const std::string& dllPath, bool enableR2R);
96
97 /**
98  * @brief remove native images (NI file) for Platform DLLs (.NETCore + TizenFX)
99  */
100 void removeNiPlatform();
101
102 /**
103  * @brief remove native images under specific directory.
104  * @param[i] rootPaths directories whicn contains native image
105  * @param[i] count number of rootPath
106  */
107 void removeNiUnderDirs(const std::string rootPaths[], int count);
108
109 /**
110  * @brief remove native images for specific package.
111  * @param[i] pkgId package ID
112  * @return ni_error_e
113  */
114 ni_error_e removeNiUnderPkgRoot(const std::string& pkgId);
115
116 /**
117  * @brief regenerate native image for all installed application
118  * @return ni_error_e
119  */
120 ni_error_e regenerateAppNI(bool enableR2R = true);
121
122 #endif /* __NI_COMMON_H__ */