refactoring launcher 24/124124/6
authorCho Woong Suk <ws77.cho@samsung.com>
Mon, 10 Apr 2017 08:39:15 +0000 (17:39 +0900)
committerJongHeon Choi <j-h.choi@samsung.com>
Mon, 10 Apr 2017 09:40:23 +0000 (18:40 +0900)
Change-Id: Ic2912985e0bf5e21d823bcf34280bd2aea2f7a54

13 files changed:
NativeLauncher/CMakeLists.txt
NativeLauncher/launcher/dotnet/dotnet_launcher.cc
NativeLauncher/launcher/dotnet/dotnet_launcher.h
NativeLauncher/launcher/dotnet/scd_launcher.cc
NativeLauncher/launcher/launcher.cc
NativeLauncher/launcher/launcher.h
NativeLauncher/launcher/main.cc
NativeLauncher/launcher/waiter/waiter.cc [deleted file]
NativeLauncher/launcher/waiter/waiter.h [deleted file]
NativeLauncher/util/utils.cc
Tizen.Runtime/Tizen.Runtime.Coreclr/AssemblyLoader.cs
Tizen.Runtime/Tizen.Runtime.Coreclr/AssemblyManager.cs
packaging/dotnet-launcher.spec

index 0d4e53b..f8a1697 100755 (executable)
@@ -38,6 +38,20 @@ IF(DEFINED VERSION)
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -DVERSION=${VERSION}")
 ENDIF(DEFINED VERSION)
 
+IF(DEFINED NATIVE_LIB_DIR)
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -DNATIVE_LIB_DIR=${NATIVE_LIB_DIR}")
+ENDIF(DEFINED NATIVE_LIB_DIR)
+
+IF(USE_MANAGED_LAUNCHER STREQUAL "ENABLE")
+       ADD_DEFINITIONS("-DUSE_MANAGED_LAUNCHER")
+ENDIF(USE_MANAGED_LAUNCHER)
+
+OPTION(NOT_USE_FUNCTION "Remove build warning" OFF)
+IF(NOT_USE_FUNCTION)
+       ADD_DEFINITIONS("-DNOT_USE_FUNCTION")
+ENDIF(NOT_USE_FUNCTION)
+
+
 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -pthread -std=c++11 -Wl,--no-as-needed -ggdb")
 SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wl,-zdefs" )
 #SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
