Exemplo n.º 1
0
 void RemovePlatformIfNotAvailable(ClrApi api, string platform)
 {
     PluginInfo.PlatformInfo platformInfo = this.PluginInfo.Platforms.FirstOrDefault(p => p.Name == platform);
     if (!api.Platforms.Contains(platform) && platformInfo != null)
     {
         this.PluginInfo.Platforms.Remove(platformInfo);
     }
 }
Exemplo n.º 2
0
        internal static void CollectSourceFilesInfo(string sourceDirectoryPath, PluginInfo pluginInfo)
        {
            foreach (string platform in new[]
            {
                PluginInfo.AndroidPlatformName,
                PluginInfo.IOSPlatformName,
                PluginInfo.WindowsPlatformName
            })
            {
                PluginInfo.PlatformInfo platformInfo =
                    pluginInfo.Platforms.FirstOrDefault(p => p.Name == platform);
                if (platformInfo == null)
                {
                    continue;
                }

                string platformSourcePath = Path.Combine(sourceDirectoryPath, platform);
                if (Directory.Exists(platformSourcePath))
                {
                    ICollection <string> extensions = PluginLinker.GetFileExtensionsForNativeCode(platform);
                    foreach (string sourceFilePath in Directory.GetFiles(platformSourcePath))
                    {
                        string relativeFilePath = Path.GetFullPath(sourceFilePath)
                                                  .Substring(Path.GetFullPath(sourceDirectoryPath).Length + 1);
                        if (extensions.Any(e => sourceFilePath.EndsWith(e, StringComparison.OrdinalIgnoreCase)))
                        {
                            PluginInfo.SourceFileInfo sourceFileInfo =
                                new PluginInfo.SourceFileInfo
                            {
                                SourceFilePath = relativeFilePath.Replace("\\", "/"),
                            };

                            if (sourceFilePath.EndsWith(".java", StringComparison.OrdinalIgnoreCase))
                            {
                                string javaPackage = CordovaPluginLinker.GetJavaSourceFilePackage(sourceFilePath);
                                if (javaPackage != null)
                                {
                                    sourceFileInfo.TargetDirectoryPath = "src/" + javaPackage.Replace('.', '/');
                                }
                            }

                            if (!platformInfo.ResourceFiles.Any(r => String.Equals(
                                                                    r.SourceFilePath, sourceFileInfo.SourceFilePath, StringComparison.OrdinalIgnoreCase)))
                            {
                                platformInfo.SourceFiles.Add(sourceFileInfo);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        void GenerateCSharpBindings()
        {
            PluginInfo.PlatformInfo iosPlatformInfo = this.PluginInfo.IOSPlatform;
            if (iosPlatformInfo == null)
            {
                throw new InvalidOperationException("iOS platform is missing in plugin.xml");
            }

            string pluginProjectName = Path.GetFileNameWithoutExtension(this.pluginProjectFilePath);
            string outputPath        = Path.GetFullPath(this.PlatformIntermediatePath);

            string iosSdkName = this.GetSharpieIosSdkName();

            Utils.Execute(
                "/usr/local/bin/sharpie",
                $"-tlm-do-not-submit bind -n {bindingNamespace} " +
                $"{pluginProjectName}/{pluginProjectName}.h " +
                $"-sdk {iosSdkName} " +
                $"-o \"{outputPath}\"",
                this.PlatformSourcePath,
                TimeSpan.FromSeconds(60));

            this.FixGeneratedCSharpCode();
        }
Exemplo n.º 4
0
        protected virtual void Init()
        {
            if (String.IsNullOrEmpty(this.SourcePath))
            {
                throw new ArgumentNullException(nameof(SourcePath));
            }
            else if (String.IsNullOrEmpty(this.IntermediatePath))
            {
                throw new ArgumentNullException(nameof(IntermediatePath));
            }

            if (!Directory.Exists(this.SourcePath))
            {
                throw new DirectoryNotFoundException("Source path not found: " + this.SourcePath);
            }

            this.PlatformSourcePath = Path.Combine(this.SourcePath, this.PlatformName);
            if (!String.IsNullOrEmpty(this.Language))
            {
                this.PlatformSourcePath += "-" + this.Language;
            }

            if (!Directory.Exists(this.PlatformSourcePath))
            {
                throw new DirectoryNotFoundException("Platform source path not found: " + this.PlatformSourcePath);
            }

            string pluginInfoFilePath = Path.Combine(this.SourcePath, "plugin.xml");

            if (!File.Exists(pluginInfoFilePath))
            {
                throw new FileNotFoundException("Plugin info file not found: " + pluginInfoFilePath);
            }

            using (StreamReader reader = File.OpenText(pluginInfoFilePath))
            {
                this.PluginInfo = PluginInfo.FromXml(reader);
            }

            if (!Directory.Exists(this.IntermediatePath))
            {
                Directory.CreateDirectory(this.IntermediatePath);
            }

            this.PlatformIntermediatePath = Path.Combine(this.IntermediatePath, this.PlatformName);
            if (!Directory.Exists(this.PlatformIntermediatePath))
            {
                Directory.CreateDirectory(this.PlatformIntermediatePath);
            }
            else
            {
                Utils.ClearDirectory(this.PlatformIntermediatePath, new string[] { "javadoc", "tools" });
            }

            PluginInfo.PlatformInfo platformInfo =
                this.PluginInfo.Platforms.SingleOrDefault(p => p.Name == this.PlatformName);
            if (platformInfo == null)
            {
                throw new InvalidOperationException(
                          "Platform info for " + this.PlatformName + " platform is missing from plugin.xml.");
            }

            Log.Important($"Compiling {this.PlatformName} APIs at\n" +
                          Utils.EnsureTrailingSlash(Path.GetFullPath(this.PlatformIntermediatePath)));
        }