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