Nuget with no dependency applies TAC
[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);
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 for TAC DLLs.
71  * @param[i] rootPaths directories whicn contains DLLs
72  * @param[i] count number of rootPath
73  */
74 void createNiUnderTAC(const std::string rootPaths[], int count);
75
76 /**
77  * @brief create native images with files under specific directory.
78  * @param[i] rootPaths directories whicn contains DLLs
79  * @param[i] count number of rootPath
80  * @param[i] enableR2R enable ready-to-run mode
81  * @param[i] isAppNI if you want to create ni files under nativeImage directory, set it true
82  */
83 void createNiUnderDirs(const std::string rootPaths[], int count, bool enableR2R, bool isAppNI = false);
84
85 /**
86  * @brief create native images for specific package. (All DLLs)
87  * @param[i] pkgId package ID
88  * @param[i] enableR2R enable ready-to-run mode
89  * @return ni_error_e
90  */
91 ni_error_e createNiUnderPkgRoot(const std::string& pkgId, bool enableR2R);
92
93 /**
94  * @brief create native image for specific dll in the package.
95  * @Details All dlls in the package are added for reference when create native image.
96  * @param[i] pkgId package ID
97  * @param[i] enableR2R enable ready-to-run mode
98  * @return ni_error_e
99  */
100 ni_error_e createNiDllUnderPkgRoot(const std::string& pkgId, const std::string& dllPath, bool enableR2R);
101
102 /**
103  * @brief remove native images (NI file) for Platform DLLs (.NETCore + TizenFX)
104  */
105 void removeNiPlatform();
106
107 /**
108  * @brief remove native images under specific directory.
109  * @param[i] rootPaths directories whicn contains native image
110  * @param[i] count number of rootPath
111  */
112 void removeNiUnderDirs(const std::string rootPaths[], int count);
113
114 /**
115  * @brief remove native images for specific package.
116  * @param[i] pkgId package ID
117  * @return ni_error_e
118  */
119 ni_error_e removeNiUnderPkgRoot(const std::string& pkgId);
120
121 /**
122  * @brief regenerate native image for all installed application
123  * @return ni_error_e
124  */
125 ni_error_e regenerateAppNI(bool enableR2R = true);
126
127 #endif /* __NI_COMMON_H__ */