Ejemplo n.º 1
0
        internal static void CopyNativeCode(string sourcePath, string[] sourceSubdirectories, string targetPath)
        {
            foreach (string platform in new[]
            {
                PluginInfo.AndroidPlatformName,
                PluginInfo.IOSPlatformName,
            })
            {
                string platformSourcePath = Path.Combine(sourcePath, platform);
                if (!Directory.Exists(platformSourcePath))
                {
                    continue;
                }

                string platformTargetPath = Path.Combine(targetPath, platform);
                if (!Directory.Exists(platformTargetPath))
                {
                    Directory.CreateDirectory(platformTargetPath);
                }

                ICollection <string> includeExtensions  = GetFileExtensionsForNativeCode(platform);
                ICollection <string> excludeDirectories = new List <string>(new[] { "build" });

                if (sourceSubdirectories != null)
                {
                    foreach (string sourceSubdirectory in sourceSubdirectories)
                    {
                        string sourceSubPath = Path.Combine(platformSourcePath, sourceSubdirectory);
                        PluginLinker.CopyFiles(
                            sourceSubPath, platformTargetPath, false, includeExtensions, excludeDirectories);
                    }
                }
                else
                {
                    foreach (string frameworkSourceDirectory in Directory.GetDirectories(platformSourcePath, "*.framework"))
                    {
                        string frameworkName = Path.GetFileName(frameworkSourceDirectory);
                        excludeDirectories.Add(frameworkName);

                        string frameworkTargetDirectory = Path.Combine(platformTargetPath, frameworkName);
                        if (!Directory.Exists(frameworkTargetDirectory))
                        {
                            Directory.CreateDirectory(frameworkTargetDirectory);
                        }

                        PluginLinker.CopyFiles(frameworkSourceDirectory, frameworkTargetDirectory, true);
                    }

                    PluginLinker.CopyFiles(
                        platformSourcePath, platformTargetPath, false, includeExtensions, excludeDirectories);
                }
            }
        }
Ejemplo n.º 2
0
        protected static void CopyFiles(
            string sourcePath,
            string targetPath,
            bool preserveDirectories,
            ICollection <string> includeExtensions  = null,
            ICollection <string> excludeDirectories = null)
        {
            PluginLinker.CopyFiles(sourcePath, targetPath, preserveDirectories, relativePath =>
            {
                if (excludeDirectories != null)
                {
                    char slash = Path.DirectorySeparatorChar;
                    foreach (string excludeDirectory in excludeDirectories)
                    {
                        if (relativePath.StartsWith(excludeDirectory + slash, StringComparison.OrdinalIgnoreCase) ||
                            relativePath.IndexOf(slash + excludeDirectory + slash, StringComparison.OrdinalIgnoreCase) > 0)
                        {
                            return(false);
                        }
                    }
                }

                if (includeExtensions != null)
                {
                    foreach (string includeExtension in includeExtensions)
                    {
                        if (relativePath.EndsWith(includeExtension, StringComparison.OrdinalIgnoreCase))
                        {
                            return(true);
                        }
                    }

                    return(false);
                }

                return(true);
            });
        }