From a2492a9fd1960f8ebf671c20f5c639307d20377a Mon Sep 17 00:00:00 2001 From: Caleb Xavier Berger Date: Mon, 18 Jan 2021 14:45:54 +0000 Subject: [PATCH] Add utility script for cross-compile workflow --- .github/workflows/get-compiler.sh | 45 +++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100755 .github/workflows/get-compiler.sh diff --git a/.github/workflows/get-compiler.sh b/.github/workflows/get-compiler.sh new file mode 100755 index 000000000..528f6e4d2 --- /dev/null +++ b/.github/workflows/get-compiler.sh @@ -0,0 +1,45 @@ +#!/bin/bash +set -eu + +case "$1" in +"pkgs") + get_pkgs + ;; +"ccomp") + get_compiler + ;; +*) + exit 1 + ;; +esac + +# Given a GOARCH target, return the GCC for that target. +case "$GOARCH" in +"amd64") + echo "x86_64-pc-linux-gnu-gcc" + ;; +"arm64") + echo "aarch64-linux-gnu-gcc" + ;; +"armhf") + echo "arm-linux-gnueabihf-gcc" + ;; +*) + echo "gcc" # Send us a pull request if RISC-V ever takes off + ;; +esac + +# Given a GOARCH target, return a list of Ubuntu packages needed to compile for that target. +function get_pkgs() { + case "$GOARCH" in + "arm64") + echo "gcc-aarch64-linux-gnu libc6-dev-arm64-cross" + ;; + "armhf") + echo "gcc-arm-linux-gnueabihf libc6-dev-armhf-cross" + ;; + "amd64" | *) + # We (currently) don't need to install more packages on amd64. + ;; + esac +} \ No newline at end of file