- for (int i = 0; i < count; i++) {
- scanFilesInDir(rootPaths[i], convert, 1);
- }
-}
-
-int createNiUnderPkgRoot(const std::string& pkgId, bool enableR2R)
-{
- std::string pkgRoot;
- if (getRootPath(pkgId, pkgRoot) < 0) {
- fprintf(stderr, "Failed to get root path from [%s]\n", pkgId.c_str());
- return -1;
+ std::vector<std::string> targetPaths;
+ splitPath(rootPaths, targetPaths);
+ for (const auto &path : targetPaths) {
+ // TAC directory should be handled specially because that contains symlink of native image file.
+ if (strstr(path.c_str(), TAC_SYMLINK_SUB_DIR) != NULL) {
+ if (!isDirectory(path)) {
+ continue;
+ }
+ // make native image symlink if not exist under tac directory
+ try {
+ for (auto& symlinkAssembly : bf::recursive_directory_iterator(path)) {
+ std::string symPath = symlinkAssembly.path().string();
+ if (!isManagedAssembly(symPath)) {
+ continue;
+ }
+
+ // if there is symlink and original file for native image, skip generation
+ std::string symNIPath = symPath.substr(0, symPath.rfind(".dll")) + ".ni.dll";
+ if (isFile(symNIPath)) {
+ continue;
+ }
+
+ // if original native image not exist, generate native image
+ std::string originPath = bf::read_symlink(symPath).string();
+ std::string originNIPath = originPath.substr(0, originPath.rfind(".dll")) + ".ni.dll";
+ if (!isFile(originNIPath)) {
+ if (!crossgen(originPath, path.c_str(), flags)) {
+ waitInterval();
+ }
+ }
+
+ // if no symlink file exist, create symlink
+ if (!isFile(symNIPath)) {
+ bf::create_symlink(originNIPath, symNIPath);
+ copySmackAndOwnership(symPath.c_str(), symNIPath.c_str(), true);
+ fprintf(stdout, "%s symbolic link file generated successfully.\n", symNIPath.c_str());
+ }
+ }
+ } catch (const bf::filesystem_error& error) {
+ fprintf(stderr, "Failed to recursive directory: %s\n", error.what());
+ return NI_ERROR_UNKNOWN;
+ }
+ } else {
+ scanFilesInDirectory(path, convert, 0);
+ }