Beispiel #1
0
        /// <summary>
        /// Writes report
        /// </summary>
        /// <param name="text"></param>
        /// <returns></returns>
        public string WriteReport(AssetSource assetFile, string textContent, string subfile = null)
        {
            string fileName = assetFile.Hash + (subfile ?? "") + ".html";
            string fullPath = Path.Combine(Options.FullTempDirectory, fileName);

            File.WriteAllText(fullPath, textContent);

            return(fileName);
        }
Beispiel #2
0
        /// <summary>
        /// Analyzes entire engine searching for RequireShaderAttribute.
        /// Returns collection of required shaders.
        /// </summary>
        /// <returns></returns>
        public IEnumerable <AssetSource> GatherRequiredShaders(BuildContext context, BuildResult result)
        {
            var options = context.Options;
            var srcList = new List <AssetSource>();


            var shaderList = Misc.GetAllClassesWithAttribute <RequireShaderAttribute>()
                             .Select(type1 => new { Type = type1, Name = type1.GetCustomAttribute <RequireShaderAttribute>().RequiredShader })
                             .DistinctBy(shader => shader.Name)
                             .ToArray();


            foreach (var shader in shaderList)
            {
                var nameExt = Path.ChangeExtension(shader.Name, ".hlsl");

                try {
                    var baseDir  = "";
                    var fullPath = context.ResolveContentPath(nameExt, out baseDir);
                    var assetSrc = new AssetSource(nameExt, baseDir, typeof(UbershaderProcessor), new string[0], context);
                    assetSrc.ReflectingType = shader.Type;

                    if (shader.Type.GetCustomAttribute <RequireShaderAttribute>().AutoGenerateHeader)
                    {
                        var headerName = assetSrc.FullSourcePath.Replace(".hlsl", ".auto.hlsl");

                        var headerText = UbershaderGenerator.GenerateVirtualHeader(shader.Type);

                        if (!File.Exists(headerName))
                        {
                            File.WriteAllText(headerName, headerText);
                        }
                        else
                        {
                            var oldText = File.ReadAllText(headerName);
                            if (oldText != headerText)
                            {
                                File.WriteAllText(headerName, headerText);
                            }
                        }
                    }



                    srcList.Add(assetSrc);
                } catch (BuildException bex) {
                    Log.Error(bex.Message);
                }
            }

            return(srcList);
        }
Beispiel #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="processor"></param>
        /// <param name="fileName"></param>
        void BuildAsset(AssetProcessor processor, string[] args, AssetSource assetFile, ref BuildResult buildResult)
        {
            try {
                //	Is up-to-date?
                if (!context.Options.ForceRebuild)
                {
                    if (!Wildcard.Match(assetFile.KeyPath, context.Options.CleanPattern, true))
                    {
                        if (!context.Options.Files.Contains(assetFile.KeyPath))
                        {
                            if (assetFile.IsUpToDate)
                            {
                                buildResult.UpToDate++;
                                return;
                            }
                        }
                    }
                }


                var keyPath = assetFile.KeyPath;

                if (keyPath.Length > 40)
                {
                    keyPath = "..." + keyPath.Substring(keyPath.Length - 40 + 3);
                }

                Log.Message("{0,-40} {1,-5}   {3}", keyPath, Path.GetExtension(keyPath), string.Join(" ", args), assetFile.Hash);

                // Apply attribute :
                var parser = new CommandLineParser(processor.GetType());
                parser.OptionLeadingChar = '/';

                parser.ParseCommandLine(processor, args);

                //
                //	Build :
                //
                processor.Process(assetFile, context);

                buildResult.Succeded++;
            } catch (Exception e) {
                Log.Error("{0} : {1}", assetFile.KeyPath, e.Message);
                buildResult.Failed++;
            }
        }
Beispiel #4
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="processor"></param>
		/// <param name="fileName"></param>
		void BuildAsset ( AssetProcessor processor, string[] args, AssetSource assetFile, ref BuildResult buildResult )
		{					
			try {
				
				//	Is up-to-date?
				if (!context.Options.ForceRebuild) {
					if (!Wildcard.Match(assetFile.KeyPath, context.Options.CleanPattern, true)) {
						if (assetFile.IsUpToDate) {
							buildResult.UpToDate ++;
							return;
						}
					}
				}


				var keyPath = assetFile.KeyPath;

				if (keyPath.Length > 40) {
					keyPath = "..." + keyPath.Substring( keyPath.Length - 40 + 3 );
				}

				Log.Message("{0,-40} {1,-5}   {3}", keyPath, Path.GetExtension(keyPath), string.Join(" ", args), assetFile.Hash );

				// Apply attribute :
				var parser =	new CommandLineParser( processor );
				parser.Configuration.OptionLeadingChar = '/';
				parser.Configuration.ThrowExceptionOnShowError = true;

				parser.ParseCommandLine( args );

				//
				//	Build :
				//
				processor.Process( assetFile, context );

				buildResult.Succeded ++;

			} catch ( Exception e ) {
				Log.Error( "{0} : {1}", assetFile.KeyPath, e.Message );
				buildResult.Failed ++;
			}
		}