Esempio n. 1
0
 public static bool BuildAsset(BuildTarget target, List <string> resourceList)
 {
     if (resourceList.Count > 0)
     {
         return(ResourcesBuilder.Build(PathUtility.AssetBundlePath, target, resourceList));
     }
     return(false);
 }
Esempio n. 2
0
        private void BuildMetadata()
        {
            if (options.Resources != null && options.Resources.Count != 0)
            {
                ResourcesBuilder resourcesBuilder = new ResourcesBuilder(symbols);
                resourcesBuilder.BuildResources(options.Resources);
            }

            MetadataBuilder mdBuilder = new MetadataBuilder(this);

            appSymbols = mdBuilder.BuildMetadata(compilationUnitList, symbols, options);

            CheckForDuplicateTypes();
            TransformSymbols();
        }
Esempio n. 3
0
    private static void ResetAllAssetBundleName()
    {
        string[] abNameArr = AssetDatabase.GetAllAssetBundleNames();
        for (int i = 0; i < abNameArr.Length; i++)
        {
            EditorUtility.DisplayProgressBar("Remove All AssetBundleName", abNameArr[i], (float)i / abNameArr.Length);
            AssetDatabase.RemoveAssetBundleName(abNameArr[i], true);
        }
        AssetDatabase.SaveAssets();
        EditorUtility.ClearProgressBar();

        //set abname
        var resourceList = ResourceBuildTool.GetBuildResources(PathUtility.FullPathToProjectPath(PathUtility.ResourcesPath));

        CollectionUtility.Insert(resourceSet, resourceList);

        if (!ResourcesBuilder.SetAssetsBundleName(resourceSet))
        {
            Debug.LogError("Error SetAssetsBundleName失敗");
        }
        EditorUtility.ClearProgressBar();
    }
Esempio n. 4
0
    public static void BuildGame(
        string buildPath,
        BuildTarget target,
        BuildOptions options,
        List <string> resourceList,
        bool isClear = false)
    {
        var scenes = GetScenes().ToArray();

        if (isClear)
        {
            EditorAssist.EmptyDirectory(PathUtility.AssetBundlePath);
        }

        //编bundle
        if (!ShellBuild.g_bSkipBundle)
        {
            if (!BuildAsset(target, resourceList))
            {
                Debug.Log("error BuildAsset failed!!!");
                return;
            }
        }


        //编配置表
        ResourcesBuilder.BuildText();
        ResourcesBuilder.CopyImage();

        //编player
        if (!ShellBuild.g_bSkipBuildPlayer)
        {
            //删除除 目录名.manifest以外的所有manifest文件
            EditorAssist.DeleteAllManifestFiles();
            var msgBuild = BuildPipeline.BuildPlayer(scenes, buildPath, target, options);
            EditorAssist.DeleteAllManifestFiles();
        }
    }
