Exemplo n.º 1
0
        private static void ConfigureBridgeOptionsForConvertPlugin(ref BridgeOptions bridgeOptions, UnityPlugin config)
        {
            bridgeOptions.ProjectProperties = new ProjectProperties();

            bridgeOptions.BridgeLocation = references["Bridge"]["Bridge.dll"];
            bridgeOptions.Lib            = build["Output"][config.pluginName + ".dll"];
            bridgeOptions.ReferencesPath = references["Bridge"].FullPath;
            bridgeOptions.ProjectProperties.Configuration = configs["Text"]["bridge.json"].PathToAssets();

            bridgeOptions.Folder            = Path.GetFullPath(".");
            bridgeOptions.Sources           = UnityPluginUtil.GetSource(config).FilesListToLine();
            bridgeOptions.ExcludeSubFolders = UnityPluginUtil.GetExclude(config).FilesListToLine();

            bridgeOptions.Rebuild         = true;
            bridgeOptions.Recursive       = true;
            bridgeOptions.Name            = config.pluginName;
            bridgeOptions.OutputLocation  = bridgeOptions.Folder;
            bridgeOptions.DefaultFileName = Path.GetFileNameWithoutExtension(bridgeOptions.Lib);
            bridgeOptions.ProjectProperties.AssemblyName    = bridgeOptions.DefaultFileName;
            bridgeOptions.ProjectProperties.DefineConstants = config.defineMacros.Join(";");
        }
        private static void GeneratePluginDLL(UnityPlugin config)
        {
            if (!config.enable)
            {
                return;
            }
            var sources = UnityPluginUtil.GetSource(config);
            var exc     = UnityPluginUtil.GetExclude(config);

            sources = sources.Except(exc).ToList();
            if (sources == null || sources.Count == 0)
            {
                return;
            }

            var refs = UnityPluginUtil.GetLib(config, true, true);

            if (refs == null || refs.Count == 0)
            {
                return;
            }

            // rename dist dll
            var dist = config.stubPath.stubDLLPath.Replace("-stub.dll", "-internal.dll");
            var os   = File.Create(dist);

            EmitResult result;

            try {
                // comment this for TMP issue(internal visibility)
                result = DLLProc.BuildDLL(config.pluginName /* + "-internal" */, os, sources, config.defineMacros,
                                          refs, true);
            } finally {
                os.Close();
            }
            if (result == null || !result.Success)
            {
                throw new Exception();
            }
        }