Merge pull request #62 from dotnet/generate_coreLib_ni_when_install
[platform/core/dotnet/launcher.git] / NativeLauncher / installer-plugin / 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);
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  * @return ni_error_e
66  */
67 ni_error_e createNiDll(const std::string& dllPath, bool enableR2R);
68
69 /**
70  * @brief create native images with files under specific directory.
71  * @param[i] rootPaths directories whicn contains DLLs
72  * @param[i] count number of rootPath
73  * @param[i] enableR2R enable ready-to-run mode
74  */
75 void createNiUnderDirs(const std::string rootPaths[], int count, bool enableR2R);
76
77 /**
78  * @brief create native images for specific package. (All DLLs)
79  * @param[i] pkgId package ID
80  * @param[i] enableR2R enable ready-to-run mode
81  * @return ni_error_e
82  */
83 ni_error_e createNiUnderPkgRoot(const std::string& pkgId, bool enableR2R);
84
85 /**
86  * @brief create native image for specific dll in the package.
87  * @Details All dlls in the package are added for reference when create native image.
88  * @param[i] pkgId package ID
89  * @param[i] enableR2R enable ready-to-run mode
90  * @return ni_error_e
91  */
92 ni_error_e createNiDllUnderPkgRoot(const std::string& pkgId, const std::string& dllPath, bool enableR2R);
93
94 /**
95  * @brief remove native images (NI file) for Platform DLLs (.NETCore + TizenFX)
96  */
97 void removeNiPlatform();
98
99 /**
100  * @brief remove native images under specific directory.
101  * @param[i] rootPaths directories whicn contains native image
102  * @param[i] count number of rootPath
103  */
104 void removeNiUnderDirs(const std::string rootPaths[], int count);
105
106 /**
107  * @brief remove native images for specific package.
108  * @param[i] pkgId package ID
109  * @return ni_error_e
110  */
111 ni_error_e removeNiUnderPkgRoot(const std::string& pkgId);
112
113 /**
114  * @brief regenerate native image for all installed application
115  * @return ni_error_e
116  */
117 ni_error_e regenerateAppNI(bool enableR2R = true);
118
119 #endif /* __NI_COMMON_H__ */