static int Main() { var options = new AutobuildOptions(); var actions = SystemBuildActions.Instance; try { options.ReadEnvironment(actions); } catch (ArgumentOutOfRangeException ex) { Console.WriteLine("The value \"{0}\" for parameter \"{1}\" is invalid", ex.ActualValue, ex.ParamName); } var builder = new Autobuilder(actions, options); Console.WriteLine($"Semmle autobuilder for {options.Language}"); return(builder.AttemptBuild()); }
/// <summary> /// Find all the relevant files and picks the best /// solution file and tools. /// </summary> /// <param name="options">The command line options.</param> public Autobuilder(IBuildActions actions, AutobuildOptions options) { Actions = actions; Options = options; pathsLazy = new Lazy <IEnumerable <string> >(() => { var files = new List <string>(); FindFiles(options.RootDirectory, options.SearchDepth, files); return(files. OrderBy(s => s.Count(c => c == Path.DirectorySeparatorChar)). ThenBy(s => Path.GetFileName(s).Length). ToArray()); }); solutionsToBuildLazy = new Lazy <IList <ISolution> >(() => { if (options.Solution.Any()) { var ret = new List <ISolution>(); foreach (var solution in options.Solution) { if (actions.FileExists(solution)) { ret.Add(new Solution(this, solution)); } else { Log(Severity.Error, "The specified solution file {0} was not found", solution); } } return(ret); } var solutions = GetExtensions(".sln"). Select(s => new Solution(this, s)). Where(s => s.ProjectCount > 0). OrderByDescending(s => s.ProjectCount). ThenBy(s => s.Path.Length). ToArray(); foreach (var sln in solutions) { Log(Severity.Info, $"Found {sln.Path} with {sln.ProjectCount} {this.Options.Language} projects, version {sln.ToolsVersion}, config {string.Join(" ", sln.Configurations.Select(c => c.FullName))}"); } return(new List <ISolution>(options.AllSolutions ? solutions : solutions.Take(1))); }); SemmleDist = Actions.GetEnvironmentVariable("SEMMLE_DIST"); SemmleJavaHome = Actions.GetEnvironmentVariable("SEMMLE_JAVA_HOME"); SemmlePlatformTools = Actions.GetEnvironmentVariable("SEMMLE_PLATFORM_TOOLS"); if (SemmleDist == null) { Log(Severity.Error, "The environment variable SEMMLE_DIST has not been set."); } }