summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorj-h.choi <j-h.choi@samsung.com>2019-08-06 09:50:38 +0900
committer조웅석/Common Platform Lab(SR)/Principal Engineer/삼성전자 <ws77.cho@samsung.com>2019-08-07 07:40:53 +0900
commit42e47e57b40b9e5365a97b9eea194ab63bb7a031 (patch)
tree6612410edee0ef31e6bc7e808053e21d4ac1ec12
parent753554e9794f8829159d95d4c5a40a360b7a81f9 (diff)
downloadlauncher-42e47e57b40b9e5365a97b9eea194ab63bb7a031.tar.gz
launcher-42e47e57b40b9e5365a97b9eea194ab63bb7a031.tar.bz2
launcher-42e47e57b40b9e5365a97b9eea194ab63bb7a031.zip
Nuget with no dependency applies TAC
-rw-r--r--NativeLauncher/inc/ni_common.h7
-rw-r--r--NativeLauncher/installer-plugin/prefer_dotnet_aot_plugin.cc2
-rw-r--r--NativeLauncher/tool/ni_common.cc37
-rw-r--r--NativeLauncher/tool/tac_common.cc13
-rw-r--r--NativeLauncher/util/utils.cc22
5 files changed, 67 insertions, 14 deletions
diff --git a/NativeLauncher/inc/ni_common.h b/NativeLauncher/inc/ni_common.h
index 3f3de82..9c1fc26 100644
--- a/NativeLauncher/inc/ni_common.h
+++ b/NativeLauncher/inc/ni_common.h
@@ -67,6 +67,13 @@ void createNiPlatform(bool enableR2R);
ni_error_e createNiDll(const std::string& dllPath, bool enableR2R);
/**
+ * @brief create native images for TAC DLLs.
+ * @param[i] rootPaths directories whicn contains DLLs
+ * @param[i] count number of rootPath
+ */
+void createNiUnderTAC(const std::string rootPaths[], int count);
+
+/**
* @brief create native images with files under specific directory.
* @param[i] rootPaths directories whicn contains DLLs
* @param[i] count number of rootPath
diff --git a/NativeLauncher/installer-plugin/prefer_dotnet_aot_plugin.cc b/NativeLauncher/installer-plugin/prefer_dotnet_aot_plugin.cc
index 91204f5..f48ffe7 100644
--- a/NativeLauncher/installer-plugin/prefer_dotnet_aot_plugin.cc
+++ b/NativeLauncher/installer-plugin/prefer_dotnet_aot_plugin.cc
@@ -84,7 +84,7 @@ extern "C" int PKGMGR_MDPARSER_PLUGIN_INSTALL(const char *pkgId, const char *app
std::string originPath = bf::read_symlink(symPath).string();
std::string originNiPath = originPath.substr(0, originPath.rfind(".dll")) + ".ni.dll";
if (!bf::exists(originNiPath)) {
- if(createNiDll(originPath, false) != NI_ERROR_NONE) {
+ if(createNiDllUnderPkgRoot(pkgId, originPath, false) != NI_ERROR_NONE) {
_ERR("Failed to create NI file [%s]", originPath.c_str());
return -1;
}
diff --git a/NativeLauncher/tool/ni_common.cc b/NativeLauncher/tool/ni_common.cc
index 69c2dcf..f1127e4 100644
--- a/NativeLauncher/tool/ni_common.cc
+++ b/NativeLauncher/tool/ni_common.cc
@@ -52,6 +52,7 @@
#define __XSTR(x) #x
#define __STR(x) __XSTR(x)
static const char* __CROSSGEN_PATH = __STR(CROSSGEN_PATH);
+static const char* __TAC_DIR = __STR(TAC_DIR);
#ifdef UNIQUE_DEFAULT_BASE_ADDR_SUPPORT
static const char* __SYSTEM_BASE_FILE = __STR(SYSTEM_BASE_FILE);
@@ -239,7 +240,7 @@ static ni_error_e crossgen(const std::string& dllPath, const std::string& appPat
return NI_ERROR_UNKNOWN;
}
- if (isAppNI) {
+ if (isAppNI && strstr(absNiPath.c_str(), __TAC_DIR) == NULL) {
absNiPath = getAppNIPath(absNiPath);
}
@@ -440,6 +441,40 @@ ni_error_e createNiDll(const std::string& dllPath, bool enableR2R)
return status;
}
+void createNiUnderTAC(const std::string rootPaths[], int count)
+{
+ std::string appPaths;
+ try {
+ for (auto& nuget : bf::recursive_directory_iterator(__TAC_DIR)) {
+ std::string nugetPath = nuget.path().string();
+ if (bf::is_directory(nugetPath)) {
+ appPaths += nugetPath;
+ appPaths += ':';
+ }
+ }
+ if (appPaths.back() == ':') {
+ appPaths.pop_back();
+ }
+
+ auto convert = [&appPaths](const std::string& path, const char* name) {
+ if (strstr(path.c_str(), TAC_APP_LIST_DB) != NULL ||
+ strstr(path.c_str(), TAC_APP_LIST_RESTORE_DB) != NULL ||
+ strstr(path.c_str(), TAC_SHA_256_INFO) != NULL)
+ return;
+ if (!crossgen(path, appPaths.c_str(), false)) {
+ waitInterval();
+ }
+ };
+
+ for (int i = 0; i < count; i++) {
+ scanFilesInDir(rootPaths[i], convert, -1);
+ }
+ } catch (const bf::filesystem_error& error) {
+ fprintf(stderr, "Failed to recursive directory: %s", error.what());
+ return;
+ }
+}
+
void createNiUnderDirs(const std::string rootPaths[], int count, bool enableR2R, bool isAppNI)
{
createCoreLibNI(enableR2R);
diff --git a/NativeLauncher/tool/tac_common.cc b/NativeLauncher/tool/tac_common.cc
index 78c20cf..b767c91 100644
--- a/NativeLauncher/tool/tac_common.cc
+++ b/NativeLauncher/tool/tac_common.cc
@@ -286,18 +286,7 @@ tac_error_e regenerateTAC()
{
const std::string tacDir[] = {__TAC_DIR};
removeNiUnderDirs(tacDir, 1);
-
- auto convert = [](const std::string& path, std::string name) {
- if (strstr(path.c_str(), TAC_APP_LIST_DB) != NULL ||
- strstr(path.c_str(), TAC_APP_LIST_RESTORE_DB) != NULL ||
- strstr(path.c_str(), TAC_SHA_256_INFO) != NULL)
- return;
- if(createNiDll(path, false) != NI_ERROR_NONE) {
- fprintf(stderr, "Failed to create NI file [%s]\n", path.c_str());
- return;
- }
- };
- scanFilesInDir(tacDir[0], convert, -1);
+ createNiUnderTAC(tacDir, 1);
return TAC_ERROR_NONE;
}
diff --git a/NativeLauncher/util/utils.cc b/NativeLauncher/util/utils.cc
index 45b2bad..3d5a5f6 100644
--- a/NativeLauncher/util/utils.cc
+++ b/NativeLauncher/util/utils.cc
@@ -619,6 +619,19 @@ std::vector<std::string> depsJsonParser(std::string rootPath, std::string execNa
}
const Json::Value runtimeTargetName = root["runtimeTarget"]["name"];
const Json::Value nugetPackages = root["targets"][runtimeTargetName.asString().c_str()];
+ std::vector<std::string> appDependencies;
+ for (auto& nuget : nugetPackages.getMemberNames()) {
+ if (strstr(nuget.c_str(), (execName.substr(0, execName.find(".Tizen."))).c_str()) != NULL ||
+ strstr(nuget.c_str(), (execName.substr(0, execName.find(".dll"))).c_str()) != NULL) {
+ const Json::Value assemblies = nugetPackages[nuget.c_str()]["runtime"];
+ if (assemblies != Json::nullValue) {
+ const Json::Value dependencies = nugetPackages[nuget.c_str()]["dependencies"];
+ for (auto& dependency : dependencies.getMemberNames()) {
+ appDependencies.push_back(dependency);
+ }
+ }
+ }
+ }
for (auto& nuget : nugetPackages.getMemberNames()) {
//Skip the nuget package related to Tizen
if (strstr(nuget.c_str(), TIZEN_DOTNET_NUGET) == NULL &&
@@ -634,6 +647,14 @@ std::vector<std::string> depsJsonParser(std::string rootPath, std::string execNa
if (strstr(dependency.c_str(), TIZEN_DOTNET_NUGET) == NULL &&
strstr(dependency.c_str(), NET_STANDARD_LIBRARY_NUGET) == NULL) {
hasDependency = true;
+ for (auto& ad : appDependencies) {
+ if (!strcmp(ad.c_str(), dependency.c_str())) {
+ hasDependency = true;
+ break;
+ } else {
+ hasDependency = false;
+ }
+ }
}
}
if (!hasDependency) {
@@ -660,6 +681,7 @@ std::vector<std::string> depsJsonParser(std::string rootPath, std::string execNa
}
}
}
+ appDependencies.clear();
ifs.close();
}
}