Exemplo n.º 1
0
        static int Run(string[] args)
        {
            if (args.Length == 0)
            {
                Console.Error.WriteLine($"No action specified");
                return(1);
            }

            if (!Enum.TryParse(args[0], out BuildAction action))
            {
                Console.Error.WriteLine($"Unknown action '{args[0]}'");
                return(2);
            }

            var actionArgs = new List <string>(args.Skip(1));

            switch (action)
            {
            case BuildAction.Build:
            case BuildAction.Clean:
                var ba = new BuildArguments();
                if (!ba.Parse(actionArgs))
                {
                    return(1);
                }
                if (ba.TargetType == TargetType.Program)
                {
                    return(0);
                }
                foreach (var sln in GetSolutions(ba))
                {
                    if (!MSBuildHelpers.BuildSolution(sln, action.ToString(), action == BuildAction.Build, ba))
                    {
                        return(1);
                    }
                }
                return(0);

            case BuildAction.GenerateProjects:
                var ga = new GenerateProjectsArguments();
                if (!ga.Parse(actionArgs))
                {
                    return(1);
                }
                return(GenerateProjects.Run(ga));

            default:
                Console.Error.WriteLine($"Unsupported action '{action}'");
                return(1);
            }
        }
Exemplo n.º 2
0
        public static int Run(GenerateProjectsArguments args)
        {
            //no-op on the editor
            if (args.SolutionName == "UE4Editor")
            {
                return(0);
            }

            if (args.Projects.Count < 1)
            {
                Console.Error.WriteLine("Need at least one game project to process!");
                Console.Error.WriteLine($"Try '{Path.GetFileNameWithoutExtension (System.Reflection.Assembly.GetEntryAssembly().Location)} --help' for more information");
                return(1);
            }

            string solutionDirectory = args.SolutionDir;
            string solutionName      = args.SolutionName;

            var gameProjects = new List <GameProjectInfo>();

            foreach (var project in args.Projects)
            {
                string gameProjectDirectory = Path.GetFullPath(Path.GetDirectoryName(project));
                string gameProjectName      = Path.GetFileNameWithoutExtension(gameProjectDirectory);

                string sourcePath = Path.Combine(gameProjectDirectory, "Source");
                gameProjects.Add(new GameProjectInfo {
                    Directory = gameProjectDirectory, Name = gameProjectName, SourceDirectory = sourcePath
                });
            }

            if (System.Diagnostics.Debugger.IsAttached)
            {
                GenerateFiles(solutionDirectory, solutionName, gameProjects);
            }
            else
            {
                try
                {
                    GenerateFiles(solutionDirectory, solutionName, gameProjects);
                }
                catch (Exception e)
                {
                    Console.Error.WriteLine(e.Message);
                    return(3);
                }
            }
            return(0);
        }