@@ -47,7 +61,7 @@ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -D_FILE_OFFSET_BITS=64")
 #SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -DLAUNCHING_TIME_MEASURE")
 
 SET(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
-SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
+SET(CMAKE_CXX_FLAGS_DEBUG "-O2 -g")
 SET(CMAKE_CXX_FLAGS_RELEASE "-O2")
 SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
 
index cb9fcd0..15b74c9 100644 (file)
@@ -50,9 +50,15 @@ CoreRuntime::CoreRuntime() :
 #ifdef RUNTIME_DIR
   RuntimeDirectory = __STR(RUNTIME_DIR);
 #endif
+#ifdef NATIVE_LIB_DIR
+  NativeLibDirectory = __STR(NATIVE_LIB_DIR);
+#endif
+
+#ifdef USE_MANAGED_LAUNCHER
 #ifdef CORECLR_LAUNCHER_ASSEMBLY_PATH
   LauncherAssembly = __STR(CORECLR_LAUNCHER_ASSEMBLY_PATH);
 #endif
+#endif
 
 #undef __STR
 #undef __XSTR
@@ -72,13 +78,16 @@ int CoreRuntime::Initialize(bool standalone)
   {
     const char *_deviceapi_directory = getenv("DeviceAPIDirectory");
     const char *_runtime_directory = getenv("RuntimeDirectory");
-    const char *_launcher_assembly = getenv("LauncherAssembly");
     if (_deviceapi_directory != nullptr)
       DeviceAPIDirectory = _deviceapi_directory;
     if (_runtime_directory != nullptr)
       RuntimeDirectory = _runtime_directory;
+
+#ifdef USE_MANAGED_LAUNCHER
+    const char *_launcher_assembly = getenv("LauncherAssembly");
     if (_launcher_assembly != nullptr)
       LauncherAssembly = _launcher_assembly;
+#endif
   }
 
   if (DeviceAPIDirectory.empty())
@@ -90,6 +99,7 @@ int CoreRuntime::Initialize(bool standalone)
   {
     DeviceAPIDirectory = AbsolutePath(DeviceAPIDirectory);
   }
+
   if (RuntimeDirectory.empty())
   {
     _ERR("Empty Runtime Directory");
@@ -99,6 +109,8 @@ int CoreRuntime::Initialize(bool standalone)
   {
     RuntimeDirectory = AbsolutePath(RuntimeDirectory);
   }
+
+#ifdef USE_MANAGED_LAUNCHER
   if (LauncherAssembly.empty())
   {
     _ERR("Empty Launcher Assembly");
@@ -108,6 +120,7 @@ int CoreRuntime::Initialize(bool standalone)
   {
     LauncherAssembly = AbsolutePath(LauncherAssembly);
   }
+#endif
 
   std::string libcoreclr(ConcatPath(RuntimeDirectory, "libcoreclr.so"));
 
@@ -143,15 +156,11 @@ int CoreRuntime::Initialize(bool standalone)
   return 0;
 }
 
-bool CoreRuntime::InitializeCoreClr(const char* assembly_probe_paths, const char* pinvoke_probe_paths)
+bool CoreRuntime::InitializeCoreClr(const char* app_id,
+                                    const char* assembly_probe_paths,
+                                    const char* pinvoke_probe_paths,
+                                    const char* tpa_list)
 {
-  std::vector<std::string> platformDirectories = {
-    RuntimeDirectory, DeviceAPIDirectory
-  };
-
-  std::string trusted_assemblies;
-  AssembliesInDirectory(platformDirectories, trusted_assemblies);
-
   const char *propertyKeys[] =
   {
     "TRUSTED_PLATFORM_ASSEMBLIES",
@@ -163,7 +172,7 @@ bool CoreRuntime::InitializeCoreClr(const char* assembly_probe_paths, const char
 
   const char *propertyValues[] =
   {
-    trusted_assemblies.c_str(),
+    tpa_list,
     assembly_probe_paths,
     assembly_probe_paths,
     pinvoke_probe_paths,
@@ -174,7 +183,7 @@ bool CoreRuntime::InitializeCoreClr(const char* assembly_probe_paths, const char
 
   int st = InitializeClr(
       selfPath.c_str(),
-      "dotnet-launcher",
+      app_id,
       sizeof(propertyKeys) / sizeof(propertyKeys[0]),
       propertyKeys,
       propertyValues,
@@ -191,7 +200,7 @@ bool CoreRuntime::InitializeCoreClr(const char* assembly_probe_paths, const char
   return true;
 }
 
-int CoreRuntime::RunManagedLauncher()
+int CoreRuntime::RunManagedLauncher(const char* app_id, const char* app_base, const char* tpa_list)
 {
   if (FileNotExist(LauncherAssembly))
   {
@@ -199,24 +208,13 @@ int CoreRuntime::RunManagedLauncher()
     return 1;
   }
 
-  std::string launcherDir = Basename(LauncherAssembly);
-  std::vector<std::string> searchDirectories = {
-    RuntimeDirectory, DeviceAPIDirectory
-  };
-
-  std::string trusted_directories = JoinStrings(searchDirectories, ":");
-
-  _DBG("coreclr_dir : %s", RuntimeDirectory.c_str());
-  _DBG("native_so_search_dir : %s", trusted_directories.c_str());
-  _DBG("launcher_assembly : %s", LauncherAssembly.c_str());
-  _DBG("launcher_dir : %s", launcherDir.c_str());
-
-  if (!InitializeCoreClr(launcherDir.c_str(), launcherDir.c_str()))
+  if (!InitializeCoreClr(app_id, app_base, app_base, tpa_list))
   {
     _ERR("Failed to initialize coreclr");
     return 1;
   }
 
+#ifdef USE_MANAGED_LAUNCHER
   void *preparedFunctionDelegate;
   int st = CreateDelegate(hostHandle, domainId,
       "Tizen.Runtime.Coreclr",
@@ -245,7 +243,7 @@ int CoreRuntime::RunManagedLauncher()
     return 1;
   }
   LaunchFunction = reinterpret_cast<LaunchFunctionPtr>(launchFunctionDelegate);
-
+#endif
   return 0;
 }
 
@@ -269,7 +267,7 @@ void CoreRuntime::Dispose()
   _DBG("Dotnet runtime disposed");
 }
 
-int CoreRuntime::Launch(const char* root, const char* path, int argc, char* argv[])
+int CoreRuntime::Launch(const char* app_id, const char* root, const char* path, int argc, char* argv[])
 {
   if (path == nullptr)
   {
@@ -295,6 +293,25 @@ int CoreRuntime::Launch(const char* root, const char* path, int argc, char* argv
     return 1;
   }
 
+  std::vector<std::string> searchDirectories = {
+    RuntimeDirectory, DeviceAPIDirectory
+#ifdef USE_MANAGED_LAUNCHER
+    , Basename(LauncherAssembly)
+#endif
+  };
+
+  //std::string trusted_directories = JoinStrings(searchDirectories, ":");
+  std::string tpa;
+  AssembliesInDirectory(searchDirectories, tpa);
+
+  std::string appRoot = root;
+  std::string appBin = ConcatPath(appRoot, "bin");
+  std::string appLib = ConcatPath(appRoot, "lib");
+  std::string probePath = appBin + ":" + appLib + ":" + NativeLibDirectory;
+
+#ifdef USE_MANAGED_LAUNCHER
+  RunManagedLauncher(app_id, probePath.c_str(), tpa.c_str());
+
   bool success = false;
   if (LaunchFunction != nullptr)
   {
@@ -307,20 +324,19 @@ int CoreRuntime::Launch(const char* root, const char* path, int argc, char* argv
   }
   else
   {
-    std::string appRoot = root;
-    std::string appBin = ConcatPath(appRoot, "bin");
-    std::string appLib = ConcatPath(appRoot, "lib");
-    std::string probePath = appBin + ":" + appLib;
-
-    int st = InitializeCoreClr(probePath.c_str(), probePath.c_str());
-    unsigned int ret = 0;
-    st = ExecuteAssembly(hostHandle, domainId, argc, (const char**)argv, path, &ret);
-    if (st < 0)
-    {
-      _ERR("Failed to Execute Assembly %s (0x%08x)", path, st);
-    }
-    return ret;
+    _ERR("Failed to find launch function");
+    return 1;
   }
+#else
+  int st = InitializeCoreClr(app_id, probePath.c_str(), probePath.c_str(), tpa.c_str());
+  unsigned int ret = 0;
+  st = ExecuteAssembly(hostHandle, domainId, argc, (const char**)argv, path, &ret);
+  if (st < 0)
+  {
+    _ERR("Failed to Execute Assembly %s (0x%08x)", path, st);
+  }
+  return ret;
+#endif
 }
 
 }  // namespace dotnetcore
index 31a8c4a..27d1298 100644 (file)
@@ -62,11 +62,11 @@ class CoreRuntime : public tizen::runtime::LauncherInterface
     ~CoreRuntime();
     int Initialize(bool standalone) override;
     void Dispose() override;
-    int RunManagedLauncher() override;
-    int Launch(const char* root, const char* path, int argc, char* argv[]) override;
+    int RunManagedLauncher(const char* app_id, const char* app_base, const char* tpa_list) override;
+    int Launch(const char* app_id, const char* root, const char* path, int argc, char* argv[]) override;
 
   private:
-    bool InitializeCoreClr(const char* assembly_probe_paths, const char* pinvoke_probe_paths);
+    bool InitializeCoreClr(const char* app_id, const char* assembly_probe_paths, const char* pinvoke_probe_paths, const char* tpa);
     coreclr_initialize_ptr InitializeClr;
     coreclr_execute_assembly_ptr ExecuteAssembly;
     coreclr_shutdown_ptr Shutdown;
@@ -74,6 +74,7 @@ class CoreRuntime : public tizen::runtime::LauncherInterface
     std::string DeviceAPIDirectory;
     std::string RuntimeDirectory;
     std::string LauncherAssembly;
+    std::string NativeLibDirectory;
     void* coreclrLib;
     void* hostHandle;
     unsigned int domainId;
index 9c573e8..2959b19 100644 (file)
@@ -208,7 +208,7 @@ void AddFilesFromDirectoryToTpaList(const char* directory, std::string& tpaList)
 
   // Walk the directory for each extension separately so that we first get files with .ni.dll extension,
   // then files with .dll extension, etc.
-  for (int extIndex = 0; extIndex < sizeof(tpaExtensions) / sizeof(tpaExtensions[0]); extIndex++)
+  for (unsigned int extIndex = 0; extIndex < sizeof(tpaExtensions) / sizeof(tpaExtensions[0]); extIndex++)
     {
       const char* ext = tpaExtensions[extIndex];
       int extLength = strlen(ext);
@@ -590,6 +590,9 @@ int main(const int argc, const char* argv[])
     const char** new_args = &vargs[0];
     setenv("SECONDPASS", "1", 1);
     status = execvp(new_args[0], (char *const *)new_args);
+    if (status == -1) {
+      dlog_print(DLOG_ERROR,"dotnet","execvp error");
+    }
     dlog_print(DLOG_INFO,"dotnet","something wrong errno: %d\n",errno);
   }
   /// service_app_end
index c2d1ce4..63fd652 100644 (file)
@@ -44,8 +44,6 @@ struct FdHandler
 static int __argc;
 static char **__argv;
 static Evas_Object *__win;
-static Evas_Object *__bg;
-static Evas_Object *__conform;
 
 class LaunchpadAdapterImpl : public LaunchpadAdapter
 {
@@ -155,7 +153,7 @@ static void PreloadLibsAndWindow(bundle *extra, int type, void *user_data)
 
        for (i = 0; i < len; i++) {
                handle = dlopen(so_array[i], RTLD_NOW);
-               _DBG("preload %s# - handle : %x\n", so_array[i], handle);
+               _DBG("preload %s# - handle : %x", so_array[i], handle);
        }
 
   // Precreate window
index 4d87457..66c3aaa 100644 (file)
@@ -28,8 +28,8 @@ class LauncherInterface
   public:
     virtual int Initialize(bool standalone) = 0;
     virtual void Dispose() = 0;
-    virtual int RunManagedLauncher() = 0;
-    virtual int Launch(const char* root, const char* path, int argc, char* argv[]) = 0;
+    virtual int RunManagedLauncher(const char* app_id, const char* app_base, const char* tpa_list) = 0;
+    virtual int Launch(const char* app_id, const char* root, const char* path, int argc, char* argv[]) = 0;
 };
 
 struct AppInfo
index c39b3e8..9bd024c 100644 (file)
 
 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;
 
@@ -68,22 +66,12 @@ 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;
@@ -117,15 +105,9 @@ 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))
+    if (runtime->Launch(appid, approot.c_str(), standalonePath, args_len, args))
     {
         _ERR("Failed to launch");
         return 0;
@@ -141,16 +123,7 @@ int main(int argc, char *argv[])
       }
       else
       {
-        auto idle_task = [](void *data) -> Eina_Bool
-        {
-          LauncherInterface* runtime = static_cast<LauncherInterface*>(data);
-          if (runtime->RunManagedLauncher() != 0)
-          {
-            _ERR("Failed to run managed launcher");
-          }
-          return ECORE_CALLBACK_CANCEL;
-        };
-        ecore_idler_add(idle_task, runtime.get());
+        _DBG("Success to initialized");
       }
     };
 
@@ -164,7 +137,7 @@ int main(int argc, char *argv[])
       // The launchpad pass the name of exe file to the first argument.
       // For the C# spec, we have to skip this first argument.
 
-      if (runtime->Launch(info.root.c_str(), info.path.c_str(), argc-1, argv+1))
+      if (runtime->Launch(info.id.c_str(), info.root.c_str(), info.path.c_str(), argc-1, argv+1))
       {
         _ERR("Failed to launch");
       }
diff --git a/NativeLauncher/launcher/waiter/waiter.cc b/NativeLauncher/launcher/waiter/waiter.cc
deleted file mode 100644 (file)
index 02fa3bf..0000000
+++ /dev/null
@@ -1,311 +0,0 @@
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#include <poll.h>
-
-#ifndef NO_TIZEN
-#include <launchpad.h>
-#include <aul.h>
-#endif
-
-#include <memory>
-#include <vector>
-#include <map>
-#include <poll.h>
-
-#include <iostream>
-
-#include "waiter.h"
-#include "log.h"
-
-namespace dotnet {
-namespace runtime {
-
-struct FdHandler
-{
-  pollfd *info;
-  Receiver receiver;
-};
-
-static volatile bool Waiting_;
-static std::vector<pollfd> Fdlist_;
-static std::map<int, FdHandler> Handlers_;
-static Waiter::AppInfo AppInfo_;
-
-void Waiter::OnPrepared()
-{
-  if (!context.Prepare())
-  {
-    _DBG("Fail to Prepare...");
-  }
-}
-
-void Waiter::OnRequested(const AppInfo& info)
-{
-  // do some job on user id is still system
-
-  if (!context.Request())
-  {
-    _DBG("Fail to Request...");
-  }
-}
-
-void Waiter::OnExecuted(const char *path, const char *app_root, int argc, char *argv[])
-{
-  if (!context.Execute(path, app_root, argc, argv))
-  {
-    _DBG("Fail to Execute...");
-  }
-}
-
-void Waiter::OnWaiting()
-{
-  // Start the loop
-  Waiting_ = true;
-
-  _DBG("start polling...");
-  while (Waiting_)
-  {
-    if (poll(Fdlist_.data(), Fdlist_.size(), -1) < 0)
-      continue;
-
-    for (auto &p : Fdlist_)
-    {
-      if ( (p.revents | POLLIN) != 0 )
-        Handlers_[p.fd].receiver(p.fd);
-    }
-  }
-  _DBG("end polling...");
-}
-
-void Waiter::Stop()
-{
-  // Stop the loop
-
-  Waiting_ = false;
-}
-
-
-void Waiter::RegisterFd(int fd, Receiver receiver)
-{
-  // register fd should be caught in event loop
-
-  _DBG("Register fd %d", fd);
-
-  pollfd info;
-  info.fd = fd;
-  info.events = POLLIN;
-  info.revents = 0;
-
-  FdHandler handler;
-  Fdlist_.push_back(info);
-  handler.info = &Fdlist_.back(); 
-  handler.receiver = receiver;
-
-  Handlers_[fd] = handler;
-}
-
-void Waiter::DeregisterFd(int fd)
-{
-  // deregister fd should be caught in event loop
-  
-  pollfd *info = Handlers_[fd].info;
-  Fdlist_.erase(Fdlist_.begin() - (info - &Fdlist_.front()));
-  Handlers_.erase(fd);
-}
-
-int Waiter::WaitToLaunching(int argc, char *argv[])
-{
-#ifndef NO_TIZEN
-  auto on_create = [](bundle *extra, int type, void *user_data)
-  {
-    _DBG("on_create..."); // XXX
-    Waiter* waiter = static_cast<Waiter*>(user_data);
-    waiter->OnPrepared();
-  };
-
-  auto on_launch = [](int argc, char **argv, const char *app_path,
-      const char *appid, const char *pkgid,
-      const char *pkg_type, void *user_data) -> int
-  {
-    _DBG("on_launch..."); // XXX
-    Waiter* waiter = static_cast<Waiter*>(user_data);
-
-    _DBG ("app path : %s", app_path);
-    _DBG ("app id : %s", appid);
-    _DBG ("pkg id : %s", pkgid);
-    _DBG ("pkg type : %s", pkg_type);
-
-    AppInfo info = {
-      AppPath : app_path,
-      AppId : appid,
-      PkgId : pkgid,
-      PkgType : pkg_type
-    };
-
-    waiter->OnRequested(info);
-    return 0;
-  };
-
-  auto on_terminate = [](int argc, char **argv, void *user_data) -> int
-  {
-    _DBG("on_terminate..."); // XXX
-    
-    string app_root(aul_get_app_root_path());
-    Waiter* waiter = static_cast<Waiter*>(user_data);
-    waiter->OnExecuted(argv[0], app_root.c_str(), argc, argv);
-    return 0;
-  };
-
-  auto on_start_loop = [](void *user_data)
-  {
-    _DBG("on_start_loop..."); // XXX
-    Waiter* waiter = static_cast<Waiter*>(user_data);
-    waiter->OnWaiting();
-  };
-
-  auto on_quit_loop = [](void *user_data)
-  {
-    _DBG("on_quit_loop..."); // XXX
-    Waiter* waiter = static_cast<Waiter*>(user_data);
-    waiter->Stop();
-  };
-
-  auto on_add_fd = [](void *user_data, int fd, loader_receiver_cb receiver)
-  {
-    _DBG("on_add_fd..."); // XXX
-    Waiter* waiter = static_cast<Waiter*>(user_data);
-    waiter->RegisterFd(fd, receiver);
-  };
-
-  auto on_remove_fd = [](void *user_data, int fd)
-  {
-    _DBG("on_remove_fd..."); // XXX
-    Waiter* waiter = static_cast<Waiter*>(user_data);
-    waiter->DeregisterFd(fd);
-  };
-
-  _DBG("launcher wait..."); // XXX
-  loader_lifecycle_callback_s callbacks = {
-    .create = on_create,
-    .launch = on_launch,
-    .terminate = on_terminate
-  };
-
-       loader_adapter_s adapter = {
-               .loop_begin = on_start_loop,
-               .loop_quit = on_quit_loop,
-               .add_fd = on_add_fd,
-               .remove_fd = on_remove_fd
-       };
-
-  return launchpad_loader_main(argc, argv, &callbacks, &adapter, this);
-#else
-  if (argc < 2)
-  {
-    _DBG("not enough args : %d", argc);
-    return -1;
-  }
-  _DBG("argv[1] = %s", argv[1]);
-  std::string app_path(argv[1]);
-  std::string app_root;
-  auto pos = app_path.find_last_of('/');
-  if (pos != std::string::npos)
-    app_root = app_path.substr(0, pos);
-  else
-    app_root = ".";
-
-  this->OnPrepared();
-  AppInfo info = {
-    AppPath : argv[1],
-    AppId : "",
-    PkgId : "",
-    PkgType : ""
-  };
-  this->OnRequested(info);
-  this->OnExecuted(app_path.c_str(), app_root.c_str(), argc, argv);
-#endif
-}
-
-void Waiter::SetContext(WaiterContext ctx)
-{
-  context = ctx;
-}
-
-WaiterContext::WaiterContext()
-{
-  Step = Status::Started;
-}
-
-bool WaiterContext::Prepare()
-{
-  if (Step == Status::Started && Prepared != nullptr && Prepared(Data) == 0)
-  {
-    Step = Status::Prepared;
-    return true;
-  }
-  return false;
-}
-
-bool WaiterContext::Request()
-{
-  if (Step == Status::Prepared && Requested != nullptr && Requested(Data) == 0)
-  {
-    Step = Status::Requested;
-    return true;
-  }
-  return false;
-}
-
-bool WaiterContext::Execute(const char *path, const char *app_root, int argc, char *argv[])
-{
-  if (Step == Status::Requested && Executed != nullptr &&
-      Executed(path, app_root, argc, argv, Data) == 0)
-  {
-    Step = Status::Executed;
-    return true;
-  }
-  return false;
-}
-
-}  // namespace runtime
-}  // namespace dotnet
-
-using dotnet::runtime::Waiter;
-using dotnet::runtime::WaiterContext;
-
-static Waiter waiter;
-
-void register_launching_callback(prepared_callback prepared,
-    requested_callback requested, executed_callback executed, void *data)
-{
-  WaiterContext context;
-  context.Prepared = prepared;
-  context.Requested = requested;
-  context.Executed = executed;
-  context.Data = data;
-
-  waiter.SetContext(context);
-}
-
-void wait_for_launching(int argc, char *argv[])
-{
-  _DBG("wait_for_launching...");
-
-  waiter.WaitToLaunching(argc, argv);
-}
-
diff --git a/NativeLauncher/launcher/waiter/waiter.h b/NativeLauncher/launcher/waiter/waiter.h
deleted file mode 100644 (file)
index bd3be5f..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <string>
-#include <functional>
-
-#include <iostream>
-
-extern "C" {
-  typedef int (*prepared_callback)(void *data);
-  typedef int (*requested_callback)(void *data);
-  typedef int (*executed_callback)(const char* path, const char* app_root, int argc, char *argv[], void *data);
-
-  void register_launching_callback(prepared_callback prepared,
-      requested_callback requested, executed_callback executed, void *data);
-  void wait_for_launching(int argc, char *argv[]);
-}
-
-namespace dotnet {
-namespace runtime {
-
-using std::string;
-using Receiver = std::function<void(int)>;
-
-enum Status
-{
-  Started,
-  Prepared,
-  Requested,
-  Executed
-};
-
-class WaiterContext
-{
-  public:
-    prepared_callback Prepared;
-    requested_callback Requested;
-    executed_callback Executed;
-
-    void *Data;
-
-    WaiterContext();
-    bool Prepare();
-    bool Request();
-    bool Execute(const char *path, const char *app_root, int argc, char *argv[]);
-
-  private:
-    Status Step;
-};
-
-class Waiter
-{
-  public:
-    struct AppInfo
-    {
-      string AppPath;
-      string AppId;
-      string PkgId;
-      string PkgType;
-    };
-
-    int WaitToLaunching(int argc, char *argv[]);
-    void Stop();
-
-    void RegisterFd(int fd, Receiver receiver);
-    void DeregisterFd(int fd);
-    void SetContext(WaiterContext ctx);
-
-  protected:
-    void OnPrepared();
-    void OnRequested(const AppInfo&);
-    void OnWaiting();
-    void OnExecuted(const char *path, const char *app_root, int argc, char *argv[]);
-
-  private:
-    WaiterContext context;
-};
-
-}  // namespace runtime
-}  // namespace dotnet
index 75dbcec..1019db4 100755 (executable)
@@ -151,6 +151,7 @@ bool FileNotExist(const std::string& path)
   return stat(path.c_str(), &sb) != 0;
 }
 
+#ifdef NOT_USE_FUNCTION
 static bool ExtCheckAndGetFileNameIfExist(const std::string&  dir, const std::string& ext, struct dirent* entry, std::string& filename)
 {
   std::string fname(entry->d_name);
@@ -177,6 +178,7 @@ static bool ExtCheckAndGetFileNameIfExist(const std::string&  dir, const std::st
 
   return true;
 }
+#endif
 
 std::string StripNIDLL(const std::string& path)
 {
index dd96abf..3423d80 100755 (executable)
@@ -40,12 +40,6 @@ namespace Tizen.Runtime.Coreclr
 
         private HashSet<FileInfo> _assemblyCache = new HashSet<FileInfo>();
 
-        private Dictionary<string, string> _unmanagedDictionary = new Dictionary<string, string>()
-        {
-            {"sqlite3", "/lib/libsqlite3.so.0"},
-            {"libsqlite3.so", "/lib/libsqlite3.so.0"}
-        };
-
         public AssemblyLoader()
         {
             AssemblyLoadContext.Default.Resolving += OnResolving;
@@ -112,18 +106,6 @@ namespace Tizen.Runtime.Coreclr
 
         protected override IntPtr LoadUnmanagedDll(string unmanagedDllName)
         {
-            if (_unmanagedDictionary.ContainsKey(unmanagedDllName))
-            {
-                if (File.Exists(_unmanagedDictionary[unmanagedDllName]))
-                {
-                    unmanagedDllName = _unmanagedDictionary[unmanagedDllName];
-                }
-                else
-                {
-                    unmanagedDllName = _unmanagedDictionary[unmanagedDllName].Replace("/lib/", "/lib64/");
-                }
-            }
-
             IntPtr native = base.LoadUnmanagedDll(unmanagedDllName);
             if (native == IntPtr.Zero)
             {
index de0b293..afd6fd4 100644 (file)
@@ -61,21 +61,9 @@ namespace Tizen.Runtime.Coreclr
         {
             try
             {
-                string preloadPath = "";
-                ICustomAttributeProvider assembly = typeof(AssemblyManager).GetTypeInfo().Assembly;
-                var attributes = assembly.GetCustomAttributes(typeof(DefaultConfigAttribute), false);
-                foreach (DefaultConfigAttribute dca in attributes)
+                if (!Initialize())
                 {
-                    ALog.Debug($"{dca.Key} = {dca.Value}");
-                    if (dca.Key == "PreloadPath")
-                    {
-                        preloadPath = dca.Value;
-                    }
-                }
-
-                if (!Initialize(preloadPath))
-                {
-                    ALog.Debug($"Failed to Initialized with {preloadPath}");
+                    ALog.Debug($"Failed to Initialized");
                 }
             }
             catch(Exception e)
@@ -105,7 +93,7 @@ namespace Tizen.Runtime.Coreclr
             PrintException(e);
         }
 
-        public static bool Initialize(string preloadFile)
+        public static bool Initialize()
         {
             try
             {
@@ -120,7 +108,6 @@ namespace Tizen.Runtime.Coreclr
                 Delegate handler = handlerInfo.CreateDelegate(unhandledException.EventHandlerType);
                 var addMethod = unhandledException.GetAddMethod(true);
                 addMethod.Invoke(appdomain, new[] {handler});
-
             }
             catch (Exception e)
             {
@@ -131,45 +118,6 @@ namespace Tizen.Runtime.Coreclr
             try
             {
                 CurrentAssemblyLoaderContext = new AssemblyLoader();
-
-                if (!string.IsNullOrEmpty(preloadFile))
-                {
-                    ALog.Debug($"Load from [{preloadFile}]");
-                    FileInfo f = new FileInfo(preloadFile);
-                    if (File.Exists(f.FullName))
-                    {
-                        using (StreamReader sr = File.OpenText(f.FullName))
-                        {
-                            string s = String.Empty;
-                            while ((s = sr.ReadLine()) != null)
-                            {
-                                ALog.Debug($"preload dll : {s}");
-                                try
-                                {
-                                    Assembly asm = CurrentAssemblyLoaderContext.LoadFromPath(s);
-
-                                    // this works strange, vm can't load types except loaded in here.
-                                    // so user code spit out not found exception.
-                                    /*
-                                    if (asm != null)
-                                    {
-                                        foreach (TypeInfo t in asm.DefinedTypes)
-                                        {
-                                            ALog.Debug("===> TYPE : " + t.FullName);
-                                            GC.KeepAlive(t.AsType());
-                                        }
-                                    }
-                                    */
-                                }
-                                catch (Exception e)
-                                {
-                                    ALog.Debug("Exception on preload");
-                                    PrintException(e);
-                                }
-                            }
-                        }
-                    }
-                }
             }
             catch (Exception e)
             {
index 78ca701..63235b0 100755 (executable)
@@ -43,6 +43,7 @@ Requires(preun): /usr/bin/systemctl
 %define _runtime_dir /usr/share/dotnet/shared/Microsoft.NETCore.App/1.0.0
 %define _install_plugin_dir /usr/etc/package-manager/parserlib
 %define _install_mdplugin_dir /etc/package-manager/parserlib/metadata
+%define _native_lib_dir /usr/share/dotnet.tizen/lib
 
 ExcludeArch: aarch64
 
@@ -58,6 +59,11 @@ launching dotnet apps without dotent runtime installed
 %prep
 %setup -q
 
+%define use_managed_launcher 0
+%if %{use_managed_launcher}
+       %define USE_MANAGED_LAUNCHER ENABLE
+%endif
+
 %build
 cmake \
        -DCMAKE_INSTALL_PREFIX=%{_prefix} \
@@ -70,10 +76,14 @@ cmake \
        -DDEVICE_API_DIR=%{_device_api_dir} \
        -DRUNTIME_DIR=%{_runtime_dir} \
        -DCROSSGEN_PATH=%{_device_api_dir}/crossgen \
+%if %{use_managed_launcher}
        -DCORECLR_LAUNCHER_ASSEMBLY_PATH=%{_bindir}/Tizen.Runtime.Coreclr.dll \
+%endif
        -DINSTALL_PLUGIN_DIR=%{_install_plugin_dir} \
        -DINSTALL_MDPLUGIN_DIR=%{_install_mdplugin_dir} \
        -DVERSION=%{version} \
+       -DUSE_MANAGED_LAUNCHER=%{?USE_MANAGED_LAUNCHER:%USE_MANAGED_LAUNCHER} \
+       -DNATIVE_LIB_DIR=%{_native_lib_dir} \
        NativeLauncher
 
 make %{?jobs:-j%jobs} VERBOSE=1
@@ -87,18 +97,26 @@ xbuild \
 %install
 rm -rf %{buildroot}
 %make_install
+%if %{use_managed_launcher}
 install -p -m 644 Tizen.Runtime/bin/Tizen.Runtime.Coreclr.dll %{buildroot}%{_bindir}
+%endif
+
+mkdir -p %{buildroot}%{_native_lib_dir}
+ln -sf %{_libdir}/libsqlite3.so.0 %{buildroot}%{_native_lib_dir}/libsqlite3.so
 
 %files
 %manifest dotnet-launcher.manifest
 %{_loaderdir}/dotnet.loader
 %{_loaderdir}/dotnet.launcher
 %{_loaderdir}/dotnet.debugger
+%{_native_lib_dir}/libsqlite3.so
 %caps(cap_mac_admin,cap_setgid=ei) %{_bindir}/dotnet-launcher
 %caps(cap_mac_admin,cap_setgid=ei) %{_bindir}/nitool
 %caps(cap_mac_admin,cap_setgid=ei) %{_install_plugin_dir}/libui-application.so
 %caps(cap_mac_admin,cap_setgid=ei) %{_install_mdplugin_dir}/libprefer_dotnet_aot_plugin.so
+%if %{use_managed_launcher}
 %caps(cap_mac_admin,cap_setgid=ei) %{_bindir}/Tizen.Runtime.Coreclr.dll
+%endif
 
 %files -n scd-launcher
 %caps(cap_mac_admin,cap_setgid=ei) %{_bindir}/scd-launcher