Skip to content

Commit

Permalink
added bazel
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Oct 7, 2024
1 parent c351fbb commit 5cb5426
Show file tree
Hide file tree
Showing 14 changed files with 531 additions and 0 deletions.
31 changes: 31 additions & 0 deletions completers/bazel_completer/cmd/analyzeProfile.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package cmd

import (
"github.com/carapace-sh/carapace"
"github.com/carapace-sh/carapace-bin/completers/bazel_completer/cmd/common"
"github.com/spf13/cobra"
)

var analyzeProfileCmd = &cobra.Command{
Use: "analyze-profile",
Short: "Analyzes build profile data for the given profile data files",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(analyzeProfileCmd).Standalone()
common.AddRemoteCachingFlags(analyzeProfileCmd)
common.AddBuildExecutionFlags(analyzeProfileCmd)
common.AddToolchainFlags(analyzeProfileCmd)
common.AddBuildTimeOptimizationFlags(analyzeProfileCmd)
common.AddStarlarkSemanticFlags(analyzeProfileCmd)
common.AddBzlmodFlags(analyzeProfileCmd)
common.AddInputAlteringFlags(analyzeProfileCmd)
common.AddInputValidationFlags(analyzeProfileCmd)
common.AddLoggingFlags(analyzeProfileCmd)
common.AddOutputFlags(analyzeProfileCmd)
common.AddMiscellaneousFlags(analyzeProfileCmd)

rootCmd.AddCommand(analyzeProfileCmd)

}
14 changes: 14 additions & 0 deletions completers/bazel_completer/cmd/common/buildExecution.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package common

import (
"github.com/spf13/cobra"
)

func AddBuildExecutionFlags(cmd *cobra.Command) {
cmd.Flags().String("experimental_ui_max_stdouterr_bytes", "", "The maximum size of the stdout / stderr files that will be printed to the console")
cmd.Flags().String("gc_thrashing_threshold", "", "The percent of tenured space occupied (0-100) above which GcThrashingDetector considers memory pressure events against its limits (-- gc_thrashing_limits)")
cmd.Flags().Bool("incompatible_remote_dangling_symlinks", false, "If set to true, symlinks uploaded to a remote or disk cache are allowed to dangle")
cmd.Flags().Bool("incompatible_remote_symlinks", false, "If set to true, Bazel will always upload symlinks as such to a remote or disk cache")
cmd.Flags().Bool("no-incompatible_remote_dangling_symlinks", false, "If set to true, symlinks uploaded to a remote or disk cache are allowed to dangle")
cmd.Flags().Bool("no-incompatible_remote_symlinks", false, "If set to true, Bazel will always upload symlinks as such to a remote or disk cache")
}
22 changes: 22 additions & 0 deletions completers/bazel_completer/cmd/common/buildTimeOptimization.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package common

import (
"github.com/spf13/cobra"
)

