Пример #1
0
 public static void Main(string[] args)
 {
     // Configure code generator in Entitas.properties file
     CodeGeneratorUtil
     .CodeGeneratorFromConfig("../../Entitas.properties")
     .Generate();
 }
Пример #2
0
 static void generate()
 {
     if (File.Exists(Preferences.configPath))
     {
         CodeGeneratorUtil
         .CodeGeneratorFromConfig(Preferences.configPath)
         .Generate();
     }
     else
     {
         printNoConfig();
     }
 }
        public static void Generate()
        {
            checkCanGenerate();

            Debug.Log("Generating...");

            var codeGenerator = CodeGeneratorUtil.CodeGeneratorFromConfig(Preferences.configPath);

            var progressOffset = 0f;

            codeGenerator.OnProgress += (title, info, progress) => {
                var cancel = EditorUtility.DisplayCancelableProgressBar(title, info, progressOffset + progress / 2);
                if (cancel)
                {
                    codeGenerator.Cancel();
                }
            };

            CodeGenFile[] dryFiles = null;
            CodeGenFile[] files    = null;

            try {
                dryFiles       = codeGenerator.DryRun();
                progressOffset = 0.5f;
                files          = codeGenerator.Generate();
            } catch (Exception ex) {
                dryFiles = new CodeGenFile[0];
                files    = new CodeGenFile[0];

                EditorUtility.DisplayDialog("Error", ex.Message, "Ok");
            }

            EditorUtility.ClearProgressBar();

            var totalGeneratedFiles = files.Select(file => file.fileName).Distinct().Count();

            var sloc = dryFiles
                       .Select(file => file.fileContent.ToUnixLineEndings())
                       .Sum(content => content.Split(new [] { '\n' }, StringSplitOptions.RemoveEmptyEntries).Length);

            var loc = files
                      .Select(file => file.fileContent.ToUnixLineEndings())
                      .Sum(content => content.Split(new [] { '\n' }).Length);

            Debug.Log("Generated " + totalGeneratedFiles + " files (" + sloc + " sloc, " + loc + " loc)");

            AssetDatabase.Refresh();
        }
Пример #4
0
 static void doctor()
 {
     _logger.Debug("Entitas Code Generator version " + EntitasResources.GetVersion());
     if (File.Exists(Preferences.configPath))
     {
         status();
         _logger.Debug("Dry Run");
         CodeGeneratorUtil
         .CodeGeneratorFromConfig(Preferences.configPath)
         .DryRun();
     }
     else
     {
         printNoConfig();
     }
 }
Пример #5
0
        static void generate(string configPath)
        {
            Console.WriteLine("Generating...");

            var codeGenerator = CodeGeneratorUtil.CodeGeneratorFromConfig(configPath);

            var dryFiles = codeGenerator.DryRun();
            var files    = codeGenerator.Generate();

            var totalGeneratedFiles = files.Select(file => file.fileName).Distinct().Count();

            var sloc = dryFiles
                       .Select(file => file.fileContent.ToUnixLineEndings())
                       .Sum(content => content.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries).Length);

            var loc = files
                      .Select(file => file.fileContent.ToUnixLineEndings())
                      .Sum(content => content.Split(new[] { '\n' }).Length);

            Console.WriteLine("Generated " + totalGeneratedFiles + " files (" + sloc + " sloc, " + loc + " loc)");
        }
Пример #6
0
        public static void Generate()
        {
            checkCanGenerate();

            Debug.Log("Generating...");

            var codeGenerator = CodeGeneratorUtil.CodeGeneratorFromConfig(EntitasPreferences.CONFIG_PATH);

            var progressOffset = 0f;

            codeGenerator.OnProgress += (title, info, progress) => {
                var cancel = EditorUtility.DisplayCancelableProgressBar(title, info, progressOffset + progress / 2);
                if (cancel)
                {
                    codeGenerator.Cancel();
                }
            };

            var dryFiles = codeGenerator.DryRun();

            progressOffset = 0.5f;
            var files = codeGenerator.Generate();

            EditorUtility.ClearProgressBar();

            var totalGeneratedFiles = files.Select(file => file.fileName).Distinct().Count();

            var sloc = dryFiles
                       .Select(file => file.fileContent.ToUnixLineEndings())
                       .Sum(content => content.Split(new [] { '\n' }, StringSplitOptions.RemoveEmptyEntries).Length);

            var loc = files
                      .Select(file => file.fileContent.ToUnixLineEndings())
                      .Sum(content => content.Split(new [] { '\n' }).Length);

            Debug.Log("Generated " + totalGeneratedFiles + " files (" + sloc + " sloc, " + loc + " loc)");

            AssetDatabase.Refresh();
        }