diff options
author | pius.lee <pius.lee@samsung.com> | 2016-11-30 18:22:11 +0900 |
---|---|---|
committer | JongHeon Choi <j-h.choi@samsung.com> | 2016-12-14 17:08:14 +0900 |
commit | ac952532bac864e145498a0cc724d84a67339ac0 (patch) | |
tree | 3856bc71f6f834c4a99e2707cf286f53ce4947c4 | |
parent | 0c867ba84c6495994b2ffb2c3149dae1ae6f5aa5 (diff) | |
download | launcher-ac952532bac864e145498a0cc724d84a67339ac0.tar.gz launcher-ac952532bac864e145498a0cc724d84a67339ac0.tar.bz2 launcher-ac952532bac864e145498a0cc724d84a67339ac0.zip |
Fix unused native image in application.
Now launcher use Native image in application's bin, lib directory.
--native option is added to dotnet-launcher.
It must be use with --standalone.
--native launch dll without managed launcher.
But it can't launch ni.dll.
Change-Id: Icf0ab0e9330ec1e94db5440e517e76710f1d81e1
-rw-r--r-- | NativeLauncher/launcher/dotnet/dotnet_launcher.cc | 12 | ||||
-rw-r--r-- | NativeLauncher/launcher/main.cc | 18 | ||||
-rw-r--r-- | Tizen.Runtime/Tizen.Runtime.Coreclr/AssemblyManager.cs | 11 |
3 files changed, 40 insertions, 1 deletions
diff --git a/NativeLauncher/launcher/dotnet/dotnet_launcher.cc b/NativeLauncher/launcher/dotnet/dotnet_launcher.cc index 509248d..cb9fcd0 100644 --- a/NativeLauncher/launcher/dotnet/dotnet_launcher.cc +++ b/NativeLauncher/launcher/dotnet/dotnet_launcher.cc @@ -277,6 +277,18 @@ int CoreRuntime::Launch(const char* root, const char* path, int argc, char* argv return 1; } + std::string cpppath(path); + + if (IsManagedAssembly(cpppath) && !IsNativeImage(cpppath)) + { + size_t extindex = cpppath.size() - 4; + cpppath = cpppath.substr(0, extindex) + ".ni" + cpppath.substr(extindex, 4); + if (!FileNotExist(cpppath)) + { + path = cpppath.c_str(); + } + } + if (FileNotExist(path)) { _ERR("File not exist : %s", path); diff --git a/NativeLauncher/launcher/main.cc b/NativeLauncher/launcher/main.cc index 3d574ec..314e719 100644 --- a/NativeLauncher/launcher/main.cc +++ b/NativeLauncher/launcher/main.cc @@ -38,12 +38,14 @@ static std::string VersionOption("--version"); static std::string StandaloneOption("--standalone"); +static std::string NativeOption("--native"); int main(int argc, char *argv[]) { int i; bool standalone = false; const char* standalonePath = nullptr; + bool nativeOnly = false; std::vector<char*> vargs; @@ -66,12 +68,22 @@ int main(int argc, char *argv[]) i++; standalonePath = argv[i]; } + else if (NativeOption.compare(argv[i]) == 0) + { + nativeOnly = true; + } else { vargs.push_back(argv[i]); } } + if (!standalone && nativeOnly) + { + fprintf(stderr, "\"--native\" option must be use with \"--standalone\"\n"); + return 1; + } + using tizen::runtime::LauncherInterface; using tizen::runtime::Launchpad; using tizen::runtime::AppInfo; @@ -120,6 +132,12 @@ int main(int argc, char *argv[]) return 1; } + if (!nativeOnly && runtime->RunManagedLauncher() != 0) + { + _ERR("Failed to run managed launcher"); + return 1; + } + int args_len = vargs.size(); char** args = &vargs[0]; if (runtime->Launch(approot.c_str(), standalonePath, args_len, args)) diff --git a/Tizen.Runtime/Tizen.Runtime.Coreclr/AssemblyManager.cs b/Tizen.Runtime/Tizen.Runtime.Coreclr/AssemblyManager.cs index ea31f8f..26b8868 100644 --- a/Tizen.Runtime/Tizen.Runtime.Coreclr/AssemblyManager.cs +++ b/Tizen.Runtime/Tizen.Runtime.Coreclr/AssemblyManager.cs @@ -165,7 +165,16 @@ namespace Tizen.Runtime.Coreclr FileInfo f = new FileInfo(dllPath); if (File.Exists(f.FullName)) { - Assembly asm = CurrentAssemblyLoaderContext.LoadFromAssemblyPath(f.FullName); + Assembly asm = null; + if (0 == string.Compare(f.FullName, f.FullName.Length - 7, ".ni", 0, 3, StringComparison.OrdinalIgnoreCase)) + { + asm = CurrentAssemblyLoaderContext.LoadFromNativeImagePath(f.FullName, null); + } + else + { + asm = CurrentAssemblyLoaderContext.LoadFromAssemblyPath(f.FullName); + } + if (asm == null) throw new FileNotFoundException($"{f.FullName} is not found"); if (asm.EntryPoint == null) throw new ArgumentException($"{f.FullName} did not have EntryPoint"); asm.EntryPoint.Invoke(null, new object[]{argv}); |