func AddBuildTimeOptimizationFlags(cmd *cobra.Command) {
cmd.Flags().String("gc_thrashing_limits", "", "Limits which, if reached, cause GcThrashingDetector to crash Bazel with an OOM")
cmd.Flags().Bool("heuristically_drop_nodes", false, "If true, Blaze will remove FileState and DirectoryListingState nodes after related File and DirectoryListing node is done to save memory")
cmd.Flags().Bool("incompatible_do_not_split_linking_cmdline", false, "When true, Bazel no longer modifies command line flags used for linking, and also doesn't selectively decide which flags go to the param file and which don't")
cmd.Flags().Bool("keep_state_after_build", false, "If false, Blaze will discard the inmemory state from this build when the build finishes")
cmd.Flags().Bool("no-heuristically_drop_nodes", false, "If true, Blaze will remove FileState and DirectoryListingState nodes after related File and DirectoryListing node is done to save memory")
cmd.Flags().Bool("no-incompatible_do_not_split_linking_cmdline", false, "When true, Bazel no longer modifies command line flags used for linking, and also doesn't selectively decide which flags go to the param file and which don't")
cmd.Flags().Bool("no-keep_state_after_build", false, "If false, Blaze will discard the inmemory state from this build when the build finishes")
cmd.Flags().Bool("no-track_incremental_state", false, "If false, Blaze will not persist data that allows for invalidation and re- evaluation on incremental builds in order to save memory on this build")
cmd.Flags().String("skyframe_high_water_mark_full_gc_drops_per_invocation", "", "Flag for advanced configuration of Bazel's internal Skyframe engine")
cmd.Flags().String("skyframe_high_water_mark_minor_gc_drops_per_invocation", "", "Flag for advanced configuration of Bazel's internal Skyframe engine")
cmd.Flags().String("skyframe_high_water_mark_threshold", "", "Flag for advanced configuration of Bazel's internal Skyframe engine")
cmd.Flags().Bool("track_incremental_state", false, "If false, Blaze will not persist data that allows for invalidation and re- evaluation on incremental builds in order to save memory on this build")

// TODO add flag completion
}
17 changes: 17 additions & 0 deletions completers/bazel_completer/cmd/common/bzlmod.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package common

import "github.com/spf13/cobra"

func AddBzlmodFlags(cmd *cobra.Command) {
cmd.Flags().StringSlice("allow_yanked_versions", []string{}, "Specified the module versions in the form of `<module1>@<version1>, <module2>@<version2>` that will be allowed in the resolved dependency graph even if they are declared yanked in the registry where they come from (if they are not coming from a NonRegistryOverride)")
cmd.Flags().String("check_bazel_compatibility", "", "Check bazel version compatibility of Bazel modules")
cmd.Flags().String("check_direct_dependencies", "", "Check if the direct `bazel_dep` dependencies declared in the root module are the same versions you get in the resolved dependency graph")
cmd.Flags().Bool("ignore_dev_dependency", false, "If true, Bazel ignores `bazel_dep` and `use_extension` declared as `dev_dependency` in the MODULE.bazel of the root module")
cmd.Flags().String("lockfile_mode", "", "Specifies how and whether or not to use the lockfile")
cmd.Flags().Bool("no-ignore_dev_dependency", false, "If true, Bazel ignores `bazel_dep` and `use_extension` declared as `dev_dependency` in the MODULE.bazel of the root module")
cmd.Flags().StringSlice("override_module", []string{}, "Override a module with a local path in the form of <module name>=<path>")
cmd.Flags().StringSlice("registry", []string{}, "Specifies the registries to use to locate Bazel module dependencies")
cmd.Flags().String("vendor_dir", "", "Specifies the directory that should hold the external repositories in vendor mode, whether for the purpose of fetching them into it or using them while building")

// TODO add flag completion
}
14 changes: 14 additions & 0 deletions completers/bazel_completer/cmd/common/inputAltering.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package common

import (
"github.com/carapace-sh/carapace"
"github.com/spf13/cobra"
)

func AddInputAlteringFlags(cmd *cobra.Command) {
cmd.Flags().String("experimental_resolved_file_instead_of_workspace", "", "If non-empty read the specified resolved file instead of the WORKSPACE file Tags: changes_inputs")

carapace.Gen(cmd).FlagCompletion(carapace.ActionMap{
"experimental_resolved_file_instead_of_workspace": carapace.ActionFiles(),
})
}
8 changes: 8 additions & 0 deletions completers/bazel_completer/cmd/common/inputValidation.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package common

import "github.com/spf13/cobra"

func AddInputValidationFlags(cmd *cobra.Command) {
cmd.Flags().Bool("check_bzl_visibility", false, "If disabled, .bzl load visibility errors are demoted to warnings")
cmd.Flags().Bool("no-check_bzl_visibility", false, "If disabled, .bzl load visibility errors are demoted to warnings")
}
Loading

0 comments on commit 5cb5426

Please sign in to comment.