...

Source file src/edge-infra.dev/pkg/lib/build/bazel/options.go

Documentation: edge-infra.dev/pkg/lib/build/bazel

     1  package bazel
     2  
     3  import "context"
     4  
     5  // Option controls instantiation of the [Bazel] command runner.
     6  type Option func(*options)
     7  
     8  type options struct {
     9  	ctx     context.Context
    10  	configs []string
    11  	bin     string
    12  }
    13  
    14  // WithCtx sets the context used for the Bazel commands. Can be used to make
    15  // commands cancellable. By default a context wired up to signal handlers is
    16  // used.
    17  func WithCtx(ctx context.Context) Option {
    18  	return func(o *options) {
    19  		o.ctx = ctx
    20  	}
    21  }
    22  
    23  // WithConfigProfiles sets the configuration profiles that will be passed to
    24  // Bazel via the `--config` flag.
    25  func WithConfigProfiles(cfgs ...string) Option {
    26  	return func(o *options) {
    27  		o.configs = append(o.configs, cfgs...)
    28  	}
    29  }
    30  
    31  // WithBinary explicitly sets the path to the `bazel` binary. By default the
    32  // value of [Binary] is used.
    33  func WithBinary(bin string) Option {
    34  	return func(o *options) {
    35  		o.bin = bin
    36  	}
    37  }
    38  

View as plain text