예제 #1
0
        public void Build()
        {
            if (_backend.IsDefault)
            {
                return;
            }

            foreach (var upk in _compiler.Input.Packages)
            {
                foreach (var f in upk.BundleFiles)
                {
                    var filename = f.UnixPath;
                    if (_compiler.Disk.GetFullPath(upk.Source, upk.SourceDirectory, ref filename))
                    {
                        CreateFile(upk.Source, ContentType.BundleFile, filename);
                    }
                }
            }

            // Emit fields and statements in sorted order for deterministic build result
            foreach (var e in _bundles.Values)
            {
                e.Fields.Sort();

                foreach (var f in e.Fields)
                {
                    Emit(f);
                }
            }

            var index    = new List <string>();
            var packages = _compiler.Input.Packages.ToArray();

            Array.Sort(packages, (a, b) => a.Name.CompareTo(b.Name));

            foreach (var e in packages)
            {
                var line = new List <string> {
                    e.Name
                };
                var files = _files.GetList(e);
                files.Sort((a, b) => a.BundleName.CompareTo(b.BundleName));

                foreach (var f in files)
                {
                    line.Add(f.BundleName);
                    line.Add(f.TargetName);
                }

                index.Add(string.Join(":", line));
            }

            var bundleFile = Path.Combine(_env.CacheDirectory, "bundle");

            using (var f = _compiler.Disk.CreateBufferedText(bundleFile))
                f.Write(string.Join("\n", index));
            _compiler.Data.Extensions.BundleFiles.Add(new BundleFile("bundle", bundleFile, ContentType.BundleFile));
        }
예제 #2
0
        LibraryProject TryGetFailedReference(LibraryProject lib, List <LibraryProject> failed)
        {
            if (failed.Count > 0)
            {
                foreach (var e in lib.References)
                {
                    foreach (var dependency in _libMap.GetList(e))
                    {
                        if (failed.Contains(dependency))
                        {
                            return(dependency);
                        }
                    }
                }
            }

            return(null);
        }
예제 #3
0
        public void Build()
        {
            if (_backend.IsDefault)
            {
                return;
            }

            foreach (var upk in _compiler.Input.Packages)
            {
                foreach (var f in upk.BundleFiles)
                {
                    var filename = f.UnixPath;
                    if (_compiler.Disk.GetFullPath(upk.Source, upk.SourceDirectory, ref filename))
                    {
                        CreateFile(upk.Source, filename);
                    }
                }
            }

            // Emit fields and statements in sorted order for deterministic build result
            foreach (var e in _bundles.Values)
            {
                e.Fields.Sort();

                foreach (var f in e.Fields)
                {
                    Emit(f);
                }
            }

            foreach (var e in _files)
            {
                e.Value.Sort((a, b) => a.BundleName.CompareTo(b.BundleName));

                var index = new List <string>();
                foreach (var f in e.Value)
                {
                    index.Add(f.BundleName + ":" + f.TargetName);
                }

                var bundleFile = Path.Combine(_env.CacheDirectory, e.Key.Name + ".bundle");
                Directory.CreateDirectory(Path.GetDirectoryName(bundleFile));
                File.WriteAllText(bundleFile, string.Join("\n", index));
                _compiler.Data.Extensions.BundleFiles.Add(new BundleFile(e.Key, e.Key.Name + ".bundle", bundleFile));
            }

            var bundles  = new List <string>();
            var packages = _compiler.Input.Packages.ToArray();

            Array.Sort(packages, (a, b) => a.Name.CompareTo(b.Name));

            foreach (var e in packages)
            {
                var bundleFile = Path.Combine(_env.CacheDirectory, e.Name + ".bundle");
                var files      = _files.GetList(e);
                files.Sort((a, b) => a.BundleName.CompareTo(b.BundleName));

                if (File.Exists(bundleFile))
                {
                    bundles.Add(e.Name);
                }
            }

            var bundlesFile = Path.Combine(_env.CacheDirectory, "bundles");

            using (var f = _compiler.Disk.CreateBufferedText(bundlesFile))
                f.Write(string.Join("\n", bundles));
            _compiler.Data.Extensions.BundleFiles.Add(new BundleFile(_compiler.Input.Package, "bundles", bundlesFile));

            // Deprecated: The 'bundle' file is no longer used, but may be used directly by 3rdparty code.
            {
                var index = new List <string>();

                foreach (var e in packages)
                {
                    var line = new List <string> {
                        e.Name
                    };
                    var files = _files.GetList(e);
                    files.Sort((a, b) => a.BundleName.CompareTo(b.BundleName));

                    foreach (var f in files)
                    {
                        line.Add(f.BundleName);
                        line.Add(f.TargetName);
                    }

                    index.Add(string.Join(":", line));
                }

                var bundleFile = Path.Combine(_env.CacheDirectory, "bundle");
                using (var f = _compiler.Disk.CreateBufferedText(bundleFile))
                    f.Write(string.Join("\n", index));
                _compiler.Data.Extensions.BundleFiles.Add(new BundleFile(_compiler.Input.Package, "bundle", bundleFile));
            }
        }
예제 #4
0
파일: GLGenerator.cs 프로젝트: mortend/uno
        Expression GetProgram(Draw draw)
        {
            _obfuscator.Minify(draw.State);

            var src      = draw.Source;
            var vsSource = GlslWriter.BuildString(_backend, draw.State.VertexShader, !Environment.Debug);
            var fsSource = GlslWriter.BuildString(_backend, draw.State.PixelShader, !Environment.Debug);
            var key      = vsSource + ":" + fsSource;

            foreach (var e in _programs.GetList(key))
            {
                if (e.Source.Package.IsAccessibleFrom(draw.Source.Package))
                {
                    return(e);
                }
            }

            int constCount   = draw.State.RuntimeConstants.Count;
            int attribCount  = draw.State.VertexAttributes.Count;
            int uniformCount = draw.State.Uniforms.Count;
            int samplerCount = draw.State.PixelSamplers.Count;
            var array        = new Expression[constCount + attribCount + uniformCount + samplerCount];
            var index        = 0;

            foreach (var v in draw.State.RuntimeConstants)
            {
                array[index++] = new Constant(src, Essentials.String, v.Name);
            }
            foreach (var v in draw.State.VertexAttributes)
            {
                array[index++] = new Constant(src, Essentials.String, v.Name);
            }
            foreach (var v in draw.State.Uniforms)
            {
                array[index++] = new Constant(src, Essentials.String, v.Name);
            }
            foreach (var v in draw.State.PixelSamplers)
            {
                array[index++] = new Constant(src, Essentials.String, v.Name);
            }

            var prog = ILFactory.CallMethod(src,
                                            "Uno.Graphics.OpenGL.GLProgram", "Create",
                                            new Constant(src, Essentials.String, vsSource),
                                            new Constant(src, Essentials.String, fsSource),
                                            new Constant(src, Essentials.Int, constCount),
                                            new Constant(src, Essentials.Int, attribCount),
                                            new NewArray(src, _stringArray, array));

            var result = _bundle.AddProgram(draw.State.Path.DrawBlock, prog);

            _programs.Add(key, result);

            if (_dumpShaders)
            {
                var prefix = Environment.Combine("shaders",
                                                 Type.QualifiedName + "." + key.GetHashCode().ToString("x8"));
                Disk.WriteAllText(prefix + ".vert", vsSource);
                Disk.WriteAllText(prefix + ".frag", fsSource);
            }

            return(result);
        }