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