summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJongHeon Choi <j-h.choi@samsung.com>2016-12-23 13:58:31 +0900
committerJongHeon Choi <j-h.choi@samsung.com>2016-12-23 14:45:48 +0900
commita0841bad8771c833eda60990e016aed08b588235 (patch)
tree3e7fcce71978c36f332205fbcbd3509bf0470350
parent18893e7cba7ed932d102b90d213d64dbd18d97ca (diff)
downloadlauncher-a0841bad8771c833eda60990e016aed08b588235.tar.gz
launcher-a0841bad8771c833eda60990e016aed08b588235.tar.bz2
launcher-a0841bad8771c833eda60990e016aed08b588235.zip
Add '--dll' option of nitoolsubmit/tizen/20161223.055000
* Create native image for dll * ex) nitool --dll /usr/bin/Tizen.Runtime.Coreclr.dll Change-Id: I9234719f66ae5f75002d132fa8183c4aabaaba4a
-rw-r--r--NativeLauncher/installer-plugin/common.cc34
-rw-r--r--NativeLauncher/installer-plugin/common.h1
-rw-r--r--NativeLauncher/installer-plugin/nitool.cc18
3 files changed, 52 insertions, 1 deletions
diff --git a/NativeLauncher/installer-plugin/common.cc b/NativeLauncher/installer-plugin/common.cc
index 377fab9..ddeabdc 100644
--- a/NativeLauncher/installer-plugin/common.cc
+++ b/NativeLauncher/installer-plugin/common.cc
@@ -60,6 +60,17 @@ static const char* JITPath = __STR(RUNTIME_DIR)"/libclrjit.so";
static void crossgen(const char* dll_path, const char* app_path);
static void smack_(const char* dll_path);
+std::string Replace(std::string &str, const std::string& from, const std::string& to)
+{
+ size_t start_pos = 0;
+ while((start_pos = str.find(from, start_pos)) != std::string::npos)
+ {
+ str.replace(start_pos, from.length(), to);
+ start_pos += to.length();
+ }
+ return str;
+}
+
void create_ni_platform()
{
std::string corlib = ConcatPath(RuntimeDir, "System.Private.CoreLib.dll");
@@ -79,6 +90,29 @@ void create_ni_platform()
});
}
+void create_ni_select(const char* dll_path)
+{
+ std::string corlib = ConcatPath(RuntimeDir, "System.Private.CoreLib.dll");
+ std::string nicorlib = ConcatPath(RuntimeDir, "System.Private.CoreLib.ni.dll");
+
+ if (FileNotExist(nicorlib))
+ {
+ crossgen(corlib.c_str(), nullptr);
+ smack_(nicorlib.c_str());
+ }
+
+ if (!FileNotExist(dll_path))
+ {
+ std::string str_path = dll_path;
+ std::string ni_path = Replace(str_path, std::string(".dll"), std::string(".ni.dll"));
+ if (FileNotExist(ni_path))
+ crossgen(dll_path, nullptr);
+ else
+ printf("Already [%s] file is exist\n", ni_path.c_str());
+ smack_(ni_path.c_str());
+ }
+}
+
static void smack_(const char* dll_path)
{
static const char* CHKSMACK = "/usr/bin/chsmack";
diff --git a/NativeLauncher/installer-plugin/common.h b/NativeLauncher/installer-plugin/common.h
index 50c33f3..5d69417 100644
--- a/NativeLauncher/installer-plugin/common.h
+++ b/NativeLauncher/installer-plugin/common.h
@@ -25,5 +25,6 @@ void create_ni_under_dirs(const char* root_paths[], int count, after_create cb);
void create_ni_under_dirs(const char* root_paths[], int count);
int create_ni_under_pkg_root(const char* pkg_name);
void create_ni_platform();
+void create_ni_select(const char* dll_path);
#endif // __INSTALLER_PLUGIN_COMMON_H__
diff --git a/NativeLauncher/installer-plugin/nitool.cc b/NativeLauncher/installer-plugin/nitool.cc
index fd090fb..b4e47ec 100644
--- a/NativeLauncher/installer-plugin/nitool.cc
+++ b/NativeLauncher/installer-plugin/nitool.cc
@@ -46,11 +46,14 @@ static void help(const char *argv0)
"Usage: %s [args] <root paths or pkg name>\n"
" --help - Display this screen\n"
" --system - Create NI under System DLLs\n"
+ " --dll - Create NI for DLL\n"
" --pkg - Create NI for package\n"
"\n"
"Example:\n"
"Create native image for dlls and exes under platform directories\n"
"%s --system\n"
+ "Create native image for dll\n"
+ "%s --dll /usr/bin/Tizen.Runtime.Coreclr.dll\n"
"Create native image under the package's bin and lib directory\n"
"%s --pkg org.tizen.FormsGallery\n\n";
printf(helpdesc, argv0, argv0, argv0);
@@ -59,6 +62,7 @@ static void help(const char *argv0)
int main(int argc, char* argv[])
{
bool pkg_mode = false;
+ bool dll_mode = false;
if (cmd_option_exists(argv, argv+argc, "--help"))
{
@@ -72,6 +76,11 @@ int main(int argc, char* argv[])
return 0;
}
+ if (cmd_option_exists(argv, argv+argc, "--dll"))
+ {
+ dll_mode = true;
+ }
+
if (cmd_option_exists(argv, argv+argc, "--pkg"))
{
pkg_mode = true;
@@ -83,7 +92,7 @@ int main(int argc, char* argv[])
{
if (pkg_mode)
fprintf(stderr, "Package name is missed\n");
- else
+ else if (dll_mode)
fprintf(stderr, "DLL path is missed\n");
help(argv[0]);
return 1;
@@ -100,6 +109,13 @@ int main(int argc, char* argv[])
}
}
}
+ else if (dll_mode)
+ {
+ for (const char* dll : args)
+ {
+ create_ni_select(dll);
+ }
+ }
else
{
create_ni_under_dirs(args.data(), args.size());