Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spell incantation for Go toolchain "build" command #28

Merged
merged 1 commit into from
Nov 23, 2020

Conversation

svengreb
Copy link
Owner

Resolves #27

To run the `go build` command of the Go toolchain, the new
`spell.Incantation` [1] has been implemented in the new build [2]
package that can be used through a Go toolchain caster [3].
The spell incantation can be configured through the following functions:

- `WithBinaryArtifactName(name string) build.Option` - sets the name for
  the binary build artifact.
- `WithCrossCompileTargetPlatforms(platforms ...string) build.Option` -
  sets the names of cross-compile platform targets.
- `WithFlags(flags ...string) build.Option` - sets additional flags to
  pass to the Go `build` command along with the base Go flags.
- `WithGoOptions(goOpts ...spellGo.Option) build.Option` - sets shared
  Go toolchain commands options.
- `WithOutputDir(dir string) build.Option` - sets the output directory,
  relative to the project root, for compilation artifacts.

To unify further implementations for the Go toolchain, a new `Options`
struct type has also been implemented in the golang [4] package that
stores global/shared Go toolchain options that are shared between
multiple Go toolchain commands:

- `WithAsmFlags(asmFlags ...string) golang.Option` - sets flags to pass
  on each `go tool asm` invocation.
- `WithRaceDetector(enableRaceDetector bool) golang.Option` - indicates
  if the race detector should be enabled.
- `WithTrimmedPath(enableTrimPath bool) golang.Option` - indicates if
  all file system paths should be removed from the resulting executable.
- `WithEnv(env map[string]string) golang.Option` - adds or overrides Go
  toolchain command specific environment variables.
- `WithFlags(flags ...string) golang.Option` - sets additional Go
  toolchain command flags.
- `WithFlagsPrefixAll(flagsPrefixAll bool) golang.Option` - indicates if
  the values of `-asmflags` and `-gcflags` should be prefixed with the
    `all=` pattern in order to apply to all packages.
- `WithGcFlags(gcFlags ...string) golang.Option` - sets flags to pass on
  each `go tool compile` invocation.
- `WithLdFlags(ldFlags ...string) golang.Option` - sets flags to pass on
  each `go tool link` invocation.
- `WithMixins(mixins ...spell.Mixin) golang.Option` - sets
  `spell.Mixin`s that can be applied by option consumers.
- `WithTags(tags ...string) golang.Option` - sets Go toolchain tags.

The new `CompileFormula(opts ...Option) []string` function [5] can be
used to compile the formula for these options.

[1]: https://pkg.go.dev/github.com/svengreb/wand/pkg/spell#Incantation
[2]: https://pkg.go.dev/github.com/svengreb/wand/pkg/spell/golang/build
[3]: https://pkg.go.dev/github.com/svengreb/wand/pkg/cast/golang#Caster
[4]: https://pkg.go.dev/github.com/svengreb/wand/pkg/spell/golang
[5]: https://pkg.go.dev/github.com/svengreb/wand/pkg/spell/golang#CompileFormula

GH-27
@svengreb svengreb added this to the 0.1.0 milestone Nov 23, 2020
@svengreb svengreb self-assigned this Nov 23, 2020
@svengreb svengreb merged commit 060b332 into main Nov 23, 2020
@svengreb svengreb deleted the feature/gh-27-spell-incantation-go-build-cmd branch November 23, 2020 20:10
@svengreb svengreb removed their assignment Nov 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Spell incantation for Go toolchain “build“ command
1 participant