From: JongHeon Choi Date: Fri, 23 Dec 2016 04:58:31 +0000 (+0900) Subject: Add '--dll' option of nitool X-Git-Tag: submit/tizen/20161223.055000^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a0841bad8771c833eda60990e016aed08b588235;p=platform%2Fcore%2Fdotnet%2Flauncher.git Add '--dll' option of nitool * Create native image for dll * ex) nitool --dll /usr/bin/Tizen.Runtime.Coreclr.dll Change-Id: I9234719f66ae5f75002d132fa8183c4aabaaba4a --- 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] \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());