Esempio n. 5
0
        private void BuildMetadata()
        {
            if ((_options.Resources != null) && (_options.Resources.Count != 0))
            {
                ResourcesBuilder resourcesBuilder = new ResourcesBuilder(_symbols);
                resourcesBuilder.BuildResources(_options.Resources);
            }

            MetadataBuilder mdBuilder = new MetadataBuilder(this);

            _appSymbols = mdBuilder.BuildMetadata(_compilationUnitList, _symbols, _options);

            // Check if any of the types defined in this assembly conflict against types in
            // imported assemblies.

            Dictionary <string, TypeSymbol> types = new Dictionary <string, TypeSymbol>();

            foreach (TypeSymbol importedType in _importedSymbols)
            {
                types[importedType.FullGeneratedName] = importedType;
            }

            foreach (TypeSymbol appType in _appSymbols)
            {
                if ((appType.IsApplicationType == false) || (appType.Type == SymbolType.Delegate))
                {
                    // Skip the check for types that are marked as imported, as they
                    // aren't going to be generated into the script.
                    // Delegates are implicitly imported types, as they're never generated into
                    // the script.
                    continue;
                }

                if ((appType.Type == SymbolType.Class) &&
                    (((ClassSymbol)appType).PrimaryPartialClass != appType))
                {
                    // Skip the check for partial types, since they should only be
                    // checked once.
                    continue;
                }

                string name = appType.FullGeneratedName;
                if (types.ContainsKey(name))
                {
                    string error = "The type '" + name + "' conflicts with another existing type with the same full name. This might be because a referenced assembly uses the same type, or you have multiple types with the same name across namespaces mapped to the same script namespace.";
                    ((IErrorHandler)this).ReportError(error, null);
                }
                else
                {
                    types[name] = appType;
                }
            }

            // Capture whether there are any test types in the project
            // when not compiling the test flavor script. This is used to determine
            // if the test flavor script should be compiled in the build task.

            if (_options.IncludeTests == false)
            {
                foreach (TypeSymbol appType in _appSymbols)
                {
                    if (appType.IsApplicationType && appType.IsTestType)
                    {
                        _options.HasTestTypes = true;
                    }
                }
            }

#if DEBUG
            if (_options.InternalTestType == "metadata")
            {
                StringWriter testWriter = new StringWriter();

                testWriter.WriteLine("Metadata");
                testWriter.WriteLine("================================================================");

                SymbolSetDumper symbolDumper = new SymbolSetDumper(testWriter);
                symbolDumper.DumpSymbols(_symbols);

                testWriter.WriteLine();
                testWriter.WriteLine();

                _testOutput = testWriter.ToString();
            }
#endif // DEBUG

            if (_options.Minimize)
            {
                SymbolObfuscator     obfuscator             = new SymbolObfuscator();
                SymbolSetTransformer obfuscationTransformer = new SymbolSetTransformer(obfuscator);

                ICollection <Symbol> obfuscatedSymbols = obfuscationTransformer.TransformSymbolSet(_symbols, /* useInheritanceOrder */ true);

#if DEBUG
                if (_options.InternalTestType == "minimizationMap")
                {
                    StringWriter testWriter = new StringWriter();

                    testWriter.WriteLine("Minimization Map");
                    testWriter.WriteLine("================================================================");

                    List <Symbol> sortedObfuscatedSymbols = new List <Symbol>(obfuscatedSymbols);
                    sortedObfuscatedSymbols.Sort(delegate(Symbol s1, Symbol s2) {
                        return(String.Compare(s1.Name, s2.Name));
                    });

                    foreach (Symbol obfuscatedSymbol in sortedObfuscatedSymbols)
                    {
                        if (obfuscatedSymbol is TypeSymbol)
                        {
                            TypeSymbol typeSymbol = (TypeSymbol)obfuscatedSymbol;

                            testWriter.WriteLine("Type '" + typeSymbol.FullName + "' renamed to '" + typeSymbol.GeneratedName + "'");
                        }
                        else
                        {
                            Debug.Assert(obfuscatedSymbol is MemberSymbol);
                            testWriter.WriteLine("    Member '" + obfuscatedSymbol.Name + "' renamed to '" + obfuscatedSymbol.GeneratedName + "'");
                        }
                    }

                    testWriter.WriteLine();
                    testWriter.WriteLine();

                    _testOutput = testWriter.ToString();
                }
#endif // DEBUG
            }
            else
            {
                if (_options.DebugFlavor)
                {
                    SymbolInternalizer   internalizer             = new SymbolInternalizer();
                    SymbolSetTransformer internalizingTransformer = new SymbolSetTransformer(internalizer);

                    internalizingTransformer.TransformSymbolSet(_symbols, /* useInheritanceOrder */ true);
                }
            }
        }
Esempio n. 6
0
        //TODO: Look at removing the internal testing type mechanism in favour of testing the compiler correctly.
        private void BuildMetadata()
        {
            if (options.Resources != null && options.Resources.Count != 0)
            {
                ResourcesBuilder resourcesBuilder = new ResourcesBuilder(symbols);
                resourcesBuilder.BuildResources(options.Resources);
            }

            MetadataBuilder mdBuilder = new MetadataBuilder(this);

            appSymbols = mdBuilder.BuildMetadata(compilationUnitList, symbols, options);

            // Check if any of the types defined in this assembly conflict.
            Dictionary <string, TypeSymbol> types = new Dictionary <string, TypeSymbol>();

            foreach (TypeSymbol appType in appSymbols)
            {
                if (appType.IsApplicationType == false || appType.Type == SymbolType.Delegate)
                {
                    // Skip the check for types that are marked as imported, as they
                    // aren't going to be generated into the script.
                    // Delegates are implicitly imported types, as they're never generated into
                    // the script.
                    continue;
                }

                if (appType.Type == SymbolType.Class &&
                    ((ClassSymbol)appType).PrimaryPartialClass != appType)
                {
                    // Skip the check for partial types, since they should only be
                    // checked once.
                    continue;
                }

                // TODO: We could allow conflicting types as long as both aren't public
                //       since they won't be on the exported types list. Internal types that
                //       conflict could be generated using full name.

                string name = appType.GeneratedName;

                if (types.ContainsKey(name))
                {
                    ((IErrorHandler)this).ReportGeneralError(string.Format(DSharpStringResources.CONFLICTING_TYPE_NAME_ERROR_FORMAT, appType.FullName, types[name].FullName));
                }
                else
                {
                    types[name] = appType;
                }
            }

            ISymbolTransformer transformer = null;

            if (options.Minimize)
            {
                transformer = new SymbolObfuscator();
            }
            else
            {
                transformer = new SymbolInternalizer();
            }

            if (transformer != null)
            {
                SymbolSetTransformer symbolSetTransformer = new SymbolSetTransformer(transformer);
                ICollection <Symbol> transformedSymbols   =
                    symbolSetTransformer.TransformSymbolSet(symbols, /* useInheritanceOrder */ true);
            }
        }