Пример #1
0
        public static void Main(string[] args)
        {
            var thisExeDir = Path.GetDirectoryName(typeof(MainClass).Assembly.Location);

            if (thisExeDir == null)
            {
                throw new InvalidOperationException($"Unable to get path of current assembly from `{typeof(MainClass).Assembly.Location}`");
            }
            var directory = new DirectoryInfo(thisExeDir);

            // go from `src/Unity.Mathematics.CodeGen/bin/Debug`

            // to `src/`, so 3 directories

            var parent = directory.Parent?.Parent?.Parent;

            if (parent == null)
            {
                throw new InvalidOperationException($"Unable to get path of current assembly from `{typeof(MainClass).Assembly.Location}`");
            }

            directory = new DirectoryInfo(Path.Combine(parent.FullName, "Unity.Mathematics"));
            if (!directory.Exists)
            {
                throw new InvalidOperationException($"The directory `{directory.FullName}` must exist");
            }

            Console.WriteLine("Generating swizzle and operators: " + directory);
            VectorGenerator.Write(directory.FullName);
            Console.WriteLine("Done");
        }
        public static void Main(string[] args)
        {
            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");

            var thisExeDir = Path.GetDirectoryName(typeof(MainClass).Assembly.Location);

            if (thisExeDir == null)
            {
                throw new InvalidOperationException($"Unable to get path of current assembly from `{typeof(MainClass).Assembly.Location}`");
            }
            var directory = new DirectoryInfo(thisExeDir);

            // go from `src/Unity.Mathematics.CodeGen/bin/Debug`

            // to `src/`, so 3 directories

            var parent = directory.Parent?.Parent?.Parent;

            if (parent == null)
            {
                throw new InvalidOperationException($"Unable to get path of current assembly from `{typeof(MainClass).Assembly.Location}`");
            }

            var implementationDirectory = new DirectoryInfo(Path.Combine(parent.FullName, "Unity.Mathematics"));

            if (!implementationDirectory.Exists)
            {
                throw new InvalidOperationException($"The directory `{implementationDirectory.FullName}` must exist");
            }

            var testDirectory = new DirectoryInfo(Path.Combine(parent.FullName, "Tests/Tests/Shared"));

            if (!testDirectory.Exists)
            {
                throw new InvalidOperationException($"The directory `{testDirectory.FullName}` must exist");
            }

            var performanceTestDirectory = new DirectoryInfo(Path.Combine(parent.FullName, "Unity.Mathematics.PerformanceTests"));

            if (!performanceTestDirectory.Exists)
            {
                throw new InvalidOperationException($"The directory `{performanceTestDirectory.FullName}` must exist");
            }

            Console.WriteLine("Generating swizzle and operators: " + directory);
            VectorGenerator.Write(implementationDirectory.FullName, testDirectory.FullName, performanceTestDirectory.FullName);
            Console.WriteLine("Done");
        }
        public static void Write(string dir)
        {
            foreach (GeneratorJob job in s_Jobs)
            {
                var typeNames = job.typeNames;
                for (int i = 1; i < typeNames.Length; i++)
                {
                    StringBuilder   builder = new StringBuilder();
                    VectorGenerator gen     = new VectorGenerator(job);

                    gen.Generate(i + 1, builder);

                    var text = builder.ToString();
                    // Convert all tabs to spaces
                    text = text.Replace("\t", "    ");
                    // Convert all EOL to platform EOL
                    text = text.Replace("\n", Environment.NewLine);

                    System.IO.File.WriteAllText(dir + "/" + typeNames[i] + ".gen.cs", text);
                }
            }
        }