summaryrefslogtreecommitdiff
path: root/config/builder.go
diff options
context:
space:
mode:
Diffstat (limited to 'config/builder.go')
-rw-r--r--config/builder.go47
1 files changed, 47 insertions, 0 deletions
diff --git a/config/builder.go b/config/builder.go
new file mode 100644
index 0000000..112f181
--- /dev/null
+++ b/config/builder.go
@@ -0,0 +1,47 @@
+package config
+
+import (
+ "phabricator.wikimedia.org/source/blubber/build"
+)
+
+// BuilderConfig contains configuration for the definition of an arbitrary
+// build command.
+//
+type BuilderConfig struct {
+ Builder []string `yaml:"builder"`
+}
+
+// Merge takes another BuilderConfig and merges its fields into this one's,
+// overwriting the builder command.
+//
+func (bc *BuilderConfig) Merge(bc2 BuilderConfig) {
+ if len(bc2.Builder) > 0 {
+ bc.Builder = bc2.Builder
+ }
+}
+
+// InstructionsForPhase injects instructions into the build related to
+// builder commands.
+//
+// PhasePostInstall
+//
+// Runs build command provided for the builder
+//
+func (bc BuilderConfig) InstructionsForPhase(phase build.Phase) []build.Instruction {
+ switch phase {
+ case build.PhasePostInstall:
+ if len(bc.Builder) == 0 {
+ return []build.Instruction{}
+ }
+
+ run := build.Run{Command: bc.Builder[0]}
+
+ if len(bc.Builder) > 1 {
+ run.Arguments = bc.Builder[1:]
+ }
+
+ return []build.Instruction{run}
+ }
+
+ return []build.Instruction{}
+}