summaryrefslogtreecommitdiff
path: root/scripts/bst-cross-build-or-show
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/bst-cross-build-or-show')
-rwxr-xr-xscripts/bst-cross-build-or-show17
1 files changed, 17 insertions, 0 deletions
diff --git a/scripts/bst-cross-build-or-show b/scripts/bst-cross-build-or-show
new file mode 100755
index 00000000..3be2b482
--- /dev/null
+++ b/scripts/bst-cross-build-or-show
@@ -0,0 +1,17 @@
+#!/bin/bash
+# This script runs a BuildStream cross-build for a given element, unless there
+# is a suitable artifact already in the remote cache in which case it just
+# runs `bst show`.
+#
+# It is intended for use by on-demand CI workers. If we just call `bst build`
+# and there is nothing to build then the CI worker will pull all of the remote
+# artifacts into a local cache, which will probably then be discarded anyway.
+
+set -eu
+bst_target_arch="$1"
+bst_target="$2"
+if [ "$(bst --target-arch=$bst_target_arch show $bst_target --deps none --format '%{state}')" == 'cached' ]; then
+ bst --colors --target-arch="$bst_target_arch" show $bst_target
+else
+ bst --colors --target-arch="$bst_target_arch" build $bst_target
+fi