Skip to content

Commit b519c19

Browse files
committed
tool: Support Go compilation
compile_and_install() expects a Go project to end with ".go" to distinguish from C sources and places the compiled binary with a name without ".go". Signed-off-by: Takahiro Itazuri <[email protected]>
1 parent d3ed424 commit b519c19

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

resources/rebuild.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,17 @@ function prepare_docker {
4242
function compile_and_install {
4343
local SRC=$1
4444
local BIN="${SRC%.*}"
45-
gcc -Wall -o $BIN $SRC
45+
if [[ $SRC == *.c ]]; then
46+
gcc -Wall -o $BIN $SRC
47+
elif [[ $SRC == *.go ]]; then
48+
pushd $SRC
49+
local MOD=$(basename $BIN)
50+
go mod init $MOD
51+
go mod tidy
52+
go build -o ../$MOD
53+
rm go.mod go.sum
54+
popd
55+
fi
4656
}
4757

4858
# Build a rootfs

0 commit comments

Comments
 (0)