Exemple #1
0
        public static int Init(InitOptions options)
        {
            var workspaceRoot = Directory.GetCurrentDirectory();
            var workspaceName = options.WorkspaceName;

            if (string.IsNullOrEmpty(workspaceName))
            {
                workspaceName = Path.GetFileName(workspaceRoot);
                ;
            }
            else
            {
                workspaceRoot = Path.Combine(workspaceRoot, workspaceName);
                Directory.CreateDirectory(workspaceRoot);
                Directory.SetCurrentDirectory(workspaceRoot);
            }

            var runfiles       = Runfiles.Create();
            var templates      = Templates.CreateDefault(runfiles);
            var workspaceMaker = new WorkspaceMaker(workspaceRoot, workspaceName, templates);

            workspaceMaker.Init();

            Console.WriteLine("Workspace created, next steps:");
            Console.WriteLine("bazel run //:gazelle");
            Console.WriteLine("bazel build //...");
            Console.WriteLine("bazel test //...");
            return(0);
        }
Exemple #2
0
        private static int Test(string tarPath)
        {
            var workspaceRoot = Directory.GetCurrentDirectory();
            var workspaceName = Path.GetFileName(workspaceRoot);
            var runfiles      = Runfiles.Create();
            var templates     = Templates.CreateDefault(runfiles);

            var workspaceContents =
                Util.UpdateWorkspaceTemplate(runfiles, tarPath, $"file:{tarPath}");

            templates.Workspace = new Template("WORKSPACE", workspaceContents);
            var workspaceMaker = new WorkspaceMaker(workspaceRoot, workspaceName, templates);

            workspaceMaker.Init();
            return(0);
        }